anderx 2 роки тому
батько
коміт
d39c257154

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/project/mapper/ProjectStaffMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.project.mapper;
 
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.project.domain.ProjectStaff;
 import org.apache.ibatis.annotations.Param;
 
@@ -23,4 +24,8 @@ public interface ProjectStaffMapper {
     List<ProjectStaff> selectByPid(Long id);
 
     void updatePidByList(@Param("pid") Long pid, @Param("split") String[] split);
+
+    void updateNameByAid(SysUser user);
+
+    List<ProjectStaff> selectByAid(Long userId);
 }

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

@@ -1,5 +1,6 @@
 package com.ruoyi.project.mapper;
 
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.project.bo.MyMonthDays;
 import com.ruoyi.project.bo.ProjectStaffRecordInput;
 import com.ruoyi.project.bo.ProjectStaffRecordOut;
@@ -31,4 +32,6 @@ public interface ProjectStaffRecordMapper {
     List<MyMonthDays> myDurationMonth(Long id, Long aid, String lastDayOfMonth, String s);
 
     ProjectStaffRecordOut selectDetailsById(Long id);
+
+    void updateNameByAid(SysUser user);
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -84,7 +84,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         if (flag){
             addWechatAppSend(in, String.format("[%s]发起打卡,请及时审核!", username));
         }
-        return AjaxResult.success();
+        return AjaxResult.success(in);
     }
 
     @Override

+ 27 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -6,6 +6,11 @@ import java.util.stream.Collectors;
 import javax.validation.Validator;
 
 import com.ruoyi.common.enums.UserRolesType;
+import com.ruoyi.project.domain.ProjectStaff;
+import com.ruoyi.project.domain.ProjectTask;
+import com.ruoyi.project.mapper.ProjectStaffMapper;
+import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
+import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.system.mapper.*;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.weChat.service.WeChatService;
@@ -64,6 +69,13 @@ public class SysUserServiceImpl implements ISysUserService
     private WeChatService weChatService;
     @Autowired
     protected Validator validator;
+    @Autowired
+    private ProjectStaffMapper projectStaffMapper;
+    @Autowired
+    private ProjectStaffRecordMapper projectStaffRecordMapper;
+    @Autowired
+    private ProjectTaskMapper projectTaskMapper;
+
 
     /**
      * 根据条件分页查询用户列表
@@ -302,9 +314,24 @@ public class SysUserServiceImpl implements ISysUserService
         userPostMapper.deleteUserPostByUserId(userId);
         // 新增用户与岗位管理
         insertUserPost(user);
+        //修改关联名称
+        updateUserName(user);
         return userMapper.updateUser(user);
     }
 
+    private void updateUserName(SysUser user) {
+        SysUser sysUser = userMapper.selectUserById(user.getUserId());
+        if (!sysUser.getNickName().equals(user.getUserName())){
+            //修改所有名字
+            projectStaffMapper.updateNameByAid(user);
+            projectStaffRecordMapper.updateNameByAid(user);
+            List<ProjectStaff> projectStaffs = projectStaffMapper.selectByAid(user.getUserId());
+            for (ProjectStaff projectStaff : projectStaffs) {
+                projectTaskMapper.updateStaffName(projectStaff.getPid());
+            }
+        }
+    }
+
     /**
      * 用户授权角色
      *

+ 11 - 1
ruoyi-system/src/main/resources/mapper/project/ProjectStaffMapper.xml

@@ -111,7 +111,12 @@
   from project_staff
   where pid = #{pid}
   </select>
-
+  <select id="selectByAid" parameterType="java.lang.Long" resultMap="BaseResultMap">
+  select
+  <include refid="Base_Column_List" />
+  from project_staff
+  where aid = #{pid}
+  </select>
   <update id="updatePidByList">
     update project_staff
     set pid = #{pid}
@@ -120,5 +125,10 @@
       #{item}
     </foreach>
   </update>
+    <update id="updateNameByAid" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+      update project_staff
+      set name = #{nickName}
+      where aid = #{userId}
+    </update>
 
 </mapper>

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

@@ -201,6 +201,7 @@
       examine_content = #{examineContent}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
   <select id="selectList" resultType="com.ruoyi.project.bo.ProjectStaffRecordOut">
     select a.id,c.job_number jobNumber,a.name   ,d.dept_id deptId ,d.dept_name deptName ,c.create_time createMonth,
     b.name projectName,b.admin_name adminName ,a.project_status projectStatus,a.content ,b.project_number projectNumber,
@@ -272,4 +273,10 @@
     and a.id =#{id}
   </select>
 
+  <update id="updateNameByAid" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+    update project_staff_record
+    set admin_name= #{nickName}
+    where aid= #{userId}
+  </update>
+
 </mapper>