Commit 99d83fb1 authored by suhuiguang's avatar suhuiguang

1.任务下发

parent ee365a0f
...@@ -5,6 +5,7 @@ import feign.RequestTemplate; ...@@ -5,6 +5,7 @@ import feign.RequestTemplate;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -39,6 +40,11 @@ public class FeignAuthRequestInterceptor implements RequestInterceptor { ...@@ -39,6 +40,11 @@ public class FeignAuthRequestInterceptor implements RequestInterceptor {
template.header("token", authToken); template.header("token", authToken);
template.header("appKey", appKey); template.header("appKey", appKey);
template.header("product", product); template.header("product", product);
} else {
template.header("X-Access-Token", RequestContext.getToken());
template.header("token", RequestContext.getToken());
template.header("appKey", RequestContext.getAppKey());
template.header("product", RequestContext.getProduct());
} }
} }
} }
...@@ -395,4 +395,9 @@ public class JgInstallationNotice extends BaseEntity { ...@@ -395,4 +395,9 @@ public class JgInstallationNotice extends BaseEntity {
@JsonSerialize(using = BizCustomDateSerializer.class) @JsonSerialize(using = BizCustomDateSerializer.class)
private Date handleDate; private Date handleDate;
/**
* 流程任务状态(来源工作流)
*/
private String approvalStatus;
} }
package com.yeejoin.amos.boot.module.jg.biz.listener; package com.yeejoin.amos.boot.module.jg.biz.listener;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.message.WorkFlowMessageListener;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.StartPlatformTokenService; import com.yeejoin.amos.boot.module.jg.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.component.robot.AmosRequestContext; import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -31,60 +26,79 @@ public class PublicWorkFlowMessage extends EmqxListener { ...@@ -31,60 +26,79 @@ public class PublicWorkFlowMessage extends EmqxListener {
@Autowired @Autowired
AmosRequestContext amosAuth; AmosRequestContext amosAuth;
private List<WorkFlowMessageListener> workFlowMessageListeners;
public PublicWorkFlowMessage(List<WorkFlowMessageListener> workFlowMessageListeners) {
this.workFlowMessageListeners = workFlowMessageListeners;
}
/** /**
* 创建任务主题 * 创建任务主题
*/ */
public static final String WORKFLOW_TASK_CREATED = "workflow/task/created"; private static final String WORKFLOW_TASK_CREATED = "workflow/task/created";
/** /**
* 执行完成任务主题 * 执行完成任务主题
*/ */
public static final String WORKFLOW_TASK_COMPLETED = "workflow/task/completed"; private static final String WORKFLOW_TASK_COMPLETED = "workflow/task/completed";
/** /**
* 流程执行结束主题 * 流程执行结束主题
*/ */
public static final String WORKFLOW_PROCESS_COMPLETE = "workflow/process/complete"; private static final String WORKFLOW_PROCESS_COMPLETE = "workflow/process/complete";
@Autowired
private JgInstallationNoticeServiceImpl jgInstallationNoticeService;
@Autowired @Autowired
StartPlatformTokenService platformTokenService; StartPlatformTokenService platformTokenService;
@Autowired
AmosRequestContext amosRequestContext;
@PostConstruct @PostConstruct
void init() throws Exception { void init() throws Exception {
emqKeeper.subscript(WORKFLOW_TASK_CREATED, 2, this); emqKeeper.subscript(WORKFLOW_TASK_CREATED, 2, this);
emqKeeper.subscript(WORKFLOW_TASK_COMPLETED, 2, this); emqKeeper.subscript(WORKFLOW_TASK_COMPLETED, 2, this);
// emqKeeper.subscript(WORKFLOW_PROCESS_COMPLETE, 2, this); emqKeeper.subscript(WORKFLOW_PROCESS_COMPLETE, 2, this);
} }
@Override @Override
public void processMessage(String topic, MqttMessage message) throws Exception { public void processMessage(String topic, MqttMessage message) {
// RequestContext.setAppKey(amosAuth.getAppKey());
// RequestContext.setProduct(amosAuth.getProduct());
// RequestContext.setToken(amosAuth.getToken());
// RequestContext.setAgencyCode(amosAuth.getUserId());
// platformTokenService.getToken();
JSONObject messageObject = JSON.parseObject(new String(message.getPayload())); JSONObject messageObject = JSON.parseObject(new String(message.getPayload()));
String businessKey = messageObject.get("businessKey").toString(); log.info("收到工作流消息,主题:{},内容:{}", topic, messageObject);
String[] s = businessKey.split("_"); String processDefinitionKey = messageObject.get("processDefinitionKey").toString();
String businessId = s[0]; String type = getApprovalStatusStr(messageObject);
String type = s[1]; WorkFlowMessageListener.BizTypeEnum bizTypeEnum = WorkFlowMessageListener.getEnum(processDefinitionKey);
messageObject.put("businessId", businessId); RequestContext.setToken(amosRequestContext.getToken());
if (topic.equals(WORKFLOW_TASK_CREATED)) { RequestContext.setAppKey(amosRequestContext.getAppKey());
if ("installationNotice".equals(type)) { RequestContext.setProduct(amosRequestContext.getProduct());
jgInstallationNoticeService.updateByWorkFlow(messageObject); workFlowMessageListeners.forEach(h -> {
} if (h.canHandlerType().equals(bizTypeEnum)) {
} else if (topic.equals(WORKFLOW_TASK_COMPLETED)) { switch (topic) {
if ("installationNotice".equals(type)) { case WORKFLOW_TASK_CREATED:
jgInstallationNoticeService.completeWorkFlow(messageObject); h.afterCreate(messageObject);
} break;
} else if (topic.equals(WORKFLOW_PROCESS_COMPLETE)) { case WORKFLOW_TASK_COMPLETED:
if ("installationNotice".equals(type)) { h.afterComplete(type, messageObject);
// jgInstallationNoticeService.completeWorkFlow(messageObject); break;
case WORKFLOW_PROCESS_COMPLETE:
h.afterFinish(messageObject);
break;
default:
break;
}
} }
});
}
private String getApprovalStatusStr(JSONObject messageObject) {
String type = "";
JSONObject variables = messageObject.getJSONObject("variables");
if (variables != null) {
type = variables.getString("approvalStatus");
} }
return type;
} }
} }
package com.yeejoin.amos.boot.module.jg.biz.message;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author Administrator
*/
@Component
public class InstallationNoticeMsgListener implements WorkFlowMessageListener {
@Autowired
JgInstallationNoticeServiceImpl jgInstallationNoticeService;
/**
* 处理消息方法-Create
* 1.更新业务数据【instanceId、nextExecutedIds、status、instanceStatus(所有执行过的加下一步待执行角色)】
* 2.创建待办(初始未完成状态)
* @param message message 消息内容
*/
@Override
public void afterCreate(JSONObject message) {
jgInstallationNoticeService.updateByWorkFlow(message);
}
@Override
public void afterComplete(String type, JSONObject message) {
jgInstallationNoticeService.completeWorkFlow(type, message);
}
@Override
public void afterFinish(JSONObject message) {
String businessKey = message.getString("businessKey");
JgInstallationNotice jgInstallationNotice = jgInstallationNoticeService.getBaseMapper().selectById(businessKey);
jgInstallationNoticeService.finishTask(jgInstallationNotice);
}
@Override
public BizTypeEnum canHandlerType() {
return BizTypeEnum.installationNotificationNew;
}
}
package com.yeejoin.amos.boot.module.jg.biz.message;
import com.alibaba.fastjson.JSONObject;
/**
* @author Administrator
*/
public interface WorkFlowMessageListener {
/**
* 处理消息方法-Create
* 1.更新业务数据【instanceId、nextExecutedIds、status、instanceStatus(所有执行过的加下一步待执行角色)】
* 2.创建待办(初始未完成状态)
* @param message message 消息内容
*/
void afterCreate(JSONObject message);
/**
* 处理消息方法-完成
* 1.更新代办(更新为已完成状态)
* 2.更新业务数据【status、instanceStatus(所有执行过的加下一步待执行角色)、新增字段-taskResult(工作流节点执行结果)】
* @param approvalStatus 工作流任务状态
* @param message message 消息内容
*/
void afterComplete(String approvalStatus, JSONObject message);
/**
* 处理消息方法-流程结束
* 1.业务处理
* @param message message 消息内容
*/
void afterFinish(JSONObject message);
/**
* 可处理的消息类型
* @return BizTypeEnum
*/
BizTypeEnum canHandlerType();
enum BizTypeEnum{
// 更名变更登记
unitRename,
// 单位变更
unitChange,
// 移装变更登记
changeRegistrationTransfer,
// 使用登记审核
useRegistration,
// 安装告知
installationNotificationNew,
// 维保备案
maintenanceFiling,
// 电梯注销
scrapCancel,
// 改造变更登记
renovationRegistrationReview,
// 维修告知
maintainNotice,
// 改造告知
renovationNoticeNew,
// 电梯停用启用
deactivateEnable,
// 移装告知
transferNotice,
// 设备移交
equipmentHandover
}
static BizTypeEnum getEnum(String name){
return BizTypeEnum.valueOf(name);
}
}
...@@ -29,6 +29,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; ...@@ -29,6 +29,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*; import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil; import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
...@@ -137,6 +138,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -137,6 +138,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired @Autowired
private PlatformTransactionManager platformTransactionManager; private PlatformTransactionManager platformTransactionManager;
@Autowired
AmosRequestContext amosRequestContext;
/** /**
* 根据sequenceNbr查询 * 根据sequenceNbr查询
* *
...@@ -246,7 +250,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -246,7 +250,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
map.put("relationId", notice.getInstanceId()); map.put("relationId", notice.getInstanceId());
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
updateTaskModel(map); updateTaskModel(map,null);
} }
TaskV2Model taskV2Model = new TaskV2Model(); TaskV2Model taskV2Model = new TaskV2Model();
...@@ -468,9 +472,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -468,9 +472,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
dto.setApplyNo(applyNo); dto.setApplyNo(applyNo);
dto.setNoticeDate(new Date()); dto.setNoticeDate(new Date());
if(SUBMIT_TYPE_FLOW.equals(submitType)) { if(SUBMIT_TYPE_FLOW.equals(submitType)) {
dto.setPromoter(reginParams.getUserModel().getUserId()); dto.setPromoter(RequestContext.getExeUserId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode())); dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
} }
dto.setCreateUserId(RequestContext.getExeUserId());
dto.setInstallUnitName(reginParams.getCompany().getCompanyName()); dto.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode()); dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setEquList((String.valueOf(obj.get("EQU_CATEGORY")))); dto.setEquList((String.valueOf(obj.get("EQU_CATEGORY"))));
...@@ -506,11 +511,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -506,11 +511,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// 发起流程 // 发起流程
ActWorkflowStartDTO dto = new ActWorkflowStartDTO(); ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY); dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(item.getSequenceNbr() + "_" + "installationNotice"); dto.setBusinessKey(item.getSequenceNbr() + "");
dto.setCompleteFirstTask(Boolean.TRUE); dto.setCompleteFirstTask(Boolean.TRUE);
HashMap<String, Object> variables = new HashMap<>();
variables.put("code", "2121");
dto.setVariables(variables);
workflowStartDTOS.add(dto); workflowStartDTOS.add(dto);
} }
}); });
...@@ -714,12 +716,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -714,12 +716,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
ArrayList<String> roleList = new ArrayList<>(); ArrayList<String> roleList = new ArrayList<>();
if(ajaxResult.getStatus() == 200) { if(ajaxResult.getStatus() == 200) {
HashMap<String, Object> map = new HashMap<>(); // HashMap<String, Object> map = new HashMap<>();
map.put("relationId", noticeDto.getInstanceId()); // map.put("relationId", noticeDto.getInstanceId());
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode()); // map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName()); // map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
map.put("isDelete", Boolean.TRUE); // map.put("isDelete", Boolean.TRUE);
updateTaskModel(map); // updateTaskModel(map);
getNext(roleList, noticeDto.getInstanceId(),taskName); getNext(roleList, noticeDto.getInstanceId(),taskName);
jgInstallationNotice.setStatus(taskName[0]); jgInstallationNotice.setStatus(taskName[0]);
...@@ -736,164 +738,141 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -736,164 +738,141 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
String userId = RequestContext.getExeUserId(); String userId = RequestContext.getExeUserId();
JgInstallationNotice jgInstallationNotice = this.jgInstallationNoticeMapper.selectById(dto.getSequenceNbr()); JgInstallationNotice jgInstallationNotice = this.jgInstallationNoticeMapper.selectById(dto.getSequenceNbr());
jgInstallationNotice.setProcessAdvice(dto.getProcessAdvice()); jgInstallationNotice.setProcessAdvice(dto.getProcessAdvice());
// 组装设备注册代码 ArrayList<String> roleList = new ArrayList<>();
StringBuffer stringBuffer = new StringBuffer(); boolean submit = submit(jgInstallationNotice, op);
// if(submit) {
//// getNext(roleList, dto.getInstanceId(),taskName);
//// jgInstallationNotice.setStatus(taskName[0]);
// if("0".equals(op)) {
// finishTask(jgInstallationNotice);
// } else {
// jgInstallationNotice.setPromoter("");
// jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
//
// HashMap<String, Object> map = new HashMap<>();
// map.put("relationId", jgInstallationNotice.getInstanceId());
// map.put("taskStatus", FlowStatusEnum.REJECTED.getCode());
// map.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
// TaskV2Model taskV2ModelOld = updateTaskModel(map);
// TaskV2Model taskV2Model = new TaskV2Model();
// //获取待办任务执行人
// List<AgencyUserModel> userList = Privilege.agencyUserClient
// .queryByRoleId(jgInstallationNotice.getNextExecuteIds(), null,Boolean.FALSE).getResult();
// List<String> userIds = userList.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
// taskV2Model.setExecuteUserIds(taskV2ModelOld.getRecUserId());
// taskV2Model.setExtras(JSON.toJSONString(jgInstallationNotice));
// taskV2Model.setRelationId(jgInstallationNotice.getInstanceId());
// Map<String, Object> userOrgRoleMap = FeignUtil.remoteCall(() -> Privilege.userOrgRoleClient.getme());
// List<String> userOrgRoleList = (List<String>) userOrgRoleMap.get("roleId");
// String roleIds = String.join(",", userOrgRoleList);
// taskV2Model.setTaskType("installNotice");
// taskV2Model.setTaskTypeLabel("安装告知");
// String url = getUrl(taskV2Model.getTaskType(), "edit");
// String format = String.format(url, jgInstallationNotice.getSequenceNbr(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNoticeStatus(), "", jgInstallationNotice.getInstanceId());
// taskV2Model.setRoutePath(format);
// taskV2Model.setTaskTitle(jgInstallationNotice.getStatus());
// taskV2Model.setTaskName(jgInstallationNotice.getStatus());
// taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
// taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
// taskV2Model.setTaskCode(jgInstallationNotice.getApplyNo());
// buildTaskModel(taskV2Model);
// }
// jgInstallationNoticeMapper.updateById(jgInstallationNotice);
// }
}
public void finishTask(JgInstallationNotice jgInstallationNotice) {
String ym = null; String ym = null;
try { try {
ym = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN_MM); ym = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN_MM);
} catch (ParseException e) { } catch (ParseException e) {
log.error("日期转换失败:{}", e); log.error("日期转换失败:{}", e);
} }
// 组装设备注册代码
ArrayList<String> roleList = new ArrayList<>(); StringBuffer stringBuffer = new StringBuffer();
boolean submit = submit(jgInstallationNotice, op); LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
if(submit) { queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,jgInstallationNotice.getSequenceNbr());
// getNext(roleList, dto.getInstanceId(),taskName); JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
// jgInstallationNotice.setStatus(taskName[0]);
if("0".equals(op)) { LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
if(roleList.size() == 0) { queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,dto.getSequenceNbr()); LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper); queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId()); stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getCity()).append(ym);
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1); String equCode = stringBuffer.toString();
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>(); ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(equCode);
queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId()); String deviceRegistrationCode = responseModel.getResult();
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2); Map<String, Object> map = new HashMap<>();
map.put("cityCode",jgInstallationNotice.getCity());
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getCity()).append(ym); map.put("countyCode",jgInstallationNotice.getCounty());
String equCode = stringBuffer.toString(); map.put("equCategory",tzsJgRegistrationInfo.getEquCategory());
map.put("isXiXian", jgInstallationNotice.getIsXixian() == null ? "null" : jgInstallationNotice.getIsXixian().equals("0") ? "null" : "1");
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(equCode); Map<String, Object> mapCode;
String deviceRegistrationCode = responseModel.getResult(); ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
Map<String, Object> map = new HashMap<>(); mapCode = code.getResult();
map.put("cityCode",jgInstallationNotice.getCity());
map.put("countyCode",jgInstallationNotice.getCounty()); LambdaQueryWrapper<SupervisoryCodeInfo> queryWrapper3 = new LambdaQueryWrapper<>();
map.put("equCategory",tzsJgRegistrationInfo.getEquCategory()); queryWrapper3.eq(SupervisoryCodeInfo::getSupervisoryCode,mapCode.get("superviseCode").toString());
map.put("isXiXian", jgInstallationNotice.getIsXixian() == null ? "null" : jgInstallationNotice.getIsXixian().equals("0") ? "null" : "1"); SupervisoryCodeInfo supervisoryCodeInfo = supervisoryCodeInfoMapper.selectOne(queryWrapper3);
Map<String, Object> mapCode; supervisoryCodeInfo.setStatus("1");
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map); supervisoryCodeInfoMapper.updateById(supervisoryCodeInfo);
mapCode = code.getResult(); jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgInstallationNotice.setHandleDate(new Date());
LambdaQueryWrapper<SupervisoryCodeInfo> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(SupervisoryCodeInfo::getSupervisoryCode,mapCode.get("superviseCode").toString()); Map<String,Object> map1 =new HashMap<>();
SupervisoryCodeInfo supervisoryCodeInfo = supervisoryCodeInfoMapper.selectOne(queryWrapper3);
supervisoryCodeInfo.setStatus("1"); // 更新其他业务表
supervisoryCodeInfoMapper.updateById(supervisoryCodeInfo); if(!ValidationUtil.isEmpty(mapCode.get("code96333"))) {
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode())); tzsJgOtherInfo.setCode96333(mapCode.get("code96333").toString());
jgInstallationNotice.setHandleDate(new Date()); map1.put("CODE96333",tzsJgOtherInfo.getCode96333() );
}
Map<String,Object> map1 =new HashMap<>(); tzsJgOtherInfo.setSupervisoryCode(mapCode.get("superviseCode").toString());
tzsJgRegistrationInfo.setEquCode(deviceRegistrationCode);
// 更新其他业务表 jgInstallationNotice.setEquRegisterCode(deviceRegistrationCode);
if(!ValidationUtil.isEmpty(mapCode.get("code96333"))) { jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString());
tzsJgOtherInfo.setCode96333(mapCode.get("code96333").toString()); Map<String,Map<String,Object>> objMap = new HashMap<>();
map1.put("CODE96333",tzsJgOtherInfo.getCode96333() ); map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() );
} map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
tzsJgOtherInfo.setSupervisoryCode(mapCode.get("superviseCode").toString()); map1.put("USE_UNIT_CREDIT_CODE",jgInstallationNotice.getUseUnitCreditCode());
tzsJgRegistrationInfo.setEquCode(deviceRegistrationCode); map1.put("USE_UNIT_NAME",jgInstallationNotice.getUseUnitName());
jgInstallationNotice.setEquRegisterCode(deviceRegistrationCode);
jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString()); map1.put("USC_UNIT_CREDIT_CODE",jgInstallationNotice.getInstallUnitCreditCode());
Map<String,Map<String,Object>> objMap = new HashMap<>(); map1.put("USC_UNIT_NAME",jgInstallationNotice.getInstallUnitName());
map1.put("EQU_CODE",tzsJgRegistrationInfo.getEquCode() ); objMap.put(tzsJgOtherInfo.getRecord(),map1);
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode()); jgInstallationNotice.setPromoter("");
map1.put("USE_UNIT_CREDIT_CODE",jgInstallationNotice.getUseUnitCreditCode()); tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
map1.put("USE_UNIT_NAME",jgInstallationNotice.getUseUnitName()); tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo);
map1.put("USC_UNIT_CREDIT_CODE",jgInstallationNotice.getInstallUnitCreditCode());
map1.put("USC_UNIT_NAME",jgInstallationNotice.getInstallUnitName()); // 更新施工信息表
objMap.put(tzsJgOtherInfo.getRecord(),map1); IdxBizJgConstructionInfo idxBizJgConstructionInfo = constructionInfoService.queryNewestDetailByRecord(jgRelationEquip.getEquId());
jgInstallationNotice.setPromoter(""); if (!ObjectUtils.isEmpty(idxBizJgConstructionInfo)) {
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap); idxBizJgConstructionInfo.setUscUnitCreditCode(jgInstallationNotice.getInstallUnitCreditCode());
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo); idxBizJgConstructionInfo.setUscUnitName(jgInstallationNotice.getInstallUnitName());
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo); idxBizJgConstructionInfo.setUscDate(jgInstallationNotice.getInstallStartDate());
// 获取施工类型id
// 更新施工信息表 LambdaQueryWrapper<DataDictionary> lambda = new LambdaQueryWrapper<>();
IdxBizJgConstructionInfo idxBizJgConstructionInfo = constructionInfoService.queryNewestDetailByRecord(jgRelationEquip.getEquId()); lambda.eq(DataDictionary::getType, CONSTRUCTION_TYPE);
if (!ObjectUtils.isEmpty(idxBizJgConstructionInfo)) { lambda.eq(DataDictionary::getName, CONSTRUCTION_TYPE_NAME);
idxBizJgConstructionInfo.setUscUnitCreditCode(jgInstallationNotice.getInstallUnitCreditCode()); List<DataDictionary> dataDictionaries = dataDictionaryMapper.selectList(lambda);
idxBizJgConstructionInfo.setUscUnitName(jgInstallationNotice.getInstallUnitName()); if (!CollectionUtils.isEmpty(dataDictionaries)) {
idxBizJgConstructionInfo.setUscDate(jgInstallationNotice.getInstallStartDate()); idxBizJgConstructionInfo.setConstructionType(String.valueOf(dataDictionaries.get(0).getSequenceNbr()));
// 获取施工类型id
LambdaQueryWrapper<DataDictionary> lambda = new LambdaQueryWrapper<>();
lambda.eq(DataDictionary::getType, CONSTRUCTION_TYPE);
lambda.eq(DataDictionary::getName, CONSTRUCTION_TYPE_NAME);
List<DataDictionary> dataDictionaries = dataDictionaryMapper.selectList(lambda);
if (!CollectionUtils.isEmpty(dataDictionaries)) {
idxBizJgConstructionInfo.setConstructionType(String.valueOf(dataDictionaries.get(0).getSequenceNbr()));
}
constructionInfoService.saveOrUpdateData(idxBizJgConstructionInfo);
}
// 使用信息表更新是否西咸
IdxBizJgUseInfo useInfo = useInfoService.getOneData(jgRelationEquip.getEquId());
if (!ObjectUtils.isEmpty(useInfo)) {
useInfo.setUseUnitCreditCode(jgInstallationNotice.getUseUnitCreditCode());
useInfo.setUseUnitName(jgInstallationNotice.getUseUnitName());
useInfo.setIsNotXiXian(jgInstallationNotice.getIsXixian() == null ? "0" : jgInstallationNotice.getIsXixian());
useInfoService.saveOrUpdateData(useInfo);
}
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
// }
// });
} else {
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
if (!ObjectUtils.isEmpty(jgInstallationNotice.getInstanceStatus())) {
jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + String.join(",", roleList));
} else {
jgInstallationNotice.setInstanceStatus(String.join(",", roleList));
}
jgInstallationNotice.setPromoter(userId);
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
}
HashMap<String, Object> map = new HashMap<>();
map.put("relationId", jgInstallationNotice.getInstanceId());
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
updateTaskModel(map);
} else {
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
HashMap<String, Object> map = new HashMap<>();
map.put("relationId", jgInstallationNotice.getInstanceId());
map.put("taskStatus", FlowStatusEnum.REJECTED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
TaskV2Model taskV2ModelOld = updateTaskModel(map);
TaskV2Model taskV2Model = new TaskV2Model();
//获取待办任务执行人
List<AgencyUserModel> userList = Privilege.agencyUserClient
.queryByRoleId(jgInstallationNotice.getNextExecuteIds(), null,Boolean.FALSE).getResult();
List<String> userIds = userList.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
taskV2Model.setExecuteUserIds(taskV2ModelOld.getRecUserId());
taskV2Model.setExtras(JSON.toJSONString(jgInstallationNotice));
taskV2Model.setRelationId(jgInstallationNotice.getInstanceId());
Map<String, Object> userOrgRoleMap = FeignUtil.remoteCall(() -> Privilege.userOrgRoleClient.getme());
List<String> userOrgRoleList = (List<String>) userOrgRoleMap.get("roleId");
String roleIds = String.join(",", userOrgRoleList);
taskV2Model.setTaskType("installNotice");
taskV2Model.setTaskTypeLabel("安装告知");
String url = getUrl(taskV2Model.getTaskType(), "edit");
String format = String.format(url, jgInstallationNotice.getSequenceNbr(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNoticeStatus(), "", jgInstallationNotice.getInstanceId());
taskV2Model.setRoutePath(format);
taskV2Model.setTaskTitle(jgInstallationNotice.getStatus());
taskV2Model.setTaskName(jgInstallationNotice.getStatus());
taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskV2Model.setTaskCode(jgInstallationNotice.getApplyNo());
buildTaskModel(taskV2Model);
} }
jgInstallationNoticeMapper.updateById(jgInstallationNotice); constructionInfoService.saveOrUpdateData(idxBizJgConstructionInfo);
}
// 使用信息表更新是否西咸
IdxBizJgUseInfo useInfo = useInfoService.getOneData(jgRelationEquip.getEquId());
if (!ObjectUtils.isEmpty(useInfo)) {
useInfo.setUseUnitCreditCode(jgInstallationNotice.getUseUnitCreditCode());
useInfo.setUseUnitName(jgInstallationNotice.getUseUnitName());
useInfo.setIsNotXiXian(jgInstallationNotice.getIsXixian() == null ? "0" : jgInstallationNotice.getIsXixian());
useInfoService.saveOrUpdateData(useInfo);
} }
} }
...@@ -905,25 +884,27 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -905,25 +884,27 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
model.setCreateDate(new Date()); model.setCreateDate(new Date());
model.setFinishStatus(Boolean.FALSE); model.setFinishStatus(Boolean.FALSE);
model.setAgencyCode("tzs"); model.setAgencyCode("tzs");
model.setCreateUserId(RequestContext.getExeUserId());
model.setStartUserId(RequestContext.getExeUserId());
model.setTaskTitle("发起了" + model.getTaskTitle()); model.setTaskTitle("发起了" + model.getTaskTitle());
Systemctl.taskV2Client.create(model); Systemctl.taskV2Client.create(model);
} }
public TaskV2Model updateTaskModel(Map<String, Object> params){ public TaskV2Model updateTaskModel(Map<String, Object> params, JSONObject jsonObject){
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); JSONObject userJson = null;
if(jsonObject != null){
userJson = JSON.parseObject(jsonObject.get("user").toString());
}
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(params.get("relationId").toString()).getResult(); List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(params.get("relationId").toString()).getResult();
TaskV2Model model = result.stream().sorted((r1, r2) -> r2.getCreateDate().compareTo(r1.getCreateDate())) // 按时间降序排序 TaskV2Model model = result.stream().min((r1, r2) -> r2.getSequenceNbr().compareTo(r1.getSequenceNbr()))
.findFirst()
.orElse(null); .orElse(null);
if(model == null){
return null;
}
model.setTaskStatus(Integer.valueOf(params.get("taskStatus").toString())); model.setTaskStatus(Integer.valueOf(params.get("taskStatus").toString()));
model.setRoutePath(model.getRoutePath().replace("nextExecuteIds", "nextExecuteIdsOld")); model.setRoutePath(model.getRoutePath().replace("nextExecuteIds", "nextExecuteIdsOld"));
model.setTaskStatusLabel(params.get("taskStatusLabel").toString()); model.setTaskStatusLabel(params.get("taskStatusLabel").toString());
model.setEndDate(new Date()); model.setEndDate(new Date());
model.setFinishStatus(Boolean.TRUE); model.setFinishStatus(Boolean.TRUE);
model.setEndUserId(reginParams.getUserModel().getUserId()); model.setEndUserId(userJson != null ? userJson.get("userId").toString() : "");
if (params.containsKey("isDelete")) { if (params.containsKey("isDelete")) {
Systemctl.taskV2Client.delete(model.getSequenceNbr().toString()); Systemctl.taskV2Client.delete(model.getSequenceNbr().toString());
} else { } else {
...@@ -951,7 +932,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -951,7 +932,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
} }
public void updateByWorkFlow(JSONObject jsonObject) { public void updateByWorkFlow(JSONObject jsonObject) {
JgInstallationNotice jgInstallationNotice = this.getById(jsonObject.get("businessId").toString()); String businessKey = jsonObject.getString("businessKey");
JgInstallationNotice jgInstallationNotice = this.getById(businessKey);
List<String> list = (List<String>) jsonObject.get("candidateGroups"); List<String> list = (List<String>) jsonObject.get("candidateGroups");
JSONArray executor = parseArray(jsonObject.get("executor").toString()); JSONArray executor = parseArray(jsonObject.get("executor").toString());
List<String> userList = new ArrayList<>(); List<String> userList = new ArrayList<>();
...@@ -965,46 +947,82 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -965,46 +947,82 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
jgInstallationNotice.setNextExecuteIds(String.join(",", list)); jgInstallationNotice.setNextExecuteIds(String.join(",", list));
jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + String.join(",", list)); jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + String.join(",", list));
jgInstallationNotice.setStatus(jsonObject.get("nodeName").toString()); jgInstallationNotice.setStatus(jsonObject.get("nodeName").toString());
FlowStatusEnum noticeStatus = this.buildNoticeStatus(jgInstallationNotice.getApprovalStatus());
jgInstallationNotice.setNoticeStatus(noticeStatus.getCode() + "");
this.updateById(jgInstallationNotice); this.updateById(jgInstallationNotice);
// 代办业务
TaskV2Model taskV2Model = new TaskV2Model(); if (!"撤回".equals(jgInstallationNotice.getApprovalStatus())) {
//获取待办任务执行人 // 创建待办
// List<AgencyUserModel> userList = Privilege.agencyUserClient TaskV2Model taskV2Model = new TaskV2Model();
// .queryByRoleId(jgInstallationNotice.getNextExecuteIds(), null,Boolean.FALSE).getResult(); taskV2Model.setExecuteUserIds(userIds);
// List<String> userIds = userList.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList()); taskV2Model.setExtras(JSON.toJSONString(jgInstallationNotice));
taskV2Model.setExecuteUserIds(userIds); taskV2Model.setRelationId(jgInstallationNotice.getInstanceId());
taskV2Model.setTaskType("installNotice");
taskV2Model.setExtras(JSON.toJSONString(jgInstallationNotice)); taskV2Model.setTaskTypeLabel("安装告知");
taskV2Model.setRelationId(jgInstallationNotice.getInstanceId()); String url = getUrl(taskV2Model.getTaskType(), "look");
taskV2Model.setTaskType("installNotice"); String format = String.format(url, jgInstallationNotice.getSequenceNbr(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNoticeStatus(), jgInstallationNotice.getInstanceId());
taskV2Model.setTaskTypeLabel("安装告知"); taskV2Model.setRoutePath(format);
String url = getUrl(taskV2Model.getTaskType(), "look"); taskV2Model.setTaskTitle(jgInstallationNotice.getStatus());
String format = String.format(url, jgInstallationNotice.getSequenceNbr(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNoticeStatus(), jgInstallationNotice.getInstanceId()); taskV2Model.setTaskName(jgInstallationNotice.getStatus());
taskV2Model.setRoutePath(format); taskV2Model.setTaskStatus(noticeStatus.getCode());
taskV2Model.setTaskTitle(jgInstallationNotice.getStatus()); taskV2Model.setTaskStatusLabel(noticeStatus.getName());
taskV2Model.setTaskName(jgInstallationNotice.getStatus()); taskV2Model.setTaskCode(jgInstallationNotice.getApplyNo());
taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode()); taskV2Model.setStartUserId(jgInstallationNotice.getCreateUserId());
taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName()); taskV2Model.setCreateUserId(jgInstallationNotice.getCreateUserId());
taskV2Model.setTaskCode(jgInstallationNotice.getApplyNo()); buildTaskModel(taskV2Model);
taskV2Model.setStartUserId(jgInstallationNotice.getCreateUserId()); }
taskV2Model.setCreateUserId(jgInstallationNotice.getCreateUserId());
buildTaskModel(taskV2Model);
} }
public void completeWorkFlow(JSONObject jsonObject) { private FlowStatusEnum buildNoticeStatus(String approvalStatus){
JgInstallationNotice jgInstallationNotice = this.getById(jsonObject.get("businessId").toString()); if("提交".equals(approvalStatus)){
return FlowStatusEnum.TO_BE_PROCESSED;
} else if("驳回".equals(approvalStatus) || "1".equals(approvalStatus)){
return FlowStatusEnum.REJECTED;
} else if("通过".equals(approvalStatus) || "0".equals(approvalStatus)){
return FlowStatusEnum.TO_BE_FINISHED;
} else {
return FlowStatusEnum.ROLLBACK;
}
}
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(jgInstallationNotice.getInstanceId()).getResult();
TaskV2Model model = result.stream().sorted((r1, r2) -> r2.getCreateDate().compareTo(r1.getCreateDate())) // 按时间降序排序 public void completeWorkFlow(String approvalStatus, JSONObject jsonObject) {
.findFirst() // 1.更新业务字段
.orElse(null); String businessKey = jsonObject.getString("businessKey");
// model.setTaskStatus(Integer.valueOf(jsonObject.get("nodeName").toString())); JgInstallationNotice jgInstallationNotice = this.getById(businessKey);
model.setRoutePath(model.getRoutePath().replace("nextExecuteIds", "nextExecuteIdsOld")); jgInstallationNotice.setInstanceId(jsonObject.get("processInstanceId").toString());
model.setTaskStatusLabel(jsonObject.get("nodeName").toString()); jgInstallationNotice.setStatus(jsonObject.get("nodeName").toString());
model.setEndDate(new Date()); jgInstallationNotice.setApprovalStatus(approvalStatus);
model.setFinishStatus(Boolean.TRUE); FlowStatusEnum noticeStatus = this.buildNoticeStatus(jgInstallationNotice.getApprovalStatus());
JSONObject userJson = JSON.parseObject(jsonObject.get("user").toString()); jgInstallationNotice.setNoticeStatus(noticeStatus.getCode() + "");
model.setEndUserId(userJson.get("userId").toString()); this.updateById(jgInstallationNotice);
Systemctl.taskV2Client.update(model, model.getSequenceNbr()); if ("撤回".equals(approvalStatus)) {
// 删除待办
HashMap<String, Object> map = new HashMap<>();
map.put("relationId", jgInstallationNotice.getInstanceId());
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
map.put("isDelete", Boolean.TRUE);
updateTaskModel(map, jsonObject);
} else {
// 更新代办为已完成及更新url
List<TaskV2Model> result = Systemctl.taskV2Client.selectListByRelationId(jgInstallationNotice.getInstanceId()).getResult();
// 按时间降序排序
TaskV2Model model = result.stream().min((r1, r2) -> r2.getSequenceNbr().compareTo(r1.getSequenceNbr()))
.orElse(null);
if (model == null) {
return;
}
String url = getUrl(model.getTaskType(), "look");
String format = String.format(url, jgInstallationNotice.getSequenceNbr(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNextExecuteIds(), jgInstallationNotice.getNoticeStatus(), jgInstallationNotice.getInstanceId());
model.setRoutePath(format);
model.setRoutePath(model.getRoutePath().replace("nextExecuteIds", "nextExecuteIdsOld"));
model.setTaskStatusLabel(jsonObject.get("nodeName").toString());
model.setEndDate(new Date());
model.setFinishStatus(Boolean.TRUE);
JSONObject userJson = JSON.parseObject(jsonObject.get("user").toString());
model.setEndUserId(userJson.get("userId").toString());
Systemctl.taskV2Client.update(model, model.getSequenceNbr());
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment