Pārlūkot izejas kodu

导入用户打卡数据开发

anderx 1 gadu atpakaļ
vecāks
revīzija
6a42d7bc0f

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

@@ -38,4 +38,6 @@ public interface ProjectStaffRecordMapper {
     void updateSumDurationProject(Long pid);
 
     void updateSumDurationStaff(Long pid);
+
+    void selectByAidAndTime(@Param("uid") Long uid, @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 22 - 18
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -717,6 +717,8 @@ public class SysUserServiceImpl implements ISysUserService
         int year =0;
         int days=0;
         Map<Integer,String> hand=new HashMap<>();
+        String startClockTime=null;
+        String endClockTime=null;
         if (!maps.isEmpty()){
             for (int i = 0; i < maps.size(); i++) {
                 //获取头部
@@ -725,8 +727,8 @@ public class SysUserServiceImpl implements ISysUserService
                     String head = map.get(0);
                     int i1 = head.indexOf(":")+1;
                     int i2 = head.indexOf("至");
-                    String startClockTime = head.substring(i1, i2).trim();
-                    String endClockTime = head.substring(i2+1).trim();
+                     startClockTime = head.substring(i1, i2).trim();
+                     endClockTime = head.substring(i2+1).trim();
                     System.out.println(startClockTime+"~"+endClockTime);
                     LocalDate date = LocalDate.parse(startClockTime, DateTimeFormatter.ISO_DATE);
                     month=date.getMonthValue();
@@ -750,7 +752,9 @@ public class SysUserServiceImpl implements ISysUserService
                             UserClockDtails newUserlock=new UserClockDtails(userClockDtails);
                           if(StringUtils.isNotEmpty(s)){
                               String[] split = s.split("\n");
-                              if (split.length==1)newUserlock.setStauts(1);
+                              if (split.length==1){
+                                  newUserlock.setStauts(1);
+                              }
                               String regex = "\\d+";
                               if (hand.get(j).matches(regex)){
                                   days=Integer.parseInt(hand.get(j));
@@ -771,7 +775,7 @@ public class SysUserServiceImpl implements ISysUserService
                                   Double hours = getHuors(startTime, endTime);
                                   newUserlock.setDuration(hours);
                               }else {
-                                  newUserlock.setDuration(0d);
+                                  newUserlock.setDuration(0.0);
                               }
                             if (!names.contains(newUserlock.getName())){
                                 names.add(newUserlock.getName());
@@ -786,20 +790,20 @@ public class SysUserServiceImpl implements ISysUserService
             }
         }
             //处理数据库
-        List<String> errorNames = new ArrayList<>();
-        List<Long> userList=new ArrayList<>();
-        for (int i = 0; i < names.size(); i++) {
-            SysUser sysUser = userMapper.selectDDUserId(uids.get(i));
-            if (sysUser==null){
-                errorNames.add(names.get(i));
-            }else {
-                userList.add(sysUser.getUserId());
-            }
-        }
-        if (!errorNames.isEmpty())throw new ServiceException(String.format("用户%s不能匹配到账号",errorNames.toString()));
-        for (Long aLong : userList) {
-            List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(null, aLong);
-        }
+//        List<String> errorNames = new ArrayList<>();
+//        List<Long> userList=new ArrayList<>();
+//        for (int i = 0; i < names.size(); i++) {
+//            SysUser sysUser = userMapper.selectDDUserId(uids.get(i));
+//            if (sysUser==null){
+//                errorNames.add(names.get(i));
+//            }else {
+//                userList.add(sysUser.getUserId());
+//            }
+//        }
+//        if (!errorNames.isEmpty())throw new ServiceException(String.format("用户%s不能匹配到账号",errorNames.toString()));
+//        for (Long uid : userList) {
+//            projectStaffRecordMapper.selectByAidAndTime(uid,startClockTime,endClockTime);
+//        }
         return list;
     }
 

+ 9 - 0
ruoyi-system/src/main/resources/mapper/project/ProjectStaffRecordMapper.xml

@@ -277,6 +277,15 @@
     where 1=1
     and a.id =#{id}
   </select>
+  <select id="selectByAidAndTime" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from project_staff_record
+    where 1=1 and aid = #{uid}
+    and record_time between #{startTime} and #{endTime}
+
+
+  </select>
 
   <update id="updateNameByAid" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
     update project_staff_record