Commit cff4aad1 authored by 韩桐桐's avatar 韩桐桐

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

parent 6c13177a
......@@ -16,13 +16,13 @@ import java.util.Date;
* @date 2024-11-08
*/
@Data
@ApiModel(value="ShCarDto", description="三环系统-车辆信息表")
@ApiModel(value = "ShCarDto", description = "三环系统-车辆信息表")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ShCarDto {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "seq")
......@@ -145,4 +145,33 @@ public class ShCarDto {
@TableField("CLAIMED_FLAG")
private String claimedFlag;
@ApiModelProperty(value = "登记证管理表的seq")
@TableField(exist = false)
private String certificateSeq;
@ApiModelProperty(value = "单位类型,个人、企业")
@TableField(exist = false)
private String companyType;
@ApiModelProperty(value = "使用单位名称")
@TableField(exist = false)
private String useUnitName;
@ApiModelProperty(value = "使用单位统一社会信用代码")
@TableField(exist = false)
private String useUnitCreditCode;
@ApiModelProperty(value = "使用单位地址")
@TableField(exist = false)
private String useUnitAddress;
@ApiModelProperty(value = "安全管理员")
@TableField(exist = false)
private String safetyManagerId;
@ApiModelProperty(value = "安全管理员联系电话")
@TableField(exist = false)
private String phone;
}
package com.yeejoin.amos.boot.module.jg.api.vo;
import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCar;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -12,6 +13,6 @@ import java.util.List;
@Data
@AllArgsConstructor
public class CarAndEquVo {
private ShCar shCar;
private ShCarDto shCar;
private List<ShCarEquVo> shCarEquVoList;
}
......@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCar;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCarEqu;
import com.yeejoin.amos.boot.module.jg.api.service.IShCarService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationManageServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.ShCarEquServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
......@@ -46,6 +48,9 @@ public class ShCarController extends BaseController {
@Autowired
IShCarService iShCarService;
@Autowired
JgUseRegistrationManageServiceImpl jgUseRegistrationManageServiceImpl;
/**
* 新增
*
......@@ -120,6 +125,10 @@ public class ShCarController extends BaseController {
shCarDtoPage.getRecords().forEach(record -> {
if ("1".equals(record.getClaimedFlag())) {
record.setClaimedFlag("是");
// 填充 证管理表的seq,用与认领后跳转证详情页
JgUseRegistrationManage manage = jgUseRegistrationManageServiceImpl.getBaseMapper().selectOne(new LambdaQueryWrapper<JgUseRegistrationManage>()
.eq(JgUseRegistrationManage::getUseRegistrationCode, record.getUseRegistrationCode()));
record.setCertificateSeq(String.valueOf(manage.getSequenceNbr()));
} else if ("0".equals(record.getClaimedFlag())) {
record.setClaimedFlag("否");
}
......
package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCarEqu;
import com.yeejoin.amos.boot.module.jg.api.vo.CarAndEquVo;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -120,6 +121,7 @@ public class ShCarEquController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "汽车详细信息列表", notes = "汽车详细信息列表")
@GetMapping(value = "/selectByCarId")
public ResponseModel<CarAndEquVo> selectByCarId(@RequestParam String carId) {
return ResponseHelper.buildResponse(shCarEquServiceImpl.queryByCarId(carId));
ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(shCarEquServiceImpl.queryByCarId(carId,reginParams));
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCar;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCarEqu;
import com.yeejoin.amos.boot.module.jg.api.mapper.ShCarEquMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IShCarEquService;
import com.yeejoin.amos.boot.module.jg.api.vo.CarAndEquVo;
import com.yeejoin.amos.boot.module.jg.api.vo.ShCarEquVo;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.stream.Collectors;
......@@ -21,39 +26,50 @@ import java.util.stream.Collectors;
* @date 2024-11-08
*/
@Service
public class ShCarEquServiceImpl extends BaseService<ShCarEqu,ShCarEqu,ShCarEquMapper> implements IShCarEquService {
public class ShCarEquServiceImpl extends BaseService<ShCarEqu, ShCarEqu, ShCarEquMapper> implements IShCarEquService {
@Autowired
ShCarServiceImpl shCarServiceImpl;
/**
* 分页查询
*/
public Page<ShCarEqu> queryForShCarEquPage(Page<ShCarEqu> page) {
public Page<ShCarEqu> queryForShCarEquPage(Page<ShCarEqu> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<ShCarEqu> queryForShCarEquList() {
return this.queryForList("" , false);
public List<ShCarEqu> queryForShCarEquList() {
return this.queryForList("", false);
}
public CarAndEquVo queryByCarId(String carId){
//根据carId获取Car
LambdaQueryWrapper<ShCar> queryWrapper1= new LambdaQueryWrapper<>();
queryWrapper1.eq(ShCar::getSequenceNbr,carId);
public CarAndEquVo queryByCarId(String carId, ReginParams reginParams) {
// 根据carId获取Car
LambdaQueryWrapper<ShCar> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ShCar::getSequenceNbr, carId);
ShCar shCar = shCarServiceImpl.getOne(queryWrapper1);
//根据carId获取设备列表
ShCarDto shCarDto = new ShCarDto();
BeanUtil.copyProperties(shCar, shCarDto);
// 补充信息
String companyType = reginParams.getCompany().getCompanyType();
AgencyUserModel userModel = reginParams.getUserModel();
shCarDto.setCompanyType(companyType);
shCarDto.setUseUnitName(reginParams.getCompany().getCompanyName());
shCarDto.setUseUnitCreditCode(reginParams.getCompany().getCompanyCode());
shCarDto.setUseUnitAddress(reginParams.getCompany().getAddress());
shCarDto.setSafetyManagerId("个人主体".equals(companyType) ? userModel.getRealName() : null);
shCarDto.setPhone("个人主体".equals(companyType) ? userModel.getMobile() : null);
// 根据carId获取设备列表
LambdaQueryWrapper<ShCarEqu> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShCarEqu::getCarId,carId);
queryWrapper.eq(ShCarEqu::getCarId, carId);
List<ShCarEqu> list = this.list(queryWrapper);
//将设备列表转换为前端可识别bean
// 将设备列表转换为前端可识别bean
List<ShCarEquVo> collect = list.stream().map(shCarEqu -> new ShCarEquVo(shCarEqu)).collect(Collectors.toList());
//封装返回VO
CarAndEquVo carAndEquVo = new CarAndEquVo(shCar, collect);
return carAndEquVo;
// 封装返回VO
return new CarAndEquVo(shCarDto, collect);
}
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -18,8 +20,10 @@ import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.ShCarMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IShCarService;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
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.FlowStatusEnum;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
......@@ -134,6 +138,9 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
JSONArray equList = JSON.parseArray(JSON.toJSONString(paramMap.get("equList")));
try {
// 清除seq,避免后续所有 业务表 都使用此 seq
paramMap.remove("sequenceNbr");
// 1. 生成设备信息 + 保存es
this.claimGenEquInfo(equList, reginParams);
......@@ -151,9 +158,10 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
return Boolean.TRUE;
} catch (Exception e) {
log.info("三环系统数据认领失败,使用登记证代码:{}", paramMap.get("USE_REGISTRATION_CODE"));
log.error("三环系统数据认领失败,使用登记证代码:{}", paramMap.get("useRegistrationCode"));
log.error("失败原因:{}",e.getMessage());
this.handleClaimFailed(equList);
return Boolean.FALSE;
throw new BadRequest("认领时出现异常,请联系管理员!");
}
}
......@@ -177,6 +185,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
equType.put("equCategoryCode", "2300");
equType.put("equDefine", "特种气瓶");
equType.put("equDefineCode", "23T0");
BigDecimal totalVolume = equList.stream().map(x -> new BigDecimal(String.valueOf(JSON.parseObject(JSON.toJSONString(x)).get("singleBottleVolume"))))
.reduce(BigDecimal.ZERO, BigDecimal::add);
JgUseRegistrationManage registrationManage = JgUseRegistrationManage.builder()
.equList("压力容器").equListCode("2300")
.equCategory("气瓶").equCategoryCode("2300")
......@@ -192,6 +202,11 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
.regType(BusinessTypeEnum.JG_VEHICLE_GAS_APPLICATION.getName())
.certificateStatus(CertificateStatusEnum.YIDENGJI.getName())
.regDate(jgVehicleInformation.getRegDate())
.createUserId(RequestContext.getExeUserId())
.volume(String.valueOf(totalVolume))
.carNumber(jgVehicleInformation.getCarNumber())
.createDate(new Date())
.gasNum(equList.size())
.useUnitAddress(jgVehicleInformation.getUseUnitAddress())
.manageType("unit")
.isScrap("0")
......@@ -239,17 +254,23 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
public void claimGenEquInfo(JSONArray equList, ReginParams reginParams) {
CompanyBo company = reginParams.getCompany();
// 保存设备后 后续业务需要的设备信息
equList.forEach(equObj -> {
for (int i = 0; i < equList.size(); i++) {
JSONObject equObj = equList.getJSONObject(i);
Date date = new Date();
// 设备record
String equRecord = UUID.randomUUID().toString();
JSON.parseObject(JSON.toJSONString(equObj)).put("record", equRecord);
JSONObject equJson = JSON.parseObject(JSON.toJSONString(equObj));
equJson.put("record", equRecord);
equObj = equJson;
// 清除原先的seq
equObj.remove("sequenceNbr");
// 使用信息
IdxBizJgUseInfo useInfo = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgUseInfo.class);
useInfo.setRecord(equRecord);
useInfo.setRecDate(date);
useInfo.setDataSource("jg_his_sh");
useInfo.setIsIntoManagement(Boolean.TRUE);
useInfo.setEquState("1");
if (CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType())) {
useInfo.setUseUnitName(company.getCompanyName().split("_")[1]);
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
......@@ -281,6 +302,7 @@ 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.setRegisterState(idxBizJgRegisterInfoService.getRegCode());
idxBizJgRegisterInfoService.save(registerInfo);
......@@ -301,12 +323,23 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
IdxBizJgTechParamsVessel vessel = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgTechParamsVessel.class);
vessel.setRecord(equRecord);
vessel.setRecDate(date);
idxBizJgTechParamsVesselService.saveOrUpdateData(vessel);
idxBizJgTechParamsVesselService.save(vessel);
// 检验检测信息
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(JSON.toJSONString(equObj), IdxBizJgInspectionDetectionInfo.class);
inspectionDetectionInfo.setRecord(equRecord);
inspectionDetectionInfo.setRecDate(date);
if (inspectionDetectionInfo.getNextInspectDate() != null) {
inspectionDetectionInfo.setNextInspectDate(DateUtil.parse(DateUtil.format(inspectionDetectionInfo.getNextInspectDate(), DatePattern.NORM_DATE_PATTERN)));
}
idxBizJgInspectionDetectionInfoService.save(inspectionDetectionInfo);
// 保存es
idxBizJgRegisterInfoService.checkEsData(equRecord);
});
// 更新 equList 中的元素
equList.set(i, equJson);
}
}
/**
......@@ -385,6 +418,10 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
vehicleInformation.setRegDate(new Date());
vehicleInformation.setCreateUserName(reginParams.getUserModel().getRealName());
vehicleInformation.setGasNum(equList.size());
vehicleInformation.setAuditPassDate(new Date());
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"))))
.reduce(BigDecimal.ZERO, BigDecimal::add);
vehicleInformation.setVolume(totalVolume.toPlainString());
......
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