feat(REQ-3300) - 完善申请用印逻辑
This commit is contained in:
parent
3bec06cb96
commit
2d85d1e3f2
@ -13,6 +13,19 @@ public interface VisaConstant {
|
||||
* 用于在流程作用域外识别变洽签的单据类型
|
||||
*/
|
||||
String WORKFLOW_VAR_VISA_TYPE_KEY = "visa-type";
|
||||
/**
|
||||
* 申请用印,针对单位创建的审批携带的 ouId
|
||||
*/
|
||||
String WORKFLOW_VAR_STAMP_OU_ID = "stamp_ou_id";
|
||||
/**
|
||||
* 申请用印,针对单位的签章类型
|
||||
*/
|
||||
String WORKFLOW_VAR_STAMP_TYPE = "stamp_type";
|
||||
/**
|
||||
* 申请用印,针对单位的签章位置
|
||||
*/
|
||||
String WORKFLOW_VAR_STAMP_RECIPIENT = "stamp_recipient";
|
||||
|
||||
/**
|
||||
* 用于发送待办的变量名
|
||||
*/
|
||||
|
||||
@ -50,4 +50,10 @@ public class RefreshableConfiguration {
|
||||
*/
|
||||
@Value("${visa.verifyChangeContextLimit: 50}")
|
||||
private Integer verifyChangeContextLimit;
|
||||
|
||||
/**
|
||||
* 申请用印创建流程的业务 ID
|
||||
*/
|
||||
@Value("${visa.stampProcessDefinitionKey:bgqzyy}")
|
||||
private String stampProcessDefinitionKey;
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.nanopart.visa.api.enums.VisaStampStatusEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaStatusEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaTypeEnum;
|
||||
import cn.axzo.nanopart.visa.api.request.ChangeStatusRequest;
|
||||
import cn.axzo.nanopart.visa.server.config.RefreshableConfiguration;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecord;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordLog;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordRelation;
|
||||
@ -47,7 +48,8 @@ public class ProcessInstanceAllEventHandler extends BasicLogSupport implements P
|
||||
protected final ChangeRecordService changeRecordService;
|
||||
protected final ChangeRecordRelationService changeRecordRelationService;
|
||||
protected final ChangeRecordBillService changeRecordBillService;
|
||||
public static List<String> SUPPORTED_DEFINITION_KEYS = Lists.newArrayList(
|
||||
protected final RefreshableConfiguration refreshableConfiguration;
|
||||
public final static List<String> SUPPORTED_DEFINITION_KEYS = Lists.newArrayList(
|
||||
DESIGN_CHANGE.getProcessDefinitionKey(),
|
||||
TECHNOLOGY_APPROVED.getProcessDefinitionKey(),
|
||||
PROJECT_VISA.getProcessDefinitionKey()
|
||||
@ -57,11 +59,14 @@ public class ProcessInstanceAllEventHandler extends BasicLogSupport implements P
|
||||
VisaOrganizationalNodeUserGateway visaOrganizationalNodeUserGateway,
|
||||
ChangeRecordService changeRecordService,
|
||||
ChangeRecordRelationService changeRecordRelationService,
|
||||
ChangeRecordBillService changeRecordBillService) {
|
||||
ChangeRecordBillService changeRecordBillService,
|
||||
RefreshableConfiguration refreshableConfiguration) {
|
||||
super(eventProducer, visaOrganizationalNodeUserGateway);
|
||||
this.changeRecordService = changeRecordService;
|
||||
this.changeRecordRelationService = changeRecordRelationService;
|
||||
this.changeRecordBillService = changeRecordBillService;
|
||||
this.refreshableConfiguration = refreshableConfiguration;
|
||||
SUPPORTED_DEFINITION_KEYS.add(refreshableConfiguration.getStampProcessDefinitionKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -10,6 +10,7 @@ import cn.axzo.nanopart.visa.server.mq.producer.VisaChangeLogPayload;
|
||||
import cn.axzo.nanopart.visa.server.rpc.VisaOrganizationalNodeUserGateway;
|
||||
import cn.axzo.workflow.common.model.response.mq.ProcessTaskDTO;
|
||||
import cn.axzo.workflow.starter.handler.ProcessTaskEventHandler;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -25,6 +26,7 @@ import static cn.axzo.nanopart.visa.server.mq.listener.workflow.process.ProcessI
|
||||
* @since 2025-01-17 11:34
|
||||
*/
|
||||
@Component
|
||||
@DependsOn("processInstanceAllEventHandler")
|
||||
public class ProcessTaskAllEventHandler extends BasicLogSupport implements ProcessTaskEventHandler {
|
||||
|
||||
public ProcessTaskAllEventHandler(EventProducer eventProducer, VisaOrganizationalNodeUserGateway visaOrganizationalNodeUserGateway) {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package cn.axzo.nanopart.visa.server.rpc;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BeforeProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceAbortDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCheckApproverDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.NodesByModelVO;
|
||||
import cn.axzo.workflow.starter.api.WorkflowCoreService;
|
||||
import cn.axzo.workflow.starter.api.WorkflowManageService;
|
||||
import cn.azxo.framework.common.logger.MethodAroundLog;
|
||||
@ -13,6 +15,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/22
|
||||
@ -61,4 +65,9 @@ public class WorkflowGateway {
|
||||
}
|
||||
return workflowManageService.hasPrintTemplate(processInstanceId);
|
||||
}
|
||||
|
||||
@MethodAroundLog(target = "workflow-engine", source = "nanopart", value = "创建流程前,拉取节点列表,用于发起时自选审批人")
|
||||
public List<NodesByModelVO> nodesBeforeCreateProcessInstance(BeforeProcessInstanceCreateDTO dto) {
|
||||
return workflowCoreService.nodesBeforeCreateProcessInstance(dto);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,44 +1,99 @@
|
||||
package cn.axzo.nanopart.visa.server.service;
|
||||
|
||||
import cn.axzo.apollo.api.req.QueryOrderToBasicReq;
|
||||
import cn.axzo.apollo.api.res.TaskOrderToBasicRes;
|
||||
import cn.axzo.apollo.workspace.api.workspace.res.GetDetailRes;
|
||||
import cn.axzo.apollo.workspace.api.workspace.res.ProjectDetailRes;
|
||||
import cn.axzo.basics.common.constant.enums.OrganizationalUnitTypeEnum;
|
||||
import cn.axzo.basics.common.util.NumberUtil;
|
||||
import cn.axzo.digital.req.ListRectifyOrderReq;
|
||||
import cn.axzo.digital.resp.RectifyOrderResp;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.maokai.api.vo.request.OrganizationalUnitQuery;
|
||||
import cn.axzo.maokai.api.vo.response.OrganizationalUnitVO;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaBillTypeEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaButtonTypeEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaConfirmBizTypeEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaLogTypeEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaRelationFieldEnum;
|
||||
import cn.axzo.nanopart.visa.api.enums.VisaStatusEnum;
|
||||
import cn.axzo.nanopart.visa.api.request.ChangeStatusRequest;
|
||||
import cn.axzo.nanopart.visa.api.request.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.nanopart.visa.api.request.VisaChangeTempCreateReq;
|
||||
import cn.axzo.nanopart.visa.api.response.VisaDetailByIdResponse;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecord;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordBill;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordConfirm;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordRelation;
|
||||
import cn.axzo.nanopart.visa.server.dto.VisaAddLogContext;
|
||||
import cn.axzo.nanopart.visa.server.dto.VisaConfirmDto;
|
||||
import cn.axzo.nanopart.visa.server.dto.VisaLogParam;
|
||||
import cn.axzo.nanopart.visa.server.rpc.ApolloConstructionAreaGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.ApolloTaskOrderApiGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.DrawingMajorGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.LogApiGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.OrganizationalUnitGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.RectifyApiGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.VisaOrganizationalNodeUserGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.VisaProjectApiGateway;
|
||||
import cn.axzo.nanopart.visa.server.rpc.WorkspaceGateway;
|
||||
import cn.axzo.nanopart.visa.server.utils.Constants;
|
||||
import cn.axzo.orggateway.api.nodeuser.dto.OrgNodeUserDTO;
|
||||
import cn.axzo.orggateway.api.nodeuser.req.ListOrgNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
||||
import cn.axzo.thor.client.model.DrawingMajorResp;
|
||||
import cn.axzo.workflow.common.model.dto.UploadFieldDTO;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_AMOUNT_CHANGE;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_ATTACH;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_CONTEXT;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_CONTEXT_DESCRIPTION;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_DESCRIPTION;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_HAPPEN_TIME;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_NO;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_PERSON;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_REASON;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_AREA;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_PROFESSIONAL;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_PROJECT;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_RECTIFICATION_ORDER;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_TASK_ORDER;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_RELATION_VISA_ORDER;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_TOPIC;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_UNIT;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_UNIT_PERSON;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_WORKSPACE_NAME;
|
||||
import static cn.axzo.nanopart.visa.server.utils.Constants.DATE_FORMAT;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/22
|
||||
@ -63,9 +118,33 @@ public class VisaHelper {
|
||||
@Resource
|
||||
private ChangeRecordConfirmService changeRecordConfirmService;
|
||||
|
||||
@Resource
|
||||
private ChangeRecordRelationService changeRecordRelationService;
|
||||
|
||||
@Resource
|
||||
private ChangeRecordBillService changeRecordBillService;
|
||||
|
||||
@Resource
|
||||
private LogApiGateway logApiGateway;
|
||||
|
||||
@Resource
|
||||
private WorkspaceGateway workspaceGateway;
|
||||
|
||||
@Resource
|
||||
private VisaProjectApiGateway visaProjectApiGateway;
|
||||
|
||||
@Resource
|
||||
private OrganizationalUnitGateway organizationalUnitGateway;
|
||||
|
||||
@Resource
|
||||
private VisaOrganizationalNodeUserGateway visaOrganizationalNodeUserGateway;
|
||||
|
||||
@Resource
|
||||
private ApolloTaskOrderApiGateway taskOrderApiGateway;
|
||||
|
||||
@Resource
|
||||
private RectifyApiGateway rectifyApiGateway;
|
||||
|
||||
/**
|
||||
* 状态更新与添加日志,此时新增记录时状态没有维护
|
||||
*/
|
||||
@ -109,16 +188,16 @@ public class VisaHelper {
|
||||
, JSONUtil.toJsonStr(Pair.of(oldContext, newContext)));
|
||||
}
|
||||
changeRecordService.changeStatus(ChangeStatusRequest.builder()
|
||||
.visaId(newContext.getChangeRecord().getId())
|
||||
.updateStatus(newContext.getStatus())
|
||||
.personId(newContext.getPersonId())
|
||||
.ouId(newContext.getOuId())
|
||||
.workspaceId(newContext.getWorkspaceId())
|
||||
.newAmountChange(newContext.getChangeRecord().getAmountChange())
|
||||
.oldAmountChange(oldContext.getChangeRecord().getAmountChange())
|
||||
.visaId(newContext.getChangeRecord().getId())
|
||||
.updateStatus(newContext.getStatus())
|
||||
.personId(newContext.getPersonId())
|
||||
.ouId(newContext.getOuId())
|
||||
.workspaceId(newContext.getWorkspaceId())
|
||||
.newAmountChange(newContext.getChangeRecord().getAmountChange())
|
||||
.oldAmountChange(oldContext.getChangeRecord().getAmountChange())
|
||||
// .newAttach(newContext.getAttachList())
|
||||
// .oldAttach(oldContext.getAttachList())
|
||||
.editFormFlag(true)
|
||||
.editFormFlag(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
@ -276,4 +355,250 @@ public class VisaHelper {
|
||||
}
|
||||
return amountDesc;
|
||||
}
|
||||
|
||||
public Map<String, Object> buildStartFormVariables(VisaChangeApproveCreateReq req) {
|
||||
Map<String, Object> formVariables = new HashMap<>();
|
||||
// 传递表单数据
|
||||
formVariables.put(FORM_FIELD_NO, req.getNo());
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||
formVariables.put(FORM_FIELD_HAPPEN_TIME, sdf.format(req.getHappenTime()));
|
||||
formVariables.put(FORM_FIELD_TOPIC, req.getTopic());
|
||||
GetDetailRes workspaceRes = workspaceGateway.getById(req.getRelationWorkspaceId());
|
||||
formVariables.put(FORM_FIELD_WORKSPACE_NAME, Objects.isNull(workspaceRes) ? "" : workspaceRes.getName());
|
||||
ProjectDetailRes projectDetailRes = visaProjectApiGateway.getProjectById(req.getRelationProject());
|
||||
formVariables.put(FORM_FIELD_RELATION_PROJECT, projectDetailRes.getProjectInfo().getName());
|
||||
formVariables.put(FORM_FIELD_RELATION_PROFESSIONAL, buildProfessionalName(req.getRelationProject(), req.getRelationProfessional()));
|
||||
formVariables.put(FORM_FIELD_REASON, req.getReason());
|
||||
formVariables.put(FORM_FIELD_RELATION_AREA, buildAreaName(req.getRelationArea()));
|
||||
formVariables.put(FORM_FIELD_CONTEXT_DESCRIPTION, buildContextDescription(req.getChangeContextAndDescriptionList()));
|
||||
formVariables.put(FORM_FIELD_UNIT_PERSON, buildUnitPerson(req.getRelationUnitAndPersonList(), req.getRelationWorkspaceId()));
|
||||
|
||||
// 非必填项
|
||||
if (Objects.nonNull(req.getAmountChange())) {
|
||||
formVariables.put(FORM_FIELD_AMOUNT_CHANGE, buildChangeAmount(req.getAmountChange()));
|
||||
}
|
||||
|
||||
// 三种单据
|
||||
if (MapUtils.isNotEmpty(req.getRelationOrderMap())) {
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> taskOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.TASK.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(taskOrders)) {
|
||||
List<Map<String, String>> taskOrderMaps = new ArrayList<>();
|
||||
taskOrders.forEach(i -> {
|
||||
Map<String, String> taskOrderMap = new HashMap<>();
|
||||
taskOrderMap.put("id", i.getNo());
|
||||
taskOrderMap.put("no", i.getNo());
|
||||
taskOrderMap.put("name", i.getName());
|
||||
taskOrderMaps.add(taskOrderMap);
|
||||
});
|
||||
formVariables.put(FORM_FIELD_RELATION_TASK_ORDER, taskOrderMaps);
|
||||
}
|
||||
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> rectificationOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.RECTIFY.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(rectificationOrders)) {
|
||||
formVariables.put(FORM_FIELD_RELATION_RECTIFICATION_ORDER, rectificationOrders);
|
||||
}
|
||||
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> visaOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.DESIGN_VISA.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(visaOrders)) {
|
||||
formVariables.put(FORM_FIELD_RELATION_VISA_ORDER, visaOrders);
|
||||
}
|
||||
}
|
||||
formVariables.put(FORM_FIELD_ATTACH, req.getAttach());
|
||||
return formVariables;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> buildContextDescription(List<VisaChangeTempCreateReq.ChangeContextAndDescription> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Map<String, Object>> contextDescriptions = new ArrayList<>();
|
||||
list.forEach(i -> {
|
||||
Map<String, Object> contextDescription = new HashMap<>();
|
||||
UploadFieldDTO uploadFieldDTO = new UploadFieldDTO();
|
||||
uploadFieldDTO.setFileKey(i.getFileKey());
|
||||
uploadFieldDTO.setFileName(i.getFileName());
|
||||
uploadFieldDTO.setFileUrl(i.getFileUrl());
|
||||
contextDescription.put(FORM_FIELD_CONTEXT, uploadFieldDTO);
|
||||
contextDescription.put(FORM_FIELD_DESCRIPTION, i.getText());
|
||||
contextDescriptions.add(contextDescription);
|
||||
});
|
||||
return contextDescriptions;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> buildUnitPerson(List<VisaChangeTempCreateReq.RelationUnitAndPerson> list, Long workspaceId) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> ouIds = list.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getOuId).distinct().collect(Collectors.toList());
|
||||
Map<Long, OrganizationalUnitVO> unitMap = organizationalUnitGateway.list(OrganizationalUnitQuery.builder().unitIds(ouIds).build())
|
||||
.stream().collect(Collectors.toMap(OrganizationalUnitVO::getId, Function.identity(), (s, t) -> s));
|
||||
|
||||
Map<Long, List<VisaChangeTempCreateReq.RelationUnitAndPerson>> unitGroupBy = list.stream().collect(Collectors.groupingBy(VisaChangeTempCreateReq.RelationUnitAndPerson::getOuId, Collectors.toList()));
|
||||
List<Map<String, Object>> unitPersons = new ArrayList<>();
|
||||
|
||||
unitGroupBy.forEach((unitId, persons) -> {
|
||||
Map<String, Object> unitPerson = new HashMap<>();
|
||||
OrganizationalUnitVO unitVo = unitMap.get(unitId);
|
||||
unitPerson.put(FORM_FIELD_UNIT, Objects.isNull(unitVo) ? "" : unitVo.getName() + "(" + OrganizationalUnitTypeEnum.getByType(unitVo.getType()).getDesc() + ")");
|
||||
List<OrgNodeUserDTO> personInfos = getPersonInfos(workspaceId, unitId, persons);
|
||||
unitPerson.put(FORM_FIELD_PERSON, buildPersonInfosStr(personInfos));
|
||||
unitPersons.add(unitPerson);
|
||||
});
|
||||
|
||||
return unitPersons;
|
||||
}
|
||||
|
||||
private List<OrgNodeUserDTO> getPersonInfos(Long workspaceId, Long unitId, List<VisaChangeTempCreateReq.RelationUnitAndPerson> persons) {
|
||||
PageResp<OrgNodeUserDTO> pageResp = visaOrganizationalNodeUserGateway.list(ListOrgNodeUserReq.builder()
|
||||
.personIds(persons.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getPersonId).collect(Collectors.toList()))
|
||||
.organizationalUnitId(unitId)
|
||||
.workspaceId(workspaceId)
|
||||
.organizationalNodeIds(persons.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getNodeId).collect(Collectors.toList()))
|
||||
.needs(ListNodeUserReq.Needs.builder().job(true).personProfile(true).build()).build());
|
||||
if (Objects.isNull(pageResp) || CollectionUtils.isEmpty(pageResp.getData())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return pageResp.getData();
|
||||
}
|
||||
|
||||
|
||||
public static String buildPersonInfosStr(List<OrgNodeUserDTO> personInfos) {
|
||||
StringBuilder personInfosStr = new StringBuilder();
|
||||
if (CollectionUtils.isEmpty(personInfos)) {
|
||||
return personInfosStr.toString();
|
||||
}
|
||||
|
||||
for (OrgNodeUserDTO info : personInfos) {
|
||||
if (personInfosStr.length() > 0) {
|
||||
personInfosStr.append(",");
|
||||
}
|
||||
personInfosStr.append(info.getPersonProfile().getRealName())
|
||||
.append(Objects.isNull(info.getJob()) ? "" : "-" + info.getJob().getName());
|
||||
}
|
||||
return personInfosStr.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过变更单id构建审批提交对象
|
||||
*
|
||||
* @param visaId 变更单id
|
||||
* @return VisaChangeApproveCreateReq
|
||||
*/
|
||||
public VisaChangeApproveCreateReq buildVisaChangeApproveCreateReqByVisaId(Long visaId) {
|
||||
if (NumberUtil.isNotPositiveNumber(visaId)) {
|
||||
return null;
|
||||
}
|
||||
ChangeRecord changeRecord = changeRecordService.getById(visaId);
|
||||
if (Objects.isNull(changeRecord)) {
|
||||
return null;
|
||||
}
|
||||
VisaChangeApproveCreateReq req = new VisaChangeApproveCreateReq();
|
||||
// 基本信息
|
||||
BeanUtil.copyProperties(changeRecord, req);
|
||||
// 工程名称
|
||||
ProjectDetailRes projectById = visaProjectApiGateway.getProjectById(changeRecord.getRelationProject());
|
||||
req.setRelationProjectName(projectById.getProjectInfo().getName());
|
||||
// 相关单位及人员
|
||||
VisaConfirmDto confirmDto = VisaConfirmDto.builder().visaId(changeRecord.getId()).bizType(VisaConfirmBizTypeEnum.CONFIRM).build();
|
||||
List<ChangeRecordConfirm> confirms = changeRecordConfirmService.findByCondition(confirmDto);
|
||||
if (CollectionUtils.isNotEmpty(confirms)) {
|
||||
req.setRelationUnitAndPersonList(confirms.stream()
|
||||
.map(item -> BeanUtil.copyProperties(item, VisaChangeTempCreateReq.RelationUnitAndPerson.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
// 发生内容说明
|
||||
List<ChangeRecordRelation> contentDescription = changeRecordRelationService.findByVisaAndVarName(changeRecord.getId(), VisaRelationFieldEnum.CONTENT_DESCRIPTION.name());
|
||||
if (CollectionUtils.isNotEmpty(contentDescription)) {
|
||||
req.setChangeContextAndDescriptionList(contentDescription.stream()
|
||||
.map(item -> {
|
||||
try {
|
||||
return JSONObject.parseObject(item.getContent(), VisaChangeTempCreateReq.ChangeContextAndDescription.class);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("发生内容说明解析失败");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
// 关联单据
|
||||
List<ChangeRecordBill> bills = changeRecordBillService.listById(changeRecord.getId());
|
||||
// 实时构建单据名称 TODO 此处应该可以使用异步进行优化
|
||||
if (CollectionUtils.isNotEmpty(bills)) {
|
||||
Map<String, List<VisaChangeTempCreateReq.OrderSimpleModel>> relationOrderMap = com.google.common.collect.Maps.newHashMap();
|
||||
bills.stream().collect(Collectors.groupingBy(b -> b.getBillType().name(),
|
||||
Collectors.mapping(Function.identity(), Collectors.toList())))
|
||||
.forEach((k, v) -> {
|
||||
if (VisaBillTypeEnum.TASK.name().equals(k)) {
|
||||
// 获取任务单数据
|
||||
QueryOrderToBasicReq queryOrderToBasicReq = new QueryOrderToBasicReq();
|
||||
queryOrderToBasicReq.setWorkspaceId(req.getRelationWorkspaceId());
|
||||
queryOrderToBasicReq.setTaskNos(v.stream().map(ChangeRecordBill::getBillNo).collect(Collectors.toList()));
|
||||
queryOrderToBasicReq.setPage(1);
|
||||
queryOrderToBasicReq.setPageSize(v.size());
|
||||
Map<String, TaskOrderToBasicRes> taskOrderMap = taskOrderApiGateway.pageOrderByForBasic(queryOrderToBasicReq).getData()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(TaskOrderToBasicRes::getTaskNo, Function.identity()));
|
||||
// 构建关联任务单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(taskOrderMap.get(item.getBillNo()))
|
||||
.map(TaskOrderToBasicRes::getTaskName)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
} else if (VisaBillTypeEnum.RECTIFY.name().equals(k)) {
|
||||
// 获取整改单数据
|
||||
ListRectifyOrderReq rectifyOrderReq = ListRectifyOrderReq.builder()
|
||||
.ids(v.stream().map(ChangeRecordBill::getBillId).collect(Collectors.toSet()))
|
||||
.build();
|
||||
Map<Long, RectifyOrderResp> rectifyOrderMap = rectifyApiGateway.listRectifyOrders(rectifyOrderReq)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(RectifyOrderResp::getId, Function.identity(), (v1, v2) -> v1));
|
||||
// 构建关联整改单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(rectifyOrderMap.get(item.getBillId()))
|
||||
.map(RectifyOrderResp::getBizName)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
} else if (VisaBillTypeEnum.DESIGN_VISA.name().equals(k)) {
|
||||
// 获取设计单数据
|
||||
Map<Long, ChangeRecord> changeRecordMap = changeRecordService.listByIds(v.stream().map(ChangeRecordBill::getBillId).collect(Collectors.toSet()))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ChangeRecord::getId, Function.identity(), (v1, v2) -> v1));
|
||||
// 构建关联设计单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(changeRecordMap.get(item.getBillId()))
|
||||
.map(ChangeRecord::getTopic)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
});
|
||||
req.setRelationOrderMap(relationOrderMap);
|
||||
}
|
||||
// 附件
|
||||
List<ChangeRecordRelation> attach = changeRecordRelationService.findByVisaAndVarName(changeRecord.getId(), VisaRelationFieldEnum.ATTACHMENT.name());
|
||||
if (CollectionUtils.isNotEmpty(attach)) {
|
||||
req.setAttach(attach.stream()
|
||||
.map(item -> {
|
||||
try {
|
||||
return JSONObject.parseObject(item.getContent(), UploadFieldDTO.class);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("附件解析失败");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return req;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,10 +21,12 @@ import cn.axzo.nanopart.visa.api.request.ChangeRecordAppendAttachReq;
|
||||
import cn.axzo.nanopart.visa.api.request.ImGroupOperationClearReq;
|
||||
import cn.axzo.nanopart.visa.api.request.ImGroupOperationReq;
|
||||
import cn.axzo.nanopart.visa.api.request.ImGroupTipsQueryReq;
|
||||
import cn.axzo.nanopart.visa.api.request.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.nanopart.visa.api.request.VisaChangeTempCreateReq;
|
||||
import cn.axzo.nanopart.visa.api.request.VisaRequestStampReq;
|
||||
import cn.axzo.nanopart.visa.api.response.ImGroupButton;
|
||||
import cn.axzo.nanopart.visa.api.response.ImGroupTipsResp;
|
||||
import cn.axzo.nanopart.visa.server.config.RefreshableConfiguration;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecord;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordRelation;
|
||||
import cn.axzo.nanopart.visa.server.dto.VisaLogParam;
|
||||
@ -37,11 +39,14 @@ import cn.axzo.nanopart.visa.server.rpc.WorkflowGateway;
|
||||
import cn.axzo.nanopart.visa.server.service.ChangeRecordLogService;
|
||||
import cn.axzo.nanopart.visa.server.service.ChangeRecordRelationService;
|
||||
import cn.axzo.nanopart.visa.server.service.ChangeRecordService;
|
||||
import cn.axzo.nanopart.visa.server.service.VisaHelper;
|
||||
import cn.axzo.workflow.common.model.dto.CooperationOrgDTO;
|
||||
import cn.axzo.workflow.common.model.dto.UploadFieldDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BeforeProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.common.model.request.form.instance.FormVariablesUpdateDTO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.NodesByModelVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -72,10 +77,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.FORM_FIELD_ATTACH;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.IM_GROUP_BIZ_INFO_VISA_ID;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.IM_GROUP_BIZ_INFO_VISA_TYPE;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.IM_GROUP_OWNER_TIPS;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.IM_GROUP_PARTICIPATE_TIPS;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.IM_GROUP_PARTICIPATE_TIPS_OPERATED;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.MSG_CENTER_APP_CODE;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.WORKFLOW_PENDING_INITIATOR_NAME;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.WORKFLOW_VAR_STAMP_OU_ID;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.WORKFLOW_VAR_STAMP_RECIPIENT;
|
||||
import static cn.axzo.nanopart.visa.api.constant.VisaConstant.WORKFLOW_VAR_STAMP_TYPE;
|
||||
import static cn.axzo.nanopart.visa.api.enums.VisaRelationFieldEnum.ESS_RECIPIENT_ID_MAP;
|
||||
import static cn.axzo.nanopart.visa.api.enums.VisaRelationFieldEnum.PRINT_PDF_FILE;
|
||||
import static cn.axzo.nanopart.visa.api.enums.VisaRelationFieldEnum.PROCESS_INSTANCE_OF_ESS;
|
||||
@ -96,6 +106,8 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
|
||||
private final WorkflowGateway workflowGateway;
|
||||
private final EssGateway essGateway;
|
||||
private final ChangeRecordLogService changeRecordLogService;
|
||||
private final RefreshableConfiguration refreshableConfiguration;
|
||||
private final VisaHelper visaHelper;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
@ -431,6 +443,15 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
|
||||
ChangeRecord visa = changeRecordService.getById(req.getVisaId());
|
||||
AssertUtil.notNull(visa, "变洽签单据不存在");
|
||||
|
||||
// 创建电子签合同
|
||||
createContract(req, visa);
|
||||
ChangeRecordRelation recipientRelation = new ChangeRecordRelation();
|
||||
Map<Long, String> essRecipientIdMap = new HashMap<>();
|
||||
recipientRelation.setVisaId(visa.getId());
|
||||
recipientRelation.setVarName(ESS_RECIPIENT_ID_MAP.name());
|
||||
recipientRelation.setVarType(VisaRelationVarTypeEnum.JSON.getType());
|
||||
recipientRelation.setContent(JSON.toJSONString(essRecipientIdMap));
|
||||
|
||||
// 用印申请信息
|
||||
List<ChangeRecordRelation> relations = req.getRequestStamps().stream().map(i -> {
|
||||
ChangeRecordRelation stamp = new ChangeRecordRelation();
|
||||
@ -438,7 +459,7 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
|
||||
stamp.setVarName(PROCESS_INSTANCE_OF_ESS.name());
|
||||
stamp.setVarType(VisaRelationVarTypeEnum.JSON.getType());
|
||||
// 发起用印的审批
|
||||
i.setProcessInstanceId(createEssProcessInstance(i, visa));
|
||||
i.setProcessInstanceId(createEssProcessInstance(i, visa, req, essRecipientIdMap));
|
||||
stamp.setContent(JSON.toJSONString(i));
|
||||
stamp.setCreateBy(req.getOperatorPersonId());
|
||||
stamp.setUpdateBy(req.getOperatorPersonId());
|
||||
@ -457,42 +478,40 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
|
||||
relations.add(relation);
|
||||
}
|
||||
|
||||
CreateContractByFileRequest createContractRequest = new CreateContractByFileRequest();
|
||||
CreateContractByFile pdfFile = new CreateContractByFile();
|
||||
pdfFile.setContractName(visa.getTopic());
|
||||
try {
|
||||
pdfFile.setBase64Files(Lists.newArrayList(downloadFileAndConvertToBase64(req.getPdfFile().getFileUrl())));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("拉取表单 PDF 文件失败");
|
||||
}
|
||||
pdfFile.setApprovers(req.getRequestStamps().stream().map(i -> {
|
||||
Approver approver = new Approver();
|
||||
approver.setSealTypes(Lists.newArrayList(i.getSealType()));
|
||||
return approver;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
createContractRequest.setByFile(pdfFile);
|
||||
createContractRequest.setAppCode(MSG_CENTER_APP_CODE);
|
||||
createContractRequest.setBizCode(String.valueOf(visa.getId()));
|
||||
OperatorInfo creator = new OperatorInfo();
|
||||
creator.setOuId(req.getOperatorOuId());
|
||||
creator.setPersonId(req.getOperatorPersonId());
|
||||
createContractRequest.setCreator(creator);
|
||||
|
||||
CreateContractByFileResponse contract = essGateway.createContract(createContractRequest);
|
||||
AssertUtil.notNull(contract, "腾讯电子签合同创建失败");
|
||||
visa.setContractId(contract.getEssContractId());
|
||||
changeRecordService.updateById(visa);
|
||||
|
||||
ChangeRecordRelation recipientRelation = new ChangeRecordRelation();
|
||||
Map<Long, String> essRecipientIdMap = new HashMap<>();
|
||||
recipientRelation.setVisaId(visa.getId());
|
||||
recipientRelation.setVarName(ESS_RECIPIENT_ID_MAP.name());
|
||||
recipientRelation.setVarType(VisaRelationVarTypeEnum.JSON.getType());
|
||||
recipientRelation.setContent(JSON.toJSONString(essRecipientIdMap));
|
||||
saveBatch(relations);
|
||||
}
|
||||
|
||||
private void createContract(VisaRequestStampReq req, ChangeRecord visa) {
|
||||
if (!StringUtils.hasText(visa.getContractId())) {
|
||||
CreateContractByFileRequest createContractRequest = new CreateContractByFileRequest();
|
||||
CreateContractByFile pdfFile = new CreateContractByFile();
|
||||
pdfFile.setContractName(visa.getTopic());
|
||||
try {
|
||||
pdfFile.setBase64Files(Lists.newArrayList(downloadFileAndConvertToBase64(req.getPdfFile().getFileUrl())));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("拉取表单 PDF 文件失败");
|
||||
}
|
||||
pdfFile.setApprovers(req.getRequestStamps().stream().map(i -> {
|
||||
Approver approver = new Approver();
|
||||
approver.setSealTypes(Lists.newArrayList(i.getSealType()));
|
||||
return approver;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
createContractRequest.setByFile(pdfFile);
|
||||
createContractRequest.setAppCode(MSG_CENTER_APP_CODE);
|
||||
createContractRequest.setBizCode(String.valueOf(visa.getId()));
|
||||
OperatorInfo creator = new OperatorInfo();
|
||||
creator.setOuId(req.getOperatorOuId());
|
||||
creator.setPersonId(req.getOperatorPersonId());
|
||||
createContractRequest.setCreator(creator);
|
||||
|
||||
CreateContractByFileResponse contract = essGateway.createContract(createContractRequest);
|
||||
AssertUtil.notNull(contract, "腾讯电子签合同创建失败");
|
||||
visa.setContractId(contract.getEssContractId());
|
||||
changeRecordService.updateById(visa);
|
||||
}
|
||||
}
|
||||
|
||||
public static String downloadFileAndConvertToBase64(String fileUrl) throws IOException {
|
||||
URL url = new URL(fileUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
@ -509,17 +528,46 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
|
||||
}
|
||||
}
|
||||
|
||||
private String createEssProcessInstance(VisaRequestStampReq.RequestStampModel model, ChangeRecord visa) {
|
||||
private String createEssProcessInstance(VisaRequestStampReq.RequestStampModel model,
|
||||
ChangeRecord visa,
|
||||
VisaRequestStampReq req,
|
||||
Map<Long, String> essRecipientIdMap) {
|
||||
BpmnProcessInstanceCreateDTO create = new BpmnProcessInstanceCreateDTO();
|
||||
create.setBusinessKey(String.valueOf(model.getOuId()));
|
||||
// TODO
|
||||
create.setSpecifyAssignerMap(Maps.of("", Lists.newArrayList()));
|
||||
create.setProcessDefinitionKey(refreshableConfiguration.getStampProcessDefinitionKey());
|
||||
create.setSpecifyAssignerMap(Maps.of(getSpecifyAssigneeActivity(visa).get().getActivityId(), Lists.newArrayList()));
|
||||
create.setTenantId(String.valueOf(visa.getRelationWorkspaceId()));
|
||||
create.setProcessDefinitionKey("");
|
||||
create.setInitiator(BpmnTaskDelegateAssigner.builder()
|
||||
// TODO
|
||||
.personId(String.valueOf(req.getOperatorPersonId()))
|
||||
.ouId(String.valueOf(req.getOperatorOuId()))
|
||||
.tenantId(String.valueOf(visa.getRelationWorkspaceId()))
|
||||
.build());
|
||||
create.setCooperationOrg(new CooperationOrgDTO());
|
||||
PersonProfileDto profile = visaProfileGateway.getProfile(req.getOperatorPersonId());
|
||||
AssertUtil.notNull(profile, "获取操作人档案异常");
|
||||
create.setPendingVariables(Maps.of(
|
||||
WORKFLOW_PENDING_INITIATOR_NAME, profile.getRealName(),
|
||||
IM_GROUP_BIZ_INFO_VISA_TYPE, visa.getType()
|
||||
));
|
||||
|
||||
VisaChangeApproveCreateReq createReq = visaHelper.buildVisaChangeApproveCreateReqByVisaId(req.getVisaId());
|
||||
AssertUtil.notNull(createReq, "未找到变洽签单据");
|
||||
|
||||
create.setStartFormVariables(visaHelper.buildStartFormVariables(createReq));
|
||||
create.setVariables(Maps.of(
|
||||
WORKFLOW_VAR_STAMP_OU_ID, model.getOuId(),
|
||||
WORKFLOW_VAR_STAMP_TYPE, model.getSealType().name(),
|
||||
WORKFLOW_VAR_STAMP_RECIPIENT, essRecipientIdMap.getOrDefault(model.getOuId(), "")
|
||||
));
|
||||
return workflowGateway.processInstanceCreate(create);
|
||||
}
|
||||
|
||||
private Optional<NodesByModelVO> getSpecifyAssigneeActivity(ChangeRecord visa) {
|
||||
BeforeProcessInstanceCreateDTO beforeCreateDto = new BeforeProcessInstanceCreateDTO();
|
||||
beforeCreateDto.setProcessDefinitionKey(refreshableConfiguration.getStampProcessDefinitionKey());
|
||||
beforeCreateDto.setTenantId(String.valueOf(visa.getRelationWorkspaceId()));
|
||||
Optional<NodesByModelVO> optActivity = workflowGateway.nodesBeforeCreateProcessInstance(beforeCreateDto).stream().filter(NodesByModelVO::getSupportSpecify).findFirst();
|
||||
AssertUtil.isTrue(optActivity.isPresent(), "审批模板未找到可设置审批人的节点");
|
||||
return optActivity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,6 +176,7 @@ import static cn.axzo.nanopart.visa.api.request.UpdateVisaChangeReq.VisaStampAct
|
||||
import static cn.axzo.nanopart.visa.api.request.UpdateVisaChangeReq.VisaStampAction.CANCEL;
|
||||
import static cn.axzo.nanopart.visa.api.request.UpdateVisaChangeReq.VisaStampAction.COMPLETE;
|
||||
import static cn.axzo.nanopart.visa.server.config.BizResultCode.CHANGE_RECORD_NOT_FOUND;
|
||||
import static cn.axzo.nanopart.visa.server.service.VisaHelper.buildPersonInfosStr;
|
||||
import static cn.axzo.nanopart.visa.server.utils.Constants.DATE_FORMAT;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
|
||||
@ -208,9 +209,6 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
@Resource
|
||||
private VisaProjectApiGateway visaProjectApiGateway;
|
||||
|
||||
@Resource
|
||||
private VisaOrganizationalNodeUserGateway nodeUserGateway;
|
||||
|
||||
@Resource
|
||||
private ReportServiceSDK reportServiceSDK;
|
||||
|
||||
@ -831,54 +829,8 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
.build());
|
||||
processDto.setTenantId(String.valueOf(req.getRelationWorkspaceId()));
|
||||
|
||||
Map<String, Object> formVariables = new HashMap<>();
|
||||
// 传递表单数据
|
||||
formVariables.put(FORM_FIELD_NO, req.getNo());
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||
formVariables.put(FORM_FIELD_HAPPEN_TIME, sdf.format(req.getHappenTime()));
|
||||
formVariables.put(FORM_FIELD_TOPIC, req.getTopic());
|
||||
GetDetailRes workspaceRes = workspaceGateway.getById(req.getRelationWorkspaceId());
|
||||
formVariables.put(FORM_FIELD_WORKSPACE_NAME, Objects.isNull(workspaceRes) ? "" : workspaceRes.getName());
|
||||
ProjectDetailRes projectDetailRes = visaProjectApiGateway.getProjectById(req.getRelationProject());
|
||||
formVariables.put(FORM_FIELD_RELATION_PROJECT, projectDetailRes.getProjectInfo().getName());
|
||||
formVariables.put(FORM_FIELD_RELATION_PROFESSIONAL, visaHelper.buildProfessionalName(req.getRelationProject(), req.getRelationProfessional()));
|
||||
formVariables.put(FORM_FIELD_REASON, req.getReason());
|
||||
formVariables.put(FORM_FIELD_RELATION_AREA, visaHelper.buildAreaName(req.getRelationArea()));
|
||||
formVariables.put(FORM_FIELD_CONTEXT_DESCRIPTION, buildContextDescription(req.getChangeContextAndDescriptionList()));
|
||||
formVariables.put(FORM_FIELD_UNIT_PERSON, buildUnitPerson(req.getRelationUnitAndPersonList(), req.getRelationWorkspaceId()));
|
||||
|
||||
// 非必填项
|
||||
if (Objects.nonNull(req.getAmountChange())) {
|
||||
formVariables.put(FORM_FIELD_AMOUNT_CHANGE, VisaHelper.buildChangeAmount(req.getAmountChange()));
|
||||
}
|
||||
|
||||
// 三种单据
|
||||
if (MapUtils.isNotEmpty(req.getRelationOrderMap())) {
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> taskOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.TASK.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(taskOrders)) {
|
||||
List<Map<String, String>> taskOrderMaps = new ArrayList<>();
|
||||
taskOrders.forEach(i -> {
|
||||
Map<String, String> taskOrderMap = new HashMap<>();
|
||||
taskOrderMap.put("id", i.getNo());
|
||||
taskOrderMap.put("no", i.getNo());
|
||||
taskOrderMap.put("name", i.getName());
|
||||
taskOrderMaps.add(taskOrderMap);
|
||||
});
|
||||
formVariables.put(FORM_FIELD_RELATION_TASK_ORDER, taskOrderMaps);
|
||||
}
|
||||
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> rectificationOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.RECTIFY.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(rectificationOrders)) {
|
||||
formVariables.put(FORM_FIELD_RELATION_RECTIFICATION_ORDER, rectificationOrders);
|
||||
}
|
||||
|
||||
List<VisaChangeTempCreateReq.OrderSimpleModel> visaOrders = req.getRelationOrderMap().getOrDefault(VisaBillTypeEnum.DESIGN_VISA.name(), null);
|
||||
if (CollectionUtils.isNotEmpty(visaOrders)) {
|
||||
formVariables.put(FORM_FIELD_RELATION_VISA_ORDER, visaOrders);
|
||||
}
|
||||
}
|
||||
formVariables.put(FORM_FIELD_ATTACH, req.getAttach());
|
||||
processDto.setStartFormVariables(formVariables);
|
||||
processDto.setStartFormVariables(visaHelper.buildStartFormVariables(req));
|
||||
processDto.setProcessDefinitionKey(req.getType().getProcessDefinitionKey());
|
||||
Map<String, Object> pendingVariables = new HashMap<>();
|
||||
PersonProfileDto profile = visaProfileGateway.getProfile(req.getOperatorPersonId());
|
||||
@ -889,75 +841,7 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
return workflowGateway.processInstanceCreate(processDto);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> buildUnitPerson(List<VisaChangeTempCreateReq.RelationUnitAndPerson> list, Long workspaceId) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> ouIds = list.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getOuId).distinct().collect(Collectors.toList());
|
||||
Map<Long, OrganizationalUnitVO> unitMap = organizationalUnitGateway.list(OrganizationalUnitQuery.builder().unitIds(ouIds).build())
|
||||
.stream().collect(Collectors.toMap(OrganizationalUnitVO::getId, Function.identity(), (s, t) -> s));
|
||||
|
||||
Map<Long, List<VisaChangeTempCreateReq.RelationUnitAndPerson>> unitGroupBy = list.stream().collect(Collectors.groupingBy(VisaChangeTempCreateReq.RelationUnitAndPerson::getOuId, Collectors.toList()));
|
||||
List<Map<String, Object>> unitPersons = new ArrayList<>();
|
||||
|
||||
unitGroupBy.forEach((unitId, persons) -> {
|
||||
Map<String, Object> unitPerson = new HashMap<>();
|
||||
OrganizationalUnitVO unitVo = unitMap.get(unitId);
|
||||
unitPerson.put(FORM_FIELD_UNIT, Objects.isNull(unitVo) ? "" : unitVo.getName() + "(" + OrganizationalUnitTypeEnum.getByType(unitVo.getType()).getDesc() + ")");
|
||||
List<OrgNodeUserDTO> personInfos = getPersonInfos(workspaceId, unitId, persons);
|
||||
unitPerson.put(FORM_FIELD_PERSON, buildPersonInfosStr(personInfos));
|
||||
unitPersons.add(unitPerson);
|
||||
});
|
||||
|
||||
return unitPersons;
|
||||
}
|
||||
|
||||
private String buildPersonInfosStr(List<OrgNodeUserDTO> personInfos) {
|
||||
StringBuilder personInfosStr = new StringBuilder();
|
||||
if (CollectionUtils.isEmpty(personInfos)) {
|
||||
return personInfosStr.toString();
|
||||
}
|
||||
|
||||
for (OrgNodeUserDTO info : personInfos) {
|
||||
if (personInfosStr.length() > 0) {
|
||||
personInfosStr.append(",");
|
||||
}
|
||||
personInfosStr.append(info.getPersonProfile().getRealName())
|
||||
.append(Objects.isNull(info.getJob()) ? "" : "-" + info.getJob().getName());
|
||||
}
|
||||
return personInfosStr.toString();
|
||||
}
|
||||
|
||||
private List<OrgNodeUserDTO> getPersonInfos(Long workspaceId, Long unitId, List<VisaChangeTempCreateReq.RelationUnitAndPerson> persons) {
|
||||
PageResp<OrgNodeUserDTO> pageResp = visaOrganizationalNodeUserGateway.list(ListOrgNodeUserReq.builder()
|
||||
.personIds(persons.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getPersonId).collect(Collectors.toList()))
|
||||
.organizationalUnitId(unitId)
|
||||
.workspaceId(workspaceId)
|
||||
.organizationalNodeIds(persons.stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getNodeId).collect(Collectors.toList()))
|
||||
.needs(ListNodeUserReq.Needs.builder().job(true).personProfile(true).build()).build());
|
||||
if (Objects.isNull(pageResp) || CollectionUtils.isEmpty(pageResp.getData())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return pageResp.getData();
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> buildContextDescription(List<VisaChangeTempCreateReq.ChangeContextAndDescription> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Map<String, Object>> contextDescriptions = new ArrayList<>();
|
||||
list.forEach(i -> {
|
||||
Map<String, Object> contextDescription = new HashMap<>();
|
||||
UploadFieldDTO uploadFieldDTO = new UploadFieldDTO();
|
||||
uploadFieldDTO.setFileKey(i.getFileKey());
|
||||
uploadFieldDTO.setFileName(i.getFileName());
|
||||
uploadFieldDTO.setFileUrl(i.getFileUrl());
|
||||
contextDescription.put(FORM_FIELD_CONTEXT, uploadFieldDTO);
|
||||
contextDescription.put(FORM_FIELD_DESCRIPTION, i.getText());
|
||||
contextDescriptions.add(contextDescription);
|
||||
});
|
||||
return contextDescriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
@ -1270,7 +1154,7 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
// 考虑发起人离职、退场情况,故加上该参数
|
||||
.containsExited(true)
|
||||
.build();
|
||||
List<OrgNodeUserBriefInfoResp> nodeUserResp = nodeUserGateway.listOrgNodeUsers(nodeUserReq);
|
||||
List<OrgNodeUserBriefInfoResp> nodeUserResp = visaOrganizationalNodeUserGateway.listOrgNodeUsers(nodeUserReq);
|
||||
if (CollectionUtils.isEmpty(nodeUserResp)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
@ -1492,7 +1376,7 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
.workspaceId(req.getRelationWorkspaceId())
|
||||
.orgNodeIds(req.getRelationUnitAndPersonList().stream().map(VisaChangeTempCreateReq.RelationUnitAndPerson::getNodeId).collect(Collectors.toList()))
|
||||
.build();
|
||||
List<OrgNodeUserBriefInfoResp> nodeUserBriefInfoResps = nodeUserGateway.listOrgNodeUsers(infoListReq);
|
||||
List<OrgNodeUserBriefInfoResp> nodeUserBriefInfoResps = visaOrganizationalNodeUserGateway.listOrgNodeUsers(infoListReq);
|
||||
AssertUtil.notEmpty(nodeUserBriefInfoResps, "所有单位确认人均已退场");
|
||||
cooperateTypeMap.forEach((k, v) -> {
|
||||
AssertUtil.isTrue(v.size() <= refreshableConfiguration.getVerifyPersonLimit(), String.format(k.getDesc() + "确认人,最多支持%d个", refreshableConfiguration.getVerifyPersonLimit()));
|
||||
@ -1729,7 +1613,7 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
"当前单据审批中,不允许操作");
|
||||
|
||||
// 组装 REQ 参数
|
||||
VisaChangeApproveCreateReq createReq = buildVisaChangeApproveCreateReqByVisaId(req.getVisaId());
|
||||
VisaChangeApproveCreateReq createReq = visaHelper.buildVisaChangeApproveCreateReqByVisaId(req.getVisaId());
|
||||
AssertUtil.notNull(createReq, "未找到变洽签单据");
|
||||
|
||||
// 校验
|
||||
@ -1852,128 +1736,7 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
syncDrawAnnotationUnBindRelation(record.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过变更单id构建审批提交对象
|
||||
*
|
||||
* @param visaId 变更单id
|
||||
* @return VisaChangeApproveCreateReq
|
||||
*/
|
||||
private VisaChangeApproveCreateReq buildVisaChangeApproveCreateReqByVisaId(Long visaId) {
|
||||
if (NumberUtil.isNotPositiveNumber(visaId)) {
|
||||
return null;
|
||||
}
|
||||
ChangeRecord changeRecord = getById(visaId);
|
||||
if (Objects.isNull(changeRecord)) {
|
||||
return null;
|
||||
}
|
||||
VisaChangeApproveCreateReq req = new VisaChangeApproveCreateReq();
|
||||
// 基本信息
|
||||
BeanUtil.copyProperties(changeRecord, req);
|
||||
// 工程名称
|
||||
ProjectDetailRes projectById = visaProjectApiGateway.getProjectById(changeRecord.getRelationProject());
|
||||
req.setRelationProjectName(projectById.getProjectInfo().getName());
|
||||
// 相关单位及人员
|
||||
VisaConfirmDto confirmDto = VisaConfirmDto.builder().visaId(changeRecord.getId()).bizType(VisaConfirmBizTypeEnum.CONFIRM).build();
|
||||
List<ChangeRecordConfirm> confirms = changeRecordConfirmService.findByCondition(confirmDto);
|
||||
if (CollectionUtils.isNotEmpty(confirms)) {
|
||||
req.setRelationUnitAndPersonList(confirms.stream()
|
||||
.map(item -> BeanUtil.copyProperties(item, VisaChangeTempCreateReq.RelationUnitAndPerson.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
// 发生内容说明
|
||||
List<ChangeRecordRelation> contentDescription = changeRecordRelationService.findByVisaAndVarName(changeRecord.getId(), VisaRelationFieldEnum.CONTENT_DESCRIPTION.name());
|
||||
if (CollectionUtils.isNotEmpty(contentDescription)) {
|
||||
req.setChangeContextAndDescriptionList(contentDescription.stream()
|
||||
.map(item -> {
|
||||
try {
|
||||
return JSONObject.parseObject(item.getContent(), VisaChangeTempCreateReq.ChangeContextAndDescription.class);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("发生内容说明解析失败");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
// 关联单据
|
||||
List<ChangeRecordBill> bills = changeRecordBillService.listById(changeRecord.getId());
|
||||
// 实时构建单据名称 TODO 此处应该可以使用异步进行优化
|
||||
if (CollectionUtils.isNotEmpty(bills)) {
|
||||
Map<String, List<VisaChangeTempCreateReq.OrderSimpleModel>> relationOrderMap = com.google.common.collect.Maps.newHashMap();
|
||||
bills.stream().collect(Collectors.groupingBy(b -> b.getBillType().name(),
|
||||
Collectors.mapping(Function.identity(), Collectors.toList())))
|
||||
.forEach((k, v) -> {
|
||||
if (VisaBillTypeEnum.TASK.name().equals(k)) {
|
||||
// 获取任务单数据
|
||||
QueryOrderToBasicReq queryOrderToBasicReq = new QueryOrderToBasicReq();
|
||||
queryOrderToBasicReq.setWorkspaceId(req.getRelationWorkspaceId());
|
||||
queryOrderToBasicReq.setTaskNos(v.stream().map(ChangeRecordBill::getBillNo).collect(Collectors.toList()));
|
||||
queryOrderToBasicReq.setPage(1);
|
||||
queryOrderToBasicReq.setPageSize(v.size());
|
||||
Map<String, TaskOrderToBasicRes> taskOrderMap = taskOrderApiGateway.pageOrderByForBasic(queryOrderToBasicReq).getData()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(TaskOrderToBasicRes::getTaskNo, Function.identity()));
|
||||
// 构建关联任务单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(taskOrderMap.get(item.getBillNo()))
|
||||
.map(TaskOrderToBasicRes::getTaskName)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
} else if (VisaBillTypeEnum.RECTIFY.name().equals(k)) {
|
||||
// 获取整改单数据
|
||||
ListRectifyOrderReq rectifyOrderReq = ListRectifyOrderReq.builder()
|
||||
.ids(v.stream().map(ChangeRecordBill::getBillId).collect(Collectors.toSet()))
|
||||
.build();
|
||||
Map<Long, RectifyOrderResp> rectifyOrderMap = rectifyApiGateway.listRectifyOrders(rectifyOrderReq)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(RectifyOrderResp::getId, Function.identity(), (v1, v2) -> v1));
|
||||
// 构建关联整改单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(rectifyOrderMap.get(item.getBillId()))
|
||||
.map(RectifyOrderResp::getBizName)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
} else if (VisaBillTypeEnum.DESIGN_VISA.name().equals(k)) {
|
||||
// 获取设计单数据
|
||||
Map<Long, ChangeRecord> changeRecordMap = listByIds(v.stream().map(ChangeRecordBill::getBillId).collect(Collectors.toSet()))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ChangeRecord::getId, Function.identity(), (v1, v2) -> v1));
|
||||
// 构建关联设计单
|
||||
relationOrderMap.put(k, v.stream()
|
||||
.map(item -> VisaChangeTempCreateReq.OrderSimpleModel.builder()
|
||||
.id(item.getBillId())
|
||||
.no(item.getBillNo())
|
||||
.name(Optional.ofNullable(changeRecordMap.get(item.getBillId()))
|
||||
.map(ChangeRecord::getTopic)
|
||||
.orElse(""))
|
||||
.build())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
});
|
||||
req.setRelationOrderMap(relationOrderMap);
|
||||
}
|
||||
// 附件
|
||||
List<ChangeRecordRelation> attach = changeRecordRelationService.findByVisaAndVarName(changeRecord.getId(), VisaRelationFieldEnum.ATTACHMENT.name());
|
||||
if (CollectionUtils.isNotEmpty(attach)) {
|
||||
req.setAttach(attach.stream()
|
||||
.map(item -> {
|
||||
try {
|
||||
return JSONObject.parseObject(item.getContent(), UploadFieldDTO.class);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("附件解析失败");
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据读取详情中的变签-校验
|
||||
|
||||
Loading…
Reference in New Issue
Block a user