|
|
@@ -67,7 +67,8 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
in.setAid(userId);
|
|
|
in.setName(username);
|
|
|
if(in.getProcessStatus()>1)in.setProcessStatus(1);
|
|
|
-// Double maxDuration= user.getDept().getMaxDuration();
|
|
|
+
|
|
|
+
|
|
|
boolean flag=false;
|
|
|
if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
|
|
|
in.setProcessStatus(2);
|
|
|
@@ -84,6 +85,52 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean addCheckMaxDuation(ProjectStaffRecord in) {
|
|
|
+ BigDecimal maxDuration= new BigDecimal(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
|
|
|
+ String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
|
|
|
+ Boolean maxflag = Boolean.parseBoolean(maxDurationProjectFlag);
|
|
|
+ Double myDuration=0d;
|
|
|
+ if (maxflag){
|
|
|
+ myDuration=getMyDuration(in.getPid(), in.getAid());
|
|
|
+ }else {
|
|
|
+ myDuration=getMyDuration(null, in.getAid());
|
|
|
+ }
|
|
|
+ BigDecimal mySum = new BigDecimal(myDuration).add(new BigDecimal(in.getDuration()));
|
|
|
+
|
|
|
+ if (mySum.compareTo(maxDuration)==1){
|
|
|
+ log.debug(String.format("超出最大额.max=%s,my=%s",maxDuration,mySum));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean updateCheckMaxDuation(ProjectStaffRecord in) {
|
|
|
+ BigDecimal maxDuration= new BigDecimal(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
|
|
|
+ String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
|
|
|
+ Boolean maxflag = Boolean.parseBoolean(maxDurationProjectFlag);
|
|
|
+ AtomicReference<Double> aDouble = new AtomicReference<>(0d);
|
|
|
+ String date=DateUtils.getDate();
|
|
|
+ List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(in.getPid(),in.getAid());
|
|
|
+ projectStaffRecords.stream().forEach(e ->{
|
|
|
+ String eDate= DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, e.getRecordTime());
|
|
|
+ if (!e.getId().equals(in.getId())){
|
|
|
+ if (date.equals(eDate)){
|
|
|
+ aDouble.updateAndGet(v -> v + e.getDuration());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ aDouble.updateAndGet(v -> v + in.getDuration());
|
|
|
+ BigDecimal mySum= new BigDecimal(aDouble.toString());
|
|
|
+ if (mySum.compareTo(maxDuration)==1){
|
|
|
+ log.debug(String.format("超出最大额.max=%s,my=%s",maxDuration,mySum));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private void addWechatAppSend(ProjectStaffRecord in, String remarks) {
|
|
|
//获取当事人
|
|
|
String openId=null;
|
|
|
@@ -251,28 +298,33 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult myDuration(Long id) {
|
|
|
- SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
- SysDept dept = user.getDept();
|
|
|
- Double maxDuration=dept.getMaxDuration();
|
|
|
- String date=DateUtils.getDate();
|
|
|
String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
|
|
|
- AtomicReference<Double> myDuration = new AtomicReference<>(0d);
|
|
|
Boolean flag = Boolean.parseBoolean(maxDurationProjectFlag);
|
|
|
if (flag){
|
|
|
if (id==null){
|
|
|
return AjaxResult.error("项目不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
- id=null;
|
|
|
}
|
|
|
- List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(id,user.getUserId());
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ SysDept dept = user.getDept();
|
|
|
+ Double maxDuration=dept.getMaxDuration();
|
|
|
+ Double myDuration=getMyDuration(id,user.getUserId());
|
|
|
+ BigDecimal res = new BigDecimal(maxDuration).subtract(new BigDecimal(myDuration.toString()));
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public Double getMyDuration(Long pid,Long aid) {
|
|
|
+ AtomicReference<Double> myDuration = new AtomicReference<>(0d);
|
|
|
+ String date=DateUtils.getDate();
|
|
|
+ List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(pid,aid);
|
|
|
projectStaffRecords.stream().forEach(e ->{
|
|
|
String eDate= DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, e.getRecordTime());
|
|
|
if (date.equals(eDate)){
|
|
|
myDuration.updateAndGet(v -> v + e.getDuration());
|
|
|
}
|
|
|
});
|
|
|
- BigDecimal res = new BigDecimal(maxDuration).subtract(new BigDecimal(myDuration.toString()));
|
|
|
- return AjaxResult.success(res);
|
|
|
+ return myDuration.get();
|
|
|
}
|
|
|
}
|