Commit 59ff38c0 authored by tianyiming's avatar tianyiming

维修告知新增代办并更新调用工作流接口

parent 80172a1e
......@@ -206,4 +206,12 @@ public class JgMaintainNoticeDto extends BaseDto {
@ApiModelProperty(value = "下一执行节点ids")
private String nextExecuteIds;
private String createUserCompanyName;
private String nextTaskId;
private String equListName;
private String supervisoryCode;
}
......@@ -313,4 +313,17 @@ public class JgMaintainNotice extends BaseEntity {
@TableField("next_execute_ids")
private String nextExecuteIds;
@TableField(value = "create_user_company_name")
private String createUserCompanyName;
@TableField("next_task_id")
private String nextTaskId;
@TableField(exist = false)
private String equListName;
@TableField(exist = false)
private String supervisoryCode;
}
......@@ -35,4 +35,7 @@ public interface JgMaintainNoticeMapper extends CustomBaseMapper<JgMaintainNotic
List<Map<String, Object>> queryEquipInformation(@Param("sequenceNbr") long sequenceNbr);
void updatePromoter(@Param("id")Long id);
Map<String, Object> getEquipInfoByRecord(String record);
}
......@@ -119,4 +119,51 @@
LEFT JOIN tz_base_enterprise_info eio ON eio.use_code = isn.install_unit_credit_code
WHERE isn.sequence_nbr = #{sequenceNbr} LIMIT 1
</select>
<select id="getEquipInfoByRecord" resultType="java.util.Map">
select
ri.product_name AS productName,
ri.brand_name AS brandName,
ri.equ_type AS equType,
ri.equ_code AS equCode,
ri.equ_price AS equPrice,
ri.product_photo AS productPhoto,
di.design_unit_credit_code AS designUnitCreditCode,
di.design_unit_name AS designUnitName,
di.design_license_num AS designLicenseNum,
di.design_use_date AS designUseDate,
di.design_date AS designDate,
di.drawing_do AS drawingDo,
di.appraisal_unit AS appraisalUnit,
di.appraisal_date AS appraisalDate,
di.design_doc AS designDoc,
di.design_standard AS designStandard,
fi.produce_unit_credit_code AS produceUnitCreditCode,
fi.produce_unit_name AS produceUnitName,
fi.produce_license_num AS produceLicenseNum,
fi.FACTORY_NUM AS produceCode,
fi.FACTORY_NUM AS factoryNum,
fi.produce_date AS produceDate,
fi.imported AS imported,
fi.produce_country AS produceCountry,
fi.factory_standard AS factoryStandard,
fi.product_quality_yield_prove AS productQualityYieldProve,
fi.ins_use_maintain_explain AS insUseMaintainExplain,
idi.INSPECT_REPORT AS inspectReport,
tec2.name AS equCategory,
tec1.name AS equList,
tec.name AS equDefine,
oi.SUPERVISORY_CODE AS supervisoryCode
FROM
idx_biz_jg_other_info oi
LEFT JOIN idx_biz_jg_register_info ri ON ri.record = oi.record
LEFT JOIN idx_biz_jg_design_info di ON di.record = oi.record
LEFT JOIN idx_biz_jg_factory_info fi ON fi.record = oi.record
LEFT JOIN idx_biz_jg_inspection_detection_info idi ON idi.record = oi.record
LEFT JOIN amos_tzs_biz.tz_equipment_category tec ON ri."EQU_CATEGORY"::text = tec.code::text
LEFT JOIN amos_tzs_biz.tz_equipment_category tec1 ON ri."EQU_LIST"::text = tec1.code::text
LEFT JOIN amos_tzs_biz.tz_equipment_category tec2 ON ri."EQU_DEFINE"::text = tec2.code::text
WHERE oi.record = #{record} ORDER BY oi."rec_date" DESC LIMIT 1
</select>
</mapper>
......@@ -575,7 +575,7 @@ public class CommonServiceImpl implements ICommonService {
JSONObject jsonObject = new JSONObject(provideMap);
jgChangeRegistrationUnitServiceImpl.saveNotice(submitType, jsonObject, reginParams);
} else if (type.equals(ApplicationFormTypeEnum.WBBA.getBusinessCode())) {
noticeObj.put("pageType","add");
noticeObj.put("receiveOrgCode", !ObjectUtils.isEmpty(basicObj.get("receiveOrgCreditCode")) ? String.valueOf(basicObj.get("receiveOrgCreditCode")) : String.valueOf(basicObj.get("receiveOrgCreditCode1")));
JSONObject jsonObject = new JSONObject(noticeObj);
jgMaintenanceContractServiceImpl.saveOrSubmit(submitType, jsonObject, reginParams);
......
......@@ -8,13 +8,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.enums.WorkFlowEnum;
import com.yeejoin.amos.boot.biz.common.service.IDataDictionaryService;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
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.JgMaintainNoticeDto;
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.JgMaintainNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintainNoticeEq;
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.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgMaintainNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgMaintainNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintainNoticeService;
......@@ -27,11 +34,9 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
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 jdk.nashorn.api.scripting.JSObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -90,6 +95,12 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
@Autowired
private TzBaseUnitLicenceMapper baseUnitLicenceMapper;
@Autowired
private CommonServiceImpl commonService;
@Autowired
private CmWorkflowServiceImpl cmWorkflowService;
/**
* 根据sequenceNbr查询
......@@ -122,17 +133,18 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
String[] fields = {"productPhoto", "designDoc", "designStandard", "factoryStandard", "productQualityYieldProve",
"insUseMaintainExplain", "inspectReport", "proxyStatementAttachment", "installContractAttachment"};
// 设备信息 "equCategory", "equDefine", "equRegisterCode", "produceCountry", "produceLicenseNum",
List<Map<String, Object>> equipmentInfos = jgMaintainNoticeMapper.queryEquipInformation(sequenceNbr);
JgMaintainNoticeEq jgMaintainNoticeEq = jgMaintainNoticeEqMapper.selectOne(new LambdaQueryWrapper<JgMaintainNoticeEq>().eq(JgMaintainNoticeEq::getEquipTransferId, sequenceNbr));
Map<String, Object> map = jgMaintainNoticeMapper.getEquipInfoByRecord(jgMaintainNoticeEq.getEquId());
for (String s : fields) {
if (maintainInfo.containsKey(s))
if (maintainInfo.containsKey(s) && !ObjectUtils.isEmpty(map.get(s)))
maintainInfo.put(s, JSON.parseArray(maintainInfo.get(s).toString()));
if (equipmentInfos.get(0).containsKey(s))
equipmentInfos.get(0).put(s, JSON.parseArray(equipmentInfos.get(0).get(s).toString()));
if (map.containsKey(s) && !ObjectUtils.isEmpty(map.get(s)))
map.put(s, JSON.parseArray(map.get(s).toString()));
}
return new HashMap<String, Map<String, Object>>() {{
put(TABLE_PAGE_ID, maintainInfo);
put("equipmentInfo", equipmentInfos.get(0));
}};
maintainInfo.putAll(map);
return new HashMap<String, Map<String, Object>>() {{put(TABLE_PAGE_ID, maintainInfo);}};
}
/**
......@@ -145,48 +157,92 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
public JgMaintainNoticeDto updateMaintainNotice(String submitType, JgMaintainNoticeDto noticeDto, String op) {
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<>();
JgMaintainNotice notice = jgMaintainNoticeMapper.selectById(noticeDto.getSequenceNbr());
// submitType=1为流程提交否则仅为保存业务数据
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
AjaxResult ajaxResult;
// 发起流程
if (!StringUtils.hasText(noticeDto.getInstanceId())) {
ProcessTaskDTO processTaskDTO = new ProcessTaskDTO();
WorkflowResultDto workflowResultDto = new WorkflowResultDto();
// 如果没有实例ID,说明是启动并执行一步
// 直接调用工作流 启动并执行API - 可以拿到两个节点的信息,用于填充业务字段
// 如果有实例ID,为撤回或者驳回后重新提交
if(!StringUtils.hasText(noticeDto.getInstanceId())){
// 发起流程
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey("maintainNotice");
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("JgMaintainNoticeServiceImpl.updateMaintainNotice启动失败:{}", e);
throw new RuntimeException(e);
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(noticeDto.getSequenceNbr().toString());
dto.setCompleteFirstTask(Boolean.TRUE);
list.add(dto);
actWorkflowBatchDTO.setProcess(list);
processTaskDTO = cmWorkflowService.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());
}
}
JgMaintainNotice notice = new JgMaintainNotice();
BeanUtils.copyProperties(noticeDto, notice);
op = "已提交";
boolean submit = submit(notice, op, null);
if (submit) {
// 查询下节点任务
getNext(roleListSecond, notice.getInstanceId(), taskName);
notice.setStatus(taskName[0]);
notice.setPromoter(RequestContext.getExeUserId());
notice.setNextExecuteIds(String.join(",", workflowResultDto.getNextExecutorRoleIds()));
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
jgMaintainNoticeMapper.updateById(notice);
// 如果为保存并提交,则创建代办
buildTask(Collections.singletonList(notice), Collections.singletonList(workflowResultDto));
} else {
// 只调用执行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);
}
dto.setVariable(commMap);
processTaskDTO = cmWorkflowService.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()));
updateById(notice);
notice.setNextTaskId(workflowResultDto.getNextTaskId());
jgMaintainNoticeMapper.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("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));
}
}
} else {
JgMaintainNotice bean = new JgMaintainNotice();
......@@ -332,8 +388,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
@SuppressWarnings({"Duplicates", "rawtypes"})
@Transactional(rollbackFor = Exception.class)
public void saveNotice(String submitType, Map<String, Object> jgMaintainNoticeDtoMap, ReginParams reginParams) {
String[] taskName = new String[]{"流程结束"};
JgMaintainNoticeDto model = JSON.parseObject(jgMaintainNoticeDtoMap.get(TABLE_PAGE_ID).toString(), JgMaintainNoticeDto.class);
JgMaintainNoticeDto model = JSON.parseObject(JSONObject.toJSONString(jgMaintainNoticeDtoMap.get(TABLE_PAGE_ID)), JgMaintainNoticeDto.class);
// 字段转换
convertField(model);
......@@ -344,73 +400,16 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
throw new RuntimeException();
}
// 获取告知单号
// List<String> applyNoList = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.WXGZ.getCode(), deviceList.size());
ResponseModel<List<String>> applyNoResult = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.GZBG.getCode(), deviceList.size());
ResponseModel<List<String>> applyNoResult = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.WXGZ.getCode(), deviceList.size());
if (CollectionUtils.isEmpty(applyNoResult.getResult())) {
log.error(" 获取告知单号失败");
throw new RuntimeException();
}
List<String> applyNoList = applyNoResult.getResult();
ArrayList<String> roleListFirst = new ArrayList<>();
ArrayList<String> roleListSecond = new ArrayList<>();
// 判断当前是否为提交
List<String> instanceIdList = new ArrayList<>();
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程
// ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
for (int i = 0; i < deviceList.size(); i++
) {
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(String.valueOf(i));
// dto.setCompleteFirstTask(true);
list.add(dto);
}
actWorkflowBatchDTO.setProcess(list);
try {
FeignClientResult result = Workflow.taskV2Client.startByVariableBatch(actWorkflowBatchDTO);
List<Object> returnList = (List<Object>) result.getResult();
for (Object obj : returnList
) {
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(obj));
String instanceId = jsonObject.getString("id");
instanceIdList.add(instanceId);
// 查询下节点任务
if (returnList.get(0).equals(obj)) {
getNext(roleListFirst, instanceId, taskName);
}
// 推动下一个节点
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
// 组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
// dto.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", "0");
dto.setVariable(map);
// 执行流程
AjaxResult ajaxResult1 = null;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto);
if (ajaxResult1.get("code").equals(200)) {
getNext(roleListSecond, instanceId, taskName);
} else {
log.error("提交失败");
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
List<WorkflowResultDto> workflowResultDtoList = workFlowInfo(submitType, deviceList);
List<JgMaintainNotice> list = new ArrayList<>();
List<JgMaintainNoticeEq> equipList = new ArrayList<>();
deviceList.forEach(obj -> {
......@@ -423,27 +422,35 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
dto.setNoticeDate(new Date());
dto.setEquCategory(String.valueOf(obj.get("EQU_CATEGORY")));
dto.setEquListCode(String.valueOf(obj.get("EQU_LIST_CODE")));
dto.setCreateUserCompanyName(reginParams.getCompany().getCompanyName());
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
dto.setNextExecuteIds(String.join(",", roleListSecond));
dto.setInstanceStatus(String.join(",", roleListFirst));
dto.setNextExecuteIds(workflowResultDtoList.get(i).getNextExecutorRoleIds());
dto.setInstanceStatus(workflowResultDtoList.get(i).getNextExecutorRoleIds() + "," + workflowResultDtoList.get(i).getExecutorRoleIds());
dto.setPromoter(reginParams.getUserModel().getUserId());
dto.setStatus(taskName[0]);
}
dto.setEquListName(obj.get("EQU_LIST").toString());
dto.setSupervisoryCode(obj.get("SUPERVISORY_CODE").toString());
dto.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setNextTaskId(workflowResultDtoList.get(i).getNextTaskId());
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipTransferId(applyNo);
if (!CollectionUtils.isEmpty(instanceIdList)) {
dto.setInstanceId(instanceIdList.get(i));
if (!CollectionUtils.isEmpty(workflowResultDtoList)) {
dto.setInstanceId(workflowResultDtoList.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);
});
jgMaintainNoticeMapper.insertBatchSomeColumn(list);
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
buildTask(list, workflowResultDtoList);
}
List<JgMaintainNoticeEq> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> {
List<JgMaintainNotice> collect = list.stream().filter(JgMaintainNotice -> jgRelationEquip.getEquipTransferId().equals(JgMaintainNotice.getApplyNo())).collect(Collectors.toList());
Long sequenceNbr = collect.get(0).getSequenceNbr();
......@@ -452,6 +459,66 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
jgMaintainNoticeEqMapper.insertBatchSomeColumn(jgRelationEquipList);
}
/**
* 插入代办
*/
private void buildTask(List<JgMaintainNotice> 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_MAINTENANCE_NOTIFICATION.getCode());
taskModelDto.setTaskTypeLabel(BusinessTypeEnum.JG_MAINTENANCE_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.getEquListName(), item.getSupervisoryCode(), item.getApplyNo()));
taskModelDtoList.add(taskModelDto);
});
commonService.buildTaskModel(taskModelDtoList);
}
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.get("SEQUENCE_NBR").toString());
dto.setCompleteFirstTask(Boolean.TRUE);
list.add(dto);
});
actWorkflowBatchDTO.setProcess(list);
try {
List<ProcessTaskDTO> processTaskDTOS = cmWorkflowService.startBatch(actWorkflowBatchDTO);
return commonService.buildWorkFlowInfo(processTaskDTOS);
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
return new ArrayList<>();
}
void getNext(ArrayList<String> roleListFirst, String instanceId, String[] taskName) {
AjaxResult aj = Workflow.taskClient.getTaskNoAuth(instanceId);
JSONObject taskNoAuth = JSON.parseObject(JSON.toJSONString(aj.get("data")));
......@@ -580,24 +647,26 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
}
public void cancel(JgMaintainNoticeDto noticeDto) {
String[] taskName = new String[]{"流程结束"};
FeignClientResult ajaxResult = Workflow.taskV2Client.rollBack(noticeDto.getInstanceId());
JgMaintainNotice jgInstallationNotice = this.baseMapper.selectById(noticeDto.getSequenceNbr());
ArrayList<String> roleList = new ArrayList<>();
if (ajaxResult.getStatus() == 200) {
getNext(roleList, noticeDto.getInstanceId(), taskName);
jgInstallationNotice.setStatus(taskName[0]);
jgInstallationNotice.setPromoter("");
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.ROLLBACK.getCode()));
updateById(jgInstallationNotice);
}
JgMaintainNotice jgMaintainNotice = this.baseMapper.selectById(noticeDto.getSequenceNbr());
ProcessTaskDTO processTaskDTO = cmWorkflowService.rollBack(jgMaintainNotice.getInstanceId());
// 提取节点等信息
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
jgMaintainNotice.setPromoter("");
jgMaintainNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.ROLLBACK.getCode()));
updateById(jgMaintainNotice);
// 删除待办
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jgMaintainNotice));
jsonObject.put("nextTaskId", jgMaintainNotice.getNextTaskId());
jsonObject.put("nextExecuteUser", jgMaintainNotice.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode());
commonService.rollbackTask(jgMaintainNotice.getInstanceId(), jsonObject);
}
@Transactional
public void accept(JgMaintainNoticeDto dto, String op, String opinion) {
String[] taskName = new String[]{"流程结束"};
String userId = RequestContext.getExeUserId();
JgMaintainNotice jgMaintainNotice = this.jgMaintainNoticeMapper.selectById(dto.getSequenceNbr());
// 组装设备注册代码
StringBuffer stringBuffer = new StringBuffer();
......@@ -607,43 +676,103 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
} catch (ParseException e) {
log.error("日期转换失败:{}", e);
}
ArrayList<String> roleList = new ArrayList<>();
boolean submit = submit(jgMaintainNotice, op, opinion);
if (submit) {
getNext(roleList, dto.getInstanceId(), taskName);
jgMaintainNotice.setStatus(taskName[0]);
if ("0".equals(op)) {
if (roleList.size() == 0) {
LambdaQueryWrapper<JgMaintainNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgMaintainNoticeEq::getEquipTransferId, dto.getSequenceNbr());
JgMaintainNoticeEq jgRelationEquip = jgMaintainNoticeEqMapper.selectOne(queryWrapper);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord, jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgMaintainNotice.getCity()).append(ym);
Map<String, Object> map = new HashMap<>();
map.put("cityCode", jgMaintainNotice.getCity());
map.put("countyCode", jgMaintainNotice.getCounty());
map.put("equCategory", tzsJgRegistrationInfo.getEquCategory());
jgMaintainNotice.setAcceptDate(new Date());
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
generateMaintainNoticeReport(jgMaintainNotice.getSequenceNbr());
jgMaintainNotice.setPromoter("");
//组装信息
TaskResultDTO taskResultDTO = assembleData(jgMaintainNotice, op, opinion);
ProcessTaskDTO processTaskDTO = cmWorkflowService.complete(jgMaintainNotice.getNextTaskId(), taskResultDTO);
// 提取节点等信息
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
TaskV2Model taskV2Model = new TaskV2Model();
if ("0".equals(op)) {
// 判断如果下一步执行角色列表为空则流程完成
if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) {
LambdaQueryWrapper<JgMaintainNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgMaintainNoticeEq::getEquipTransferId, dto.getSequenceNbr());
JgMaintainNoticeEq jgRelationEquip = jgMaintainNoticeEqMapper.selectOne(queryWrapper);
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord, jgRelationEquip.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
stringBuffer.append(tzsJgRegistrationInfo.getEquCategory()).append(jgMaintainNotice.getCity()).append(ym);
jgMaintainNotice.setAcceptDate(new Date());
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
generateMaintainNoticeReport(jgMaintainNotice.getSequenceNbr());
jgMaintainNotice.setPromoter("");
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
this.generateMaintainNoticeReport(jgMaintainNotice.getSequenceNbr());
// 上个代办改为已办
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", jgMaintainNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
commonService.updateTaskModel(taskMap);
} else {
jgMaintainNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
if (!ObjectUtils.isEmpty(jgMaintainNotice.getInstanceStatus())) {
jgMaintainNotice.setInstanceStatus(jgMaintainNotice.getInstanceStatus() + "," + workflowResultDto.getNextExecutorRoleIds());
} else {
jgMaintainNotice.setNextExecuteIds(String.join(",", roleList));
if (!ObjectUtils.isEmpty(jgMaintainNotice.getInstanceStatus())) {
jgMaintainNotice.setInstanceStatus(jgMaintainNotice.getInstanceStatus() + "," + String.join(",", roleList));
} else {
jgMaintainNotice.setInstanceStatus(String.join(",", roleList));
}
jgMaintainNotice.setPromoter(userId);
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
jgMaintainNotice.setInstanceStatus(workflowResultDto.getNextExecutorRoleIds());
}
} else {
jgMaintainNotice.setPromoter("");
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
jgMaintainNotice.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", jgMaintainNotice.getInstanceId());
taskV2Model = commonService.updateTaskModel(taskMap);
TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto);
// 创建新的代办
taskModelDto.setModel(jgMaintainNotice);
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));
}
jgMaintainNoticeMapper.updateById(jgMaintainNotice);
} else {
jgMaintainNotice.setPromoter("");
jgMaintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.REJECTED.getCode()));
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", jgMaintainNotice.getNoticeStatus());
taskMap.put("taskStatusLabel", FlowStatusEnum.REJECTED.getName());
taskMap.put("relationId", jgMaintainNotice.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(jgMaintainNotice);
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));
}
jgMaintainNotice.setNextTaskId(workflowResultDto.getNextTaskId());
jgMaintainNoticeMapper.updateById(jgMaintainNotice);
}
private TaskResultDTO assembleData(JgMaintainNotice jgMaintainNotice, String op, String opinion) {
TaskResultDTO taskResultDTO = new TaskResultDTO();
taskResultDTO.setResultCode("approvalStatus");
taskResultDTO.setTaskId(jgMaintainNotice.getNextTaskId());
if (!StringUtils.isEmpty(opinion)) {
taskResultDTO.setComment(opinion);
}
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", op);
taskResultDTO.setVariable(map);
return taskResultDTO;
}
}
\ 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