@@ -4,7 +4,6 @@ import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | import com.ningdatech.log.annotation.WebLog; | ||||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | import com.ningdatech.pmapi.common.util.ExcelDownUtil; | ||||
import com.ningdatech.pmapi.projectdeclared.manage.DelayedApplyManage; | import com.ningdatech.pmapi.projectdeclared.manage.DelayedApplyManage; | ||||
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; | |||||
import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | ||||
import com.ningdatech.pmapi.projectdeclared.model.vo.DelayedApplyVO; | import com.ningdatech.pmapi.projectdeclared.model.vo.DelayedApplyVO; | ||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | ||||
@@ -16,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.validation.annotation.Validated; | import org.springframework.validation.annotation.Validated; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Classname DelayedProjectController | * @Classname DelayedProjectController | ||||
@@ -39,6 +39,12 @@ public class DelayedApplyController { | |||||
return delayedApplyManage.projectLibList(req); | return delayedApplyManage.projectLibList(req); | ||||
} | } | ||||
@ApiOperation(value = "查看某个项目的延期列表", notes = "查看某个项目的延期列表") | |||||
@GetMapping("/delay-list/{projectId}") | |||||
public List<DelayedApplyVO> delayList(@PathVariable Long projectId) { | |||||
return delayedApplyManage.delayList(projectId); | |||||
} | |||||
@ApiOperation(value = "延期的内容详情", notes = "延期的内容详情") | @ApiOperation(value = "延期的内容详情", notes = "延期的内容详情") | ||||
@GetMapping("/detail/{projectId}") | @GetMapping("/detail/{projectId}") | ||||
public DelayedApplyVO detailByProjectId(@PathVariable Long projectId) { | public DelayedApplyVO detailByProjectId(@PathVariable Long projectId) { | ||||
@@ -304,4 +304,22 @@ public class DelayedApplyManage { | |||||
} | } | ||||
return BeanUtil.copyProperties(delayApply,DelayedApplyVO.class); | return BeanUtil.copyProperties(delayApply,DelayedApplyVO.class); | ||||
} | } | ||||
/** | |||||
* 查看某个项目的 延期列表 | |||||
* @param projectId | |||||
* @return | |||||
*/ | |||||
public List<DelayedApplyVO> delayList(Long projectId) { | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectId); | |||||
List<ProjectDelayApply> delays = projectDelayApplyService.list(Wrappers.lambdaQuery(ProjectDelayApply.class) | |||||
.in(ProjectDelayApply::getProjectId, allVersionProjectId)); | |||||
if(CollUtil.isEmpty(delays)){ | |||||
return Collections.emptyList(); | |||||
} | |||||
return delays.stream().map(d -> BeanUtil.copyProperties(d,DelayedApplyVO.class)) | |||||
.collect(Collectors.toList()); | |||||
} | |||||
} | } |
@@ -81,6 +81,8 @@ public class OperationManage { | |||||
entity.setProjectCode(project.getProjectCode()); | entity.setProjectCode(project.getProjectCode()); | ||||
entity.setUpdateOn(LocalDateTime.now()); | entity.setUpdateOn(LocalDateTime.now()); | ||||
entity.setUpdateBy(user.getUsername()); | entity.setUpdateBy(user.getUsername()); | ||||
//强制放入 计划终验时间 | |||||
entity.setFinalInspectionDate(project.getPlanAcceptanceTime()); | |||||
if(operationService.saveOrUpdate(entity)){ | if(operationService.saveOrUpdate(entity)){ | ||||
stateMachineUtils.pass(project); | stateMachineUtils.pass(project); | ||||
project.setUpdateOn(LocalDateTime.now()); | project.setUpdateOn(LocalDateTime.now()); | ||||
@@ -0,0 +1,55 @@ | |||||
package com.ningdatech.pmapi.projectlib.enumeration; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
import lombok.NoArgsConstructor; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Objects; | |||||
/** | |||||
* | |||||
* 预警填报类型枚举 | |||||
* @author CMM | |||||
* @since 2023/02/24 16:14 | |||||
*/ | |||||
@Getter | |||||
@NoArgsConstructor | |||||
@AllArgsConstructor | |||||
public enum WarningOperationTypeEnum { | |||||
/** | |||||
* 预警实施类型枚举 | |||||
*/ | |||||
CHUYAN(1, "项目初验",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()), | |||||
ZHONGYAN(2, "项目终验",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); | |||||
private Integer code; | |||||
private String desc; | |||||
//对应的 待提交时的项目状态 | |||||
private Integer projectStutas; | |||||
public static String getDescByCode(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return StringUtils.EMPTY; | |||||
} | |||||
for (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t.desc; | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
public static WarningOperationTypeEnum getByCode(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return null; | |||||
} | |||||
for (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -164,12 +164,18 @@ public class AnnualPlanLibManage { | |||||
//计划出 计划验收时间 | //计划出 计划验收时间 | ||||
LocalDateTime planAcceptanceTime = getPlanAcceptanceTime(req); | LocalDateTime planAcceptanceTime = getPlanAcceptanceTime(req); | ||||
LambdaUpdateWrapper<Project> update = | LambdaUpdateWrapper<Project> update = | ||||
Wrappers.lambdaUpdate(Project.class).set(Project::getApprovalAmount, req.getApprovedAmount()) | |||||
.set(Project::getApprovedFile, req.getApprovedFileId()).set(Project::getBuildCycle, req.getBuildCycle()) | |||||
Wrappers.lambdaUpdate(Project.class) | |||||
.set(Project::getApprovalAmount, req.getApprovedAmount()) | |||||
.set(Project::getApprovedFile, req.getApprovedFileId()) | |||||
.set(Project::getBuildCycle, req.getBuildCycle()) | |||||
.set(Project::getOriginBuildCycle,req.getBuildCycle()) | |||||
.set(Project::getApprovedConstructionPlanFile, req.getBuildPlanFileId()) | .set(Project::getApprovedConstructionPlanFile, req.getBuildPlanFileId()) | ||||
.set(Project::getApprovalDate, req.getApprovedDate()).set(Project::getStatus, project.getStatus()) | |||||
.set(Project::getApprovalDate, req.getApprovedDate()) | |||||
.set(Project::getStatus, project.getStatus()) | |||||
.set(Project::getStage, project.getStage()) | .set(Project::getStage, project.getStage()) | ||||
.set(Objects.nonNull(planAcceptanceTime),Project::getPlanAcceptanceTime,planAcceptanceTime) | .set(Objects.nonNull(planAcceptanceTime),Project::getPlanAcceptanceTime,planAcceptanceTime) | ||||
//记录原始的 计划验收时间 | |||||
.set(Objects.nonNull(planAcceptanceTime),Project::getOriginPlanAcceptanceTime,planAcceptanceTime) | |||||
.eq(Project::getId, req.getProjectId()); | .eq(Project::getId, req.getProjectId()); | ||||
projectService.update(update); | projectService.update(update); | ||||
} | } | ||||
@@ -240,6 +240,238 @@ public class ProjectLibManage { | |||||
} | } | ||||
/** | /** | ||||
* @param projectId 项目详情 | |||||
* @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO | |||||
* @author ZPF | |||||
* @since 2023/02/11 11:15 | |||||
*/ | |||||
public ProjectDetailVO getProjectDetail(Long projectId) { | |||||
// 查询最新的项目申报信息 | |||||
Project projectInfo = projectService.getNewProject(projectId); | |||||
if (Objects.isNull(projectInfo)) { | |||||
return null; | |||||
} | |||||
ProjectDetailVO vo = new ProjectDetailVO(); | |||||
BeanUtils.copyProperties(projectInfo, vo); | |||||
vo.buildDynamicForm(projectInfo.getDynamicForm()); | |||||
// 查询应用 | |||||
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()) | |||||
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct()) | |||||
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion())); | |||||
Optional.ofNullable(applications).ifPresent(apps -> | |||||
vo.setProjectApplications(CollUtils.convert(apps, | |||||
ProjectHelper::convertVO) | |||||
)); | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectInfo); | |||||
//查询采购备案 | |||||
List<Purchase> purchases = purchaseService.listByProjectId(projectId); | |||||
vo.setPurchases(BeanUtil.copyToList(purchases, PurchaseVO.class)); | |||||
//查询合同备案 | |||||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId) | |||||
.last(BizConst.LIMIT_1)); | |||||
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); | |||||
vo.setContract(contractVO); | |||||
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) | |||||
.in(PaymentPlan::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PaymentPlan::getPaymentTime)); | |||||
if (Objects.nonNull(contractVO)) { | |||||
contractVO.setPayments(convertPayments(payments, | |||||
contractVO.getTotalAmount())); | |||||
} | |||||
//查询实施信息 | |||||
Operation operation = operationService.getOne(Wrappers.lambdaQuery(Operation.class) | |||||
.in(Operation::getProjectId, allVersionProjectId) | |||||
.orderByAsc(Operation::getCreateOn) | |||||
.last(BizConst.LIMIT_1)); | |||||
vo.setOperation(BeanUtil.copyProperties(operation, OperationVO.class)); | |||||
SafetyMonitorVO safetyVo = new SafetyMonitorVO(); | |||||
//查询风险监测 | |||||
List<SupplierSafetyQualification> ssq = supplierSafetyQualificationService.list(Wrappers.lambdaQuery(SupplierSafetyQualification.class) | |||||
.eq(SupplierSafetyQualification::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(ssq)){ | |||||
safetyVo.setSupplierSafetyQualification(ssq.stream() | |||||
.map(s -> BeanUtil.copyProperties(s, SupplierSafetyQualificationVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
vo.setSafetyInfo(safetyVo); | |||||
List<PersonSafetyInfo> psi = personSafetyInfoService.list(Wrappers.lambdaQuery(PersonSafetyInfo.class) | |||||
.eq(PersonSafetyInfo::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(psi)){ | |||||
safetyVo.setPersonSafetyInfo(psi.stream() | |||||
.map(p -> BeanUtil.copyProperties(p, PersonSafetyInfoVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
//查询初验信息 | |||||
List<PreInsAcceptancePerson> acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) | |||||
.in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PreInsAcceptancePerson::getCreateOn)); | |||||
vo.setAcceptancePersons(convertPersons(acceptancePersons)); | |||||
//查询终验信息 | |||||
//查询年度投资金额 要是已验收的项目 | |||||
if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { | |||||
List<AnnualAmountVO> annualAmounts = Lists.newArrayList(); | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(projectInfo.getProjectYear()) | |||||
.annualAmount(projectInfo.getAnnualPlanAmount()) | |||||
.build()); | |||||
List<ProjectRenewalFundDeclaration> renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) | |||||
.eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) | |||||
.orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); | |||||
Optional.ofNullable(renewalDeclarations).ifPresent(declarations -> | |||||
declarations.forEach(declaration -> { | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(declaration.getProjectYear()) | |||||
.annualAmount(declaration.getAnnualPaymentAmount()) | |||||
.build()); | |||||
}) | |||||
); | |||||
vo.setAnnualAccumulateAmountList(annualAmounts); | |||||
} | |||||
// 处理文件名 | |||||
List<Long> fileIdList = new ArrayList<>(); | |||||
BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
if (!fileIdList.isEmpty()) { | |||||
List<File> files = fileService.listByIds(fileIdList); | |||||
Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | |||||
vo.setApprovedFileName(fileMap.get(vo.getApprovedFile())); | |||||
vo.setApprovedConstructionPlanFileName(fileMap.get(vo.getApprovedConstructionPlanFile())); | |||||
} | |||||
return vo; | |||||
} | |||||
/** | |||||
* @param projectId 项目详情 不查询最新版本 | |||||
* @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO | |||||
* @author ZPF | |||||
* @since 2023/02/11 11:15 | |||||
*/ | |||||
public ProjectDetailVO getProjectDetailThisVersion(Long projectId) { | |||||
// 查询最新的项目申报信息 | |||||
Project projectInfo = projectService.getById(projectId); | |||||
if (Objects.isNull(projectInfo)) { | |||||
return null; | |||||
} | |||||
ProjectDetailVO vo = new ProjectDetailVO(); | |||||
BeanUtils.copyProperties(projectInfo, vo); | |||||
vo.buildDynamicForm(projectInfo.getDynamicForm()); | |||||
// 查询应用 | |||||
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()) | |||||
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct()) | |||||
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion())); | |||||
Optional.ofNullable(applications).ifPresent(apps -> | |||||
vo.setProjectApplications(CollUtils.convert(apps, | |||||
ProjectHelper::convertVO) | |||||
)); | |||||
//审批信息 | |||||
ProcessDetailReq req = new ProcessDetailReq(); | |||||
req.setInstanceId(projectInfo.getInstCode()); | |||||
req.setProjectId(projectId); | |||||
vo.setProcess(todoService.getProcessDetail(req)); | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectInfo); | |||||
//查询采购备案 | |||||
List<Purchase> purchases = purchaseService.listByProjectId(projectId); | |||||
vo.setPurchases(BeanUtil.copyToList(purchases, PurchaseVO.class)); | |||||
//查询合同备案 | |||||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId) | |||||
.last(BizConst.LIMIT_1)); | |||||
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); | |||||
vo.setContract(contractVO); | |||||
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) | |||||
.in(PaymentPlan::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PaymentPlan::getPaymentTime)); | |||||
if (Objects.nonNull(contractVO)) { | |||||
contractVO.setPayments(convertPayments(payments, | |||||
contractVO.getTotalAmount())); | |||||
} | |||||
//查询实施信息 | |||||
Operation operation = operationService.getOne(Wrappers.lambdaQuery(Operation.class) | |||||
.in(Operation::getProjectId, allVersionProjectId) | |||||
.orderByAsc(Operation::getCreateOn) | |||||
.last(BizConst.LIMIT_1)); | |||||
vo.setOperation(BeanUtil.copyProperties(operation, OperationVO.class)); | |||||
SafetyMonitorVO safetyVo = new SafetyMonitorVO(); | |||||
//查询风险监测 | |||||
List<SupplierSafetyQualification> ssq = supplierSafetyQualificationService.list(Wrappers.lambdaQuery(SupplierSafetyQualification.class) | |||||
.eq(SupplierSafetyQualification::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(ssq)){ | |||||
safetyVo.setSupplierSafetyQualification(ssq.stream() | |||||
.map(s -> BeanUtil.copyProperties(s, SupplierSafetyQualificationVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
vo.setSafetyInfo(safetyVo); | |||||
List<PersonSafetyInfo> psi = personSafetyInfoService.list(Wrappers.lambdaQuery(PersonSafetyInfo.class) | |||||
.eq(PersonSafetyInfo::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(psi)){ | |||||
safetyVo.setPersonSafetyInfo(psi.stream() | |||||
.map(p -> BeanUtil.copyProperties(p, PersonSafetyInfoVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
//查询初验信息 | |||||
List<PreInsAcceptancePerson> acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) | |||||
.in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PreInsAcceptancePerson::getCreateOn)); | |||||
vo.setAcceptancePersons(convertPersons(acceptancePersons)); | |||||
//查询终验信息 | |||||
//查询年度投资金额 要是已验收的项目 | |||||
if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { | |||||
List<AnnualAmountVO> annualAmounts = Lists.newArrayList(); | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(projectInfo.getProjectYear()) | |||||
.annualAmount(projectInfo.getAnnualPlanAmount()) | |||||
.build()); | |||||
List<ProjectRenewalFundDeclaration> renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) | |||||
.eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) | |||||
.orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); | |||||
Optional.ofNullable(renewalDeclarations).ifPresent(declarations -> | |||||
declarations.forEach(declaration -> { | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(declaration.getProjectYear()) | |||||
.annualAmount(declaration.getAnnualPaymentAmount()) | |||||
.build()); | |||||
}) | |||||
); | |||||
vo.setAnnualAccumulateAmountList(annualAmounts); | |||||
} | |||||
// 处理文件名 | |||||
List<Long> fileIdList = new ArrayList<>(); | |||||
BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
if (!fileIdList.isEmpty()) { | |||||
List<File> files = fileService.listByIds(fileIdList); | |||||
Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | |||||
vo.setApprovedFileName(fileMap.get(vo.getApprovedFile())); | |||||
vo.setApprovedConstructionPlanFileName(fileMap.get(vo.getApprovedConstructionPlanFile())); | |||||
} | |||||
return vo; | |||||
} | |||||
/** | |||||
* 申报新项目时 保存项目信息和其它相关联的信息 | * 申报新项目时 保存项目信息和其它相关联的信息 | ||||
* | * | ||||
* @param projectDto | * @param projectDto | ||||
@@ -639,213 +871,6 @@ public class ProjectLibManage { | |||||
} | } | ||||
/** | /** | ||||
* @param projectId 项目详情 | |||||
* @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO | |||||
* @author ZPF | |||||
* @since 2023/02/11 11:15 | |||||
*/ | |||||
public ProjectDetailVO getProjectDetail(Long projectId) { | |||||
// 查询最新的项目申报信息 | |||||
Project projectInfo = projectService.getNewProject(projectId); | |||||
if (Objects.isNull(projectInfo)) { | |||||
return null; | |||||
} | |||||
ProjectDetailVO vo = new ProjectDetailVO(); | |||||
BeanUtils.copyProperties(projectInfo, vo); | |||||
vo.buildDynamicForm(projectInfo.getDynamicForm()); | |||||
// 查询应用 | |||||
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()) | |||||
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct()) | |||||
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion())); | |||||
Optional.ofNullable(applications).ifPresent(apps -> | |||||
vo.setProjectApplications(CollUtils.convert(apps, | |||||
ProjectHelper::convertVO) | |||||
)); | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectInfo); | |||||
//查询采购备案 | |||||
List<Purchase> purchases = purchaseService.listByProjectId(projectId); | |||||
vo.setPurchases(BeanUtil.copyToList(purchases, PurchaseVO.class)); | |||||
//查询合同备案 | |||||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId) | |||||
.last(BizConst.LIMIT_1)); | |||||
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); | |||||
vo.setContract(contractVO); | |||||
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) | |||||
.in(PaymentPlan::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PaymentPlan::getPaymentTime)); | |||||
if (Objects.nonNull(contractVO)) { | |||||
contractVO.setPayments(convertPayments(payments, | |||||
contractVO.getTotalAmount())); | |||||
} | |||||
//查询实施信息 | |||||
Operation operation = operationService.getOne(Wrappers.lambdaQuery(Operation.class) | |||||
.in(Operation::getProjectId, allVersionProjectId) | |||||
.orderByAsc(Operation::getCreateOn) | |||||
.last(BizConst.LIMIT_1)); | |||||
vo.setOperation(BeanUtil.copyProperties(operation, OperationVO.class)); | |||||
SafetyMonitorVO safetyVo = new SafetyMonitorVO(); | |||||
//查询风险监测 | |||||
List<SupplierSafetyQualification> ssq = supplierSafetyQualificationService.list(Wrappers.lambdaQuery(SupplierSafetyQualification.class) | |||||
.eq(SupplierSafetyQualification::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(ssq)){ | |||||
safetyVo.setSupplierSafetyQualification(ssq.stream() | |||||
.map(s -> BeanUtil.copyProperties(s, SupplierSafetyQualificationVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
vo.setSafetyInfo(safetyVo); | |||||
List<PersonSafetyInfo> psi = personSafetyInfoService.list(Wrappers.lambdaQuery(PersonSafetyInfo.class) | |||||
.eq(PersonSafetyInfo::getProjectCode, projectInfo.getProjectCode())); | |||||
if(CollUtil.isNotEmpty(psi)){ | |||||
safetyVo.setPersonSafetyInfo(psi.stream() | |||||
.map(p -> BeanUtil.copyProperties(p, PersonSafetyInfoVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | |||||
//查询初验信息 | |||||
List<PreInsAcceptancePerson> acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) | |||||
.in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PreInsAcceptancePerson::getCreateOn)); | |||||
vo.setAcceptancePersons(convertPersons(acceptancePersons)); | |||||
//查询终验信息 | |||||
//查询年度投资金额 要是已验收的项目 | |||||
if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { | |||||
List<AnnualAmountVO> annualAmounts = Lists.newArrayList(); | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(projectInfo.getProjectYear()) | |||||
.annualAmount(projectInfo.getAnnualPlanAmount()) | |||||
.build()); | |||||
List<ProjectRenewalFundDeclaration> renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) | |||||
.eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) | |||||
.orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); | |||||
Optional.ofNullable(renewalDeclarations).ifPresent(declarations -> | |||||
declarations.forEach(declaration -> { | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(declaration.getProjectYear()) | |||||
.annualAmount(declaration.getAnnualPaymentAmount()) | |||||
.build()); | |||||
}) | |||||
); | |||||
vo.setAnnualAccumulateAmountList(annualAmounts); | |||||
} | |||||
// 处理文件名 | |||||
List<Long> fileIdList = new ArrayList<>(); | |||||
BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
if (!fileIdList.isEmpty()) { | |||||
List<File> files = fileService.listByIds(fileIdList); | |||||
Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | |||||
vo.setApprovedFileName(fileMap.get(vo.getApprovedFile())); | |||||
vo.setApprovedConstructionPlanFileName(fileMap.get(vo.getApprovedConstructionPlanFile())); | |||||
} | |||||
return vo; | |||||
} | |||||
/** | |||||
* @param projectId 项目详情 不查询最新版本 | |||||
* @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO | |||||
* @author ZPF | |||||
* @since 2023/02/11 11:15 | |||||
*/ | |||||
public ProjectDetailVO getProjectDetailThisVersion(Long projectId) { | |||||
// 查询最新的项目申报信息 | |||||
Project projectInfo = projectService.getById(projectId); | |||||
if (Objects.isNull(projectInfo)) { | |||||
return null; | |||||
} | |||||
ProjectDetailVO vo = new ProjectDetailVO(); | |||||
BeanUtils.copyProperties(projectInfo, vo); | |||||
vo.buildDynamicForm(projectInfo.getDynamicForm()); | |||||
// 查询应用 | |||||
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()) | |||||
.eq(ProjectApplication::getIsConstruct, projectInfo.getIsConstruct()) | |||||
.eq(ProjectApplication::getProjectVersion, projectInfo.getVersion())); | |||||
Optional.ofNullable(applications).ifPresent(apps -> | |||||
vo.setProjectApplications(CollUtils.convert(apps, | |||||
ProjectHelper::convertVO) | |||||
)); | |||||
//审批信息 | |||||
ProcessDetailReq req = new ProcessDetailReq(); | |||||
req.setInstanceId(projectInfo.getInstCode()); | |||||
req.setProjectId(projectId); | |||||
vo.setProcess(todoService.getProcessDetail(req)); | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(projectInfo); | |||||
//查询采购备案 | |||||
List<Purchase> purchases = purchaseService.listByProjectId(projectId); | |||||
vo.setPurchases(BeanUtil.copyToList(purchases, PurchaseVO.class)); | |||||
//查询合同备案 | |||||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId) | |||||
.last(BizConst.LIMIT_1)); | |||||
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); | |||||
vo.setContract(contractVO); | |||||
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) | |||||
.in(PaymentPlan::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PaymentPlan::getPaymentTime)); | |||||
if (Objects.nonNull(contractVO)) { | |||||
contractVO.setPayments(convertPayments(payments, | |||||
contractVO.getTotalAmount())); | |||||
} | |||||
//查询初验信息 | |||||
List<PreInsAcceptancePerson> acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) | |||||
.in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) | |||||
.orderByAsc(PreInsAcceptancePerson::getCreateOn)); | |||||
vo.setAcceptancePersons(convertPersons(acceptancePersons)); | |||||
//查询终验信息 | |||||
//查询年度投资金额 要是已验收的项目 | |||||
if (ProjectStatusEnum.ACCEPTED.getCode().equals(projectInfo.getStatus())) { | |||||
List<AnnualAmountVO> annualAmounts = Lists.newArrayList(); | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(projectInfo.getProjectYear()) | |||||
.annualAmount(projectInfo.getAnnualPlanAmount()) | |||||
.build()); | |||||
List<ProjectRenewalFundDeclaration> renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) | |||||
.eq(ProjectRenewalFundDeclaration::getProjectId, vo.getId()) | |||||
.orderByAsc(ProjectRenewalFundDeclaration::getProjectYear)); | |||||
Optional.ofNullable(renewalDeclarations).ifPresent(declarations -> | |||||
declarations.forEach(declaration -> { | |||||
annualAmounts.add(AnnualAmountVO.builder() | |||||
.projectId(projectInfo.getId()) | |||||
.projectYear(declaration.getProjectYear()) | |||||
.annualAmount(declaration.getAnnualPaymentAmount()) | |||||
.build()); | |||||
}) | |||||
); | |||||
vo.setAnnualAccumulateAmountList(annualAmounts); | |||||
} | |||||
// 处理文件名 | |||||
List<Long> fileIdList = new ArrayList<>(); | |||||
BizUtils.notBlank(vo.getApprovedFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
BizUtils.notBlank(vo.getApprovedConstructionPlanFile(), w -> fileIdList.add(Long.parseLong(w))); | |||||
if (!fileIdList.isEmpty()) { | |||||
List<File> files = fileService.listByIds(fileIdList); | |||||
Map<String, String> fileMap = CollUtils.listToMap(files, w -> w.getId().toString(), File::getOriginalFileName); | |||||
vo.setApprovedFileName(fileMap.get(vo.getApprovedFile())); | |||||
vo.setApprovedConstructionPlanFileName(fileMap.get(vo.getApprovedConstructionPlanFile())); | |||||
} | |||||
return vo; | |||||
} | |||||
/** | |||||
* 获取项目初步方案详情 | * 获取项目初步方案详情 | ||||
* | * | ||||
* @param projectId | * @param projectId | ||||
@@ -325,6 +325,10 @@ public class Project implements Serializable { | |||||
@Compare("建设周期(月)") | @Compare("建设周期(月)") | ||||
private String buildCycle; | private String buildCycle; | ||||
@ApiModelProperty("原始建设周期(月)") | |||||
@Compare("建设周期(月)") | |||||
private Integer originBuildCycle; | |||||
@ApiModelProperty("建设方案文件") | @ApiModelProperty("建设方案文件") | ||||
@Compare("建设方案文件") | @Compare("建设方案文件") | ||||
private String constructionPlanFile; | private String constructionPlanFile; | ||||
@@ -453,10 +457,17 @@ public class Project implements Serializable { | |||||
@Compare("合同总金额") | @Compare("合同总金额") | ||||
private BigDecimal contractAmount; | private BigDecimal contractAmount; | ||||
@ApiModelProperty("计划验收时间") | |||||
@ApiModelProperty("计划验收时间(有可能是延期后的)") | |||||
@Compare("计划验收时间") | @Compare("计划验收时间") | ||||
private LocalDateTime planAcceptanceTime; | private LocalDateTime planAcceptanceTime; | ||||
@ApiModelProperty("原本计划验收时间") | |||||
@Compare("原本计划验收时间") | |||||
private LocalDateTime originPlanAcceptanceTime; | |||||
@ApiModelProperty("延期月份数") | |||||
private Integer applyDelayMonths; | |||||
@ApiModelProperty("申请延期佐证材料") | @ApiModelProperty("申请延期佐证材料") | ||||
private String applyDelayFile; | private String applyDelayFile; | ||||
@@ -3,6 +3,7 @@ package com.ningdatech.pmapi.projectlib.model.vo; | |||||
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.alibaba.fastjson.annotation.JSONField; | import com.alibaba.fastjson.annotation.JSONField; | ||||
import com.ningdatech.basic.util.NdDateUtils; | import com.ningdatech.basic.util.NdDateUtils; | ||||
import com.ningdatech.pmapi.common.compare.Compare; | |||||
import com.ningdatech.pmapi.common.util.BizUtils; | import com.ningdatech.pmapi.common.util.BizUtils; | ||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | import com.ningdatech.pmapi.portrait.model.vo.TagVO; | ||||
import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; | import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; | ||||
@@ -405,6 +406,17 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("是否退回|驳回的项目版本") | @ApiModelProperty("是否退回|驳回的项目版本") | ||||
private Boolean isBackReject; | private Boolean isBackReject; | ||||
@ApiModelProperty("原本计划验收时间") | |||||
@Compare("原本计划验收时间") | |||||
private LocalDateTime originPlanAcceptanceTime; | |||||
@ApiModelProperty("延期月份数") | |||||
private Integer applyDelayMonths; | |||||
@ApiModelProperty("原始建设周期(月)") | |||||
@Compare("建设周期(月)") | |||||
private Integer originBuildCycle; | |||||
public String getVersionStr() { | public String getVersionStr() { | ||||
if (Objects.nonNull(this.newest) && this.newest) { | if (Objects.nonNull(this.newest) && this.newest) { | ||||
this.versionStr = "当前版本"; | this.versionStr = "当前版本"; | ||||
@@ -14,6 +14,7 @@ import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | ||||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | ||||
import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | |||||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | import com.ningdatech.pmapi.sys.manage.NoticeManage; | ||||
import com.ningdatech.pmapi.sys.model.entity.Notify; | import com.ningdatech.pmapi.sys.model.entity.Notify; | ||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | ||||
@@ -54,17 +55,7 @@ public class EarlyWarningListener { | |||||
private final IProjectService projectService; | private final IProjectService projectService; | ||||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | |||||
private final UserInfoHelper userInfoHelper; | |||||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||||
private final NoticeManage noticeManage; | |||||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||||
private final INotifyService notifyService; | |||||
private final EarlyWarningManage earlyWarningManage; | |||||
@Async | @Async | ||||
@EventListener | @EventListener | ||||
@@ -120,72 +111,18 @@ public class EarlyWarningListener { | |||||
return; | return; | ||||
} | } | ||||
for(HistoricActivityInstance hai : hais){ | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | |||||
//1.存入 预警记录 | |||||
String assignee = hai.getAssignee(); | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee); | |||||
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); | |||||
String content = convertContent(noticeContent,project.getProjectName(), | |||||
InstTypeEnum.getByCode(pi.getInstType()),timeout); | |||||
records.setAreaCode(project.getAreaCode()); | |||||
records.setBuildOrgCode(project.getBuildOrgCode()); | |||||
records.setBuildOrgName(project.getBuildOrgName()); | |||||
records.setCreateOn(LocalDateTime.now()); | |||||
records.setWarningTime(LocalDateTime.now()); | |||||
records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); | |||||
records.setInstType(pi.getInstType()); | |||||
records.setNoticeMethod(noticeMethod); | |||||
records.setNoticeContent(content); | |||||
records.setProjectName(project.getProjectName()); | |||||
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | |||||
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); | |||||
records.setWarningEmployeecode(assignee); | |||||
earlyWarningRecordsService.save(records); | |||||
//2.消息提醒 | |||||
Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content); | |||||
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name()); | |||||
notifyService.save(notify); | |||||
//3.发短信 | |||||
if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){ | |||||
SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext(); | |||||
context.setReceiveNumber(user.getMobile()); | |||||
context.setContent(content); | |||||
yxtCallOrSmsHelper.sendSms(context); | |||||
} | |||||
//4.浙政钉 | |||||
if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){ | |||||
// 获取发送浙政钉工作通知必要信息 | |||||
WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(assignee); | |||||
passWorkNoticeInfo.setMsg(content); | |||||
// 放入工作通知暂存表中,通过扫表异步发送 | |||||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); | |||||
} | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | } | ||||
} | |||||
/** | |||||
* 转换出 通知的内容 | |||||
* @param noticeContent | |||||
* @param projectName | |||||
* @param instTypeEnum | |||||
* @param timeout | |||||
* @return | |||||
*/ | |||||
private String convertContent(String noticeContent, String projectName, InstTypeEnum instTypeEnum, Integer timeout) { | |||||
noticeContent = noticeContent.replace("{projectName}",projectName) | |||||
.replace("{flowType}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{flowType}") | |||||
.replace("{time}",String.valueOf(timeout)); | |||||
log.info("通知内容 :{}",noticeContent); | |||||
return noticeContent; | |||||
for(HistoricActivityInstance hai : hais){ | |||||
String employeeCode = hai.getAssignee(); | |||||
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,timeout,pi.getInstType(), | |||||
hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() | |||||
,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | |||||
} | |||||
} | } | ||||
} | } |
@@ -7,11 +7,16 @@ import com.alibaba.fastjson.JSONArray; | |||||
import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | import com.ningdatech.pmapi.common.enumeration.CommonEnum; | ||||
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; | |||||
import com.ningdatech.pmapi.projectdeclared.model.entity.Operation; | |||||
import com.ningdatech.pmapi.projectdeclared.service.IContractService; | |||||
import com.ningdatech.pmapi.projectdeclared.service.IOperationService; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; | import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | |||||
import com.wflow.bean.entity.WflowEarlyWarning; | import com.wflow.bean.entity.WflowEarlyWarning; | ||||
import com.wflow.enums.WarningRuleTypeEnum; | import com.wflow.enums.WarningRuleTypeEnum; | ||||
import com.wflow.service.IEarlyWarningService; | import com.wflow.service.IEarlyWarningService; | ||||
@@ -23,7 +28,9 @@ import org.springframework.scheduling.annotation.Scheduled; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.net.InetAddress; | import java.net.InetAddress; | ||||
import java.net.UnknownHostException; | import java.net.UnknownHostException; | ||||
import java.time.*; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import java.util.Objects; | import java.util.Objects; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
@@ -44,10 +51,14 @@ public class EarlyWarningInstanceNotStartTask { | |||||
private final IProjectService projectService; | private final IProjectService projectService; | ||||
private final IProjectInstService projectInstService; | |||||
private final EarlyWarningManage earlyWarningManage; | |||||
@Scheduled(cron = "0 2 * * * ?") | |||||
public void doTask() throws UnknownHostException { | |||||
private final IContractService contractService; | |||||
private final IOperationService operationService; | |||||
@Scheduled(cron = "0 0/2 * * * ?") | |||||
public void doEarlyWarningDeclared() throws UnknownHostException { | |||||
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | ||||
return; | return; | ||||
} | } | ||||
@@ -74,6 +85,7 @@ public class EarlyWarningInstanceNotStartTask { | |||||
return; | return; | ||||
} | } | ||||
String noticeContent = warning.getNoticeContent(); | |||||
String rule = warning.getRule(); | String rule = warning.getRule(); | ||||
if(StringUtils.isNotBlank(rule)){ | if(StringUtils.isNotBlank(rule)){ | ||||
JSONArray ruleArray = JSON.parseArray(rule); | JSONArray ruleArray = JSON.parseArray(rule); | ||||
@@ -89,7 +101,7 @@ public class EarlyWarningInstanceNotStartTask { | |||||
WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); | WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); | ||||
if(Objects.isNull(flowTypeEnum)){ | if(Objects.isNull(flowTypeEnum)){ | ||||
log.info("匹配不到 流程类型"); | |||||
log.info("匹配不到 业务类型"); | |||||
return; | return; | ||||
} | } | ||||
@@ -98,15 +110,51 @@ public class EarlyWarningInstanceNotStartTask { | |||||
String areaCode = warning.getAreaCode(); | String areaCode = warning.getAreaCode(); | ||||
//测试先用分钟 | //测试先用分钟 | ||||
//查询 所有这个区域的项目 未提交的项目 | //查询 所有这个区域的项目 未提交的项目 | ||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.eq(Project::getAreaCode, areaCode) | .eq(Project::getAreaCode, areaCode) | ||||
.eq(Project::getNewest, Boolean.TRUE) | .eq(Project::getNewest, Boolean.TRUE) | ||||
.eq(Project::getStatus,projectStutas)); | .eq(Project::getStatus,projectStutas)); | ||||
List<Long> projectIds = projects.stream().map(Project::getId) | |||||
log.info("needNextProjects :{}",needNextProjects.size()); | |||||
//需要发通知的项目 | |||||
List<Project> needToWaringProjects = needNextProjects.stream() | |||||
.filter(p -> { | |||||
//判断 当状态在 建设中的时候 是不是要初验了 | |||||
if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){ | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(p); | |||||
//如果合同信息提交过了 才是 待初验状态 | |||||
if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){ | |||||
if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId))){ | |||||
return Boolean.FALSE; | |||||
} | |||||
} | |||||
} | |||||
log.info("projectId :{}",p.getId()); | |||||
log.info("秒数差 :{}",Duration.between(p.getUpdateOn(),LocalDateTime.now()).getSeconds()); | |||||
if(Duration.between(p.getUpdateOn(),LocalDateTime.now()).getSeconds() >= time * 60 && //time * 60 | |||||
Duration.between(p.getUpdateOn(),LocalDateTime.now()).getSeconds() <= time * 60 + 119){ //time * 60 | |||||
return Boolean.TRUE; | |||||
} | |||||
return Boolean.FALSE; | |||||
}) | |||||
.collect(Collectors.toList()); | .collect(Collectors.toList()); | ||||
projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) | |||||
.in(ProjectInst::getProjectId,projectIds) | |||||
.eq(ProjectInst::getInstType,biz)); | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | |||||
for(Project needToWaringProject : needToWaringProjects){ | |||||
//去预警通知 | |||||
String employeeCode = needToWaringProject.getSponsor(); | |||||
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz, | |||||
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, | |||||
WarningRuleTypeEnum.DECLARED_WARNING.getCode()); | |||||
} | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -116,4 +164,128 @@ public class EarlyWarningInstanceNotStartTask { | |||||
log.info("=========== 预警填报超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | log.info("=========== 预警填报超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | ||||
} | } | ||||
@Scheduled(cron = "10 0/2 * * * ?") | |||||
public void doEarlyWarningOperation() throws UnknownHostException { | |||||
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | |||||
return; | |||||
} | |||||
log.info("=========== 预警实施超时任务开始 ========"); | |||||
StopWatch stopWatch = new StopWatch(); | |||||
stopWatch.start(); | |||||
// 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则 | |||||
List<WflowEarlyWarning> warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) | |||||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode())); | |||||
for(WflowEarlyWarning warning : warnings){ | |||||
//2. 取出rule的数据 | |||||
if(!warning.getIsOpen()){ | |||||
log.info(warning.getId() + " 此规则关闭了"); | |||||
continue; | |||||
} | |||||
String noticeMethod = warning.getNoticeMethod(); | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | |||||
String noticeContent = warning.getNoticeContent(); | |||||
String rule = warning.getRule(); | |||||
if(StringUtils.isNotBlank(rule)){ | |||||
JSONArray ruleArray = JSON.parseArray(rule); | |||||
if(CollUtil.isNotEmpty(ruleArray)){ | |||||
ruleArray.forEach(r -> { | |||||
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); | |||||
Integer time = rJson.getInteger("time"); | |||||
Integer biz = rJson.getInteger("biz"); | |||||
if(Objects.isNull(time) || Objects.isNull(biz)){ | |||||
log.info("规则数据 错误 :{}",rJson); | |||||
return; | |||||
} | |||||
WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(biz); | |||||
if(Objects.isNull(operationTypeEnum)){ | |||||
log.info("匹配不到 业务类型"); | |||||
return; | |||||
} | |||||
//得出 对应待提交的项目状态 | |||||
Integer projectStutas = operationTypeEnum.getProjectStutas(); | |||||
String areaCode = warning.getAreaCode(); | |||||
//测试先用分钟 | |||||
//查询 所有这个区域的项目 未提交的项目 | |||||
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.eq(Project::getAreaCode, areaCode) | |||||
.eq(Project::getNewest, Boolean.TRUE) | |||||
.eq(Project::getStatus,projectStutas)); | |||||
log.info("needNextProjects :{}",needNextProjects.size()); | |||||
List<String> projectCodes = needNextProjects.stream().map(Project::getProjectCode).collect(Collectors.toList()); | |||||
List<Operation> operations = operationService.list(Wrappers.lambdaQuery(Operation.class) | |||||
.in(Operation::getProjectCode, projectCodes)); | |||||
Map<String,Operation> operationMap = operations.stream().collect(Collectors.toMap(Operation::getProjectCode,o -> o)); | |||||
//需要发通知的项目 | |||||
List<Project> needToWaringProjects = needNextProjects.stream() | |||||
.filter(p -> { | |||||
//判断 当状态在 建设中的时候 是不是要初验了 | |||||
if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){ | |||||
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(p); | |||||
//如果合同信息提交过了 才是 待初验状态 | |||||
if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){ | |||||
if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class) | |||||
.in(Contract::getProjectId, allVersionProjectId))){ | |||||
return Boolean.FALSE; | |||||
} | |||||
} | |||||
} | |||||
//判断 实施信息中 初验和终验的时间 | |||||
if(!operationMap.containsKey(p.getProjectCode())){ | |||||
return Boolean.FALSE; | |||||
} | |||||
Operation operation = operationMap.get(p.getProjectCode()); | |||||
if(WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)){ | |||||
//初验 | |||||
if(Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).getSeconds() >= time * 60 && //time * 60 | |||||
Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).getSeconds() <= time * 60 + 119){ //time * 60 | |||||
return Boolean.TRUE; | |||||
} | |||||
}else if(WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)){ | |||||
//终验 | |||||
if(Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).getSeconds() >= time * 60 && //time * 60 | |||||
Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).getSeconds() <= time * 60 + 119){ //time * 60 | |||||
return Boolean.TRUE; | |||||
} | |||||
} | |||||
return Boolean.FALSE; | |||||
}) | |||||
.collect(Collectors.toList()); | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | |||||
for(Project needToWaringProject : needToWaringProjects){ | |||||
//去预警通知 | |||||
String employeeCode = needToWaringProject.getSponsor(); | |||||
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz, | |||||
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, | |||||
WarningRuleTypeEnum.OPERATION_WARNING.getCode()); | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
} | |||||
stopWatch.stop(); | |||||
log.info("=========== 预警实施超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | |||||
} | |||||
} | } |
@@ -0,0 +1,155 @@ | |||||
package com.ningdatech.pmapi.sys.manage; | |||||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | |||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; | |||||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||||
import com.ningdatech.yxt.model.cmd.SendSmsCmd; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.stereotype.Component; | |||||
import java.time.LocalDateTime; | |||||
import java.util.Objects; | |||||
/** | |||||
* @Classname EarlyWarningManage | |||||
* @Description | |||||
* @Date 2023/8/7 9:25 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@Component | |||||
@AllArgsConstructor | |||||
@Slf4j | |||||
public class EarlyWarningManage { | |||||
private final UserInfoHelper userInfoHelper; | |||||
private final NoticeManage noticeManage; | |||||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | |||||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||||
private final INotifyService notifyService; | |||||
/** | |||||
* 预警通知 | |||||
* @param noticeMethod | |||||
* @param noticeContent | |||||
* @param timeout | |||||
* @param employeeCode | |||||
* @param project | |||||
*/ | |||||
public void doEarlyWarning(String noticeMethod,String noticeContent, Integer timeout,Integer biz, | |||||
LocalDateTime startTime,String employeeCode, Project project,Integer ruleType) { | |||||
//1.存入 预警记录 | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); | |||||
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); | |||||
String content = StringUtils.EMPTY; | |||||
switch (WarningRuleTypeEnum.checkByCode(ruleType)){ | |||||
case PROCESS_WARNING: | |||||
content = convertContent(noticeContent,project.getProjectName(), | |||||
InstTypeEnum.getByCode(biz),timeout); | |||||
break; | |||||
case DECLARED_WARNING: | |||||
content = convertContent(noticeContent,project.getProjectName(), | |||||
WarningOperationTypeEnum.getByCode(biz),timeout); | |||||
break; | |||||
case OPERATION_WARNING: | |||||
content = convertContent(noticeContent,project.getProjectName(), | |||||
WarningFlowTypeEnum.getByCode(biz),timeout); | |||||
break; | |||||
default: | |||||
log.info("匹配不到 规则类型"); | |||||
return; | |||||
} | |||||
records.setAreaCode(project.getAreaCode()); | |||||
records.setBuildOrgCode(project.getBuildOrgCode()); | |||||
records.setBuildOrgName(project.getBuildOrgName()); | |||||
records.setCreateOn(LocalDateTime.now()); | |||||
records.setWarningTime(LocalDateTime.now()); | |||||
records.setInstStart(startTime); | |||||
records.setInstType(biz); | |||||
records.setNoticeMethod(noticeMethod); | |||||
records.setNoticeContent(content); | |||||
records.setProjectName(project.getProjectName()); | |||||
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | |||||
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); | |||||
records.setWarningEmployeecode(employeeCode); | |||||
earlyWarningRecordsService.save(records); | |||||
//2.消息提醒 | |||||
Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content); | |||||
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name()); | |||||
notifyService.save(notify); | |||||
//3.发短信 | |||||
if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){ | |||||
SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext(); | |||||
context.setReceiveNumber(user.getMobile()); | |||||
context.setContent(content); | |||||
yxtCallOrSmsHelper.sendSms(context); | |||||
} | |||||
//4.浙政钉 | |||||
if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){ | |||||
// 获取发送浙政钉工作通知必要信息 | |||||
WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(employeeCode); | |||||
passWorkNoticeInfo.setMsg(content); | |||||
// 放入工作通知暂存表中,通过扫表异步发送 | |||||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); | |||||
} | |||||
} | |||||
/** | |||||
* 转换出 通知的内容 | |||||
* @param noticeContent | |||||
* @param projectName | |||||
* @param instTypeEnum | |||||
* @param timeout | |||||
* @return | |||||
*/ | |||||
private String convertContent(String noticeContent, String projectName, InstTypeEnum instTypeEnum, Integer timeout) { | |||||
noticeContent = noticeContent.replace("{projectName}",projectName) | |||||
.replace("{flowType}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{flowType}") | |||||
.replace("{stepName}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{stepName}") | |||||
.replace("{time}",String.valueOf(timeout)); | |||||
log.info("通知内容 :{}",noticeContent); | |||||
return noticeContent; | |||||
} | |||||
private String convertContent(String noticeContent, String projectName, WarningFlowTypeEnum warningFlowTypeEnum, Integer timeout) { | |||||
noticeContent = noticeContent.replace("{projectName}",projectName) | |||||
.replace("{flowType}",Objects.nonNull(warningFlowTypeEnum) ? warningFlowTypeEnum.getDesc() : "{flowType}") | |||||
.replace("{stepName}",Objects.nonNull(warningFlowTypeEnum) ? warningFlowTypeEnum.getDesc() : "{stepName}") | |||||
.replace("{time}",String.valueOf(timeout)); | |||||
log.info("通知内容 :{}",noticeContent); | |||||
return noticeContent; | |||||
} | |||||
private String convertContent(String noticeContent, String projectName, WarningOperationTypeEnum operationTypeEnum, Integer timeout) { | |||||
noticeContent = noticeContent.replace("{projectName}",projectName) | |||||
.replace("{flowType}",Objects.nonNull(operationTypeEnum) ? operationTypeEnum.getDesc() : "{flowType}") | |||||
.replace("{stepName}",Objects.nonNull(operationTypeEnum) ? operationTypeEnum.getDesc() : "{stepName}") | |||||
.replace("{time}",String.valueOf(timeout)); | |||||
log.info("通知内容 :{}",noticeContent); | |||||
return noticeContent; | |||||
} | |||||
} |
@@ -1,6 +1,8 @@ | |||||
package com.ningdatech.pmapi.sys.model.vo; | package com.ningdatech.pmapi.sys.model.vo; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | import com.wflow.enums.WarningRuleTypeEnum; | ||||
import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
@@ -107,10 +109,22 @@ public class WflowEarlyWarningRecordsVO implements Serializable { | |||||
private String updateBy; | private String updateBy; | ||||
public String getInstTypeName(){ | public String getInstTypeName(){ | ||||
if(Objects.nonNull(this.instType)){ | |||||
InstTypeEnum instEnum = InstTypeEnum.getByCode(this.instType); | |||||
if(Objects.nonNull(instEnum)){ | |||||
return instEnum.getDesc(); | |||||
if(Objects.nonNull(this.instType) && Objects.nonNull(this.ruleType)){ | |||||
if(this.ruleType.equals(WarningRuleTypeEnum.PROCESS_WARNING.getCode())){ | |||||
InstTypeEnum instEnum = InstTypeEnum.getByCode(this.instType); | |||||
if(Objects.nonNull(instEnum)){ | |||||
return instEnum.getDesc(); | |||||
} | |||||
}else if(this.ruleType.equals(WarningRuleTypeEnum.DECLARED_WARNING.getCode())){ | |||||
WarningFlowTypeEnum warningFlowTypeEnum = WarningFlowTypeEnum.getByCode(this.instType); | |||||
if(Objects.nonNull(warningFlowTypeEnum)){ | |||||
return warningFlowTypeEnum.getDesc(); | |||||
} | |||||
}else if(this.ruleType.equals(WarningRuleTypeEnum.OPERATION_WARNING.getCode())){ | |||||
WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(this.instType); | |||||
if(Objects.nonNull(operationTypeEnum)){ | |||||
return operationTypeEnum.getDesc(); | |||||
} | |||||
} | } | ||||
} | } | ||||
return StringUtils.EMPTY; | return StringUtils.EMPTY; | ||||
@@ -256,6 +256,9 @@ public class HandlerManage { | |||||
declaredProject.setInstCode(instanceId); | declaredProject.setInstCode(instanceId); | ||||
declaredProject.setApplyDelayFile(delayApply.getDelayApplyFile()); | declaredProject.setApplyDelayFile(delayApply.getDelayApplyFile()); | ||||
declaredProject.setApplyDelayReason(delayApply.getDelayApplyReason()); | declaredProject.setApplyDelayReason(delayApply.getDelayApplyReason()); | ||||
//增加总延期的月份 | |||||
declaredProject.setApplyDelayMonths(Objects.nonNull(declaredProject.getApplyDelayMonths()) ? | |||||
declaredProject.getApplyDelayMonths() + delayApply.getDelayTime() : delayApply.getDelayTime()); | |||||
projectService.updateById(declaredProject); | projectService.updateById(declaredProject); | ||||
} | } | ||||
@@ -1115,6 +1115,9 @@ public class TodoCenterManage { | |||||
project.setUpdateOn(LocalDateTime.now()); | project.setUpdateOn(LocalDateTime.now()); | ||||
projectService.save(project); | projectService.save(project); | ||||
oldProject.setIsBackReject(Boolean.TRUE); | |||||
projectService.updateById(oldProject); | |||||
ProjectInst oldInst = projectInstService.getOne(Wrappers.lambdaUpdate(ProjectInst.class) | ProjectInst oldInst = projectInstService.getOne(Wrappers.lambdaUpdate(ProjectInst.class) | ||||
.eq(ProjectInst::getProjectId, oldProject.getId()) | .eq(ProjectInst::getProjectId, oldProject.getId()) | ||||
.eq(ProjectInst::getInstCode, oldProject.getInstCode())); | .eq(ProjectInst::getInstCode, oldProject.getInstCode())); | ||||