Commit fbac7206 authored by suhuiguang's avatar suhuiguang

1.车用气瓶使用登记增加作废功能

parent 27ff8cb2
......@@ -5,21 +5,20 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
*
*
* @author system_generator
* @date 2024-03-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="JgVehicleInformationDto", description="")
@ApiModel(value = "JgVehicleInformationDto", description = "")
public class JgVehicleInformationDto extends BaseDto {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "设备监管码")
......@@ -228,4 +227,15 @@ public class JgVehicleInformationDto extends BaseDto {
@ApiModelProperty(value = "电话")
private String phone;
@ApiModelProperty(value = "作废日期")
private Date cancelDate;
@ApiModelProperty(value = "作废人员id")
private String cancelUserId;
@ApiModelProperty(value = "作废原因")
private String cancelReason;
}
......@@ -408,4 +408,23 @@ public class JgVehicleInformation extends BaseEntity {
@TableField(value = "phone")
private String phone;
/**
* 作废日期
*/
@TableField("cancel_date")
private Date cancelDate;
/**
* 作废人员id
*/
@TableField("cancel_user_id")
private String cancelUserId;
/**
* 作废原因
*/
@TableField("cancel_reason")
private String cancelReason;
}
......@@ -199,7 +199,7 @@ public class JgVehicleInformationVo implements Serializable {
private String currentUserId;
private List<Map<String, Object>> equipmentLists;
private List<? extends Map> equipmentLists;
@ApiModelProperty(value = "主键ID")
protected Long sequenceNbr;
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.entity.JgVehicleInformation;
import com.yeejoin.amos.boot.module.jg.api.vo.JgVehicleInformationVo;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
......@@ -182,4 +183,12 @@ public class JgVehicleInformationController extends BaseController {
@RequestParam(value = "printType", defaultValue = "0") String printType) {
jgVehicleInformationServiceImpl.exportVehicleUseRegistrationCertificate(sequenceNbr, response, printType);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "车用气瓶使用登记单条作废", notes = "车用气瓶使用登记单条作废")
@PutMapping(value = "/cancel/application")
public ResponseModel<JgVehicleInformation> cancelApplication(@RequestBody JgVehicleInformationDto vehicleInformationDto) {
JgVehicleInformation result = jgVehicleInformationServiceImpl.cancelApplication(vehicleInformationDto.getSequenceNbr(), vehicleInformationDto.getCancelReason());
return ResponseHelper.buildResponse(result);
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
......@@ -136,7 +137,7 @@ public interface ICommonService {
* @param currentDocumentId 业务id
* @return Object
*/
Object queryHistoryDataObj(Long currentDocumentId);
JSONArray queryHistoryDataObj(Long currentDocumentId);
/**
* 统计指定设备流程中的引用次数(12个流程中,非待提交、非已撤回、非已驳回)
......
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -1644,11 +1645,11 @@ public class CommonServiceImpl implements ICommonService {
}
@Override
public Object queryHistoryDataObj(Long currentDocumentId) {
public JSONArray queryHistoryDataObj(Long currentDocumentId) {
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, currentDocumentId);
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.getBaseMapper().selectOne(lambda);
return jgRegistrationHistory != null ? JSON.parse(jgRegistrationHistory.getChangeData()) : null;
return jgRegistrationHistory != null ? JSON.parseArray(jgRegistrationHistory.getChangeData()) : new JSONArray();
}
@Override
......
......@@ -1264,7 +1264,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
installationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
installationNotice.setCancelReason(cancelReason);
installationNotice.setCancelDate(new Date());
installationNotice.setCreateUserId(RequestContext.getExeUserId());
installationNotice.setCancelUserId(RequestContext.getExeUserId());
installationNotice.setNextExecuteUserIds(null);
installationNotice.setPromoter(null);
this.updateById(installationNotice);
......
......@@ -145,9 +145,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
}
} else {
// 完成的显示历史表的数据
JSONArray objects = (JSONArray) commonService.queryHistoryDataObj(dto.getSequenceNbr());
JSONArray objects = commonService.queryHistoryDataObj(dto.getSequenceNbr());
// 兼容老数据
if (objects == null) {
if (objects.isEmpty()) {
List<Map<String, Object>> list = maintenanceContractMapper.selectEquipList(sequenceNbr);
if (!ObjectUtils.isEmpty(list)) {
vo.setEquipmentLists(list);
......
......@@ -974,9 +974,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
registerInfo.setEquCode(equCode);
mapData.put("equCode", equCode);
lambda.set(true, IdxBizJgRegisterInfo::getEquCode, equCode);
// 更新新生成的历史数据的设备代码
jgRegistrationHistory.setChangeData(JSON.toJSONString(mapData));
jgRegistrationHistoryService.updateById(jgRegistrationHistory);
}
}
......@@ -1370,37 +1367,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
/**
* 填充设备最新的数据至历史json
*
* @param jsonObject 历史json
* @param jgUseRegistration 使用信息
* @param record 设备唯一标识
*/
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
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> desDetail = this.baseMapper.getDesDetail(record);
if (!ObjectUtils.isEmpty(desDetail)) {
detail.putAll(desDetail);
}
// 安装信息
Map<String, Object> installDetail = this.baseMapper.getiInstallDetail(record);
// 维保信息
Map<String, Object> maintenanceDetail = this.baseMapper.getMaintenanceDetail(record);
if (!ObjectUtils.isEmpty(maintenanceDetail)) {
detail.putAll(maintenanceDetail);
}
if (!ObjectUtils.isEmpty(installDetail)) {
detail.putAll(installDetail);
}
jsonObject.putAll(detail);
}
}
/**
* 参数为监管码
*
* @param supervisoryCode
......@@ -1539,6 +1505,37 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
}
/**
* 填充设备最新的数据至历史json
*
* @param jsonObject 历史json
* @param jgUseRegistration 使用信息
* @param record 设备唯一标识
*/
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
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> desDetail = this.baseMapper.getDesDetail(record);
if (!ObjectUtils.isEmpty(desDetail)) {
detail.putAll(desDetail);
}
// 安装信息
Map<String, Object> installDetail = this.baseMapper.getiInstallDetail(record);
// 维保信息
Map<String, Object> maintenanceDetail = this.baseMapper.getMaintenanceDetail(record);
if (!ObjectUtils.isEmpty(maintenanceDetail)) {
detail.putAll(maintenanceDetail);
}
if (!ObjectUtils.isEmpty(installDetail)) {
detail.putAll(installDetail);
}
jsonObject.putAll(detail);
}
}
private UseFlagParamDto buildUseFlagParamDto(JgUseRegistration useRegistration, IdxBizJgRegisterInfo registerInfo, IdxBizJgFactoryInfo factoryInfo, Map<String, Object> exportParamsMap) {
UseFlagParamDto useFlagParamDto = new UseFlagParamDto();
useFlagParamDto.setReceiveCompanyCode(useRegistration.getReceiveCompanyCode());
......@@ -1626,7 +1623,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
jgUseRegistration.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
jgUseRegistration.setCancelReason(cancelReason);
jgUseRegistration.setCancelDate(new Date());
jgUseRegistration.setCreateUserId(RequestContext.getExeUserId());
jgUseRegistration.setCancelUserId(RequestContext.getExeUserId());
jgUseRegistration.setNextExecuteUserIds("");
jgUseRegistration.setPromoter("");
this.updateById(jgUseRegistration);
......
......@@ -23,8 +23,10 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgVehicleInformationMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgVehicleInformationService;
import com.yeejoin.amos.boot.module.jg.api.vo.JgVehicleInformationVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
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.service.ICmWorkflowService;
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.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
......@@ -115,8 +117,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
private JgUseRegistrationServiceImpl jgUseRegistrationService;
@Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
private JgUseRegistrationMapper jgUseRegistrationMapper;
private ESEquipmentCategory esEquipmentCategory;
/**
* 新增(提交)车用气瓶
......@@ -475,15 +478,37 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
vehicleInfoEqWrapper.eq(JgVehicleInformationEq::getVehicleId, sequenceNbr);
List<JgVehicleInformationEq> vehicleInformationEqList = jgVehicleInformationEqService.getBaseMapper().selectList(vehicleInfoEqWrapper);
vo.setEquipmentLists(
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr,
// 非完成、非已作废时显示实时数据
if (!(dto.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) || dto.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()))) {
vo.setEquipmentLists(
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr,
vehicleInformationEqList.stream()
.map(JgVehicleInformationEq::getEquId)
.collect(Collectors.toList())
).stream()
.peek(v -> v.put("chargingMedium", Systemctl.dictionarieClient.value("FILLING_MEDIUM", v.get("chargingMedium") + "").getResult().getDictDataValue()))
.collect(Collectors.toList())
);
} else {
// 完成及已作废时显示历史数据详情
JSONArray objects = commonService.queryHistoryDataObj(dto.getSequenceNbr());
// 兼容老数据
if (objects.isEmpty()) {
vo.setEquipmentLists(
this.baseMapper.queryForUnitVesselEquipment(sequenceNbr,
vehicleInformationEqList.stream()
.map(JgVehicleInformationEq::getEquId)
.collect(Collectors.toList())
).stream()
.peek(v -> v.put("chargingMedium", Systemctl.dictionarieClient.value("FILLING_MEDIUM", v.get("chargingMedium") + "").getResult().getDictDataValue()))
.collect(Collectors.toList())
);
.peek(v -> v.put("chargingMedium", Systemctl.dictionarieClient.value("FILLING_MEDIUM", v.get("chargingMedium") + "").getResult().getDictDataValue()))
.collect(Collectors.toList())
);
} else {
List equList = objects.toJavaList(Map.class);
vo.setEquipmentLists(equList);
}
}
vo.setEquDefineCode(
vo.getEquipmentLists().stream()
.findFirst()
......@@ -676,6 +701,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 更新es
updateEsData(mapData, jgVehicleInformation, otherInfo);
}
// 更新新生成的历史数据的设备代码
jgRegistrationHistory.setChangeData(JSON.toJSONString(jsonArray));
jgRegistrationHistoryService.updateById(jgRegistrationHistory);
// 更新代办状态
HashMap<String, Object> params = new HashMap<>();
......@@ -693,7 +721,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
this.getBaseMapper().updateById(jgVehicleInformation);
}
public void updateEsData(JSONObject dataMap, JgVehicleInformation jgVehicleInformation, IdxBizJgOtherInfo otherInfo) {
private void updateEsData(JSONObject dataMap, JgVehicleInformation jgVehicleInformation, IdxBizJgOtherInfo otherInfo) {
// 更新es
HashMap<String, Map<String, Object>> objMap = new HashMap<>();
HashMap<String, Object> param = new HashMap<>();
......@@ -712,7 +740,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
tzsServiceFeignClient.commonUpdateEsDataByIds(objMap);
}
public void buildTask(JgVehicleInformation jgVehicleInformation, WorkflowResultDto workflowResultDto) {
private void buildTask(JgVehicleInformation jgVehicleInformation, WorkflowResultDto workflowResultDto) {
// 代办消息
ArrayList<TaskModelDto> list = new ArrayList<>();
TaskModelDto dto = new TaskModelDto();
......@@ -763,7 +791,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
return this.baseMapper.getListPage(page, dto, roleIds);
}
public void updateEquipMessage(JgVehicleInformation jgVehicleInformation, JSONObject map, IdxBizJgRegisterInfo registerInfo, IdxBizJgOtherInfo otherInfo) {
private void updateEquipMessage(JgVehicleInformation jgVehicleInformation, JSONObject map, IdxBizJgRegisterInfo registerInfo, IdxBizJgOtherInfo otherInfo) {
String useOrgCode = jgVehicleInformation.getUseRegistrationCode();
map.remove("status");
map.remove("instanceId");
......@@ -1021,4 +1049,130 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
throw new BadRequest("存在已经登记过的气瓶!");
}
}
@Transactional(rollbackFor = Exception.class)
public JgVehicleInformation cancelApplication(Long sequenceNbr, String cancelReason) {
// 1.更新为已作废
JgVehicleInformation vehicleInformation = this.getById(sequenceNbr);
String oldStatus = vehicleInformation.getStatus();
vehicleInformation.setStatus(FlowStatusEnum.TO_BE_DISCARD.getName());
vehicleInformation.setCancelReason(cancelReason);
vehicleInformation.setCancelDate(new Date());
vehicleInformation.setCancelUserId(RequestContext.getExeUserId());
vehicleInformation.setNextExecuteUserIds("");
vehicleInformation.setPromoter("");
this.updateById(vehicleInformation);
// 2.更新关联的业务
processElseDataByStatus(oldStatus, vehicleInformation);
return vehicleInformation;
}
private void processElseDataByStatus(String flowStatus, JgVehicleInformation vehicleInformation) {
switch (flowStatus) {
case "使用单位待提交":
// 1.删除暂存时生成的待办
commonService.deleteTaskModel(vehicleInformation.getSequenceNbr() + "");
break;
case "已完成":
// 1.删除与设备的关系,设备可再次发起使用登记
this.clearUseInfoOfEquip(vehicleInformation);
break;
default:
// 流程中
// 1.待办任务更新为已完成
this.finishedTask(vehicleInformation);
// 2.终止流程-工作流报错暂时注释掉
// iCmWorkflowService.stopProcess(vehicleInformation.getInstanceId());
}
}
private void clearUseInfoOfEquip(JgVehicleInformation vehicleInformation) {
LambdaQueryWrapper<JgVehicleInformationEq> eqLambdaQueryWrapper = new LambdaQueryWrapper<JgVehicleInformationEq>().eq(JgVehicleInformationEq::getVehicleId, vehicleInformation.getSequenceNbr());
List<JgVehicleInformationEq> eqList = jgVehicleInformationEqMapper.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);
});
}
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);
updateWrapper.set(IdxBizJgRegisterInfo::getCarNumber, 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);
updateWrapper.set(IdxBizJgUseInfo::getUsePlace, null);
updateWrapper.set(IdxBizJgUseInfo::getLongitudeLatitude, null);
updateWrapper.set(IdxBizJgUseInfo::getAddress, null);
updateWrapper.set(IdxBizJgUseInfo::getSafetyManageDt, null);
updateWrapper.set(IdxBizJgUseInfo::getSafetyManagerId, null);
updateWrapper.set(IdxBizJgUseInfo::getSafetyManager, null);
updateWrapper.set(IdxBizJgUseInfo::getFactoryUseSiteStreet, null);
useInfoMapper.update(null, updateWrapper);
}
private void finishedTask(JgVehicleInformation vehicleInformation) {
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", vehicleInformation.getInstanceId());
TaskMessageDto taskMessageDto = new TaskMessageDto();
vehicleInformation.setOtherAccessories(null);
vehicleInformation.setDriveLicenseBack(null);
vehicleInformation.setDriveLicenseFront(null);
BeanUtils.copyProperties(vehicleInformation, 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