Commit b4ca7700 authored by suhuiguang's avatar suhuiguang

1.使用登记单条作废

parent 16d23935
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil; import com.yeejoin.amos.component.feign.utils.FeignUtil;
...@@ -54,8 +55,8 @@ public class JgUseRegistrationController extends BaseController { ...@@ -54,8 +55,8 @@ public class JgUseRegistrationController extends BaseController {
String.valueOf(map.get("instanceId")), String.valueOf(map.get("instanceId")),
String.valueOf(map.get("operate")), String.valueOf(map.get("operate")),
String.valueOf(map.get("comment")), String.valueOf(map.get("comment")),
String.valueOf(map.getOrDefault("carNumber","")), String.valueOf(map.getOrDefault("carNumber", "")),
String.valueOf(map.getOrDefault("manageType","")), String.valueOf(map.getOrDefault("manageType", "")),
String.valueOf(map.get("nextTaskId"))); String.valueOf(map.get("nextTaskId")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
...@@ -66,7 +67,7 @@ public class JgUseRegistrationController extends BaseController { ...@@ -66,7 +67,7 @@ public class JgUseRegistrationController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回") @ApiOperation(httpMethod = "POST", value = "撤回", notes = "撤回")
public ResponseModel<Object> withdraw(@RequestBody JSONObject map) { public ResponseModel<Object> withdraw(@RequestBody JSONObject map) {
jgUseRegistrationServiceImpl.withdraw(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")), jgUseRegistrationServiceImpl.withdraw(String.valueOf(map.get("instanceId")), String.valueOf(map.get("nextTaskId")),
String.valueOf(map.getOrDefault("manageType",""))); String.valueOf(map.getOrDefault("manageType", "")));
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse("ok");
} }
...@@ -93,7 +94,7 @@ public class JgUseRegistrationController extends BaseController { ...@@ -93,7 +94,7 @@ public class JgUseRegistrationController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询") @ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/getList") @GetMapping(value = "/getList")
public ResponseModel<Page<Map<String, Object>>> getList(JgUseRegistrationDto dto, public ResponseModel<Page<Map<String, Object>>> getList(JgUseRegistrationDto dto,
@ApiParam(value = "排序字段",required = false) @RequestParam(value = "sort",required = false) String sort, @ApiParam(value = "排序字段", required = false) @RequestParam(value = "sort", required = false) String sort,
@RequestParam(value = "current") int current, @RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) { @RequestParam(value = "size") int size) {
Page<Map<String, Object>> page = new Page<>(current, size); Page<Map<String, Object>> page = new Page<>(current, size);
...@@ -105,8 +106,8 @@ public class JgUseRegistrationController extends BaseController { ...@@ -105,8 +106,8 @@ public class JgUseRegistrationController extends BaseController {
} else { } else {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION); dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
} }
Page<Map<String, Object>> list = jgUseRegistrationServiceImpl.getList(dto,sort, page, dto.getRoleIds()); Page<Map<String, Object>> list = jgUseRegistrationServiceImpl.getList(dto, sort, page, dto.getRoleIds());
list.getRecords().forEach(x-> x.put("companyType",info.getCompany().getCompanyType())); list.getRecords().forEach(x -> x.put("companyType", info.getCompany().getCompanyType()));
return ResponseHelper.buildResponse(list); return ResponseHelper.buildResponse(list);
} }
...@@ -219,4 +220,12 @@ public class JgUseRegistrationController extends BaseController { ...@@ -219,4 +220,12 @@ public class JgUseRegistrationController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "使用登记单条作废", notes = "使用登记单条作废")
@PutMapping(value = "/cancel/application")
public ResponseModel<JgUseRegistration> cancelApplication(@RequestBody JgUseRegistrationDto jgUseRegistration) {
JgUseRegistration result = jgUseRegistrationServiceImpl.cancelApplication(jgUseRegistration.getSequenceNbr(), jgUseRegistration.getCancelReason());
return ResponseHelper.buildResponse(result);
}
} }
...@@ -32,11 +32,13 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo; ...@@ -32,11 +32,13 @@ 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.dao.ESEquipmentCategory;
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.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil; import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService; import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.common.StringUtil; import com.yeejoin.amos.boot.module.ymt.api.common.StringUtil;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquCodeTypeEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquCodeTypeEnum;
...@@ -145,7 +147,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -145,7 +147,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired @Autowired
private JgUseRegistrationMapper jgUseRegistrationMapper; private JgUseRegistrationMapper jgUseRegistrationMapper;
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回"); @Autowired
private ESEquipmentCategory esEquipmentCategory;
private final List<String> NOT_FLOWING_STATE = Arrays.asList("使用单位待提交", "一级受理已驳回", "使用单位已撤回", "已作废");
/** /**
* @param auditPassDate 通过时间 * @param auditPassDate 通过时间
...@@ -1357,8 +1362,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1357,8 +1362,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
* @param record 设备唯一标识 * @param record 设备唯一标识
*/ */
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) { private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成时显示设备最新信息。前置需求:一个设备只能同时发起一个流程 // 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
if (!jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName())) { if (!(jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) || jgUseRegistration.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()))) {
// 基本信息 + 制造信息 // 基本信息 + 制造信息
Map<String, Object> detail = this.baseMapper.getDetail(record); Map<String, Object> detail = this.baseMapper.getDetail(record);
// 设计信息 // 设计信息
...@@ -1590,4 +1595,131 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1590,4 +1595,131 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
} }
} }
/**
* 使用登记单条作废
* @param sequenceNbr 唯一标识
* @param cancelReason 作废原因
* @return JgUseRegistration
*/
@Transactional(rollbackFor = Exception.class)
public JgUseRegistration cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgUseRegistration jgUseRegistration = this.getById(sequenceNbr);
String oldStatus = jgUseRegistration.getStatus();
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
jgUseRegistration.setCancelReason(cancelReason);
jgUseRegistration.setCancelDate(new Date());
jgUseRegistration.setCreateUserId(RequestContext.getExeUserId());
jgUseRegistration.setNextExecuteUserIds(null);
jgUseRegistration.setPromoter(null);
this.updateById(jgUseRegistration);
// 2.更新关联的业务
processElseDataByStatus(oldStatus, jgUseRegistration);
return jgUseRegistration;
}
private void processElseDataByStatus(String flowStatus, JgUseRegistration jgUseRegistration) {
switch (flowStatus){
case "使用单位待提交":
// 1.删除暂存时生成的待办
commonServiceImpl.deleteTaskModel(jgUseRegistration.getSequenceNbr() + "");
break;
case "已完成":
// 1.删除与设备的关系,设备可再次发起使用登记
this.clearUseInfoOfEquip(jgUseRegistration);
// 2.清空redis(缓存的流程中及已完成使用登记的设备)
this.clearDataForCheckEquipRepeatUsed(jgUseRegistration);
break;
default:
// 流程中
// 1.待办任务更新为已完成
this.finishedTask(jgUseRegistration);
// 2.终止流程-工作流报错暂时注释掉
// iCmWorkflowService.stopProcess(jgUseRegistration.getInstanceId());
// 3.清空redis(缓存的流程中及已完成使用登记的设备)
this.clearDataForCheckEquipRepeatUsed(jgUseRegistration);
}
}
private void clearUseInfoOfEquip(JgUseRegistration jgUseRegistration) {
LambdaQueryWrapper<JgUseRegistrationEq> eqLambdaQueryWrapper = new LambdaQueryWrapper<JgUseRegistrationEq>().eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr());
List<JgUseRegistrationEq> eqList = jgRelationEquipMapper.selectList(eqLambdaQueryWrapper);
eqList.forEach(e->{
String record = e.getEquId();
// 1.使用信息表部分字段赋空
this.rollBackUseInfo(record);
// 2.回滚更新idx_biz_jg_register_info表
this.rollBackRegisterInfo(record);
// 3.回滚更新idx_biz_jg_supervision_info表
this.rollBackSupervisionInfo(record);
// 4.es的EQU_STATE, USE_ORG_CODE、ORG_BRANCH_CODE、ORG_BRANCH_NAME、STATUS
this.rollBackForEquipEsInfo(record);
// 5.检验检测流水表-找不到关系暂不更新(删除)
// 6.idx_biz_jg_other_info表监管码、96333、claimStatus,监管码、96333、claimStatus
});
}
private void rollBackForEquipEsInfo(String record) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if(optional.isPresent()){
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setUSE_ORG_CODE(null);
esEquipmentCategoryDto.setSTATUS(null);
esEquipmentCategoryDto.setEQU_STATE(null);
esEquipmentCategoryDto.setORG_BRANCH_CODE(null);
esEquipmentCategoryDto.setORG_BRANCH_NAME(null);
esEquipmentCategory.save(esEquipmentCategoryDto);
}
}
private void rollBackSupervisionInfo(String record) {
LambdaUpdateWrapper<IdxBizJgSupervisionInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgSupervisionInfo::getRecord, record);
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchName, null);
updateWrapper.set(IdxBizJgSupervisionInfo::getOrgBranchCode,null);
updateWrapper.set(IdxBizJgSupervisionInfo::getCompanyOrgBranchCode, null);
idxBizJgSupervisionInfoMapper.update(null, updateWrapper);
}
private void rollBackRegisterInfo(String record) {
LambdaUpdateWrapper<IdxBizJgRegisterInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgRegisterInfo::getRecord, record);
// 未注册,来源cb_data_dictionary type = 'ZC'
updateWrapper.set(IdxBizJgRegisterInfo::getRegisterState, "6046");
updateWrapper.set(IdxBizJgRegisterInfo::getUseOrgCode, null);
idxBizJgRegisterInfoService.update(updateWrapper);
}
private void rollBackUseInfo(String record) {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord,record);
updateWrapper.set(IdxBizJgUseInfo::getCity,null);
updateWrapper.set(IdxBizJgUseInfo::getCityName,null);
updateWrapper.set(IdxBizJgUseInfo::getCounty,null);
updateWrapper.set(IdxBizJgUseInfo::getCountyName,null);
updateWrapper.set(IdxBizJgUseInfo::getStreetName,null);
updateWrapper.set(IdxBizJgUseInfo::getProvince,null);
updateWrapper.set(IdxBizJgUseInfo::getProvinceName,null);
updateWrapper.set(IdxBizJgUseInfo::getEquState,null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitCreditCode,null);
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitName,null);
useInfoMapper.update(null,updateWrapper);
}
private void finishedTask(JgUseRegistration jgUseRegistration) {
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", jgUseRegistration.getInstanceId());
TaskMessageDto taskMessageDto = new TaskMessageDto();
jgUseRegistration.setOtherAccessories(null);
BeanUtils.copyProperties(jgUseRegistration, taskMessageDto);
taskMap.put("model", taskMessageDto);
commonServiceImpl.updateTaskModel(taskMap);
}
} }
\ No newline at end of file
...@@ -75,4 +75,13 @@ public enum FlowStatusEnum { ...@@ -75,4 +75,13 @@ public enum FlowStatusEnum {
return null; return null;
} }
public static FlowStatusEnum getEumByName(String name) {
for (FlowStatusEnum statusEnum : FlowStatusEnum.values()) {
if (statusEnum.getName().equals(name)) {
return statusEnum;
}
}
return null;
}
} }
\ 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