|
|
@@ -1,9 +1,12 @@
|
|
|
package com.ruoyi.project.service.impl;
|
|
|
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.enums.UserRolesType;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
@@ -11,14 +14,13 @@ import com.ruoyi.project.bo.ProjectStaffRecordInput;
|
|
|
import com.ruoyi.project.bo.ProjectStaffRecordOut;
|
|
|
import com.ruoyi.project.domain.ProjectStaffRecord;
|
|
|
import com.ruoyi.project.domain.ProjectStaffRecordLog;
|
|
|
-import com.ruoyi.project.domain.ProjectTask;
|
|
|
import com.ruoyi.project.mapper.ProjectStaffRecordLogMapper;
|
|
|
import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
|
|
|
import com.ruoyi.project.mapper.ProjectTaskMapper;
|
|
|
import com.ruoyi.project.service.ProjectStaffRecordService;
|
|
|
import com.ruoyi.system.mapper.SysUserMapper;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
-import com.ruoyi.system.service.ISysUserService;
|
|
|
+import com.ruoyi.system.service.impl.SysConfigServiceImpl;
|
|
|
import com.ruoyi.weChat.service.WeChatService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -26,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
-import java.util.Arrays;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
@@ -52,6 +54,11 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
@Autowired
|
|
|
private SysUserMapper userMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysConfigServiceImpl configService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public AjaxResult add(ProjectStaffRecord in) {
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
@@ -60,7 +67,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
in.setAid(userId);
|
|
|
in.setName(username);
|
|
|
if(in.getProcessStatus()>1)in.setProcessStatus(1);
|
|
|
- Double maxDuration= user.getDept().getMaxDuration();
|
|
|
+// Double maxDuration= user.getDept().getMaxDuration();
|
|
|
boolean flag=false;
|
|
|
if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
|
|
|
in.setProcessStatus(2);
|
|
|
@@ -241,4 +248,25 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
}
|
|
|
return successMsg.toString();
|
|
|
}
|
|
|
+
|
|
|
+ @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)id=null;
|
|
|
+ List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(id,user.getUserId());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|