@@ -32,12 +32,15 @@ import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.PaymentPlan; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.PreInsAcceptancePerson; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.PaymentPlanVO; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.PreInsAcceptancePersonVO; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; | |||
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.projectdeclared.utils.GenerateProjectCodeUtil; | |||
@@ -66,6 +69,7 @@ import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.math.BigDecimal; | |||
import java.time.LocalDateTime; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
@@ -102,6 +106,8 @@ public class ProjectLibManage { | |||
private final IPreInsAcceptancePersonService acceptancePersonService; | |||
private final IPaymentPlanService paymentPlanService; | |||
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) { | |||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | |||
query.eq(Project::getNewest,Boolean.TRUE); | |||
@@ -540,7 +546,12 @@ public class ProjectLibManage { | |||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||
.in(Contract::getProjectId, allVersionProjectId) | |||
.last(BizConst.LIMIT_1)); | |||
vo.setContract(BeanUtil.copyProperties(contract, ContractVO.class)); | |||
ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class); | |||
vo.setContract(contractVO); | |||
List<PaymentPlan> payments = paymentPlanService.list(Wrappers.lambdaQuery(PaymentPlan.class) | |||
.eq(PaymentPlan::getProjectId, projectId) | |||
.orderByAsc(PaymentPlan::getPaymentTime)); | |||
contractVO.setPayments(convertPayments(payments,contractVO.getTotalAmount())); | |||
//查询初验信息 | |||
List<PreInsAcceptancePerson> acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) | |||
@@ -788,4 +799,18 @@ public class ProjectLibManage { | |||
return acceptancePersons.stream().map(u -> BeanUtil.copyProperties(u,PreInsAcceptancePersonVO.class)).collect(Collectors.toList()); | |||
} | |||
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()); | |||
} | |||
} |
@@ -0,0 +1,102 @@ | |||
package com.ningdatech.pmapi.scheduler.listener; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.cache.model.cache.CacheKey; | |||
import com.ningdatech.cache.repository.CachePlusOps; | |||
import com.ningdatech.pmapi.common.constant.BizConst; | |||
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.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.wflow.bean.entity.WflowCcTasks; | |||
import com.wflow.service.WflowCcTasksService; | |||
import com.wflow.workflow.notify.event.CcTaskEvent; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.flowable.engine.HistoryService; | |||
import org.flowable.engine.history.HistoricProcessInstance; | |||
import org.springframework.context.event.EventListener; | |||
import org.springframework.scheduling.annotation.Async; | |||
import org.springframework.stereotype.Component; | |||
import java.time.Duration; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.CC_MSG_TEMPLATE; | |||
/** | |||
* 工作流开始 事件监听 | |||
* | |||
* @author ZPF | |||
* @return | |||
* @since 2023/04/14 14:19 | |||
*/ | |||
@Slf4j | |||
@Component | |||
@RequiredArgsConstructor | |||
public class CcTaskListener { | |||
private final IProjectInstService projectInstService; | |||
private final HistoryService historyService; | |||
private final IProjectService projectService; | |||
private final NoticeManage noticeManage; | |||
private final WflowCcTasksService ccTasksService; | |||
private final CachePlusOps cachePlusOps; | |||
private static final String DUP_KEY = "ccTasks"; | |||
private static final String NODE = "node:"; | |||
@Async | |||
@EventListener | |||
public void onApplicationEvent(CcTaskEvent event) { | |||
log.info("进入抄送人任务 事件监听!{}", JSON.toJSONString(event)); | |||
String instCode = event.getInstCode(); | |||
String processDefinitionId = event.getProcessDefinitionId(); | |||
String nodeId = event.getNodeId(); | |||
String taskId = event.getTaskId(); | |||
//这里 redis 处理一下 1分钟处理同一 nodeId 一次 | |||
if (cachePlusOps.get(NODE + nodeId + DUP_KEY) != null) { | |||
log.info("一分钟只能处理该nodeId一次!{}", nodeId); | |||
return; | |||
} | |||
//1分钟 | |||
CacheKey key = new CacheKey(); | |||
key.setKey(NODE + nodeId + DUP_KEY); | |||
key.setExpire(Duration.ofMinutes(1)); | |||
cachePlusOps.set(key, nodeId); | |||
//1.去查找 项目实例关系表 | |||
List<WflowCcTasks> tasks = ccTasksService.list(Wrappers.lambdaQuery(WflowCcTasks.class) | |||
.eq(WflowCcTasks::getInstanceId, instCode) | |||
.eq(WflowCcTasks::getNodeId, nodeId)); | |||
if (Objects.isNull(tasks)) { | |||
return; | |||
} | |||
tasks.stream().forEach(task -> { | |||
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() | |||
.processInstanceId(instCode) | |||
.singleResult(); | |||
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) | |||
.eq(ProjectInst::getInstCode, instCode) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.isNull(projectInst) || Objects.isNull(instance)){ | |||
return; | |||
} | |||
Long projectId = projectInst.getProjectId(); | |||
Project project = projectService.getNewProject(projectId); | |||
//发送消息 | |||
noticeManage.sendNotice(task.getUserId(),93L,project,instance.getProcessDefinitionName(), | |||
CC_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW_CC); | |||
}); | |||
} | |||
} |
@@ -46,7 +46,9 @@ public enum MsgTypeEnum { | |||
/** | |||
* 项目审核驳回 | |||
*/ | |||
PROJECT_REVIEW_REJECT(7,"项目审核"); | |||
PROJECT_REVIEW_REJECT(7,"项目审核"), | |||
PROJECT_REVIEW_CC(8,"项目抄送"); | |||
private Integer code; | |||
private String desc; | |||
@@ -10,6 +10,8 @@ public interface WorkNoticeContant { | |||
public final String BACK_MSG_TEMPLATE = "【%s】的【%s】被退回,请及时处理。"; | |||
public final String REJECT_MSG_TEMPLATE = "【%s】的【%s】被驳回,请及时处理。"; | |||
public final String CC_MSG_TEMPLATE = "【%s】的【%s】有消息抄送您,请查看详情"; | |||
public final String AUDIT_WORK_TITLE = "审核任务"; | |||
public final String EXPERT_REVIEW_TEMPLATE = "【%s】的【%s】待您评审,请及时处理。"; | |||