|
|
@@ -1,6 +1,5 @@ |
|
|
|
package com.ningdatech.pmapi.projectdeclared.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
@@ -12,32 +11,33 @@ import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.basic.util.NdDateUtils; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; |
|
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelDownUtil; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelExportStyle; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.dto.ContractSaveDTO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.PaymentPlan; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.vo.FinalAcceptanceVO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.vo.PaymentPlanVO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IContractService; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IPaymentPlanService; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IPreInsAcceptancePersonService; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; |
|
|
|
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import com.wflow.bean.entity.WflowModels; |
|
|
|
import com.wflow.exception.BusinessException; |
|
|
|
import com.wflow.workflow.bean.dto.OrgInfoDTO; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessStartParamsVo; |
|
|
|
import com.wflow.workflow.service.ProcessInstanceService; |
|
|
|
import com.wflow.workflow.service.ProcessModelService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@@ -46,9 +46,6 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@@ -69,16 +66,13 @@ public class FinalAcceptanceManage { |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
private final StateMachineUtils stateMachineUtils; |
|
|
|
|
|
|
|
private final IPurchaseService purchaseService; |
|
|
|
|
|
|
|
private final IContractService contractService; |
|
|
|
|
|
|
|
private final IPaymentPlanService paymentPlanService; |
|
|
|
private final ProcessModelService processModelService; |
|
|
|
|
|
|
|
private final IPreInsAcceptancePersonService acceptancePersonService; |
|
|
|
private final ProcessInstanceService processInstanceService; |
|
|
|
|
|
|
|
private final StateMachineUtils stateMachineUtils; |
|
|
|
private final DefaultDeclaredProjectManage declaredProjectManage; |
|
|
|
|
|
|
|
/** |
|
|
|
* 待采购的-项目列表 |
|
|
@@ -102,12 +96,6 @@ public class FinalAcceptanceManage { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> projectIds = page.getRecords().stream().map(Project::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds)); |
|
|
|
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v)); |
|
|
|
|
|
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
|
|
item.setId(w.getId()); |
|
|
@@ -125,11 +113,6 @@ public class FinalAcceptanceManage { |
|
|
|
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); |
|
|
|
item.setApprovedAmount(w.getApprovalAmount()); |
|
|
|
item.setApprovalDate(w.getApprovalDate()); |
|
|
|
if(purchaseMap.containsKey(w.getId())){ |
|
|
|
Purchase purchase = purchaseMap.get(w.getId()); |
|
|
|
item.setTransactionAmount(purchase.getTransactionAmount()); |
|
|
|
item.setTransactionTime(purchase.getTransactionTime()); |
|
|
|
} |
|
|
|
item.setBuildCycle(StringUtils.isNotBlank(w.getBuildCycle()) ? |
|
|
|
Integer.valueOf(w.getBuildCycle()) : null); |
|
|
|
return item; |
|
|
@@ -153,12 +136,6 @@ public class FinalAcceptanceManage { |
|
|
|
AtomicInteger serialNumber = new AtomicInteger(0); |
|
|
|
List<DeclaredProjectExportDTO> collect = Lists.newArrayList(); |
|
|
|
if(CollUtil.isNotEmpty(records)){ |
|
|
|
List<Long> projectIds = records.stream().map(Project::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds)); |
|
|
|
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v)); |
|
|
|
|
|
|
|
collect = records.stream().map(r -> { |
|
|
|
DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO(); |
|
|
|
BeanUtils.copyProperties(r, exportDTO); |
|
|
@@ -196,114 +173,6 @@ public class FinalAcceptanceManage { |
|
|
|
return StringUtils.EMPTY; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取合同备案详情 |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ContractVO detailContractByProjectId(Long projectId) { |
|
|
|
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) |
|
|
|
.eq(Contract::getProjectId, projectId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
ContractVO vo = BeanUtil.copyProperties(contract, ContractVO.class); |
|
|
|
|
|
|
|
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) |
|
|
|
.eq(PaymentPlan::getProjectId, projectId) |
|
|
|
.orderByAsc(PaymentPlan::getPaymentTime)); |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(payments)){ |
|
|
|
vo.setPayments(convertPayments(payments,contract.getTotalAmount())); |
|
|
|
} |
|
|
|
|
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
private List<PaymentPlanVO> convertPayments(List<PaymentPlan> payments,BigDecimal totalAmount) { |
|
|
|
if(CollUtil.isEmpty(payments)){ |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
return payments.stream().map(p -> { |
|
|
|
PaymentPlanVO vo = BeanUtil.copyProperties(p, PaymentPlanVO.class); |
|
|
|
vo.setRatio((Objects.isNull(totalAmount)||totalAmount.compareTo(BigDecimal.ZERO) == 0) ? "0%" |
|
|
|
: p.getPaymentAmount().multiply(BigDecimal.valueOf(100)) |
|
|
|
.divide(totalAmount,BigDecimal.ROUND_CEILING,BigDecimal.ROUND_CEILING) + "%"); |
|
|
|
return vo; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填写合同信息 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String submitContract(ContractSaveDTO dto) { |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
String employeeCode = user.getEmployeeCode(); |
|
|
|
VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); |
|
|
|
|
|
|
|
Long projectId = dto.getProjectId(); |
|
|
|
VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!"); |
|
|
|
Project project = projectService.getNewProject(dto.getProjectId()); |
|
|
|
VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); |
|
|
|
|
|
|
|
//首先要判断 项目当前状态 是不是 采购结果备案 |
|
|
|
VUtils.isTrue(!ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(project.getStatus()) || |
|
|
|
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(project.getStage())) |
|
|
|
.throwMessage("提交失败 该项目不是 建设中或者已立项阶段"); |
|
|
|
|
|
|
|
Contract contractEntity = new Contract(); |
|
|
|
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) |
|
|
|
.eq(Contract::getProjectId, projectId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
BeanUtil.copyProperties(dto,contractEntity); |
|
|
|
if(Objects.isNull(contract)){ |
|
|
|
contractEntity.setCreateOn(LocalDateTime.now()); |
|
|
|
contractEntity.setCreateBy(employeeCode); |
|
|
|
}else{ |
|
|
|
contractEntity.setId(contract.getId()); |
|
|
|
} |
|
|
|
contractEntity.setProjectId(projectId); |
|
|
|
if(contractService.saveOrUpdate(contractEntity)){ |
|
|
|
//存 付款计划信心 |
|
|
|
if(Objects.nonNull(dto.getPayments())){ |
|
|
|
//先删除 |
|
|
|
paymentPlanService.remove(Wrappers.lambdaQuery(PaymentPlan.class) |
|
|
|
.eq(PaymentPlan::getProjectId,projectId)); |
|
|
|
if(CollUtil.isNotEmpty(dto.getPayments())){ |
|
|
|
List<PaymentPlan> payments = dto.getPayments().stream().map(d -> { |
|
|
|
PaymentPlan plan = BeanUtil.copyProperties(d, PaymentPlan.class); |
|
|
|
plan.setProjectId(projectId); |
|
|
|
plan.setCreateOn(LocalDateTime.now()); |
|
|
|
plan.setUpdateOn(LocalDateTime.now()); |
|
|
|
plan.setCreateBy(employeeCode); |
|
|
|
plan.setUpdateBy(employeeCode); |
|
|
|
return plan; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
paymentPlanService.saveBatch(payments); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//判断下 如果和初验都完成了 才进入下一阶段 |
|
|
|
if(StringUtils.isNotBlank(project.getPreliminaryInspectionMaterials())){ |
|
|
|
//进入到下一状态 |
|
|
|
stateMachineUtils.pass(project); |
|
|
|
} |
|
|
|
project.setUpdateOn(LocalDateTime.now()); |
|
|
|
if(Objects.nonNull(dto.getDeliveryTime())){ |
|
|
|
project.setDeliveryTime(dto.getDeliveryTime()); |
|
|
|
} |
|
|
|
if(Objects.nonNull(dto.getTotalAmount())){ |
|
|
|
project.setContractAmount(dto.getTotalAmount()); |
|
|
|
} |
|
|
|
projectService.updateById(project); |
|
|
|
|
|
|
|
return "填写成功"; |
|
|
|
} |
|
|
|
|
|
|
|
public FinalAcceptanceVO detailByProjectId(Long projectId) { |
|
|
|
FinalAcceptanceVO vo = new FinalAcceptanceVO(); |
|
|
@@ -325,7 +194,57 @@ public class FinalAcceptanceManage { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String startProcess(DefaultDeclaredDTO dto) { |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
String employeeCode = user.getEmployeeCode(); |
|
|
|
VUtils.isTrue(Objects.isNull(user) || Objects.isNull(employeeCode)) |
|
|
|
.throwMessage("获取登录用户失败!"); |
|
|
|
|
|
|
|
ProjectDTO projectDto = dto.getProjectInfo(); |
|
|
|
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); |
|
|
|
Project projectInfo = projectService.getNewProject(projectDto.getId()); |
|
|
|
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); |
|
|
|
VUtils.isTrue(StringUtils.isBlank(projectDto.getFinalAcceptanceMaterials())).throwMessage("提交失败 请提交终验材料!"); |
|
|
|
|
|
|
|
String regionCode = projectInfo.getAreaCode(); |
|
|
|
|
|
|
|
//放入终验材料 |
|
|
|
projectInfo.setFinalAcceptanceMaterials(projectDto.getFinalAcceptanceMaterials()); |
|
|
|
|
|
|
|
WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) |
|
|
|
.eq(WflowModels::getRegionCode, regionCode) |
|
|
|
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.ACCEPTANCE_DECLARATION_APPROVAL_PROCESS.getCode()) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
if (Objects.isNull(model)) { |
|
|
|
log.error("此 【{}】区域找不到 验收申报流程配置", regionCode); |
|
|
|
throw new BusinessException(String.format("此 【%s】区域找不到 验收申报流程配置", regionCode)); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
//首先要判断 项目当前状态 是不是 方案待申报 |
|
|
|
VUtils.isTrue(!ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode().equals(projectInfo.getStatus()) || |
|
|
|
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(projectInfo.getStage())) |
|
|
|
.throwMessage("提交失败 该项目不是 待终验状态或者已立项阶段"); |
|
|
|
|
|
|
|
ProcessStartParamsVo params = new ProcessStartParamsVo(); |
|
|
|
params.setUser(declaredProjectManage.buildUser(employeeCode)); |
|
|
|
params.setProcessUsers(Collections.emptyMap()); |
|
|
|
//放入条件判断的项目字段 |
|
|
|
//把条件值给放入工作流 |
|
|
|
declaredProjectManage.buildCondition(params, dto); |
|
|
|
// 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 |
|
|
|
Map<String, OrgInfoDTO> orgModelMap = declaredProjectManage.buildOrgModelMap(employeeCode, projectInfo); |
|
|
|
String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap); |
|
|
|
log.info("终验方案项目申报成功 【{}】", instanceId); |
|
|
|
|
|
|
|
//保存终验项目 |
|
|
|
//生成新版本 并且进入下一状态 |
|
|
|
// projectInfo = projectLibManage.saveProjectWithVersionAndPass(projectInfo,instanceId, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()); |
|
|
|
// |
|
|
|
// |
|
|
|
// //发送给第一个审批人消息 |
|
|
|
// noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, |
|
|
|
// WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); |
|
|
|
|
|
|
|
return instanceId; |
|
|
|
} |
|
|
|
} |