package com.changhong.epc.rely.api.service.workFlow.impl;
|
|
import com.alibaba.fastjson.TypeReference;
|
import com.changhong.epc.constter.base.Context;
|
import com.changhong.epc.constter.system.SystemClients;
|
import com.changhong.epc.constter.system.prop.ChangHongProperties;
|
import com.changhong.epc.constter.system.prop.ChangHongProperties.PassPortName;
|
import com.changhong.epc.rely.api.service.workFlow.WorkFlowService;
|
import com.changhong.epc.rely.api.tool.HttpUtil;
|
import com.changhong.epc.rely.api.tool.WorkflowTool;
|
import com.iemsoft.framework.cloud.core.constant.BaseConst;
|
import com.iemsoft.framework.cloud.core.exception.IEMRuntimeException;
|
import com.iemsoft.framework.cloud.core.thread.Keys;
|
import com.iemsoft.framework.cloud.core.thread.ThreadData;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import com.iemsoft.framework.cloud.core.tools.http.Http;
|
import com.iemsoft.framework.cloud.core.tools.http.IEMHttpException;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.ui.ModelMap;
|
|
import java.util.Map;
|
import java.util.Objects;
|
import java.util.concurrent.TimeoutException;
|
@Slf4j
|
@Service("workFlowServiceImpl")
|
public class WorkFlowServiceImpl implements WorkFlowService,BaseConst,SystemClients {
|
|
@Autowired
|
private WorkflowTool workflowTool;
|
|
|
@Autowired
|
private ChangHongProperties changHongProperties;
|
|
/**
|
* 删除流程定义,批量
|
*/
|
@Override
|
public Map<String, Object> defineDelete(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.DEF_DELETE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 部署流程定义
|
*/
|
@Override
|
public Map<String, Object> definePeploy(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.DEF_DEPLOY, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 流程定义分页查询
|
*/
|
@Override
|
public Map<String, Object> defineSeache(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.DEF_SEACHE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 创建流程定义
|
*/
|
@Override
|
public Map<String, Object> defineCreate(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
// System.out.println("进入方法2");
|
// System.out.println("参数:"+JSONTool.toJson(maps));
|
// System.out.println("入口参数"+ changHongProperties.getPassUrl(PassPortName.DEF_CREATE, null));
|
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.DEF_CREATE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 退回流程实例
|
*/
|
@Override
|
public Map<String, Object> instBack(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_BACK, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 设置代理
|
*/
|
@Override
|
public Map<String, Object> agentCreat(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.CREATE_AGENT, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 创建流程实例
|
*/
|
@Override
|
public Map<String, Object> instCreat(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_CREATE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 撤销流程实例
|
*/
|
@Override
|
public Map<String, Object> instDrawBack(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_DRAWBACK, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 结束流程实例
|
*/
|
@Override
|
public Map<String, Object> instOver(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_OVER, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 设置代办
|
*/
|
@Override
|
public Map<String, Object> chargeCreate(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.CREATE_CHARGE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 执行流程实例
|
*/
|
@Override
|
public Map<String, Object> instFinish(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_FINISH, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 查询流程待办
|
*/
|
@Override
|
public Map<String, Object> instSeacheHandle(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map;
|
try {
|
maps.put("tenantId", ThreadData.get(Keys.TENANT_ID));
|
maps.put("compId", ThreadData.get(Keys.COMPANY_ID));
|
maps.put("appId", SpringUtil.getBean(ChangHongProperties.class).getProcessServiceId());
|
maps.put("openId", Context.getOpenId());
|
maps.put("sourceSystem", "epc");
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.SEACHE_HANDLE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 流程实例log(参数为空即查询所有)
|
*/
|
@Override
|
public Map<String, Object> instLog(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_LOG, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 获取所有可退回项目
|
*/
|
@Override
|
public Map<String, Object> getBack(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_BACK, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 查询代理(参数为空即查询所有信息)
|
*/
|
@Override
|
public Map<String, Object> instAgent(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_AGENT, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 查询代理去除流程定义信息
|
*/
|
@Override
|
public Map<String, Object> instAgentDefMsg(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.AGENT_DEFMSG, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 查询流程实例(参数都为空,即查询所有)
|
*/
|
@Override
|
public Map<String, Object> instSeache(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
maps.put("sourceSystem", "epc");
|
maps.put("openId", Context.getOpenId());
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.INST_SEACHE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
/**
|
* 租户注册系统
|
*/
|
@Override
|
public Map<String, Object> appCreate(Map<String,Object> maps) throws TimeoutException {
|
Map<String,Object> map = null;
|
try {
|
map = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.APP_CREATE, null)
|
, null,workflowTool.getProcess(maps).getFlowmap()
|
, null, new TypeReference<Map<String,Object>>(){}.getType());
|
// System.out.println("最后参数"+JSONTool.toJson(workflowTool.getProcess(maps).getFlowmap()));
|
return map;
|
} catch (Exception e) {
|
throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
|
}
|
}
|
|
@Override
|
public Integer initialization(Integer tenantId, Integer companyId) {
|
if(check(tenantId, companyId)){
|
return 1;
|
}
|
return Http.post(changHongProperties.getPassUrl(PassPortName.UBP_INITIALIZATION, null), Map.class)
|
.addUrlParam(workflowTool.getProcess(
|
new ModelMap("tenantId", tenantId)
|
.addAttribute("companyId", companyId)
|
.addAttribute("serviceId", changHongProperties.getProcessServiceId())
|
).getChackmap()
|
)
|
.addValidate(res->{
|
if(!Objects.equals(res.get("resCode"), "00000")){
|
throw new IEMHttpException(Objects.toString(res.get("resMsg")));
|
}
|
})
|
.execute(new TypeReference<Map<String, String>>(){}.getType())
|
.map(res->res.get("data"))
|
.map(Object::toString)
|
.map(Integer::valueOf)
|
.orElse(0);
|
}
|
|
@Override
|
public Boolean check(Integer tenantId, Integer companyId) {
|
return Http.post(changHongProperties.getPassUrl(PassPortName.UBP_CHECK, null), Map.class)
|
.addUrlParam(workflowTool.getProcess(
|
new ModelMap("tenantId", tenantId)
|
.addAttribute("companyId", companyId)
|
.addAttribute("serviceId", changHongProperties.getProcessServiceId())
|
).getChackmap()
|
)
|
.addValidate(res->{
|
if(!Objects.equals(res.get("resCode"), "00000")){
|
throw new IEMHttpException(Objects.toString(res.get("resMsg")));
|
}
|
})
|
.execute(new TypeReference<Map<String, String>>(){}.getType())
|
.map(res->res.get("data"))
|
.map(Object::toString)
|
.map(Boolean::valueOf)
|
.orElse(false);
|
}
|
|
}
|