Commit 487c02df authored by 韩桐桐's avatar 韩桐桐

fix(jg):三环车用气瓶认领 接口 修改

parent fd33d05e
......@@ -813,10 +813,15 @@
SELECT COUNT( 1 )
FROM idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_other_info joi ON joi."RECORD" = jri."RECORD"
WHERE
jri."USE_ORG_CODE" = #{useRegistrationCode}
AND jri."RECORD" != #{equipId}
<where>
<if test="useRegistrationCode != null and useRegistrationCode != ''">
jri."USE_ORG_CODE" = #{useRegistrationCode}
</if>
<if test="equipId != null and equipId != ''">
AND jri."RECORD" != #{equipId}
</if>
AND joi.CLAIM_STATUS = '已认领'
</where>
</select>
<select id="queryOutOfMaintenanceRecord" resultType="java.util.Map">
......
......@@ -45,8 +45,11 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XIAN_YANG;
import static com.yeejoin.amos.boot.module.jg.api.enums.VehicleApanageEnum.XI_XIAN;
/**
* 三环系统-车辆信息表服务实现类
......@@ -137,12 +140,34 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
JSONArray equList = JSON.parseArray(JSON.toJSONString(paramMap.get("equList")));
// 0. 必要校验
// 0.1 使用登记证的唯一校验
String useRegistrationCode = String.valueOf(paramMap.get("useRegistrationCode"));
Boolean used = commonService.useRegistrationCertificateAccountUnique(useRegistrationCode, null);
if (used) {
throw new BadRequest("使用登记证编号已存在!");
}
// 0.2 设备代码的唯一校验
Set<String> equCodeSet = equList.stream().map(equ -> {
JSONObject jsonObject = JSON.parseObject(toJSONString(equ));
return jsonObject.getString("equCode");
}).collect(Collectors.toSet());
if (equCodeSet.size() < equList.size())
throw new BadRequest("设备代码重复!");
equCodeSet.forEach(equCode -> {
Boolean useFlag = commonService.checkEquCodeUniqueness(equCode);
if (useFlag) {
throw new BadRequest("设备代码已存在系统中!");
}
});
try {
// 清除seq,避免后续所有 业务表 都使用此 seq
paramMap.remove("sequenceNbr");
// 1. 生成设备信息 + 保存es
this.claimGenEquInfo(equList, reginParams);
this.claimGenEquInfo(useRegistrationCode, paramMap, equList, reginParams);
// 2. 生成车用气瓶使用登记证单据( JgVehicleInformation JgVehicleInformationEq )信息
JgVehicleInformation jgVehicleInformation = this.claimGenVehicleInfoAbout(paramMap, equList, reginParams);
......@@ -159,7 +184,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
} catch (Exception e) {
log.error("三环系统数据认领失败,使用登记证代码:{}", paramMap.get("useRegistrationCode"));
log.error("失败原因:{}",e.getMessage());
log.error("失败原因:{}", e.getMessage());
this.handleClaimFailed(equList);
throw new BadRequest("认领时出现异常,请联系管理员!");
}
......@@ -203,7 +228,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
.certificateStatus(CertificateStatusEnum.YIDENGJI.getName())
.regDate(jgVehicleInformation.getRegDate())
.createUserId(RequestContext.getExeUserId())
.volume(String.valueOf(totalVolume))
.volume(totalVolume.toPlainString())
.carNumber(jgVehicleInformation.getCarNumber())
.createDate(new Date())
.gasNum(equList.size())
......@@ -251,7 +276,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
*
* @param equList 设备集合
*/
public void claimGenEquInfo(JSONArray equList, ReginParams reginParams) {
public void claimGenEquInfo(String useRegistrationCode, Map<String, Object> paramMap, JSONArray equList, ReginParams reginParams) {
CompanyBo company = reginParams.getCompany();
// 保存设备后 后续业务需要的设备信息
for (int i = 0; i < equList.size(); i++) {
......@@ -278,6 +303,10 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
useInfo.setUseUnitName(company.getCompanyName());
useInfo.setUseUnitCreditCode(company.getCompanyCode());
}
useInfo.setORegUnit((String) paramMap.get("oRegUnit"));
useInfo.setORegDate((String) paramMap.get("oRegDate"));
useInfo.setOldUseRegistrationTable(JSON.toJSONString(paramMap.get("oldUseRegistrationTable")));
useInfo.setOldUseRegistrationCertificate(JSON.toJSONString(paramMap.get("oldUseRegistrationCertificate")));
idxBizJgUseInfoService.save(useInfo);
// 设计信息
......@@ -302,7 +331,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgRegisterInfo.class);
registerInfo.setRecord(equRecord);
registerInfo.setRecDate(date);
registerInfo.setUseOrgCode(equObj.getString("useRegistrationCode"));
registerInfo.setUseOrgCode(useRegistrationCode);
registerInfo.setWhetherSkidMountedPressureVessel("0");
registerInfo.setRegisterState(idxBizJgRegisterInfoService.getRegCode());
idxBizJgRegisterInfoService.save(registerInfo);
......@@ -310,6 +340,15 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgSupervisionInfo.class);
supervisionInfo.setRecord(equRecord);
supervisionInfo.setRecDate(date);
if (!StringUtils.isEmpty(supervisionInfo.getOrgBranchCode())) {
String[] orgBranchCode = supervisionInfo.getOrgBranchCode().split("_");
supervisionInfo.setOrgBranchCode(orgBranchCode[0]);
supervisionInfo.setOrgBranchName(orgBranchCode[1]);
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(orgBranchCode[0]).getResult();
// 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class);
supervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode());
}
idxBizJgSupervisionInfoService.save(supervisionInfo);
// 其他信息
......@@ -317,6 +356,18 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
otherInfo.setRecord(equRecord);
otherInfo.setClaimStatus("已认领");
otherInfo.setRecDate(date);
// ---生成监管码
Map<String, Object> map = new HashMap<>();
String vehicleApanage = (String) paramMap.get("vehicleApanage");
// 判断是否为西咸
String isXiXian = XI_XIAN.getCode().equals(vehicleApanage) ? "1" : "0";
map.put("cityCode", XI_XIAN.getCode().equals(vehicleApanage) ? XIAN_YANG.getCode() : vehicleApanage);
map.put("isXiXian", isXiXian);
map.put("equCategory", registerInfo.getEquCategory());
map.put("countyCode", XI_XIAN.getCode().equals(vehicleApanage) ? XIAN_YANG.getCode() : vehicleApanage);
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
Map<String, Object> result = code.getResult();
otherInfo.setSupervisoryCode((String) result.get("superviseCode"));
idxBizJgOtherInfoService.save(otherInfo);
// 压力容器技术参数
......@@ -329,6 +380,12 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgInspectionDetectionInfo.class);
inspectionDetectionInfo.setRecord(equRecord);
inspectionDetectionInfo.setRecDate(date);
// 检验机构信息
if (!StringUtils.isEmpty(inspectionDetectionInfo.getInspectOrgName())) {
String[] inspectOrg = inspectionDetectionInfo.getInspectOrgName().split("_");
inspectionDetectionInfo.setInspectOrgCode(inspectOrg[0]);
inspectionDetectionInfo.setInspectOrgName(inspectOrg[1]);
}
if (inspectionDetectionInfo.getNextInspectDate() != null) {
inspectionDetectionInfo.setNextInspectDate(DateUtil.parse(DateUtil.format(inspectionDetectionInfo.getNextInspectDate(), DatePattern.NORM_DATE_PATTERN)));
}
......@@ -419,7 +476,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
vehicleInformation.setCreateUserName(reginParams.getUserModel().getRealName());
vehicleInformation.setGasNum(equList.size());
vehicleInformation.setAuditPassDate(new Date());
vehicleInformation.setRegType("1");//历史登记
vehicleInformation.setRegType("1");// 历史登记
vehicleInformation.setStatus(FlowStatusEnum.TO_BE_FINISHED.getName());
vehicleInformation.setCreateDate(new Date());
BigDecimal totalVolume = equList.stream().map(x -> new BigDecimal(String.valueOf(JSON.parseObject(JSON.toJSONString(x)).get("singleBottleVolume"))))
......
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