浏览代码

新增考勤合并数据统计返回

anderx 1 年之前
父节点
当前提交
41306f52c1

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserRecordMapper.java

@@ -40,4 +40,6 @@ public interface UserRecordMapper {
     void userRecordMerge(Long userId);
 
     void deleteByUserId(Long userId);
+
+    List<UserRecord> selectByUserId(Long userId);
 }

+ 7 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -946,12 +946,18 @@ public class SysUserServiceImpl implements ISysUserService
     }
 
     @Override
-    public void userRecordMerge() {
+    public AjaxResult userRecordMerge() {
         Long userId = SecurityUtils.getUserId();
+        List<UserRecord> list = userRecordMapper.selectByUserId(userId);
+        //未匹配数量
+        List<UserRecord> collect = list.stream().filter(userRecord -> userRecord.getClockStatus() == 2).collect(Collectors.toList());
+        int unmatched = collect.size();
+        int matched = list.size()-unmatched;
         //合并到打卡表
         userRecordMapper.userRecordMerge(userId);
         //清楚考勤合并数据
         userRecordMapper.deleteByUserId(userId);
+        return AjaxResult.success(String.format("导入数据未匹配%s条,完成匹配%s条.", unmatched,matched));
     }
 
     @Override

+ 8 - 1
ruoyi-system/src/main/resources/mapper/UserRecordMapper.xml

@@ -182,7 +182,7 @@
         select count(*)
         from user_record
         where create_id = #{userId}
-        and status = #{status}
+        and status = #{status} and clock_status in (0,1)
     </select>
     <select id="checkClockUserRecord" resultType="java.lang.Integer">
         select count(*)
@@ -191,6 +191,13 @@
         and  status in(0,1)
         and clock_status =1
     </select>
+    <select id="selectByUserId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from user_record
+        where  create_id = #{userId}
+
+    </select>
 
     <update id="updateTypeDuration">
         update user_record