Kaynağa Gözat

项目数据导入修改

anderx 1 yıl önce
ebeveyn
işleme
c106cbee48

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

@@ -637,10 +637,10 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         StringBuilder failureMsg = new StringBuilder();
         Long companyId = deptService.selectCompanyByDeptId();
         List<Long> pids=new ArrayList<>();
+        BigDecimal maxDuration= BigDecimal.valueOf(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
         for (ProjectStaffRecordOut p : list){
+            String recordTimes = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, p.getRecordTime());
             try {
-                String recordTimes = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, p.getRecordTime());
-                BigDecimal maxDuration= BigDecimal.valueOf(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
                 // 验证是否存在
                 ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(p.getId());
                 if (StringUtils.isNull(projectStaffRecord)){
@@ -655,11 +655,11 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                         throw new ServiceException(String.format("新增必须知道打卡人"));
                     }
                     pushProjectId(companyId, pids, p);
-                    Double myDuration = getMyDuration(projectStaffRecord.getPid(), projectStaffRecord.getAid(), recordTimes);
-                    myDuration-=projectStaffRecord.getDuration();
+                    Double myDuration = getMyDuration(p.getPid(), p.getAid(), recordTimes);
                     myDuration+=p.getDuration();
                     if (maxDuration.compareTo(new BigDecimal(myDuration))<0){
-                        throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s]",maxDuration,myDuration));
+                        throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s],项目[%s]打卡人[%s]时间[%s]",
+                                maxDuration,myDuration,p.getProjectName(),p.getName(),recordTimes));
                     }
                     p.setProcessStatus(2);
                     projectStaffRecordMapper.insertSelective(p);
@@ -673,7 +673,8 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                         myDuration-=projectStaffRecord.getDuration();
                         myDuration+=p.getDuration();
                         if (maxDuration.compareTo(new BigDecimal(myDuration))<0){
-                            throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s]",maxDuration,myDuration));
+                            throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s],项目[%s]打卡人[%s]时间[%s]",
+                                    maxDuration,myDuration,p.getProjectName(),p.getAdminName(),recordTimes));
                         }
                         projectTaskMapper.updateDuration(projectStaffRecord.getPid());
                         sysUserMapper.updateDuration(projectStaffRecord.getAid());