|
|
@@ -639,20 +639,10 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
List<Long> pids=new ArrayList<>();
|
|
|
for (ProjectStaffRecordOut p : list){
|
|
|
try {
|
|
|
-
|
|
|
- // 验证是否存在
|
|
|
- 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));
|
|
|
- }
|
|
|
+ // 验证是否存在
|
|
|
+ ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(p.getId());
|
|
|
if (StringUtils.isNull(projectStaffRecord)){
|
|
|
// BeanValidators.validateWithException(validator, projectStaffRecord);
|
|
|
if (StringUtils.isNotBlank(p.getJobNumber())){
|
|
|
@@ -664,15 +654,27 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
}else {
|
|
|
throw new ServiceException(String.format("新增必须知道打卡人"));
|
|
|
}
|
|
|
-
|
|
|
pushProjectId(companyId, pids, p);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
p.setProcessStatus(2);
|
|
|
projectStaffRecordMapper.insertSelective(p);
|
|
|
successNum++;
|
|
|
successMsg.append("<br/>" + successNum + "、项目: " + p.getProjectName() + " 导入成功");
|
|
|
}else if (updateSupport){
|
|
|
BeanValidators.validateWithException(validator, p);
|
|
|
- if (!Objects.equals(p.getDuration(), projectStaffRecord.getDuration())){
|
|
|
+ if (p.getDuration()!=projectStaffRecord.getDuration()){
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
projectTaskMapper.updateDuration(projectStaffRecord.getPid());
|
|
|
sysUserMapper.updateDuration(projectStaffRecord.getAid());
|
|
|
}
|