优化模块绑定评审流程模版功能

This commit is contained in:
daiqy88
2026-01-28 15:43:51 +08:00
parent 0126d1c548
commit 9b34d485c1
5 changed files with 94 additions and 18 deletions

View File

@@ -108,9 +108,9 @@ public class SystemApproveController implements IApproveFeignClient {
return approveServer.deleteApproveFlowMap(mapId);
}
@PostMapping("/queryAllApproveFlowMap")
public SdmResponse queryAllApproveFlowMap() {
return approveServer.queryAllApproveFlowMap();
@GetMapping("/queryAllApproveFlowMap")
public SdmResponse queryAllApproveFlowMap(@RequestParam("current") int current, @RequestParam("size") int size) {
return approveServer.queryAllApproveFlowMap(current,size);
}
}

View File

@@ -0,0 +1,15 @@
package com.sdm.system.model.entity;
import com.sdm.common.entity.bo.BaseBean;
public class ApproveFlowBean extends BaseBean {
public ApproveFlowBean() {
init();
}
public long id;
public String flowName;
public String flowCode;
}

View File

@@ -3,6 +3,9 @@ package com.sdm.system.model.entity;
import com.sdm.common.entity.bo.BaseBean;
import com.sdm.common.entity.data.BaseData;
import java.util.ArrayList;
import java.util.List;
public class SimulationApproveFlowMapBean extends BaseBean {
public SimulationApproveFlowMapBean() {
@@ -19,6 +22,8 @@ public class SimulationApproveFlowMapBean extends BaseBean {
public String flowCode;
public List<ApproveFlowBean> flowList = new ArrayList<>();
public long tenantId;
public long creator;

View File

@@ -99,6 +99,6 @@ public interface ISimulatinoApprovalService {
* 获取所有审批流程映射
* @return
*/
SdmResponse queryAllApproveFlowMap();
SdmResponse queryAllApproveFlowMap(int current, int size);
}

View File

@@ -4,17 +4,20 @@ import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.bo.DataPageInfo;
import com.sdm.common.entity.constants.NumberConstants;
import com.sdm.common.entity.enums.ApproveTypeEnum;
import com.sdm.common.entity.enums.MessageTemplateEnum;
import com.sdm.common.entity.req.system.FlowStatusParam;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import com.sdm.common.entity.req.system.SendMsgReq;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.feign.inter.system.IMessageFeignClient;
import com.sdm.common.log.CoreLogger;
import com.sdm.common.utils.HttpClientUtil;
import com.sdm.outbridge.service.lyric.IFreeLinkService;
import com.sdm.system.dao.SimulationApproveMapper;
import com.sdm.system.model.entity.ApproveFlowBean;
import com.sdm.system.model.entity.ApproveTemplateBean;
import com.sdm.system.model.entity.SimulationApproveFlowMapBean;
import com.sdm.system.service.ISimulatinoApprovalService;
@@ -29,7 +32,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@@ -539,22 +545,38 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
{
SdmResponse response = SdmResponse.success();
String moduleCode = mapBean.moduleCode;
String flowCode = mapBean.flowCode;
//String flowCode = mapBean.flowCode;
long tenantId = ThreadLocalContext.getTenantId();
long creator = ThreadLocalContext.getUserId();
List<SimulationApproveFlowMapBean> mapBeans = approveMapper.queryModuleApproveFlowMap(moduleCode,flowCode,tenantId);
if(!mapBeans.isEmpty())
{
response = SdmResponse.success("模块审批流程已存在");
}
else
{
mapBean.creator = creator;
mapBean.tenantId = tenantId;
if(approveMapper.addModuleApproveFlowMap(mapBean) <= 0)
String existFlowCode = "";
for(ApproveFlowBean flowBean : mapBean.flowList) {
String flowCode = flowBean.flowCode;
List<SimulationApproveFlowMapBean> mapBeans = approveMapper.queryModuleApproveFlowMap(moduleCode, flowCode, tenantId);
if (!mapBeans.isEmpty())
{
response = SdmResponse.failed("添加模块审批流程失败");
if(!existFlowCode.isEmpty())
{
existFlowCode += ",";
}
existFlowCode += flowBean.flowName;
}
else
{
SimulationApproveFlowMapBean flowMapBean = new SimulationApproveFlowMapBean();
flowMapBean.flowCode = flowCode;
flowMapBean.flowName = flowBean.flowName;
flowMapBean.moduleCode = mapBean.moduleCode;
flowMapBean.moduleName = mapBean.moduleName;
flowMapBean.creator = creator;
flowMapBean.tenantId = tenantId;
if (approveMapper.addModuleApproveFlowMap(flowMapBean) <= 0) {
response = SdmResponse.failed("添加模块审批流程失败");
}
}
}
if(!existFlowCode.isEmpty())
{
response = SdmResponse.success("模块审批流程["+existFlowCode+"]已存在");
}
return response;
}
@@ -615,12 +637,46 @@ public class SimulationApproveServiceImpl implements ISimulatinoApprovalService
* 获取所有审批流程映射
* @return
*/
public SdmResponse queryAllApproveFlowMap()
public SdmResponse queryAllApproveFlowMap(int current, int size)
{
SdmResponse sdmResponse = SdmResponse.success();
long tenantId = ThreadLocalContext.getTenantId();
List<SimulationApproveFlowMapBean> flowMapBeans = approveMapper.queryAllModuleApproveFlowMap(tenantId);
sdmResponse.setData(flowMapBeans);
Map<String,SimulationApproveFlowMapBean> flowMapBeanMap = new HashMap<>();
for(SimulationApproveFlowMapBean mapBean : flowMapBeans)
{
SimulationApproveFlowMapBean flowMapBean = flowMapBeanMap.get(mapBean.moduleCode);
if(flowMapBean == null)
{
flowMapBean = mapBean;
flowMapBeanMap.put(mapBean.moduleCode, flowMapBean);
}
ApproveFlowBean approveFlowBean = new ApproveFlowBean();
approveFlowBean.flowName = mapBean.flowName;
approveFlowBean.flowCode = mapBean.flowCode;
approveFlowBean.id = mapBean.id;
flowMapBean.flowList.add(approveFlowBean);
}
DataPageInfo<List<SimulationApproveFlowMapBean>> pageInfo = new DataPageInfo<>();
List<SimulationApproveFlowMapBean> flowMapBeanList = flowMapBeanMap.values().stream().toList();
int total = flowMapBeanList.size();
int beginPos = (current-1)*size;
int endPos = beginPos + size;
List<SimulationApproveFlowMapBean> queryTemplate = new ArrayList<>();
if(flowMapBeanList.size() > beginPos)
{
if(flowMapBeanList.size() > endPos)
{
queryTemplate = flowMapBeanList.subList(beginPos,endPos);
}
else
{
queryTemplate = flowMapBeanList.subList(beginPos,flowMapBeanList.size());
}
}
pageInfo.data = queryTemplate;
pageInfo.total = total;
sdmResponse.setData(pageInfo);
return sdmResponse;
}
}