Commit 4878f8e6 authored by 韩桐桐's avatar 韩桐桐

feat(jg):维修告知作废

parent 20e21464
...@@ -233,4 +233,13 @@ public class JgMaintainNoticeDto extends BaseDto { ...@@ -233,4 +233,13 @@ public class JgMaintainNoticeDto extends BaseDto {
@ApiModelProperty("工程装置") @ApiModelProperty("工程装置")
private String projectContraption; private String projectContraption;
@ApiModelProperty("作废原因")
private String cancelReason;
@ApiModelProperty("作废日期")
private Date cancelDate;
@ApiModelProperty("作废人员id")
private String cancelUserId;
} }
...@@ -8,6 +8,8 @@ import lombok.EqualsAndHashCode; ...@@ -8,6 +8,8 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* 维修告知 * 维修告知
...@@ -366,4 +368,28 @@ public class JgMaintainNotice extends BaseEntity { ...@@ -366,4 +368,28 @@ public class JgMaintainNotice extends BaseEntity {
*/ */
@TableField("project_contraption") @TableField("project_contraption")
private String projectContraption; private String projectContraption;
/**
* 告知设备列表
*/
@TableField(exist = false)
private List<Map<String, Object>> deviceList;
/**
* 作废原因
*/
@TableField("cancel_reason")
private String cancelReason;
/**
* 作废日期
*/
@TableField("cancel_date")
private Date cancelDate;
/**
* 作废人员id
*/
@TableField("cancel_user_id")
private String cancelUserId;
} }
...@@ -61,4 +61,12 @@ public interface IJgMaintainNoticeService extends IService<JgMaintainNotice> { ...@@ -61,4 +61,12 @@ public interface IJgMaintainNoticeService extends IService<JgMaintainNotice> {
void generateMaintainNoticeReport(Long sequenceNbr,HttpServletResponse response); void generateMaintainNoticeReport(Long sequenceNbr,HttpServletResponse response);
boolean deleteBySequenceNbr(Long[] sequenceNbr); boolean deleteBySequenceNbr(Long[] sequenceNbr);
/**
* 作废申请
* @param sequenceNbr 业务唯一标识
* @param cancelReason 作废原因
* @return JgInstallationNoticeDto
*/
JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason, Map<String, Object> model);
} }
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
isn.create_user_company_name AS createUserCompanyName, isn.create_user_company_name AS createUserCompanyName,
isn.next_execute_user_ids AS nextExecuteUserIds, isn.next_execute_user_ids AS nextExecuteUserIds,
isn.transfer_to_user_ids AS transferToUserIds, isn.transfer_to_user_ids AS transferToUserIds,
isn.cancel_reason AS cancelReason,
(SELECT name from tz_equipment_category ec WHERE ec.code = isn.equ_list_code) AS equListName, (SELECT name from tz_equipment_category ec WHERE ec.code = isn.equ_list_code) AS equListName,
DATE_FORMAT(isn.create_date,'%Y-%m-%d') AS createDate, DATE_FORMAT(isn.create_date,'%Y-%m-%d') AS createDate,
(select name from tz_equipment_category ec WHERE ec.code = isn.equ_category) AS equCategoryName (select name from tz_equipment_category ec WHERE ec.code = isn.equ_category) AS equCategoryName
......
...@@ -144,4 +144,12 @@ public class JgMaintainNoticeController extends BaseController { ...@@ -144,4 +144,12 @@ public class JgMaintainNoticeController extends BaseController {
public void generateReport(HttpServletResponse response, @RequestParam("sequenceNbr") Long sequenceNbr) { public void generateReport(HttpServletResponse response, @RequestParam("sequenceNbr") Long sequenceNbr) {
iJgMaintainNoticeService.generateMaintainNoticeReport(sequenceNbr,response); iJgMaintainNoticeService.generateMaintainNoticeReport(sequenceNbr,response);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "维修告知单个作废", notes = "维修告知单个作废")
@PutMapping(value = "/cancel/application")
public ResponseModel<JgMaintainNotice> cancelApplication(@RequestBody Map<String, Object> model) {
JgMaintainNotice result = iJgMaintainNoticeService.cancelApplication(Long.parseLong((String) model.get("sequenceNbr")), (String) model.get("cancelReason"), model);
return ResponseHelper.buildResponse(result);
}
} }
...@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; 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.entity.DataDictionary;
...@@ -30,7 +29,10 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; ...@@ -30,7 +29,10 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest; import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext; import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; 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.IIdxBizJgRegisterInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgRegisterInfoService;
import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils; import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo;
...@@ -48,6 +50,8 @@ import org.springframework.beans.BeanUtils; ...@@ -48,6 +50,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -78,6 +82,12 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -78,6 +82,12 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
private final List<String> NOT_FLOWING_STATE = Arrays.asList("6610", "6614", "6615", "6617", "6616"); private final List<String> NOT_FLOWING_STATE = Arrays.asList("6610", "6614", "6615", "6617", "6616");
@Autowired @Autowired
EventPublisher eventPublisher;
@Autowired
private ICmWorkflowService iCmWorkflowService;
@Autowired
IJgInstallationNoticeService iJgInstallationNoticeService; IJgInstallationNoticeService iJgInstallationNoticeService;
@Autowired @Autowired
...@@ -182,11 +192,12 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -182,11 +192,12 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
if (!ValidationUtil.isEmpty(notice.getStreet()) && !ValidationUtil.isEmpty(notice.getStreetName())) { if (!ValidationUtil.isEmpty(notice.getStreet()) && !ValidationUtil.isEmpty(notice.getStreetName())) {
maintainInfo.put("street", notice.getStreet() + "_" + notice.getStreetName()); maintainInfo.put("street", notice.getStreet() + "_" + notice.getStreetName());
} }
if (Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_FINISHED.getCode()) { if ((Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_FINISHED.getCode()) ||
// 完成时显示历史数据 (Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_DISCARD.getCode())) {
// 完成 或者 作废时显示历史数据
JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr()); JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr());
// 兼容老数据 // 兼容老数据
if (hisData == null) { if (hisData == null || ObjectUtils.isEmpty(hisData.get("deviceList"))) {
// 老数据逻辑 // 老数据逻辑
setNewEquipInfo(sequenceNbr, maintainInfo); setNewEquipInfo(sequenceNbr, maintainInfo);
return new HashMap<String, Map<String, Object>>() {{ return new HashMap<String, Map<String, Object>>() {{
...@@ -196,8 +207,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -196,8 +207,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
// 新数据逻辑 // 新数据逻辑
hisData.putAll(maintainInfo); hisData.putAll(maintainInfo);
CommonServiceImpl.formatTime2StrDateForEquip(hisData); CommonServiceImpl.formatTime2StrDateForEquip(hisData);
setNewEquipInfo(sequenceNbr, maintainInfo); // setNewEquipInfo(sequenceNbr, maintainInfo);
hisData.put("deviceList", maintainInfo.get("deviceList")); // hisData.put("deviceList", maintainInfo.get("deviceList"));
return new HashMap<String, Map<String, Object>>() {{ return new HashMap<String, Map<String, Object>>() {{
this.put(TABLE_PAGE_ID, hisData); this.put(TABLE_PAGE_ID, hisData);
}}; }};
...@@ -343,7 +354,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -343,7 +354,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
notice.setEquList(String.valueOf(deviceList.get(0).get("EQU_LIST"))); notice.setEquList(String.valueOf(deviceList.get(0).get("EQU_LIST")));
jgMaintainNoticeMapper.updateById(notice); jgMaintainNoticeMapper.updateById(notice);
// 如果为保存并提交,则创建代办 // 如果为保存并提交,则创建代办
buildTask(Collections.singletonList(notice), Collections.singletonList(workflowResultDto), Boolean.TRUE); buildTask(notice, Collections.singletonList(workflowResultDto), Boolean.TRUE);
} else { } else {
// 只调用执行API,返回下个节点信息,用于填充业务字段 // 只调用执行API,返回下个节点信息,用于填充业务字段
//组装信息 //组装信息
...@@ -385,7 +396,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -385,7 +396,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
TaskV2Model taskV2Model = commonService.updateTaskModel(map); TaskV2Model taskV2Model = commonService.updateTaskModel(map);
if (ObjectUtils.isEmpty(taskV2Model)) { if (ObjectUtils.isEmpty(taskV2Model)) {
// 如果为保存并提交,则创建代办 // 如果为保存并提交,则创建代办
buildTask(Collections.singletonList(notice), Collections.singletonList(workflowResultDto), Boolean.FALSE); buildTask(notice, Collections.singletonList(workflowResultDto), Boolean.FALSE);
} else { } else {
TaskModelDto taskModelDto = new TaskModelDto(); TaskModelDto taskModelDto = new TaskModelDto();
BeanUtils.copyProperties(taskV2Model, taskModelDto); BeanUtils.copyProperties(taskV2Model, taskModelDto);
...@@ -422,6 +433,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -422,6 +433,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
equipList.add(jgRelationEquip); equipList.add(jgRelationEquip);
}); });
jgMaintainNoticeEqMapper.insertBatchSomeColumn(equipList); jgMaintainNoticeEqMapper.insertBatchSomeColumn(equipList);
// 更新历史表
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName(), JSON.parseObject(JSON.toJSONString(notice)), "", notice.getSequenceNbr().toString());
return noticeDto; return noticeDto;
} catch (BadRequest | LocalBadRequest e) { } catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -555,45 +568,43 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -555,45 +568,43 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
throw new RuntimeException(); throw new RuntimeException();
} }
String applyNo = applyNoResult.getResult().get(0); String applyNo = applyNoResult.getResult().get(0);
List<WorkflowResultDto> workflowResultDtoList = workFlowInfo(submitType, deviceList, model.getReceiveCompanyCode()); List<WorkflowResultDto> workflowResultDtoList = workFlowInfo(submitType, model.getReceiveCompanyCode());
List<JgMaintainNotice> list = new ArrayList<>();
List<JgMaintainNoticeEq> equipList = new ArrayList<>(); List<JgMaintainNoticeEq> equipList = new ArrayList<>();
CompanyBo companyBo = commonService.getOneCompany(model.getReceiveCompanyCode()); CompanyBo companyBo = commonService.getOneCompany(model.getReceiveCompanyCode());
// 维修告知表添加数据 // 维修告知表添加数据
JgMaintainNotice dto = new JgMaintainNotice(); JgMaintainNotice notice = new JgMaintainNotice();
BeanUtils.copyProperties(model, dto); BeanUtils.copyProperties(model, notice);
dto.setApplyNo(applyNo); notice.setApplyNo(applyNo);
// 统计使用 // 统计使用
dto.setReceiveCompanyOrgCode(companyBo.getOrgCode()); notice.setReceiveCompanyOrgCode(companyBo.getOrgCode());
dto.setNoticeDate(new Date()); notice.setNoticeDate(new Date());
dto.setEquListCode(model.getEquListCode()); notice.setEquListCode(model.getEquListCode());
dto.setCreateUserCompanyName(reginParams.getCompany().getCompanyName()); notice.setCreateUserCompanyName(reginParams.getCompany().getCompanyName());
if (SUBMIT_TYPE_FLOW.equals(submitType)) { if (SUBMIT_TYPE_FLOW.equals(submitType)) {
dto.setNextExecuteIds(workflowResultDtoList.get(0).getNextExecutorRoleIds()); notice.setNextExecuteIds(workflowResultDtoList.get(0).getNextExecutorRoleIds());
dto.setInstanceStatus(workflowResultDtoList.get(0).getNextExecutorRoleIds() + "," + workflowResultDtoList.get(0).getExecutorRoleIds()); notice.setInstanceStatus(workflowResultDtoList.get(0).getNextExecutorRoleIds() + "," + workflowResultDtoList.get(0).getExecutorRoleIds());
dto.setPromoter(reginParams.getUserModel().getUserId()); notice.setPromoter(reginParams.getUserModel().getUserId());
dto.setNextExecuteUserIds(workflowResultDtoList.get(0).getNextExecutorUserIds()); notice.setNextExecuteUserIds(workflowResultDtoList.get(0).getNextExecutorUserIds());
dto.setNextTaskId(workflowResultDtoList.get(0).getNextTaskId()); notice.setNextTaskId(workflowResultDtoList.get(0).getNextTaskId());
dto.setInstanceId(workflowResultDtoList.get(0).getInstanceId()); notice.setInstanceId(workflowResultDtoList.get(0).getInstanceId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode())); notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
} else { } else {
dto.setNextExecuteUserIds(reginParams.getUserModel().getUserId()); notice.setNextExecuteUserIds(reginParams.getUserModel().getUserId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode())); notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
} }
dto.setEquListCode(String.valueOf(deviceList.get(0).get("EQU_LIST_CODE"))); notice.setEquListCode(String.valueOf(deviceList.get(0).get("EQU_LIST_CODE")));
dto.setEquCategory(String.valueOf(deviceList.get(0).get("EQU_CATEGORY_CODE"))); notice.setEquCategory(String.valueOf(deviceList.get(0).get("EQU_CATEGORY_CODE")));
dto.setInstallUnitName(reginParams.getCompany().getCompanyName()); notice.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode()); notice.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setCreateUserName(reginParams.getUserModel().getRealName()); notice.setCreateUserName(reginParams.getUserModel().getRealName());
dto.setCreateUserId(reginParams.getUserModel().getUserId()); notice.setCreateUserId(reginParams.getUserModel().getUserId());
DataDictionary dictionary = iDataDictionaryService.getByCode(dto.getMaintainType(), "WXLX"); DataDictionary dictionary = iDataDictionaryService.getByCode(notice.getMaintainType(), "WXLX");
dto.setMaintainTypeDesc(dictionary.getName()); notice.setMaintainTypeDesc(dictionary.getName());
dto.setFullAddress(dto.getProvinceName() + dto.getCityName() + dto.getCountyName() + dto.getStreetName() + dto.getAddress()); notice.setFullAddress(notice.getProvinceName() + notice.getCityName() + notice.getCountyName() + notice.getStreetName() + notice.getAddress());
dto.setEquCategoryDesc(String.valueOf(deviceList.get(0).get("EQU_CATEGORY"))); notice.setEquCategoryDesc(String.valueOf(deviceList.get(0).get("EQU_CATEGORY")));
dto.setEquList(String.valueOf(deviceList.get(0).get("EQU_LIST"))); notice.setEquList(String.valueOf(deviceList.get(0).get("EQU_LIST")));
list.add(dto);
deviceList.forEach(obj -> { deviceList.forEach(obj -> {
JgMaintainNoticeEq jgRelationEquip = new JgMaintainNoticeEq(); JgMaintainNoticeEq jgRelationEquip = new JgMaintainNoticeEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR"))); jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
...@@ -603,21 +614,20 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -603,21 +614,20 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
jgRelationEquip.setEquCategoryCode(String.valueOf(obj.get("EQU_CATEGORY_CODE"))); jgRelationEquip.setEquCategoryCode(String.valueOf(obj.get("EQU_CATEGORY_CODE")));
equipList.add(jgRelationEquip); equipList.add(jgRelationEquip);
}); });
jgMaintainNoticeMapper.insertBatchSomeColumn(list); notice.setCreateDate(new Date());
jgMaintainNoticeMapper.insert(notice);
if (SUBMIT_TYPE_FLOW.equals(submitType)) { if (SUBMIT_TYPE_FLOW.equals(submitType)) {
buildTask(list, workflowResultDtoList, Boolean.TRUE); buildTask(notice, workflowResultDtoList, Boolean.TRUE);
} else { } else {
// 暂存任务 // 暂存任务
buildTaskDraft(list); buildTaskDraft(notice);
} }
List<JgMaintainNoticeEq> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> { List<JgMaintainNoticeEq> jgRelationEquipList = equipList.stream().map(jgRelationEquip -> jgRelationEquip.setEquipTransferId(String.valueOf(notice.getSequenceNbr()))).collect(Collectors.toList());
List<JgMaintainNotice> collect = list.stream().filter(JgMaintainNotice -> jgRelationEquip.getEquipTransferId().equals(JgMaintainNotice.getApplyNo())).collect(Collectors.toList());
Long sequenceNbr = collect.get(0).getSequenceNbr();
return jgRelationEquip.setEquipTransferId(String.valueOf(sequenceNbr));
}).collect(Collectors.toList());
jgMaintainNoticeEqMapper.insertBatchSomeColumn(jgRelationEquipList); jgMaintainNoticeEqMapper.insertBatchSomeColumn(jgRelationEquipList);
this.updateRedisBatch(list); this.updateRedisBatch(notice);
return list; // 写入历史表
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName(), JSON.parseObject(JSON.toJSONString(notice)), "", notice.getSequenceNbr().toString());
return Collections.singletonList(notice);
} catch (BadRequest | LocalBadRequest e) { } catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
this.rollBackForDelRedisData(); this.rollBackForDelRedisData();
...@@ -631,80 +641,80 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -631,80 +641,80 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
} }
} }
private void updateRedisBatch(List<JgMaintainNotice> jgMaintainNotices) { private void updateRedisBatch(JgMaintainNotice jgMaintainNotice) {
jgMaintainNotices.stream().filter(n -> StringUtil.isNotEmpty(n.getInstanceId())).forEach(jgMaintainNotice -> { if (!ObjectUtils.isEmpty(jgMaintainNotice.getInstanceId())){
commonService.saveExecuteFlowData2Redis(jgMaintainNotice.getInstanceId(), this.buildInstanceRuntimeData(jgMaintainNotice)); commonService.saveExecuteFlowData2Redis(jgMaintainNotice.getInstanceId(), this.buildInstanceRuntimeData(jgMaintainNotice));
}); }
} }
/** /**
* 暂存任务生成待办 * 暂存任务生成待办
* *
* @param list 业务信息 * @param maintainNotice 业务信息
*/ */
private void buildTaskDraft(List<JgMaintainNotice> list) { private void buildTaskDraft(JgMaintainNotice maintainNotice) {
List<TaskModelDto> modelDtos = new ArrayList<>(); List<TaskModelDto> modelDtos = new ArrayList<>();
list.forEach(obj -> {
TaskModelDto dto = new TaskModelDto(); TaskModelDto dto = new TaskModelDto();
//行数据 //行数据
TaskMessageDto taskMessageDto = new TaskMessageDto(); TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(obj, taskMessageDto); BeanUtils.copyProperties(maintainNotice, taskMessageDto);
taskMessageDto.setNextTaskId(obj.getNextTaskId()); taskMessageDto.setNextTaskId(maintainNotice.getNextTaskId());
dto.setModel(taskMessageDto); dto.setModel(taskMessageDto);
//摘要 按原有规则组装 //摘要 按原有规则组装
dto.setTaskContent(String.format("来自%s的业务办理,【申请单号%s】",obj.getEquList(), obj.getApplyNo())); dto.setTaskContent(String.format("来自%s的业务办理,【申请单号%s】",maintainNotice.getEquList(), maintainNotice.getApplyNo()));
//申请单号 //申请单号
dto.setTaskCode(obj.getApplyNo()); dto.setTaskCode(maintainNotice.getApplyNo());
//业务类型枚举code值 //业务类型枚举code值
dto.setTaskType(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode()); dto.setTaskType(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode());
////业务主键 ////业务主键
dto.setRelationId(obj.getSequenceNbr() + ""); dto.setRelationId(maintainNotice.getSequenceNbr() + "");
modelDtos.add(dto); modelDtos.add(dto);
});
commonService.buildTaskModel(modelDtos); commonService.buildTaskModel(modelDtos);
} }
/** /**
* 插入代办 * 插入代办
*/ */
private void buildTask(List<JgMaintainNotice> list, List<WorkflowResultDto> workflowResultList, Boolean bool) { private void buildTask(JgMaintainNotice dto, List<WorkflowResultDto> workflowResultList, Boolean bool) {
List<TaskModelDto> taskModelDtoList = new ArrayList<>(); List<TaskModelDto> taskModelDtoList = new ArrayList<>();
WorkflowResultDto workflowResultDto = workflowResultList.get(0); WorkflowResultDto workflowResultDto = workflowResultList.get(0);
list.forEach(item -> {
TaskModelDto taskModelDto = new TaskModelDto(); TaskModelDto taskModelDto = new TaskModelDto();
taskModelDto.setFlowCreateDate(item.getCreateDate()); taskModelDto.setFlowCreateDate(dto.getCreateDate());
taskModelDto.setTaskName(workflowResultDto.getNextTaskName()); // 工作流API返回 taskModelDto.setTaskName(workflowResultDto.getNextTaskName()); // 工作流API返回
taskModelDto.setTaskCode(item.getApplyNo()); taskModelDto.setTaskCode(dto.getApplyNo());
taskModelDto.setTaskType(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode()); taskModelDto.setTaskType(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getCode());
taskModelDto.setTaskTypeLabel(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName()); taskModelDto.setTaskTypeLabel(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName());
String instanceId = workflowResultList.stream().filter(e -> e.getInstanceId().equals(item.getInstanceId())).findFirst().orElse(null).getInstanceId(); String instanceId = workflowResultList.stream().filter(e -> e.getInstanceId().equals(dto.getInstanceId())).findFirst().orElse(null).getInstanceId();
taskModelDto.setRelationId(instanceId); taskModelDto.setRelationId(instanceId);
taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); // 工作流API返回 taskModelDto.setExecuteUserIds(workflowResultDto.getNextExecutorUserIds()); // 工作流API返回
taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName()); taskModelDto.setTaskStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowStatus(commonService.getDictionaryCodeByName(FlowStatusEnum.TO_BE_PROCESSED.getName())); // 流程状态枚举 taskModelDto.setFlowStatus(commonService.getDictionaryCodeByName(FlowStatusEnum.TO_BE_PROCESSED.getName())); // 流程状态枚举
taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName()); taskModelDto.setFlowStatusLabel(FlowStatusEnum.TO_BE_PROCESSED.getName());
taskModelDto.setFlowCode(item.getNextTaskId()); taskModelDto.setFlowCode(dto.getNextTaskId());
taskModelDto.setStartUserId(item.getCreateUserId()); taskModelDto.setStartUserId(dto.getCreateUserId());
taskModelDto.setStartUser(item.getCreateUserName()); taskModelDto.setStartUser(dto.getCreateUserName());
taskModelDto.setStartUserCompanyName(item.getCreateUserCompanyName()); // 任务发起人所在单位 taskModelDto.setStartUserCompanyName(dto.getCreateUserCompanyName()); // 任务发起人所在单位
taskModelDto.setStartDate(item.getCreateDate()); taskModelDto.setStartDate(dto.getCreateDate());
TaskMessageDto taskMessageDto = new TaskMessageDto(); TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(item, taskMessageDto); BeanUtils.copyProperties(dto, taskMessageDto);
taskMessageDto.setNextTaskId(item.getNextTaskId()); taskMessageDto.setNextTaskId(dto.getNextTaskId());
taskModelDto.setModel(taskMessageDto); taskModelDto.setModel(taskMessageDto);
taskModelDto.setNextExecuteUser(item.getNextExecuteIds()); taskModelDto.setNextExecuteUser(dto.getNextExecuteIds());
taskModelDto.setTaskContent(String.format("来自%s的业务办理,【申请单号:%s】",item.getEquList(), item.getApplyNo())); taskModelDto.setTaskContent(String.format("来自%s的业务办理,【申请单号:%s】",dto.getEquList(), dto.getApplyNo()));
taskModelDtoList.add(taskModelDto); taskModelDtoList.add(taskModelDto);
if (bool) { if (bool) {
// 删除暂存时生成的待办 // 删除暂存时生成的待办
commonService.deleteTasksByRelationId(item.getSequenceNbr() + ""); commonService.deleteTasksByRelationId(dto.getSequenceNbr() + "");
} }
});
commonService.buildTaskModel(taskModelDtoList); commonService.buildTaskModel(taskModelDtoList);
} }
private List<WorkflowResultDto> workFlowInfo(String submitType, List<Map<String, Object>> deviceList, String receiveCompanyCode) { private List<WorkflowResultDto> workFlowInfo(String submitType,String receiveCompanyCode) {
if (SUBMIT_TYPE_FLOW.equals(submitType)) { if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程 // 发起流程
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO(); ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
...@@ -919,7 +929,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -919,7 +929,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
// 提取节点等信息 // 提取节点等信息
WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0); WorkflowResultDto workflowResultDto = commonService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO)).get(0);
TaskV2Model taskV2Model = new TaskV2Model(); TaskV2Model taskV2Model;
if ("0".equals(op)) { if ("0".equals(op)) {
// 判断如果下一步执行角色列表为空则流程完成 // 判断如果下一步执行角色列表为空则流程完成
if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) { if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) {
...@@ -927,8 +937,6 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -927,8 +937,6 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
queryWrapper.eq(JgMaintainNoticeEq::getEquipTransferId, dto.getSequenceNbr()); queryWrapper.eq(JgMaintainNoticeEq::getEquipTransferId, dto.getSequenceNbr());
List<JgMaintainNoticeEq> jgRelationEquip = jgMaintainNoticeEqMapper.selectList(queryWrapper); List<JgMaintainNoticeEq> jgRelationEquip = jgMaintainNoticeEqMapper.selectList(queryWrapper);
for (JgMaintainNoticeEq jgMaintainNoticeEq : jgRelationEquip) { for (JgMaintainNoticeEq jgMaintainNoticeEq : jgRelationEquip) {
this.saveHisDataBeforeUpdate(jgMaintainNotice, jgMaintainNoticeEq.getEquId());
LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RegistrationInfo> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(RegistrationInfo::getRecord, jgMaintainNoticeEq.getEquId()); queryWrapper2.eq(RegistrationInfo::getRecord, jgMaintainNoticeEq.getEquId());
RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2); RegistrationInfo tzsJgRegistrationInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
...@@ -1082,12 +1090,6 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -1082,12 +1090,6 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
} }
} }
private void saveHisDataBeforeUpdate(JgMaintainNotice jgMaintainNotice, String equId) {
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId);
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName(), new JSONObject(map), null, jgMaintainNotice.getSequenceNbr().toString());
}
private TaskResultDTO assembleData(JgMaintainNotice jgMaintainNotice, String op, String opinion) { private TaskResultDTO assembleData(JgMaintainNotice jgMaintainNotice, String op, String opinion) {
TaskResultDTO taskResultDTO = new TaskResultDTO(); TaskResultDTO taskResultDTO = new TaskResultDTO();
taskResultDTO.setResultCode("approvalStatus"); taskResultDTO.setResultCode("approvalStatus");
...@@ -1101,4 +1103,71 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto ...@@ -1101,4 +1103,71 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
taskResultDTO.setVariable(map); taskResultDTO.setVariable(map);
return taskResultDTO; return taskResultDTO;
} }
@Override
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason, Map<String, Object> model) {
// 1.更新为已作废
JgMaintainNotice maintainNotice = this.getById(sequenceNbr);
String oldNoticeStatus = maintainNotice.getNoticeStatus();
maintainNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
maintainNotice.setCancelReason(cancelReason);
maintainNotice.setCancelDate(new Date());
maintainNotice.setCancelUserId(RequestContext.getExeUserId());
maintainNotice.setNextExecuteUserIds(null);
maintainNotice.setPromoter(null);
this.updateById(maintainNotice);
// 2.更新关联的业务
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), maintainNotice, model);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(maintainNotice)));
}
});
return maintainNotice;
}
private List<String> getEquList(JgMaintainNotice jgMaintainNotice) {
LambdaQueryWrapper<JgMaintainNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgMaintainNoticeEq::getEquipTransferId, jgMaintainNotice.getSequenceNbr());
List<JgMaintainNoticeEq> jgInstallationNoticeEqs = jgMaintainNoticeEqMapper.selectList(queryWrapper);
return jgInstallationNoticeEqs.stream().map(JgMaintainNoticeEq::getEquId).collect(Collectors.toList());
}
private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgMaintainNotice maintainNotice, Map<String, Object> model) {
switch (oldNoticeStatus) {
case TO_BE_SUBMITTED: // 待提交
// 1.删除暂存时生成的待办
commonService.deleteTasksByRelationId(maintainNotice.getSequenceNbr() + "");
break;
case TO_BE_FINISHED: // 已完成
// 1.清空redis 缓存的流程中及已完成安装告知的设备
this.delRepeatUseEquipData(maintainNotice);
break;
default:
// 流程中(驳回、撤回等)
// 1.待办任务更新为已完成
this.finishedTask(maintainNotice);
// 2.终止流程-工作流报错暂时注释掉
iCmWorkflowService.stopProcess(maintainNotice.getInstanceId(), maintainNotice.getCancelReason());
// 3.清空redis(缓存的流程中及已完成安装告知的设备)
this.delRepeatUseEquipData(maintainNotice);
}
}
private void finishedTask(JgMaintainNotice maintainNotice) {
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("relationId", maintainNotice.getInstanceId());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(maintainNotice, taskMessageDto);
taskMap.put("model", taskMessageDto);
commonService.updateTaskModel(taskMap);
}
} }
\ 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