Commit 12f6294c authored by 刘林's avatar 刘林

fix(JG):使用登记证添加气瓶类别

parent 3f121992
package com.yeejoin.amos.boot.module.jg.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum CylinderTypeEnum {
CYLINDER("瓶", "2300"),
SPECIAL_CYLINDER("特种气瓶", "23T0");
private final String name;
private final String code;
}
......@@ -17,7 +17,7 @@
ur.apply_no as applyNo,
ur.next_execute_ids as nextExecuteIds,
ur.promoter,
ur.supervisory_code as supervisoryCode,
GROUP_CONCAT(DISTINCT other.supervisory_code) as supervisoryCode,
ur.use_registration_code as useRegistrationCode,
date_format(ur.audit_pass_date,'%Y-%m-%d') as auditPassDate,
ur.receive_org_name as receiveOrgName,
......@@ -233,7 +233,7 @@
ur.apply_no as applyNo,
ur.next_execute_ids as nextExecuteIds,
ur.promoter as promoter,
ur.supervisory_code as supervisoryCode,
GROUP_CONCAT(DISTINCT other.supervisory_code) as supervisoryCode,
ur.use_registration_code as useRegistrationCode,
date_format(ur.audit_pass_date, '%Y-%m-%d') as auditPassDate,
ur.receive_org_name as receiveOrgName,
......
......@@ -26,6 +26,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
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.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PrintingTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
......@@ -799,7 +800,7 @@ public class CommonServiceImpl implements ICommonService {
* @param response response
* @param pathResource PDF模版路径
* @param printFileName 生成文件名称
* @param v
* @param textSize 字体大小
*/
private void fillParamValueToPdf(Map<String, Object> map, HttpServletResponse response, String pathResource, String printFileName, float textSize) {
// 读取资源文件夹下的模板
......@@ -1482,7 +1483,11 @@ public class CommonServiceImpl implements ICommonService {
String equDefine = equipRegistrationInfo.getEquDefine(); // 设备品种 "3110"
if (!ObjectUtils.isEmpty(equCategory)) {
// 设备种类简称
String equCategoryAbbrName = EquipTypeEnum.getMessage(equCategory.substring(0, 1));
String equCategoryAbbrName = Optional.ofNullable(CylinderTypeEnum.CYLINDER.getCode().equals(equCategory) ?
CylinderTypeEnum.CYLINDER.getName() : equCategory)
.map(category -> category.substring(0, 1))
.map(EquipTypeEnum::getMessage)
.orElse(null);
// 设备代码中间两位
String equipType2MidDigits;
......
......@@ -22,6 +22,7 @@ import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.EquipTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationEqMapper;
......@@ -527,7 +528,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.map(v -> (String) v.get("record"))
.collect(Collectors.toList())
);
if (!"2300".equals(map.get("EQU_CATEGORY_CODE")) && inspectionDetectionInfoList.stream().anyMatch(info ->
if (!CylinderTypeEnum.CYLINDER.getCode().equals(map.get("EQU_CATEGORY_CODE")) && inspectionDetectionInfoList.stream().anyMatch(info ->
ObjectUtils.isEmpty(info) || ObjectUtils.isEmpty(info.getInspectType()) ||
ObjectUtils.isEmpty(info.getInspectConclusion()) || ObjectUtils.isEmpty(info.getInspectOrgCode()) ||
ObjectUtils.isEmpty(info.getInspectOrgName()))) {
......@@ -850,6 +851,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
LambdaQueryWrapper<IdxBizJgOtherInfo> lambdaOth = new QueryWrapper<IdxBizJgOtherInfo>().lambda();
lambdaOth.eq(IdxBizJgOtherInfo::getRecord, String.valueOf(mapData.get("equipId")));
IdxBizJgOtherInfo otherInfo = otherInfoMapper.selectOne(lambdaOth);
jgUseRegistration.setSupervisoryCode(otherInfo.getSupervisoryCode());
// 注册信息
LambdaQueryWrapper<IdxBizJgRegisterInfo> lambdaReg = new QueryWrapper<IdxBizJgRegisterInfo>().lambda();
lambdaReg.eq(IdxBizJgRegisterInfo::getRecord, String.valueOf(mapData.get("equipId")));
......@@ -1173,7 +1175,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) jsonObject.get("equipmentLists");
List<String> records = equipmentLists.stream().map(v -> (String) v.get("record")).collect(Collectors.toList());
jsonObject.remove("equipmentLists");
if ("2300".equals(jsonObject.get("EQU_CATEGORY_CODE"))) {
if (CylinderTypeEnum.CYLINDER.getCode().equals(jsonObject.get("EQU_CATEGORY_CODE"))) {
jsonObject.put("equipmentLists", jgUseRegistrationMapper.queryForUnitVesselEquipment(records));
} else {
jsonObject.put("equipmentLists", jgUseRegistrationMapper.queryForUnitPipelineEquipment(records));
......
......@@ -262,97 +262,6 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
return Collections.singletonList(vehicleInformation);
}
public void updateHistory(JSONObject map, String equipId, String currentDocumentId, String supervisoryCode) {
JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory();
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
// lambda.eq(JgRegistrationHistory::getEquId, equipId);
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, currentDocumentId);
lambda.eq(JgRegistrationHistory::getRegistrationClass, "车用气瓶登记");
Integer integer = jgRegistrationHistoryService.getBaseMapper().selectCount(lambda);
if (integer > 0) {
jgRegistrationHistory.setChangeData(JSON.toJSONString(map));
jgRegistrationHistoryService.update(jgRegistrationHistory, lambda);
} else {
jgRegistrationHistory.setChangeData(JSON.toJSONString(map));
jgRegistrationHistory.setStatus("new");
jgRegistrationHistory.setRegistrationClass("车用气瓶登记");
jgRegistrationHistory.setSupervisoryCode(supervisoryCode);
jgRegistrationHistory.setEquId(equipId);
jgRegistrationHistory.setCurrentDocumentId(currentDocumentId);
jgRegistrationHistoryService.save(jgRegistrationHistory);
}
}
private void createTaskModel(JgVehicleInformation vehicle, String taskName, String submitType, String nextUserIds) {
if ("1".equals(submitType)) {
TaskModelDto taskModelDto = new TaskModelDto();
taskModelDto.setFlowCreateDate(vehicle.getRegDate());
taskModelDto.setTaskName(taskName);
taskModelDto.setTaskCode(vehicle.getApplyNo());
taskModelDto.setTaskContent(this.buildTaskContent(vehicle));
taskModelDto.setTaskDesc("");
taskModelDto.setTaskType(BusinessTypeEnum.JG_VEHICLE_GAS_APPLICATION.getCode());
taskModelDto.setTaskTypeLabel(BusinessTypeEnum.JG_VEHICLE_GAS_APPLICATION.getName());
taskModelDto.setRelationId(vehicle.getInstanceId());
taskModelDto.setExecuteUserIds(nextUserIds);
FlowStatusEnum flowStatusEnum = this.getTaskStatus(submitType);
taskModelDto.setTaskStatus(flowStatusEnum.getCode());
taskModelDto.setTaskStatusLabel(flowStatusEnum.getName());
taskModelDto.setFlowStatus(this.getTaskStatusByName(vehicle.getStatus()));
taskModelDto.setFlowStatusLabel(vehicle.getStatus());
taskModelDto.setStartUserId(vehicle.getCreateUserId());
taskModelDto.setStartUser(vehicle.getRecUserName());
taskModelDto.setFlowCode(vehicle.getNextTaskId());
taskModelDto.setStartUserCompanyName(vehicle.getUseUnitName());
taskModelDto.setNextExecuteUser(vehicle.getNextExecuteIds());
taskModelDto.setStartDate(vehicle.getCreateDate());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtil.copyProperties(vehicle, taskMessageDto);
taskModelDto.setModel(taskMessageDto);
commonService.buildTaskModel(Collections.singletonList(taskModelDto));
// redis流程实时数据更新
commonService.saveExecuteFlowData2Redis(vehicle.getInstanceId(), this.buildInstanceRuntimeData(vehicle));
}
}
/**
* 摘要构建
*
* @param dto 业务
* @return 摘要
*/
private String buildTaskContent(JgVehicleInformation dto) {
List<Map<String, Object>> list = this.baseMapper.selectEquipList(dto.getSequenceNbr());
String supervisoryCode = "";
String equList = "";
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
if (map.containsKey("EQU_LIST")) {
equList = map.get("EQU_LIST") + "";
}
if (map.containsKey("SUPERVISORY_CODE")) {
supervisoryCode = map.get("SUPERVISORY_CODE") + "";
}
}
supervisoryCode = StringUtils.isEmpty(supervisoryCode) ? "无" : supervisoryCode;
String format = String.format("来自%s【%s】等的业务办理,【申请单号:%s】等", equList, supervisoryCode, dto.getApplyNo());
return format;
}
private FlowStatusEnum getTaskStatus(String operate) {
if ("0".equals(operate)) {
return FlowStatusEnum.TO_BE_FINISHED;
} else {
return FlowStatusEnum.REJECTED;
}
}
private Integer getTaskStatusByName(String auditStatus) {
return commonService.getDictionaryCodeByName(auditStatus);
}
/**
* 撤回操作
*
......@@ -496,7 +405,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
try {
boolean isLocked = lock.tryLock(0, 180, TimeUnit.SECONDS);
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if(!isLocked){
if (!isLocked) {
throw new BadRequest("当前流程已经被执行!请重新打开页面查看并执行!");
}
// 流程执行时,状态及权限校验
......@@ -625,7 +534,7 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
CompanyModel receiveParentResult = Privilege.companyClient.seleteOne(receiveCompanyResult.getParentId()).getResult();
receiveCompanyCode = receiveParentResult.getCompanyCode();
}
String code = generateVehicleUseRegistrationCode(receiveCompanyCode);
String code = this.generateVehicleUseRegistrationCode(receiveCompanyCode);
jgVehicleInformation.setUseRegistrationCode(code);
jgVehicleInformation.setAuditPassDate(new Date());
......@@ -867,11 +776,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
/**
* 根据车辆属地生成使用登记证
*
* @param receiveCompanyCode 车辆属地
* @return String
*/
private String generateVehicleUseRegistrationCode(String receiveCompanyCode) {
StringBuilder useRegistration = new StringBuilder("3T");
StringBuilder useRegistration = new StringBuilder("3T");
if (!ObjectUtils.isEmpty(receiveCompanyCode)) {
ResponseModel<String> stringResponseModel = tzsServiceFeignClient.useRegistrationCode(useRegistration.append(VehicleApanageEnum.of(receiveCompanyCode)) + "");
return stringResponseModel.getResult();
......@@ -911,9 +821,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
throw new BadRequest("使用登记证导出失败,请稍后重试或检查数据完整性!");
}
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", vehicleInformationEqList.get(0).getEquId()));
if (registerInfo != null) {
populateEquipmentInformation(registerInfo, exportParamsMap);
List<IdxBizJgRegisterInfo> registerInfoList = idxBizJgRegisterInfoMapper.selectList(new QueryWrapper<IdxBizJgRegisterInfo>().in("RECORD", vehicleInformationEqList.stream()
.map(JgVehicleInformationEq::getEquId)
.filter(Objects::nonNull)
.collect(Collectors.toList())));
if (!ValidationUtil.isEmpty(registerInfoList)) {
populateEquipmentInformation(registerInfoList, exportParamsMap);
}
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOneData(vehicleInformationEqList.get(0).getEquId());
......@@ -955,27 +868,34 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
}
}
private void populateEquipmentInformation(IdxBizJgRegisterInfo registerInfo, Map<String, Object> exportParamsMap) {
String equList = registerInfo.getEquList();
String equCategory = registerInfo.getEquCategory();
String equDefine = registerInfo.getEquDefine();
List<EquipmentCategory> categoryList0 = commonService.getEquipmentCategoryList(equList, null);
List<EquipmentCategory> categoryList1 = commonService.getEquipmentCategoryList(equCategory, null);
List<EquipmentCategory> categoryList2 = commonService.getEquipmentCategoryList(equDefine, null);
if (notEmptyAndHasName(categoryList0)) {
exportParamsMap.put("equList", categoryList0.get(0).getName());
}
if (notEmptyAndHasName(categoryList1)) {
exportParamsMap.put("equCategory", categoryList1.get(0).getName());
}
if (notEmptyAndHasName(categoryList2)) {
exportParamsMap.put("equDefine", "特种气瓶(车用)");
}
if (registerInfo.getEquCode() == null) {
throw new BadRequest("使用登记证导出失败,设备代码为空!");
private void populateEquipmentInformation(List<IdxBizJgRegisterInfo> registerInfoList, Map<String, Object> exportParamsMap) {
Optional<IdxBizJgRegisterInfo> optionalRegisterInfo = registerInfoList.stream().findFirst();
if (optionalRegisterInfo.isPresent()) {
IdxBizJgRegisterInfo registerInfo = optionalRegisterInfo.get();
String equList = registerInfo.getEquList();
String equCategory = registerInfo.getEquCategory();
String equDefine = registerInfo.getEquDefine();
List<EquipmentCategory> categoryList0 = commonService.getEquipmentCategoryList(equList, null);
List<EquipmentCategory> categoryList1 = commonService.getEquipmentCategoryList(equCategory, null);
List<EquipmentCategory> categoryList2 = commonService.getEquipmentCategoryList(equDefine, null);
if (notEmptyAndHasName(categoryList0)) {
exportParamsMap.put("equList", categoryList0.get(0).getName());
}
if (notEmptyAndHasName(categoryList1)) {
exportParamsMap.put("equCategory", categoryList1.get(0).getName());
}
if (notEmptyAndHasName(categoryList2)) {
exportParamsMap.put("equDefine", "特种气瓶(车用)");
}
if (registerInfoList.stream().anyMatch(r -> r.getEquCode() == null)) {
throw new BadRequest("使用登记证导出失败,设备代码为空!");
}
exportParamsMap.put("equCode", registerInfoList.stream()
.map(IdxBizJgRegisterInfo::getEquCode)
.filter(Objects::nonNull)
.collect(Collectors.joining(", ")));
exportParamsMap.put("equListCode", equList);
}
exportParamsMap.put("equCode", registerInfo.getEquCode());
exportParamsMap.put("equListCode", equList);
}
private boolean notEmptyAndHasName(List<EquipmentCategory> categoryList) {
......
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