Browse Source

新增合并工时后重新统计

anderx 1 year ago
parent
commit
c1e96f47ea

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

@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.parameters.P;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Validator;
@@ -67,8 +68,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     private WeChatService weChatService;
     @Autowired
     private ISysDeptService deptService;
-    @Autowired
-    private SysUserMapper userMapper;
+
 
     @Autowired
     private SysConfigServiceImpl configService;
@@ -345,6 +345,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void mateUserRecord(ProjectStaffRecordInput in) {
         in.setPageSize(999999);
         List<ProjectStaffRecordOut> projectStaffRecordOuts = listRecord(in);
@@ -352,6 +353,25 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         if (!collect.isEmpty()){
             projectStaffRecordMapper.mateUserRecord(collect);
         }
+        pushProjectAndAidDuration(projectStaffRecordOuts);
+
+
+    }
+
+    /**
+     * 项目重新计算统计值
+     */
+    private void pushProjectAndAidDuration(List<ProjectStaffRecordOut> projectStaffRecordOuts) {
+        List<Long> pidList = projectStaffRecordOuts.stream()
+                .map(ProjectStaffRecordOut::getPid)
+                .distinct()
+                .collect(Collectors.toList());
+        pidList.forEach(projectTaskMapper::updateDuration);
+        List<Long> aidList = projectStaffRecordOuts.stream()
+                .map(ProjectStaffRecordOut::getAid)
+                .distinct()
+                .collect(Collectors.toList());
+        aidList.forEach(sysUserMapper::updateDuration);
     }
 
 
@@ -449,13 +469,13 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         //获取当事人
         String openId=null;
         if (processStatus==1){
-            SysUser sysUser = userMapper.selectSuperUserByUid(aid);
+            SysUser sysUser = sysUserMapper.selectSuperUserByUid(aid);
             openId=sysUser.getOpenId();
             if (StringUtils.isBlank(openId)){
                 log.debug(String.format("查询上级openId为空,%s",remarks));
             }
         }else if(processStatus==2||processStatus==3){
-            SysUser sysUser = userMapper.selectUserById(aid
+            SysUser sysUser = sysUserMapper.selectUserById(aid
             );
             openId=sysUser.getOpenId();
             if (StringUtils.isBlank(openId)){