Commit e84ef003 authored by zhangsen's avatar zhangsen

安装告知模块 功能开发

parent 4e2c7589
......@@ -248,5 +248,14 @@ public class JgInstallationNoticeDto extends BaseDto {
@JsonSerialize(using = BizCustomDateSerializer.class)
private Date handleDate;
private String createUserCompanyName;
//下一步任务ID
private String nextTaskId;
/**
* 创建人
*/
private String createUserName;
}
......@@ -400,4 +400,19 @@ public class JgInstallationNotice extends BaseEntity {
*/
private String approvalStatus;
@TableField(value = "\"create_user_company_name\"")
private String createUserCompanyName;
//下一步任务ID
@TableField(value = "\"next_taskId\"")
private String nextTaskId;
/**
* 创建人
*/
@TableField("\"create_user_name\"")
private String createUserName;
}
......@@ -13,12 +13,18 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgTransferNoticeEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
import com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils;
......@@ -35,10 +41,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import com.yeejoin.amos.feign.workflow.model.*;
import fr.opensagres.xdocreport.core.io.IOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......@@ -141,6 +144,13 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
private ICmWorkflowService iCmWorkflowService;
@Autowired
private CommonServiceImpl commonService;
/**
* 根据sequenceNbr查询
*
......@@ -184,10 +194,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
equipmentInfos.get(0).put(s, parseArray(equipmentInfos.get(0).get(s).toString()));
}
}
Map<String, Object> map = equipmentInfos.get(0);
BeanUtil.copyProperties(installationInfo, map, "equList", "supervisoryCode");
return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", installationInfo);
this.put("equipmentInfo", equipmentInfos.get(0));
this.put("installationInfo", map);
}};
}
......@@ -198,89 +208,104 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
*/
@SuppressWarnings({"rawtypes", "Duplicates"})
public JgInstallationNoticeDto updateInstallationNotice(String submitType, JgInstallationNoticeDto noticeDto, String op) {
boolean instancedId = ObjectUtils.isEmpty(noticeDto.getInstanceId());
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (Objects.isNull(noticeDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空");
}
String[] taskName = new String[]{"流程结束"};
// 字段转换
this.convertField(noticeDto);
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
JgInstallationNotice notice = this.getById(noticeDto.getSequenceNbr());
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
AjaxResult ajaxResult;
// 发起流程
if (!StringUtils.hasText(noticeDto.getInstanceId())) {
// 发起流程
ProcessTaskDTO processTaskDTO = new ProcessTaskDTO();
WorkflowResultDto workflowResultDto = new WorkflowResultDto();
// 如果没有实例ID,说明是启动并执行一步
// 直接调用工作流 启动并执行API - 可以拿到两个节点的信息,用于填充业务字段
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey("1");
try {
ajaxResult = Workflow.taskClient.startByVariable(dto);
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString();
noticeDto.setInstanceId(instanceId);
// 查询下节点任务
getNext(roleListFirst, instanceId,taskName);
noticeDto.setInstanceStatus(String.join(",", roleListFirst));
} catch (Exception e) {
log.error("提交失败:{}", e);
dto.setBusinessKey(noticeDto.getSequenceNbr().toString());
dto.setCompleteFirstTask(Boolean.TRUE);
list.add(dto);
actWorkflowBatchDTO.setProcess(list);
processTaskDTO = iCmWorkflowService.startBatch(actWorkflowBatchDTO).get(0);
// 提取节点等信息
workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
BeanUtils.copyProperties(noticeDto, notice);
if (!ObjectUtils.isEmpty(notice.getInstanceStatus())) {
notice.setInstanceStatus(notice.getInstanceStatus() + "," + workflowResultDto.getNextExecutorRoleIds());
} else {
notice.setInstanceStatus(workflowResultDto.getNextExecutorRoleIds());
}
notice.setPromoter(RequestContext.getExeUserId());
notice.setNextExecuteIds(String.join(",", workflowResultDto.getNextExecutorRoleIds()));
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
notice.setNextTaskId(workflowResultDto.getNextTaskId());
this.updateById(notice);
// 如果为保存并提交,则创建代办
buildTask(Collections.singletonList(notice), Collections.singletonList(workflowResultDto));
} else {
ProcessTaskDTO processTaskDTO = new ProcessTaskDTO();
WorkflowResultDto workflowResultDto = new WorkflowResultDto();
// 只调用执行API,返回下个节点信息,用于填充业务字段
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(notice.getNextTaskId());
HashMap<String, Object> commMap = new HashMap<>();
if (notice.getNoticeStatus().equals("6614") || notice.getNoticeStatus().equals("6615")) {
commMap.put("approvalStatus", "提交");
} else {
commMap.put("approvalStatus", op);
}
JgInstallationNotice notice = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto,notice);
boolean submit = submit(notice, op);
if(submit) {
// 查询下节点任务
getNext(roleListSecond, notice.getInstanceId(),taskName);
notice.setStatus(taskName[0]);
dto.setVariable(commMap);
processTaskDTO = iCmWorkflowService.complete(notice.getNextTaskId(), dto);
// 提取节点等信息
workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
BeanUtils.copyProperties(noticeDto, notice);
if (!ObjectUtils.isEmpty(notice.getInstanceStatus())) {
notice.setInstanceStatus(notice.getInstanceStatus() + "," + roleListSecond);
notice.setInstanceStatus(notice.getInstanceStatus() + "," + workflowResultDto.getNextExecutorRoleIds());
} else {
notice.setInstanceStatus(String.join(",", roleListSecond));
notice.setInstanceStatus(workflowResultDto.getNextExecutorRoleIds());
}
notice.setPromoter(RequestContext.getExeUserId());
notice.setNextExecuteIds(String.join(",", roleListSecond));
notice.setNextExecuteIds(String.join(",", workflowResultDto.getNextExecutorRoleIds()));
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
jgInstallationNoticeMapper.updateById(notice);
}
if (!instancedId) {
notice.setNextTaskId(workflowResultDto.getNextTaskId());
this.updateById(notice);
// 上个代办改为已办
HashMap<String, Object> map = new HashMap<>();
map.put("taskStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
map.put("relationId", notice.getInstanceId());
map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
updateTaskModel(map,null);
map.put("flowStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
map.put("flowStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
TaskV2Model taskV2Model = commonService.updateTaskModel(map);
if (ObjectUtils.isEmpty(taskV2Model)) {
// 如果为保存并提交,则创建代办
buildTask(Collections.singletonList(notice), Collections.singletonList(workflowResultDto));
} else {
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
taskModelDto.setModel(notice);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowCode(notice.getNextTaskId());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
}
}
TaskV2Model taskV2Model = new TaskV2Model();
//获取待办任务执行人
List<AgencyUserModel> userList = Privilege.agencyUserClient
.queryByRoleId(notice.getNextExecuteIds(), null,Boolean.FALSE).getResult();
List<String> userIds = userList.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
taskV2Model.setExecuteUserIds(CollectionUtils.isEmpty(userIds)?"": String.join(",", userIds));
taskV2Model.setExtras(JSON.toJSONString(notice));
taskV2Model.setRelationId(notice.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(), "look");
String format = String.format(url, notice.getSequenceNbr(), notice.getNextExecuteIds(), notice.getNextExecuteIds(), notice.getNoticeStatus(), notice.getInstanceId());
taskV2Model.setRoutePath(format);
taskV2Model.setTaskTitle(notice.getStatus());
taskV2Model.setTaskName(notice.getStatus());
taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskV2Model.setTaskCode(notice.getApplyNo());
buildTaskModel(taskV2Model);
} else {
JgInstallationNotice bean = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto, bean);
jgInstallationNoticeMapper.updateById(bean);
this.updateById(bean);
}
return noticeDto;
}
......@@ -433,11 +458,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@SuppressWarnings({"Duplicates", "rawtypes"})
@Transactional(rollbackFor = Exception.class)
public void saveNotice(String submitType, JSONObject jgInstallationNoticeDtoMap, ReginParams reginParams) {
String[] taskName = new String[]{"流程结束"};
// TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
// JgInstallationNoticeDto model = BeanUtil.toBeanIgnoreError(jgInstallationNoticeDtoMap.get(TABLE_PAGE_ID).toString(), JgInstallationNoticeDto.class);
JgInstallationNoticeDto model = JSON.parseObject(jgInstallationNoticeDtoMap.get(TABLE_PAGE_ID).toString(), JgInstallationNoticeDto.class);
// 字段转换
convertField(model);
......@@ -447,7 +468,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (CollectionUtils.isEmpty(deviceList)) {
throw new BadRequest("设备列表为空");
}
// 获取告知单号
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.AZGZ.getCode(), deviceList.size());
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
......@@ -460,9 +480,57 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
throw new BadRequest("告知单生成失败!");
}
// 启动工作流并返回信息
List<WorkflowResultDto> workflowResultList = workFlowInfo(submitType, deviceList);
List<JgInstallationNotice> list = new ArrayList<>();
List<JgInstallationNoticeEq> equipList = new ArrayList<>();
//业务数据组装等
businessData(submitType, reginParams, model, deviceList, applyNoList, list, equipList, workflowResultList);
jgInstallationNoticeMapper.insertBatchSomeColumn(list);
// 如果为保存并提交,则创建代办
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
buildTask(list, workflowResultList);
}
List<JgInstallationNoticeEq> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> {
List<JgInstallationNotice> collect = list.stream().filter(jgInstallationNotice -> jgRelationEquip.getEquipTransferId().equals(jgInstallationNotice.getApplyNo())).collect(Collectors.toList());
Long sequenceNbr = collect.get(0).getSequenceNbr();
return jgRelationEquip.setEquipTransferId(String.valueOf(sequenceNbr));
}).collect(Collectors.toList());
jgInstallationNoticeEqMapper.insertBatchSomeColumn(jgRelationEquipList);
}
private void buildTask(List<JgInstallationNotice> list, List<WorkflowResultDto> workflowResultList) {
List<TaskModelDto> taskModelDtoList = new ArrayList<>();
WorkflowResultDto workflowResultDto = workflowResultList.get(0);
list.forEach(item -> {
TaskModelDto taskModelDto = new TaskModelDto();
taskModelDto.setFlowCreateDate(item.getCreateDate());
taskModelDto.setTaskName(workflowResultDto.getNextTaskName()); // 工作流API返回
taskModelDto.setTaskCode(item.getApplyNo());
taskModelDto.setTaskType(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getCode());
taskModelDto.setTaskTypeLabel(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName());
taskModelDto.setRelationId(item.getInstanceId());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); // 工作流API返回
taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowStatus(commonService.getDictionaryCodeByName(FlowStatusEnum.TO_BE_PROCESSED.getName())); // 流程状态枚举
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowCode(item.getNextTaskId());
taskModelDto.setStartUserId(item.getCreateUserId());
taskModelDto.setStartUser(item.getCreateUserName());
taskModelDto.setStartUserCompanyName(item.getCreateUserCompanyName()); // 任务发起人所在单位
taskModelDto.setStartDate(item.getCreateDate());
taskModelDto.setModel(item);
taskModelDto.setNextExecuteUser(item.getNextExecuteIds());
taskModelDto.setTaskContent(String.format("来自%s【%s】的业务办理,【申请单号:%s】", item.getEquList(), item.getEquRegisterCode(), item.getApplyNo()));
taskModelDtoList.add(taskModelDto);
});
commonService.buildTaskModel(taskModelDtoList);
}
private void businessData(String submitType, ReginParams reginParams, JgInstallationNoticeDto model, List<Map<String, Object>> deviceList, List<String> applyNoList, List<JgInstallationNotice> list, List<JgInstallationNoticeEq> equipList, List<WorkflowResultDto> workflowResultList) {
deviceList.forEach(obj -> {
JgInstallationNoticeEq jgRelationEquip = new JgInstallationNoticeEq();
JgInstallationNotice dto = new JgInstallationNotice();
......@@ -472,116 +540,61 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
dto.setApplyNo(applyNo);
dto.setNoticeDate(new Date());
if(SUBMIT_TYPE_FLOW.equals(submitType)) {
dto.setPromoter(RequestContext.getExeUserId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
dto.setNextExecuteIds(workflowResultList.get(i).getNextExecutorRoleIds());
dto.setInstanceStatus(workflowResultList.get(i).getNextExecutorRoleIds() + "," + workflowResultList.get(i).getExecutorRoleIds());
dto.setPromoter(reginParams.getUserModel().getUserId());
dto.setNextTaskId(workflowResultList.get(i).getNextTaskId());
}
dto.setCreateUserId(RequestContext.getExeUserId());
dto.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setEquList((String.valueOf(obj.get("EQU_CATEGORY"))));
dto.setEntrustingUnitName(dto.getUseUnitName());
dto.setCreateUserCompanyName(reginParams.getCompany().getCompanyName());
dto.setEquRegisterCode(String.valueOf(obj.get("EQU_CODE")));
StringBuffer buffer = new StringBuffer();
buffer.append(dto.getProvinceName()).append(dto.getCityName()).append(dto.getCountyName()).append(dto.getAddress());
dto.setEquAddress(buffer.toString());
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipTransferId(applyNo);
if (!CollectionUtils.isEmpty(workflowResultList)) {
dto.setInstanceId(workflowResultList.get(i).getInstanceId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
} else {
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
}
dto.setCreateUserName(reginParams.getUserModel().getRealName());
dto.setCreateUserId(reginParams.getUserModel().getUserId());
list.add(dto);
equipList.add(jgRelationEquip);
});
}
jgInstallationNoticeMapper.insertBatchSomeColumn(list);
List<JgInstallationNoticeEq> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> {
List<JgInstallationNotice> collect = list.stream().filter(jgInstallationNotice -> jgRelationEquip.getEquipTransferId().equals(jgInstallationNotice.getApplyNo())).collect(Collectors.toList());
Long sequenceNbr = collect.get(0).getSequenceNbr();
return jgRelationEquip.setEquipTransferId(String.valueOf(sequenceNbr));
}).collect(Collectors.toList());
jgInstallationNoticeEqMapper.insertBatchSomeColumn(jgRelationEquipList);
// 需要在事务提交之后,否则事务隔离查询不出数据
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> workflowStartDTOS = new ArrayList<>();
list.forEach(item -> {
/**
* 工作流启动并执行
* @param submitType 是否提交
* @param deviceList 设备信息
* @return 工作流返回相关数据
*/
private List<WorkflowResultDto> workFlowInfo(String submitType, List<Map<String, Object>> deviceList) {
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
deviceList.forEach(item -> {
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(item.getSequenceNbr() + "");
dto.setBusinessKey(item.get("SEQUENCE_NBR").toString());
dto.setCompleteFirstTask(Boolean.TRUE);
workflowStartDTOS.add(dto);
}
list.add(dto);
});
try {
actWorkflowBatchDTO.setProcess(workflowStartDTOS);
Workflow.taskV2Client.startByVariableBatch(actWorkflowBatchDTO);
} catch (Exception e) {
log.error("提交失败:{}", e);
actWorkflowBatchDTO.setProcess(list);
List<ProcessTaskDTO> processTaskDTOS = iCmWorkflowService.startBatch(actWorkflowBatchDTO);
// 组装工作流返回的数据
return commonService.buildWorkFlowInfo(processTaskDTOS);
}
return new ArrayList<>();
}
});
// platformTransactionManager.commit(transactionStatus);
// list.forEach(item -> {
// // 代办业务
// if(SUBMIT_TYPE_FLOW.equals(submitType)) {
// TaskV2Model taskV2Model = new TaskV2Model();
// //获取待办任务执行人
// List<AgencyUserModel> userList = Privilege.agencyUserClient
// .queryByRoleId(item.getNextExecuteIds(), null,Boolean.FALSE).getResult();
// List<String> userIds = userList.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
// taskV2Model.setExecuteUserIds(CollectionUtils.isEmpty(userIds)?"": String.join(",", userIds));
// taskV2Model.setExtras(JSON.toJSONString(item));
// taskV2Model.setRelationId(item.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(), "look");
// String format = String.format(url, item.getSequenceNbr(), item.getNextExecuteIds(), item.getNextExecuteIds(), item.getNoticeStatus(), item.getInstanceId());
// taskV2Model.setRoutePath(format);
// taskV2Model.setTaskTitle(item.getStatus());
// taskV2Model.setTaskName(item.getStatus());
// taskV2Model.setTaskStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
// taskV2Model.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
// taskV2Model.setTaskCode(item.getApplyNo());
// buildTaskModel(taskV2Model);
// }
// });
}
void getNext(ArrayList<String> roleListFirst, String instanceId, String[] taskName) {
AjaxResult aj = Workflow.taskClient.getTaskNoAuth(instanceId);
JSONObject taskNoAuth = JSON.parseObject(JSON.toJSONString(aj.get("data")));
if (!ObjectUtils.isEmpty(taskNoAuth)) {
String nextTaskId = taskNoAuth.getString("id");
AjaxResult taskGroupName = Workflow.taskClient.getTaskGroupName(nextTaskId);
taskName[0] = taskNoAuth.getString("name");
JSONArray data = parseArray(JSON.toJSONString(taskGroupName.get("data")));
for (Object datum : data) {
if (((Map) datum).containsKey("groupId")) {
roleListFirst.add(((Map) datum).get("groupId").toString());
}
}
}
}
private void convertField(JgInstallationNoticeDto model) {
// 处理图片
if(!ValidationUtil.isEmpty(model.getProxyStatementAttachmentList())) {
......@@ -666,145 +679,53 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
}
private String convertImageUrl(List<Map<String, String>> urlList) {
String urls = "";
if (!CollectionUtils.isEmpty(urlList)) {
urls = urlList.stream().map(map -> map.get("url")).collect(Collectors.joining(","));
}
return urls;
}
public boolean submit(JgInstallationNotice notice,String op) {
AjaxResult ajaxResult = Workflow.taskClient.getTask(notice.getInstanceId());
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
if(!ValidationUtil.isEmpty(notice.getProcessAdvice())) {
dto.setComment(notice.getProcessAdvice());
}
HashMap<String, Object> map = new HashMap<>();
if(notice.getNoticeStatus().equals("6614") || notice.getNoticeStatus().equals("6615") ) {
map.put("approvalStatus", "提交");
} else {
map.put("approvalStatus", op);
}
dto.setVariable(map);
//执行流程
AjaxResult ajaxResult1 = null;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto);
if (ajaxResult1.get("code").equals(200)) {
return true;
} else {
return false;
}
} catch (Exception e) {
log.error("提交失败:{}", e);
return false;
}
}
public void cancel(JgInstallationNoticeDto noticeDto) {
String[] taskName = new String[]{"流程结束"};
FeignClientResult ajaxResult = Workflow.taskV2Client.rollBack(noticeDto.getInstanceId());
JgInstallationNotice jgInstallationNotice = this.baseMapper.selectById(noticeDto.getSequenceNbr());
ArrayList<String> roleList = new ArrayList<>();
if(ajaxResult.getStatus() == 200) {
// HashMap<String, Object> map = new HashMap<>();
// map.put("relationId", noticeDto.getInstanceId());
// map.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
// map.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
// map.put("isDelete", Boolean.TRUE);
// updateTaskModel(map);
getNext(roleList, noticeDto.getInstanceId(),taskName);
jgInstallationNotice.setStatus(taskName[0]);
ProcessTaskDTO processTaskDTO = iCmWorkflowService.rollBack(jgInstallationNotice.getInstanceId());
// 提取节点等信息
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
jgInstallationNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.ROLLBACK.getCode()));
jgInstallationNoticeMapper.updateById(jgInstallationNotice);
}
jgInstallationNotice.setNextTaskId(workflowResultDto.getNextTaskId());
this.updateById(jgInstallationNotice);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(jgInstallationNotice));
jsonObject.put("taskType", BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getCode());
jsonObject.put("nextExecuteUser", jgInstallationNotice.getNextExecuteIds());
commonService.rollbackTask(jgInstallationNotice.getInstanceId(), jsonObject);
}
@Transactional(rollbackFor = Exception.class)
public void accept(JgInstallationNoticeDto dto,String op) {
String[] taskName = new String[]{"流程结束"};
String userId = RequestContext.getExeUserId();
JgInstallationNotice jgInstallationNotice = this.jgInstallationNoticeMapper.selectById(dto.getSequenceNbr());
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
JgInstallationNotice jgInstallationNotice = this.getById(dto.getSequenceNbr());
jgInstallationNotice.setProcessAdvice(dto.getProcessAdvice());
ArrayList<String> roleList = new ArrayList<>();
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) {
// 组装设备注册代码
StringBuffer stringBuffer = new StringBuffer();
String ym = null;
try {
ym = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN_MM);
} catch (ParseException e) {
log.error("日期转换失败:{}", e);
}
// 组装设备注册代码
StringBuffer stringBuffer = new StringBuffer();
// 执行工作流并返回组装好的工作流信息
WorkflowResultDto workflowResultDto = getWorkflowResultDto(op, jgInstallationNotice);
jgInstallationNotice.setPromoter(reginParams.getUserModel().getUserId());
TaskV2Model taskV2Model = new TaskV2Model();
if ("0".equals(op)) {
if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,jgInstallationNotice.getSequenceNbr());
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId,dto.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord,jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgInstallationNotice.getCity()).append(ym);
String equCode = stringBuffer.toString();
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(equCode);
String deviceRegistrationCode = responseModel.getResult();
Map<String, Object> map = new HashMap<>();
......@@ -815,7 +736,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
Map<String, Object> mapCode;
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
mapCode = code.getResult();
LambdaQueryWrapper<SupervisoryCodeInfo> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(SupervisoryCodeInfo::getSupervisoryCode,mapCode.get("superviseCode").toString());
SupervisoryCodeInfo supervisoryCodeInfo = supervisoryCodeInfoMapper.selectOne(queryWrapper3);
......@@ -823,9 +743,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
supervisoryCodeInfoMapper.updateById(supervisoryCodeInfo);
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgInstallationNotice.setHandleDate(new Date());
Map<String,Object> map1 =new HashMap<>();
// 更新其他业务表
if(!ValidationUtil.isEmpty(mapCode.get("code96333"))) {
tzsJgOtherInfo.setCode96333(mapCode.get("code96333").toString());
......@@ -840,7 +758,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
map1.put("SUPERVISORY_CODE",tzsJgOtherInfo.getSupervisoryCode());
map1.put("USE_UNIT_CREDIT_CODE",jgInstallationNotice.getUseUnitCreditCode());
map1.put("USE_UNIT_NAME",jgInstallationNotice.getUseUnitName());
map1.put("USC_UNIT_CREDIT_CODE",jgInstallationNotice.getInstallUnitCreditCode());
map1.put("USC_UNIT_NAME",jgInstallationNotice.getInstallUnitName());
objMap.put(tzsJgOtherInfo.getRecord(),map1);
......@@ -848,7 +765,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
tzsJgOtherInfoMapper.updateById(tzsJgOtherInfo);
tzsJgRegistrationInfoMapper.updateById(tzsJgRegistrationInfo);
// 更新施工信息表
IdxBizJgConstructionInfo idxBizJgConstructionInfo = constructionInfoService.queryNewestDetailByRecord(jgRelationEquip.getEquId());
if (!ObjectUtils.isEmpty(idxBizJgConstructionInfo)) {
......@@ -865,7 +781,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
constructionInfoService.saveOrUpdateData(idxBizJgConstructionInfo);
}
// 使用信息表更新是否西咸
IdxBizJgUseInfo useInfo = useInfoService.getOneData(jgRelationEquip.getEquId());
if (!ObjectUtils.isEmpty(useInfo)) {
......@@ -874,155 +789,103 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
useInfo.setIsNotXiXian(jgInstallationNotice.getIsXixian() == null ? "0" : jgInstallationNotice.getIsXixian());
useInfoService.saveOrUpdateData(useInfo);
}
}
public void buildTaskModel(TaskV2Model model){
// ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
model.setStartDate(new Date());
model.setTaskSource("workFlow");
model.setCreateDate(new Date());
//model.setFinishStatus(Boolean.FALSE);
model.setAgencyCode("tzs");
model.setTaskTitle("发起了" + model.getTaskTitle());
Systemctl.taskV2Client.create(model);
}
public TaskV2Model updateTaskModel(Map<String, Object> params, JSONObject jsonObject){
JSONObject userJson = null;
if(jsonObject != null){
userJson = JSON.parseObject(jsonObject.get("user").toString());
}
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(params.get("relationId").toString()).getResult();
TaskV2Model model = result.stream().min((r1, r2) -> r2.getSequenceNbr().compareTo(r1.getSequenceNbr()))
.orElse(null);
if(model == null){
return null;
}
model.setTaskStatus(Integer.valueOf(params.get("taskStatus").toString()));
model.setRoutePath(model.getRoutePath().replace("nextExecuteIds", "nextExecuteIdsOld"));
model.setTaskStatusLabel(params.get("taskStatusLabel").toString());
model.setEndDate(new Date());
//model.setFinishStatus(Boolean.TRUE);
model.setEndUserId(userJson != null ? userJson.get("userId").toString() : "");
if (params.containsKey("isDelete")) {
Systemctl.taskV2Client.delete(model.getSequenceNbr().toString());
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("relationId", jgInstallationNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("model", jgInstallationNotice);
taskV2Model = commonService.updateTaskModel(taskMap);
} else {
jgInstallationNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
if (!ObjectUtils.isEmpty(jgInstallationNotice.getInstanceStatus())) {
jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + workflowResultDto.getNextExecutorRoleIds());
} else {
Systemctl.taskV2Client.update(model, model.getSequenceNbr());
jgInstallationNotice.setInstanceStatus(workflowResultDto.getNextExecutorRoleIds());
}
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_PROCESSED.getName());
taskMap.put("relationId", jgInstallationNotice.getInstanceId());
taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
taskModelDto.setModel(jgInstallationNotice);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowCode(workflowResultDto.getNextTaskId());
taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
}
return model;
} else {
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", jgInstallationNotice.getNoticeStatus());
taskMap.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
taskMap.put("relationId", jgInstallationNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.REJECTED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.REJECTED.getName());
taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
taskModelDto.setModel(jgInstallationNotice);
taskModelDto.setTaskName(workflowResultDto.getNextTaskName());
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
taskModelDto.setFlowStatus(FlowStatusEnum.REJECTED.getCode());
taskModelDto.setFlowStatusLabel(FlowStatusEnum.REJECTED.getName());
taskModelDto.setFlowCode(workflowResultDto.getNextTaskId());
taskModelDto.setNextExecuteUser(workflowResultDto.getNextExecutorRoleIds());
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
}
jgInstallationNotice.setNextTaskId(workflowResultDto.getNextTaskId());
this.updateById(jgInstallationNotice);
}
private String getUrl(String type, String pageType) {
String json = null;
try {
json = IOUtils.toString(bizTypeInfo.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<Map> list = parseArray(json, Map.class);
String url = null;
for (Map map : list) {
if (map.get("type").equals(type)&& pageType.equals(map.get("pageType"))){
url = map.get("url").toString();
break;
}
}
return url;
}
public void updateByWorkFlow(JSONObject jsonObject) {
String businessKey = jsonObject.getString("businessKey");
JgInstallationNotice jgInstallationNotice = this.getById(businessKey);
List<String> list = (List<String>) jsonObject.get("candidateGroups");
JSONArray executor = parseArray(jsonObject.get("executor").toString());
List<String> userList = new ArrayList<>();
for (Object datum : executor) {
if (((Map) datum).containsKey("userId")) {
userList.add(((Map) datum).get("userId").toString());
}
}
String userIds = String.join(",", userList);
jgInstallationNotice.setInstanceId(jsonObject.get("processInstanceId").toString());
jgInstallationNotice.setNextExecuteIds(String.join(",", list));
jgInstallationNotice.setInstanceStatus(jgInstallationNotice.getInstanceStatus() + "," + String.join(",", list));
jgInstallationNotice.setStatus(jsonObject.get("nodeName").toString());
FlowStatusEnum noticeStatus = this.buildNoticeStatus(jgInstallationNotice.getApprovalStatus());
jgInstallationNotice.setNoticeStatus(noticeStatus.getCode() + "");
this.updateById(jgInstallationNotice);
if (!"撤回".equals(jgInstallationNotice.getApprovalStatus())) {
// 创建待办
TaskV2Model taskV2Model = new TaskV2Model();
taskV2Model.setExecuteUserIds(userIds);
taskV2Model.setExtras(JSON.toJSONString(jgInstallationNotice));
taskV2Model.setRelationId(jgInstallationNotice.getInstanceId());
taskV2Model.setTaskType("installNotice");
taskV2Model.setTaskTypeLabel("安装告知");
String url = getUrl(taskV2Model.getTaskType(), "look");
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(noticeStatus.getCode());
taskV2Model.setTaskStatusLabel(noticeStatus.getName());
taskV2Model.setTaskCode(jgInstallationNotice.getApplyNo());
taskV2Model.setStartUserId(jgInstallationNotice.getCreateUserId());
//taskV2Model.setCreateUserId(jgInstallationNotice.getCreateUserId());
buildTaskModel(taskV2Model);
}
}
private FlowStatusEnum buildNoticeStatus(String approvalStatus){
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;
/**
* 执行工作流并返回组装好的工作流信息
* @param op 是否通过
* @param jgTransferNotice 业务信息 opinion 备注信息
* @return 返回组装好的工作流信息
*/
private WorkflowResultDto getWorkflowResultDto(String op, JgInstallationNotice jgTransferNotice) {
ProcessTaskDTO processTaskDTO = new ProcessTaskDTO();
WorkflowResultDto workflowResultDto = new WorkflowResultDto();
// 只调用执行API,返回下个节点信息,用于填充业务字段
//组装信息
TaskResultDTO workDto = new TaskResultDTO();
workDto.setResultCode("approvalStatus");
workDto.setTaskId(jgTransferNotice.getNextTaskId());
HashMap<String, Object> commMap = new HashMap<>();
if (jgTransferNotice.getNoticeStatus().equals("6614") || jgTransferNotice.getNoticeStatus().equals("6615")) {
commMap.put("approvalStatus", "提交");
} else {
return FlowStatusEnum.ROLLBACK;
commMap.put("approvalStatus", op);
}
workDto.setVariable(commMap);
workDto.setComment(jgTransferNotice.getProcessAdvice());
processTaskDTO = iCmWorkflowService.complete(jgTransferNotice.getNextTaskId(), workDto);
// 提取节点等信息
workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
return workflowResultDto;
}
public void completeWorkFlow(String approvalStatus, JSONObject jsonObject) {
// 1.更新业务字段
String businessKey = jsonObject.getString("businessKey");
JgInstallationNotice jgInstallationNotice = this.getById(businessKey);
jgInstallationNotice.setInstanceId(jsonObject.get("processInstanceId").toString());
jgInstallationNotice.setStatus(jsonObject.get("nodeName").toString());
jgInstallationNotice.setApprovalStatus(approvalStatus);
FlowStatusEnum noticeStatus = this.buildNoticeStatus(jgInstallationNotice.getApprovalStatus());
jgInstallationNotice.setNoticeStatus(noticeStatus.getCode() + "");
this.updateById(jgInstallationNotice);
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
}
......@@ -592,7 +592,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(jgInstallationNotice));
jsonObject.put("taskType", BusinessTypeEnum.JG_ADVICE_REMOVAL.getCode());
jsonObject.put("nextExecuteUser", jgInstallationNotice.getNextExecuteIds());
commonService.rollbackTask(jgInstallationNotice.getInstanceId(), JSON.parseObject(JSON.toJSONString(jgInstallationNotice)));
commonService.rollbackTask(jgInstallationNotice.getInstanceId(), jsonObject);
}
@Transactional
......@@ -633,6 +633,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
taskMap.put("relationId", jgTransferNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("model", jgTransferNotice);
taskV2Model = commonService.updateTaskModel(taskMap);
} else {
jgTransferNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
......
......@@ -9,13 +9,13 @@
"type": "102",
"pageType": "look",
"name": "安装告知",
"url": "/mixuap?appId=1742358052905971713&id=1735246137364869121&sequenceNbr=%s&roleIds=%s&&userId={userId}&nextExecuteIds=%s&formType=detail&noticeStatus=%s&instanceId=%s"
"url": "/mixuap?appId=1742358052905971713&id=1735246137364869121&roleIds={roleIds}&userId={userId}&formType=detail"
},
{
"type": "102",
"pageType": "edit",
"name": "安装告知",
"url": "/mixuap?appId=1742358052905971713&id=1734127099570057217&sequenceNbr=%s&roleIds=%s&userId={userId}&nextExecuteIds=%s&formType=edit&noticeStatus=%s&instanceId=%s"
"url": ""
},
{
"type": "103",
......
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