|
@@ -1,5 +1,6 @@
|
|
|
package com.ozs.pm.service.impl;
|
|
|
|
|
|
+import java.lang.invoke.LambdaConversionException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
@@ -720,57 +721,12 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
|
|
SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
|
|
|
Long deptId = sysUser.getDeptId();
|
|
|
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
|
|
- String[] ancestors = sysDept.getAncestors().split(",");
|
|
|
- String deptLevel = null;
|
|
|
- if(ancestors.length == 2){ //C级
|
|
|
- deptLevel = "C";
|
|
|
- } else if(ancestors.length == 3){ //B级
|
|
|
- deptLevel = "B";
|
|
|
- } else if(ancestors.length == 4){ //A级
|
|
|
- deptLevel = "A";
|
|
|
- }
|
|
|
- LambdaQueryWrapper<SysProcurementStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(SysProcurementStandard::getDeptId,deptId)
|
|
|
- .eq(SysProcurementStandard::getCategory,pmDemand.getProjectType())
|
|
|
- .eq(SysProcurementStandard::getState,1);//0不限1限额
|
|
|
- SysProcurementStandard sysProcurementStandard = sysProcurementStandardService.getOne(lambdaQueryWrapper);
|
|
|
-
|
|
|
- PmAuditDeptRef pmAuditDeptRef = new PmAuditDeptRef();
|
|
|
- pmAuditDeptRef.setRefId(pmDemand.getDemandId());
|
|
|
- pmAuditDeptRef.setRefType("2");
|
|
|
- pmAuditDeptRef.setStatus(0);
|
|
|
- pmAuditDeptRef.setCreated(pmDemandReqVo.getUpdateBy());
|
|
|
- pmAuditDeptRef.setCreateTime(DateUtils.getNowDate());
|
|
|
- pmAuditDeptRef.setUpdated(pmDemandReqVo.getUpdateBy());
|
|
|
- pmAuditDeptRef.setUpdateTime(pmAuditDeptRef.getCreateTime());
|
|
|
-
|
|
|
- if(!ObjectUtils.isEmpty(sysProcurementStandard)){ //限额
|
|
|
- BigDecimal maximum = sysProcurementStandard.getMaximum();
|
|
|
- if(maximum.doubleValue() < pmDemand.getEvaluation()) { //需求超额了,提交给上级部门
|
|
|
- String parentDeptLevel = null;
|
|
|
- Long parentDeptId = null;
|
|
|
- if("A".endsWith(deptLevel)){
|
|
|
- parentDeptLevel = "B";
|
|
|
- parentDeptId = sysDept.getParentId();
|
|
|
- } else if("B".endsWith(deptLevel)) {
|
|
|
- parentDeptLevel = "C";
|
|
|
- parentDeptId = sysDept.getParentId();
|
|
|
- } else { //C级提交同级
|
|
|
- parentDeptLevel = "C";
|
|
|
- parentDeptId = deptId;
|
|
|
- }
|
|
|
-
|
|
|
- pmAuditDeptRef.setDeptId(parentDeptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(parentDeptLevel);
|
|
|
- } else { //没超额,提交给同级
|
|
|
- pmAuditDeptRef.setDeptId(deptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(deptLevel);
|
|
|
- }
|
|
|
- } else { //不限额,提交给同级
|
|
|
- pmAuditDeptRef.setDeptId(deptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(deptLevel);
|
|
|
- }
|
|
|
- pmAuditDeptRefService.save(pmAuditDeptRef);
|
|
|
+ pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
|
|
|
+ , "2"
|
|
|
+ , deptId
|
|
|
+ , BigDecimal.valueOf(pmDemand.getEvaluation())
|
|
|
+ , sysUser.getUserId()
|
|
|
+ , pmDemand.getProjectType());
|
|
|
|
|
|
PmDemand pmDemandUpdate = new PmDemand();
|
|
|
pmDemandUpdate.setDemandId(pmDemand.getDemandId());
|
|
@@ -800,65 +756,35 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
|
|
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
|
|
String[] ancestors = sysDept.getAncestors().split(",");
|
|
|
String deptLevel = null;
|
|
|
- if(ancestors.length == 2){ //C级
|
|
|
+ if (ancestors.length == 2) { //C级
|
|
|
deptLevel = "C";
|
|
|
- } else if(ancestors.length == 3){ //B级
|
|
|
+ } else if (ancestors.length == 3) { //B级
|
|
|
deptLevel = "B";
|
|
|
- } else if(ancestors.length == 4){ //A级
|
|
|
+ } else if (ancestors.length == 4) { //A级
|
|
|
deptLevel = "A";
|
|
|
}
|
|
|
- LambdaQueryWrapper<SysProcurementStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(SysProcurementStandard::getDeptId,deptId)
|
|
|
- .eq(SysProcurementStandard::getCategory,pmDemand.getProjectType())
|
|
|
- .eq(SysProcurementStandard::getState,1);//0不限1限额
|
|
|
- SysProcurementStandard sysProcurementStandard = sysProcurementStandardService.getOne(lambdaQueryWrapper);
|
|
|
-
|
|
|
- PmAuditDeptRef pmAuditDeptRef = new PmAuditDeptRef();
|
|
|
- pmAuditDeptRef.setRefId(pmDemand.getDemandId());
|
|
|
- pmAuditDeptRef.setRefType("2");
|
|
|
- pmAuditDeptRef.setCreated(pmDemandReqVo.getUpdateBy());
|
|
|
- pmAuditDeptRef.setCreateTime(DateUtils.getNowDate());
|
|
|
- pmAuditDeptRef.setUpdated(pmDemandReqVo.getUpdateBy());
|
|
|
- pmAuditDeptRef.setUpdateTime(pmAuditDeptRef.getCreateTime());
|
|
|
-
|
|
|
- if(!ObjectUtils.isEmpty(sysProcurementStandard)){ //限额
|
|
|
- BigDecimal maximum = sysProcurementStandard.getMaximum();
|
|
|
- if(maximum.doubleValue() < pmDemand.getEvaluation()) { //需求超额了,提交给上级部门
|
|
|
- String parentDeptLevel = null;
|
|
|
- Long parentDeptId = null;
|
|
|
- if("A".endsWith(deptLevel)){
|
|
|
- parentDeptLevel = "B";
|
|
|
- parentDeptId = sysDept.getParentId();
|
|
|
- pmAuditDeptRef.setStatus(0);
|
|
|
- pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
|
|
|
- } else if("B".endsWith(deptLevel)) {
|
|
|
- parentDeptLevel = "C";
|
|
|
- parentDeptId = sysDept.getParentId();
|
|
|
- pmAuditDeptRef.setStatus(0);
|
|
|
- pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
|
|
|
- } else { //C级 审核通过
|
|
|
- parentDeptLevel = "C";
|
|
|
- parentDeptId = deptId;
|
|
|
+ LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
|
|
|
+ lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
|
|
|
+ lw.eq(PmAuditDeptRef::getRefType, "2");
|
|
|
+ List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
|
|
|
+ boolean flay = true;
|
|
|
+ if (!ObjectUtils.isEmpty(list)) {
|
|
|
+ for (PmAuditDeptRef pmAuditDeptRef : list) {
|
|
|
+ // 判断 deptLevel 是否还有更高的 且是 待审核的数据
|
|
|
+ if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
|
|
|
+ && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
|
|
|
+ flay = false;
|
|
|
+ }
|
|
|
+ // 更新当前 deptLevel 级别的审核状态
|
|
|
+ if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
|
|
|
pmAuditDeptRef.setStatus(1);
|
|
|
- pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
|
|
|
+ pmAuditDeptRefService.updateById(pmAuditDeptRef);
|
|
|
}
|
|
|
-
|
|
|
- pmAuditDeptRef.setDeptId(parentDeptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(parentDeptLevel);
|
|
|
-
|
|
|
- } else { //没超额,审核通过
|
|
|
- pmAuditDeptRef.setDeptId(deptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(deptLevel);
|
|
|
- pmAuditDeptRef.setStatus(1);
|
|
|
- pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
|
|
|
}
|
|
|
- } else { //不限额,审核通过
|
|
|
- pmAuditDeptRef.setDeptId(deptId);
|
|
|
- pmAuditDeptRef.setDeptLevel(deptLevel);
|
|
|
- pmAuditDeptRef.setStatus(1);
|
|
|
+ }
|
|
|
+ if (flay) {
|
|
|
pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
|
|
|
}
|
|
|
- pmAuditDeptRefService.save(pmAuditDeptRef);
|
|
|
|
|
|
List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
|
|
|
uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
|