浏览代码

导入用户打卡数据开发

anderx 1 年之前
父节点
当前提交
77359c74a5

+ 9 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -148,6 +148,15 @@ public class SysUser extends BaseEntity
 
     private Integer projectQuantitySort;
     private Integer durationSort;
+    private Long ddUserId;
+
+    public Long getDdUserId() {
+        return ddUserId;
+    }
+
+    public void setDdUserId(Long ddUserId) {
+        this.ddUserId = ddUserId;
+    }
 
     public String getDeptName() {
         return deptName;

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

@@ -142,4 +142,6 @@ public interface SysUserMapper
     void updateDuration(Long aid);
 
     int selectParticipateProjectSum(Long userId);
+
+    SysUser selectDDUserId(String ddUserId);
 }

+ 19 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -13,6 +13,7 @@ import javax.validation.Validator;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.enums.UserRolesType;
 import com.ruoyi.project.domain.ProjectStaff;
+import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectTask;
 import com.ruoyi.project.mapper.ProjectStaffMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
@@ -711,6 +712,7 @@ public class SysUserServiceImpl implements ISysUserService
     public  List<UserClockDtails> pushUserClock(List<Map<Integer, String>> maps) {
         List<UserClockDtails> list=new ArrayList<>();
         List<String> names=new ArrayList<>();
+        List<String> uids=new ArrayList<>();
         int month =0;
         int year =0;
         int days=0;
@@ -773,6 +775,7 @@ public class SysUserServiceImpl implements ISysUserService
                               }
                             if (!names.contains(newUserlock.getName())){
                                 names.add(newUserlock.getName());
+                                uids.add(newUserlock.getUserId());
                             }
                             list.add(newUserlock);
                           }
@@ -782,8 +785,22 @@ public class SysUserServiceImpl implements ISysUserService
                 }
             }
         }
-            names.forEach(System.out::println);
-           return list;
+            //处理数据库
+        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);
+        }
+        return list;
     }
 
 

+ 8 - 0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -347,6 +347,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			AND (a.dept_id = #{companyId} OR a.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
 		</if>
 	</select>
+
+	<select id="selectDDUserId" resultType="com.ruoyi.common.core.domain.entity.SysUser">
+		select a.user_id userId, a.user_name userName,a.nick_name nickName,a.open_id openId
+		from sys_user a left join sys_user b on a.superior_id=b.user_id
+		where a.del_flag=0
+		and a.dd_user_id = #{ddUserId}
+	</select>
 	<select id="selectParticipateProjectSum" parameterType="java.lang.Long" resultType="java.lang.Integer">
 		select (count(b.id)+count(c.id))counts
 		from sys_user a left join project_task b on a.user_id =b.aid
@@ -355,6 +362,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 
 
+
 	<update id="userAddDuration">
 		update sys_user set duration = format(duration+#{duration},2)
 		where user_id = #{userId}