Commit 68c6fed4 authored by 韩桐桐's avatar 韩桐桐

feat(jg):改造告知作废

parent 57c368c2
package com.yeejoin.amos.boot.module.jg.api.dto;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.jg.api.common.BizCustomDateSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -270,4 +268,14 @@ public class JgReformNoticeDto extends BaseDto {
*/
@ApiModelProperty (value = "工作流下一节点任务id")
private String nextTaskId;
@ApiModelProperty("作废原因")
private String cancelReason;
@ApiModelProperty("作废日期")
private Date cancelDate;
@ApiModelProperty("作废人员id")
private String cancelUserId;
}
......@@ -11,6 +11,7 @@ import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 改造告知
......@@ -382,4 +383,28 @@ public class JgReformNotice extends BaseEntity {
*/
@TableField("receive_company_org_code")
private String receiveCompanyOrgCode;
/**
* 告知设备列表
*/
@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;
}
......@@ -68,5 +68,5 @@ public interface IJgMaintainNoticeService extends IService<JgMaintainNotice> {
* @param cancelReason 作废原因
* @return JgInstallationNoticeDto
*/
JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason, Map<String, Object> model);
JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason);
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.JgReformNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNotice;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
......@@ -67,4 +68,12 @@ public interface IJgReformNoticeService extends IService<JgReformNotice> {
* @return pdf文件路径
*/
void generateInstallationNoticeReport(Long sequenceNbr,HttpServletResponse response);
/**
* 作废申请
* @param sequenceNbr 业务唯一标识
* @param cancelReason 作废原因
* @return JgInstallationNoticeDto
*/
JgReformNotice cancelApplication(Long sequenceNbr, String cancelReason);
}
......@@ -34,6 +34,7 @@
isn.instance_status AS instanceStatus,
isn.inform_number AS informNumber,
isn.next_task_id as nextTaskId,
isn.cancel_reason as cancelReason,
DATE_FORMAT(isn.plan_date,'%Y-%m-%d') AS planDate,
DATE_FORMAT(isn.notice_date,'%Y-%m-%d') AS noticeDate,
DATE_FORMAT(isn.accept_date,'%Y-%m-%d') AS acceptDate,
......@@ -84,7 +85,7 @@
</if>
</if>
<if test="type == 'supervision'">
AND (isn.notice_status in ('6612', '6613', '6614', '6616') )
AND (isn.notice_status in ('6612', '6613', '6614', '6616','6617') )
AND (isn.receive_org_code = #{orgCode} or isn.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
AND isn.instance_id <![CDATA[<>]]> ''
</if>
......
......@@ -241,7 +241,7 @@ public class CommonController extends BaseController {
}
private Map<String, Object> mapPointTypeToMap(FlowStatusEnum e) {
if (FlowStatusEnum.TO_SUBMITTED.getCode() == e.getCode() || FlowStatusEnum.TO_BE_DISCARD.getCode() == e.getCode()) {
if (FlowStatusEnum.TO_SUBMITTED.getCode() == e.getCode()) {
return null;
}
Map<String, Object> record = new HashMap<>();
......
......@@ -148,8 +148,8 @@ public class JgMaintainNoticeController extends BaseController {
@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);
public ResponseModel<JgMaintainNotice> cancelApplication(@RequestBody JgMaintainNoticeDto dto) {
JgMaintainNotice result = iJgMaintainNoticeService.cancelApplication(dto.getSequenceNbr(), dto.getCancelReason());
return ResponseHelper.buildResponse(result);
}
}
......@@ -146,4 +146,12 @@ public class JgReformNoticeController extends BaseController {
public void generateReport(HttpServletResponse response, @RequestParam("sequenceNbr") Long sequenceNbr) {
jgReformNoticeService.generateInstallationNoticeReport(sequenceNbr,response);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "改造告知单个作废", notes = "改造告知单个作废")
@PutMapping(value = "/cancel/application")
public ResponseModel<JgReformNotice> cancelApplication(@RequestBody JgReformNoticeDto dto) {
JgReformNotice result = jgReformNoticeService.cancelApplication(dto.getSequenceNbr(), dto.getCancelReason());
return ResponseHelper.buildResponse(result);
}
}
......@@ -434,6 +434,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
});
jgMaintainNoticeEqMapper.insertBatchSomeColumn(equipList);
// 更新历史表
notice.setDeviceList(deviceList);
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_NOTIFICATION.getName(), JSON.parseObject(JSON.toJSONString(notice)), "", notice.getSequenceNbr().toString());
return noticeDto;
} catch (BadRequest | LocalBadRequest e) {
......@@ -1108,7 +1109,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
@Override
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason, Map<String, Object> model) {
public JgMaintainNotice cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgMaintainNotice maintainNotice = this.getById(sequenceNbr);
String oldNoticeStatus = maintainNotice.getNoticeStatus();
......@@ -1120,7 +1121,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
maintainNotice.setPromoter(null);
this.updateById(maintainNotice);
// 2.更新关联的业务
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), maintainNotice, model);
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), maintainNotice);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
......@@ -1137,7 +1138,7 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
return jgInstallationNoticeEqs.stream().map(JgMaintainNoticeEq::getEquId).collect(Collectors.toList());
}
private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgMaintainNotice maintainNotice, Map<String, Object> model) {
private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgMaintainNotice maintainNotice) {
switch (oldNoticeStatus) {
case TO_BE_SUBMITTED: // 待提交
// 1.删除暂存时生成的待办
......
......@@ -17,7 +17,9 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgReformNoticeEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgReformNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgReformNoticeMapper;
......@@ -27,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.context.EquipUsedCheckStrategyContext;
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.service.ICmWorkflowService;
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.ymt.api.entity.EquipmentCategory;
......@@ -43,6 +48,7 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
......@@ -50,6 +56,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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.ObjectUtils;
import org.springframework.util.StringUtils;
......@@ -119,6 +127,10 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
private JgRegistrationHistoryMapper jgRegistrationHistoryMapper;
@Autowired
ESEquipmentCategory esEquipmentCategory;
@Autowired
private EventPublisher eventPublisher;
@Autowired
private ICmWorkflowService iCmWorkflowService;
/**
* 根据sequenceNbr查询
......@@ -141,8 +153,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
reformNoticeMap.put("street", notice.getStreet() + "_" + notice.getStreetName());
}
reformNoticeMap.put("constructionManagerId", notice.getConstructionManagerId() + "_" + notice.getConstructionManager());
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());
if (!ValidationUtil.isEmpty(hisData)) {
// 格式化基本通用信息的时间类型字段
......@@ -263,7 +275,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
notice.setNextTaskId(workflowResultDto.getNextTaskId());
notice.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
notice.setCreateDate(new Date());
updateById(notice);
// 上个代办改为已办
TaskV2Model taskV2Model = this.updateLastTodo(notice, FlowStatusEnum.TO_BE_PROCESSED);
......@@ -518,10 +530,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
private void checkRepeatUsed(String submitType, List<String> records, JgReformNotice jgReformNotice) {
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 流程中校验
records.forEach(record -> {
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
.equipRepeatUsedCheck(record, jgReformNotice.getInstallUnitCreditCode());
});
records.forEach(record -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
.equipRepeatUsedCheck(record, jgReformNotice.getInstallUnitCreditCode()));
}
}
......@@ -716,22 +726,6 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
model.setConstructionManager(constructionManagerIdList[1]);
}
}
// String inspectUnitId = model.getInspectUnitId();
// if (!ObjectUtils.isEmpty(inspectUnitId)) {
// String[] inspectUnitIdList = inspectUnitId.split("_");
// if (inspectUnitIdList.length > 1) {
// model.setInspectUnitId(inspectUnitIdList[0]);
// model.setInspectUnitName(inspectUnitIdList[1]);
// }
// }
}
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;
}
/**
......@@ -853,7 +847,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
jgReformNoticeEqMapper.updateById(noticeEq);
});
// 通过时记录历史数据
this.saveHisDataBeforeUpdate(jgReformNotice, jsonObject);
this.saveHisDataBeforeUpdate(String.valueOf(jgReformNotice.getSequenceNbr()), jsonObject);
jgReformNotice.setAcceptDate(new Date());
jgReformNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgReformNotice.setPromoter("");
......@@ -898,8 +892,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
}
private void saveHisDataBeforeUpdate(JgReformNotice jgReformNotice, JSONObject jsonObject) {
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MODIFICATION_NOTIFICATION.getName(), new JSONObject(jsonObject), null, String.valueOf(jgReformNotice.getSequenceNbr()));
private void saveHisDataBeforeUpdate(String sequenceNbr, JSONObject jsonObject) {
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MODIFICATION_NOTIFICATION.getName(), new JSONObject(jsonObject), null, sequenceNbr);
}
public InstanceRuntimeData buildInstanceRuntimeData(JgReformNotice jgReformNotice) {
......@@ -929,4 +923,87 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
TaskModelDto taskModelDto = TaskModelDto.builder().flowCreateDate(taskV2Model.getFlowCreateDate()).taskName(workflowResultDto.getNextTaskName()).taskCode(taskV2Model.getTaskCode()).taskType(taskV2Model.getTaskType()).taskTypeLabel(taskV2Model.getTaskTypeLabel()).relationId(taskV2Model.getRelationId()).executeUserIds(workflowResultDto.getNextExecutorUserIds()).taskStatusLabel(statusEnum.getName()).flowStatus(statusEnum.getCode()).flowCode(workflowResultDto.getNextTaskId()).flowStatusLabel(statusEnum.getName()).taskContent(String.format("来自%s的业务办理,【申请单号:%s】", transfer.getEquListName(), transfer.getApplyNo())).taskDesc(String.format("来自%s的业务办理,【申请单号%s】", transfer.getEquList(), transfer.getApplyNo())).startUserCompanyName(transfer.getCreateUserCompanyName()).startUserId(taskV2Model.getStartUserId()).startUser(taskV2Model.getStartUser()).startDate(taskV2Model.getStartDate()).model(taskMessageDto).pageType(statusEnum.getCode() == 6614 ? "edit" : "look").nextExecuteUser(workflowResultDto.getNextExecutorRoleIds()).build();
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
}
@Override
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JgReformNotice cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgReformNotice reformNotice = this.getById(sequenceNbr);
String oldNoticeStatus = reformNotice.getNoticeStatus();
reformNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
reformNotice.setCancelReason(cancelReason);
reformNotice.setCancelDate(new Date());
reformNotice.setCancelUserId(RequestContext.getExeUserId());
reformNotice.setNextExecuteUserIds(null);
reformNotice.setPromoter(null);
this.updateById(reformNotice);
// 2.更新关联的业务
this.processElseDataByStatus(Objects.requireNonNull(FlowStatusEnum.getEumByCode(Integer.parseInt(oldNoticeStatus))), reformNotice);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
eventPublisher.publish(new CancellationEvent(this, getEquList(reformNotice)));
}
});
return reformNotice;
}
private List<String> getEquList(JgReformNotice reformNotice) {
LambdaQueryWrapper<JgReformNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgReformNoticeEq::getEquipTransferId, reformNotice.getSequenceNbr());
List<JgReformNoticeEq> reformNoticeEqs = jgReformNoticeEqMapper.selectList(queryWrapper);
return reformNoticeEqs.stream().map(JgReformNoticeEq::getEquId).collect(Collectors.toList());
}
private void processElseDataByStatus(FlowStatusEnum oldNoticeStatus, JgReformNotice reformNotice) {
switch (oldNoticeStatus) {
case TO_BE_SUBMITTED: // 待提交
// 1.删除暂存时生成的待办
commonService.deleteTasksByRelationId(reformNotice.getSequenceNbr() + "");
// 4.记录到历史表
this.recordHistoryWhenVoided(reformNotice);
break;
case TO_BE_FINISHED: // 已完成
// 1.清空redis 缓存的流程中及已完成安装告知的设备
this.delRepeatUseEquipData(reformNotice);
break;
default:
// 流程中(驳回、撤回等)
// 1.待办任务更新为已完成
this.finishedTask(reformNotice);
// 2.终止流程-工作流报错暂时注释掉
iCmWorkflowService.stopProcess(reformNotice.getInstanceId(), reformNotice.getCancelReason());
// 3.清空redis(缓存的流程中及已完成安装告知的设备)
this.delRepeatUseEquipData(reformNotice);
// 4.记录到历史表
this.recordHistoryWhenVoided(reformNotice);
}
}
private void finishedTask(JgReformNotice reformNotice) {
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", reformNotice.getInstanceId());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(reformNotice, taskMessageDto);
taskMap.put("model", taskMessageDto);
commonService.updateTaskModel(taskMap);
}
/**
* 作废时记录数据到历史表
* @param reformNotice
*/
private void recordHistoryWhenVoided(JgReformNotice reformNotice) {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(reformNotice));
List<String> equList = getEquList(reformNotice);
Iterable<ESEquipmentCategoryDto> esEquipmentCategoryDtos = esEquipmentCategory.findAllById(equList);
List<Map<String, Object>> deviceList = getEquipListMaps(esEquipmentCategoryDtos);
jsonObject.put("deviceList", deviceList);
this.saveHisDataBeforeUpdate(String.valueOf(reformNotice.getSequenceNbr()), jsonObject);
}
}
\ 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