Parcourir la source

新增获取项目打卡月份数据表

anderx il y a 1 an
Parent
commit
bc6a643c3d

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

@@ -642,6 +642,17 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
 
                 // 验证是否存在
                 ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(p.getId());
+                String recordTimes = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, p.getRecordTime());
+                BigDecimal maxDuration= BigDecimal.valueOf(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
+                Double myDuration = getMyDuration(projectStaffRecord.getPid(), projectStaffRecord.getAid(), recordTimes);
+                //如果修改要减去之前的加上现在的,新增直接加
+                if (updateSupport){
+                    myDuration-=projectStaffRecord.getDuration();
+                }
+                myDuration+=p.getDuration();
+                if (maxDuration.compareTo(new BigDecimal(myDuration))<0){
+                    throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s]",maxDuration,myDuration));
+                }
                 if (StringUtils.isNull(projectStaffRecord)){
 //                    BeanValidators.validateWithException(validator, projectStaffRecord);
                     if (StringUtils.isNotBlank(p.getJobNumber())){
@@ -653,6 +664,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                     }else {
                         throw new ServiceException(String.format("新增必须知道打卡人"));
                     }
+
                     pushProjectId(companyId, pids, p);
                     p.setProcessStatus(2);
                     projectStaffRecordMapper.insertSelective(p);
@@ -660,15 +672,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                     successMsg.append("<br/>" + successNum + "、项目: " + p.getProjectName() + " 导入成功");
                 }else if (updateSupport){
                     BeanValidators.validateWithException(validator, p);
-                    if (p.getDuration()!=projectStaffRecord.getDuration()){
-                        String recordTimes = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, p.getRecordTime());
-                        BigDecimal maxDuration= new BigDecimal(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
-                        Double myDuration = getMyDuration(projectStaffRecord.getPid(), projectStaffRecord.getAid(), recordTimes);
-                        myDuration-=projectStaffRecord.getDuration();
-                        myDuration+=p.getDuration();
-                        if (maxDuration.compareTo(new BigDecimal(myDuration))<0){
-                            throw new ServiceException(String.format("工时超出最大打卡,最大[%s]当前[%s]",maxDuration,myDuration));
-                        }
+                    if (!Objects.equals(p.getDuration(), projectStaffRecord.getDuration())){
                         projectTaskMapper.updateDuration(projectStaffRecord.getPid());
                         sysUserMapper.updateDuration(projectStaffRecord.getAid());
                     }