|
@@ -1,8 +1,11 @@
|
|
|
package com.zjugis.business.flow.project.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.zjugis.business.bean.entity.Contract;
|
|
|
import com.zjugis.business.bean.entity.Project;
|
|
|
import com.zjugis.business.bean.entity.ProjectMilestone;
|
|
|
+import com.zjugis.business.bean.response.ProjectResponse;
|
|
|
import com.zjugis.business.constants.DictConstants;
|
|
|
import com.zjugis.business.constants.FlowStatusConstants;
|
|
|
import com.zjugis.business.constants.XmztConstants;
|
|
@@ -10,13 +13,17 @@ import com.zjugis.business.converter.ProjectStatus.ProjectStatusConvert;
|
|
|
import com.zjugis.business.converter.common.SelectConvert;
|
|
|
import com.zjugis.business.flow.project.controller.vo.ProjectVO;
|
|
|
import com.zjugis.business.mapper.ProjectMapper;
|
|
|
+import com.zjugis.business.service.ContractService;
|
|
|
import com.zjugis.business.service.ProjectMilestoneService;
|
|
|
import com.zjugis.business.service.ProjectService;
|
|
|
+import com.zjugis.framework.common.exception.ServiceException;
|
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
import com.zjugis.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import com.zjugis.framework.workflow.model.IFlowInstance;
|
|
|
+import com.zjugis.framework.workflow.model.ProcessDto;
|
|
|
import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
|
|
|
import com.zjugis.framework.workflow.utils.Select;
|
|
|
+import com.zjugis.framework.workflow.utils.UrlUtils;
|
|
|
import com.zjugis.module.system.api.dept.DeptApi;
|
|
|
import com.zjugis.module.system.api.dict.DictDataApi;
|
|
|
import com.zjugis.module.system.api.dict.dto.DictDataRespDTO;
|
|
@@ -29,6 +36,8 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.zjugis.business.constants.ResponseStatusEnum.WORKFLOW_ERROR;
|
|
|
+
|
|
|
/**
|
|
|
* @author ljy
|
|
|
* @version 1.0
|
|
@@ -42,21 +51,18 @@ public class FlowProjectService {
|
|
|
|
|
|
@Autowired
|
|
|
ProjectService projectService;
|
|
|
-
|
|
|
@Autowired
|
|
|
ProjectMilestoneService projectMilestoneService;
|
|
|
-
|
|
|
@Autowired
|
|
|
ProjectMapper projectMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
WorkflowClient workflowClient;
|
|
|
-
|
|
|
@Autowired
|
|
|
AdminUserApi adminUserApi;
|
|
|
-
|
|
|
@Autowired
|
|
|
DeptApi deptApi;
|
|
|
+ @Autowired
|
|
|
+ private ContractService contractService;
|
|
|
|
|
|
public Map<String, Object> getFormParams(String flowInstanceId) {
|
|
|
String userId = SecurityFrameworkUtils.getLoginUserId();
|
|
@@ -85,6 +91,53 @@ public class FlowProjectService {
|
|
|
return createModelMap();
|
|
|
}
|
|
|
|
|
|
+ public Map<String, Object> getChildParams(String flowInstanceId) {
|
|
|
+ String userId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(flowInstanceId);
|
|
|
+ if (flowResult.isSuccess()) {
|
|
|
+ Project entity = projectService.selectByInstanceId(flowInstanceId);
|
|
|
+ if (Objects.isNull(entity)) {
|
|
|
+ entity = new Project();
|
|
|
+ entity.setInstanceId(flowInstanceId);
|
|
|
+ entity.setLxsj(LocalDate.now());
|
|
|
+ entity.setIsSign(1);
|
|
|
+ entity.setWorkerId(userId);
|
|
|
+ entity.setFlowStatus(FlowStatusConstants.FLOW_NOT_START);
|
|
|
+ entity.setXmzt(XmztConstants.STATUS_APPLY);
|
|
|
+ CommonResult<AdminUserRespDTO> result = adminUserApi.getUser(userId);
|
|
|
+ AdminUserRespDTO user = result.getCheckedData();
|
|
|
+ entity.setApplyWorkerName(user.getNickname());
|
|
|
+ entity.setApplyWorkerDeptId(user.getDeptId());
|
|
|
+ entity.setApplyWorkerDept(StringUtils.isBlank(user.getDeptName()) ? deptApi.getDept(user.getDeptId()).getCheckedData().getName() : user.getDeptName());
|
|
|
+ projectService.insert(entity);
|
|
|
+ }
|
|
|
+ return createChildMap(flowInstanceId, entity, userId);
|
|
|
+ }
|
|
|
+ return createModelMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> createChildMap(String flowInstanceId, Project entity, String userId) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("formEntity", entity);
|
|
|
+ if (StringUtils.isNotEmpty(entity.getPid())) {
|
|
|
+ Project parent = projectService.selectById(entity.getPid());
|
|
|
+ map.put("parent", parent);
|
|
|
+ Contract contract = contractService.selectMainByProject(entity.getPid());
|
|
|
+ map.put("parentContract", contract);
|
|
|
+ }
|
|
|
+ List<ProjectMilestone> milestoneList = projectMilestoneService.list(entity.getId());
|
|
|
+ map.put("milestoneListJson", JSON.toJSONString(milestoneList));
|
|
|
+ List<Select> hyTypeList = SelectConvert.INSTANCE.convertList(dictDataApi.getDictDataList(DictConstants.TYPE_HY).getCheckedData());
|
|
|
+ map.put("hyTypeList", JSON.toJSONString(hyTypeList));
|
|
|
+ if (entity.getHyId() != null) {
|
|
|
+ CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_HY, String.valueOf(entity.getHyId()));
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ map.put("hyName", result.getData().getLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, Object> createModelMap() {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("formEntity", new HashMap<>());
|
|
@@ -109,8 +162,8 @@ public class FlowProjectService {
|
|
|
|
|
|
public int updateById(Project project) {
|
|
|
int res = projectMapper.updateById(project);
|
|
|
- String flowDesc = StringUtils.join(Arrays.asList(project.getXmmc(), project.getLxsj(),project.getXmjl()), "/");
|
|
|
- workflowClient.saveFlowDescribe(project.getInstanceId(),flowDesc);
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(project.getXmmc(), project.getLxsj(), project.getXmjl()), "/");
|
|
|
+ workflowClient.saveFlowDescribe(project.getInstanceId(), flowDesc);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -121,4 +174,52 @@ public class FlowProjectService {
|
|
|
vo.setDetail(milestoneList);
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+ public String childProcess(String projectId) {
|
|
|
+ String userId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ String mark = "zxmsq";
|
|
|
+ ProcessDto processDto = new ProcessDto();
|
|
|
+ processDto.setFlowTemplateMark(mark);
|
|
|
+ processDto.setPromoterId(userId);
|
|
|
+ String returnUrl = workflowClient.createProcess(processDto);
|
|
|
+ if (returnUrl.contains("error_code")) {
|
|
|
+ throw new ServiceException(WORKFLOW_ERROR.getCode(), returnUrl);
|
|
|
+ }
|
|
|
+ CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(UrlUtils.getParam(returnUrl, "flowInstanceId"));
|
|
|
+ if (flowResult.isSuccess()) {
|
|
|
+ Project entity = new Project();
|
|
|
+ Project parent = projectService.selectById(projectId);
|
|
|
+ ProjectResponse projectResponse = projectService.selectWithChildren(projectId);
|
|
|
+ List<ProjectResponse> children = projectResponse.getChildren();
|
|
|
+ String xmbh = projectResponse.getXmbh();
|
|
|
+ if(CollectionUtil.isEmpty(children)){
|
|
|
+ entity.setXmbh(xmbh+"-1");
|
|
|
+ }else {
|
|
|
+ int i = children.size() + 1;
|
|
|
+ entity.setXmbh(xmbh+"-"+i);
|
|
|
+ }
|
|
|
+ entity.setXzqdm(parent.getXzqdm());
|
|
|
+ entity.setProjectTypeId(parent.getProjectTypeId());
|
|
|
+ entity.setProjectTypeName(parent.getProjectTypeName());
|
|
|
+ entity.setHyId(parent.getHyId());
|
|
|
+ entity.setXsryId(parent.getXsryId());
|
|
|
+ entity.setBelongCompanyid(parent.getBelongCompanyid());
|
|
|
+ entity.setBelongCompanyname(parent.getBelongCompanyname());
|
|
|
+ entity.setShareRatio(parent.getShareRatio());
|
|
|
+ entity.setPid(projectId);
|
|
|
+ entity.setInstanceId(UrlUtils.getParam(returnUrl, "flowInstanceId"));
|
|
|
+ entity.setLxsj(LocalDate.now());
|
|
|
+ entity.setIsSign(1);
|
|
|
+ entity.setWorkerId(userId);
|
|
|
+ entity.setFlowStatus(FlowStatusConstants.FLOW_NOT_START);
|
|
|
+ entity.setXmzt(XmztConstants.STATUS_APPLY);
|
|
|
+ CommonResult<AdminUserRespDTO> result = adminUserApi.getUser(userId);
|
|
|
+ AdminUserRespDTO user = result.getCheckedData();
|
|
|
+ entity.setApplyWorkerName(user.getNickname());
|
|
|
+ entity.setApplyWorkerDeptId(user.getDeptId());
|
|
|
+ entity.setApplyWorkerDept(StringUtils.isBlank(user.getDeptName()) ? deptApi.getDept(user.getDeptId()).getCheckedData().getName() : user.getDeptName());
|
|
|
+ projectService.insert(entity);
|
|
|
+ }
|
|
|
+ return returnUrl;
|
|
|
+ }
|
|
|
}
|