Commit 24097fa3 authored by 韩桐桐's avatar 韩桐桐

fix(jg):三环数据认领改动

parent 7318ca55
...@@ -16,7 +16,7 @@ public interface IShCarService { ...@@ -16,7 +16,7 @@ public interface IShCarService {
Page<ShCarDto> queryForShCarPage(Page<ShCarDto> page, ShCarDto dto); Page<ShCarDto> queryForShCarPage(Page<ShCarDto> page, ShCarDto dto);
Boolean claim(Map<String, Object> paramMap); Boolean claim(String claimOneself,Map<String, Object> paramMap);
ShCar searchForSanHan(Map<?, ?> map); ShCar searchForSanHan(Map<?, ?> map);
} }
...@@ -113,6 +113,15 @@ public class ShCarEquVo { ...@@ -113,6 +113,15 @@ public class ShCarEquVo {
private String produceUnitName; private String produceUnitName;
private String equList;
private String equCategory;
private String equDefine;
/**
* 是否车用气瓶
*/
private String whetherVehicleCylinder;
public ShCarEquVo(ShCarEqu shCarEqu) { public ShCarEquVo(ShCarEqu shCarEqu) {
this.setSequenceNbr(shCarEqu.getSequenceNbr()); this.setSequenceNbr(shCarEqu.getSequenceNbr());
......
...@@ -17,6 +17,7 @@ import org.typroject.tyboot.component.event.RestEventTrigger; ...@@ -17,6 +17,7 @@ import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -124,10 +125,12 @@ public class JgChangeVehicleRegistrationUnitController extends BaseController { ...@@ -124,10 +125,12 @@ public class JgChangeVehicleRegistrationUnitController extends BaseController {
public ResponseModel<Page<JgUseRegistrationManageDto>> getUseRegistrationCodeData( public ResponseModel<Page<JgUseRegistrationManageDto>> getUseRegistrationCodeData(
@RequestParam(value = "current") int current, @RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "size") int size,
@RequestParam(value = "useUnitCreditCode") String useUnitCreditCode, @RequestParam(value = "useUnitCreditCode", required = false) String useUnitCreditCode,
@RequestParam(value = "whetherVehicleCylinder") String whetherVehicleCylinder, @RequestParam(value = "whetherVehicleCylinder") String whetherVehicleCylinder,
@RequestParam(value = "certificateStatus") String certificateStatus, @RequestParam(value = "certificateStatus") String certificateStatus,
@RequestParam(value = "useRegistrationCode", required = false) String useRegistrationCode) { @RequestParam(value = "useRegistrationCode", required = false) String useRegistrationCode) {
if (ValidationUtil.isEmpty(useUnitCreditCode))
throw new BadRequest("请先选择原使用单位");
JgUseRegistrationManageDto dto = new JgUseRegistrationManageDto(); JgUseRegistrationManageDto dto = new JgUseRegistrationManageDto();
Page<JgUseRegistrationManageDto> page = new Page<JgUseRegistrationManageDto>(); Page<JgUseRegistrationManageDto> page = new Page<JgUseRegistrationManageDto>();
page.setCurrent(current); page.setCurrent(current);
......
...@@ -206,7 +206,8 @@ public class ShCarController extends BaseController { ...@@ -206,7 +206,8 @@ public class ShCarController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "认领三环系统数据", notes = "认领三环系统数据") @ApiOperation(httpMethod = "POST", value = "认领三环系统数据", notes = "认领三环系统数据")
@PostMapping(value = "/claim") @PostMapping(value = "/claim")
public ResponseModel<Boolean> claim(@RequestBody Map<String, Object> paramMap) { public ResponseModel<Boolean> claim(@RequestParam(value = "claimOneself",defaultValue = "true")String claimOneself,
return ResponseHelper.buildResponse(shCarServiceImpl.claim(paramMap)); @RequestBody Map<String, Object> paramMap) {
return ResponseHelper.buildResponse(shCarServiceImpl.claim(claimOneself,paramMap));
} }
} }
...@@ -19,6 +19,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -19,6 +19,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
...@@ -120,8 +121,9 @@ public class ShCarEquController extends BaseController { ...@@ -120,8 +121,9 @@ public class ShCarEquController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "汽车详细信息列表", notes = "汽车详细信息列表") @ApiOperation(httpMethod = "GET",value = "汽车详细信息列表", notes = "汽车详细信息列表")
@GetMapping(value = "/selectByCarId") @GetMapping(value = "/selectByCarId")
public ResponseModel<CarAndEquVo> selectByCarId(@RequestParam String carId) { public ResponseModel<Map<String,Object>> selectByCarId(@RequestParam(value = "carId") String carId,
@RequestParam(value = "claimOneself") String claimOneself) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(shCarEquServiceImpl.queryByCarId(carId,reginParams)); return ResponseHelper.buildResponse(shCarEquServiceImpl.queryByCarId(carId,claimOneself,reginParams));
} }
} }
...@@ -788,6 +788,11 @@ public class CommonServiceImpl implements ICommonService { ...@@ -788,6 +788,11 @@ public class CommonServiceImpl implements ICommonService {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues("OLD_INSTALLATION_UNIT").getResult(); List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues("OLD_INSTALLATION_UNIT").getResult();
result.forEach(x -> convertAndAddToUnitList(x, unitList)); result.forEach(x -> convertAndAddToUnitList(x, unitList));
} }
// 使用单位追加 三环认领的(业主可能未注册系统,别人帮忙认领的,帮忙认领后会保存一份原使用单位的数据到字典)
if ("使用单位".equals(type)) {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues("OLD_USE_UNIT").getResult();
result.forEach(x -> convertAndAddToUnitList(x, unitList));
}
List<Map<String, Object>> unitListByType = commonMapper.getUnitListByType(type); List<Map<String, Object>> unitListByType = commonMapper.getUnitListByType(type);
unitList.addAll(unitListByType); unitList.addAll(unitListByType);
return unitList; return unitList;
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; 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.dto.ShCarDto;
...@@ -13,11 +15,14 @@ import com.yeejoin.amos.boot.module.jg.api.vo.ShCarEquVo; ...@@ -13,11 +15,14 @@ import com.yeejoin.amos.boot.module.jg.api.vo.ShCarEquVo;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -49,7 +54,8 @@ public class ShCarEquServiceImpl extends BaseService<ShCarEqu, ShCarEqu, ShCarEq ...@@ -49,7 +54,8 @@ public class ShCarEquServiceImpl extends BaseService<ShCarEqu, ShCarEqu, ShCarEq
return this.queryForList("", false); return this.queryForList("", false);
} }
public CarAndEquVo queryByCarId(String carId, ReginParams reginParams) { public Map<String,Object> queryByCarId(String carId,String claimOneself, ReginParams reginParams) {
Map<String,Object> result = new HashMap<String,Object>();
// 根据carId获取Car // 根据carId获取Car
LambdaQueryWrapper<ShCar> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ShCar> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(ShCar::getSequenceNbr, carId); queryWrapper1.eq(ShCar::getSequenceNbr, carId);
...@@ -60,33 +66,97 @@ public class ShCarEquServiceImpl extends BaseService<ShCarEqu, ShCarEqu, ShCarEq ...@@ -60,33 +66,97 @@ public class ShCarEquServiceImpl extends BaseService<ShCarEqu, ShCarEqu, ShCarEq
String companyType = reginParams.getCompany().getCompanyType(); String companyType = reginParams.getCompany().getCompanyType();
AgencyUserModel userModel = reginParams.getUserModel(); AgencyUserModel userModel = reginParams.getUserModel();
shCarDto.setCompanyType(companyType); shCarDto.setCompanyType(companyType);
shCarDto.setUseUnitName(reginParams.getCompany().getCompanyName());
shCarDto.setUseUnitCreditCode(reginParams.getCompany().getCompanyCode());
String[] code = reginParams.getCompany().getCompanyCode().split("_"); String[] code = reginParams.getCompany().getCompanyCode().split("_");
String useUnitCode = code.length > 1 ? code[1] : code[0]; String useUnitCode = code.length > 1 ? code[1] : code[0];
if ("个人主体".equals(companyType)) { if ("true".equals(claimOneself)){//认领自己的
shCarDto.setUseUnitAddress((String) commonService.getEnterpriseInfo(useUnitCode).get("address")); shCarDto.setUseUnitName(reginParams.getCompany().getCompanyName());
} else { shCarDto.setUseUnitCreditCode(reginParams.getCompany().getCompanyCode());
shCarDto.setUseUnitAddress(reginParams.getCompany().getAddress()); if ("个人主体".equals(companyType)) {
shCarDto.setUseUnitAddress((String) commonService.getEnterpriseInfo(useUnitCode).get("address"));
} else {
shCarDto.setUseUnitAddress(reginParams.getCompany().getAddress());
}
}
if ("false".equals(claimOneself)){//帮别人认领 取 原三环数据填充表单
shCarDto.setUseUnitName(shCar.getOwner());
shCarDto.setUseUnitCreditCode(shCar.getOwner());
shCarDto.setUseUnitAddress(shCar.getAddress());
} }
shCarDto.setSafetyManagerId("个人主体".equals(companyType) ? userModel.getRealName() : null); shCarDto.setSafetyManagerId("个人主体".equals(companyType) ? userModel.getRealName() : null);
shCarDto.setPhone("个人主体".equals(companyType) ? userModel.getMobile() : null); shCarDto.setPhone("个人主体".equals(companyType) ? userModel.getMobile() : null);
if (!ValidationUtil.isEmpty(shCarDto.getVehicleAttribute())){
switch (shCarDto.getVehicleAttribute()) {
case "A":
shCarDto.setVehicleAttribute("PRIVATE_CAR");
break;
case "B":
shCarDto.setVehicleAttribute("BUS");
break;
case "H":
shCarDto.setVehicleAttribute("SERVICE_VEHICLE");
break;
case "P":
shCarDto.setVehicleAttribute("SERVICE_CAR");
break;
case "V":
shCarDto.setVehicleAttribute("MINIVAN");
break;
case "X":
shCarDto.setVehicleAttribute("OTHER");
break;
case "T":
shCarDto.setVehicleAttribute("TAXI");
break;
case "J":
shCarDto.setVehicleAttribute("TRAINING_CAR");
break;
default:
shCarDto.setVehicleAttribute("OTHER");
}
}
if("原车".equals(shCarDto.getCylinderInstallationMethod())){
shCarDto.setCylinderInstallationMethod("ORIGINAL_CAR");
}else if("加装".equals(shCarDto.getCylinderInstallationMethod())){
shCarDto.setCylinderInstallationMethod("RELOADING");
}
// 根据carId获取设备列表 // 根据carId获取设备列表
LambdaQueryWrapper<ShCarEqu> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ShCarEqu> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShCarEqu::getCarId, carId); queryWrapper.eq(ShCarEqu::getCarId, carId);
List<ShCarEqu> list = this.list(queryWrapper); List<ShCarEqu> list = this.list(queryWrapper);
// 将设备列表转换为前端可识别bean // 将设备列表转换为前端可识别bean
List<ShCarEquVo> collect = list.stream() List<ShCarEquVo> collect = list.stream().map(shCarEqu -> {
.map(shCarEqu -> { ShCarEquVo shCarEquVo = new ShCarEquVo(shCarEqu);
ShCarEquVo shCarEquVo = new ShCarEquVo(shCarEqu); shCarEquVo.setWhetherVehicleCylinder("1");
shCarEquVo.setUseInnerCode(shCarDto.getCarNumber()); shCarEquVo.setEquList("2000");
shCarEquVo.setEquType(shCarEqu.getSequenceCode()); shCarEquVo.setEquCategory("2300");
return shCarEquVo; shCarEquVo.setEquDefine("23T0");
}) return shCarEquVo;
.collect(Collectors.toList()); }).collect(Collectors.toList());
// 封装返回VO // 封装返回VO
return new CarAndEquVo(shCarDto, collect); HashMap<String ,Object> hashMap = JSONObject.parseObject(JSON.toJSONString(shCarDto), HashMap.class);
hashMap.put("equList", collect);
result.put("completeDataSanHuan", hashMap);
// 帮别人认领 + 单位变更给自己
if ("false".equals(claimOneself)){
HashMap<String, Object> gasCylinderChangeObj = new HashMap<>();
if ("个人主体".equals(companyType)) {
String[] companyName = reginParams.getCompany().getCompanyName().split("_");
String newUseUnitCreditCodeStr = companyName.length > 1 ? companyName[1] : companyName[0];
gasCylinderChangeObj.put("newUseUnitCreditCode", newUseUnitCreditCodeStr);// 使用单位
gasCylinderChangeObj.put("address",commonService.getEnterpriseInfo(useUnitCode).get("address"));
gasCylinderChangeObj.put("companyType", "person");
} else {
gasCylinderChangeObj.put("newUseUnitCreditCode", reginParams.getCompany().getCompanyName());// 使用单位
gasCylinderChangeObj.put("address",commonService.getEnterpriseInfo(reginParams.getCompany().getCompanyCode()).get("address"));
gasCylinderChangeObj.put("companyType", "company");
}
gasCylinderChangeObj.put("useRegistrationCode",shCarDto.getUseRegistrationCode());
gasCylinderChangeObj.put("carNumber",shCarDto.getCarNumber());
result.put("gasCylinderChange",gasCylinderChangeObj);
}
return result;
} }
......
...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON; ...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
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.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
...@@ -21,24 +22,23 @@ import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum; ...@@ -21,24 +22,23 @@ 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.mapper.ShCarMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IShCarService; 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.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.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.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -99,6 +99,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -99,6 +99,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
@Resource @Resource
private JgUseRegistrationManageServiceImpl useRegistrationManageService; private JgUseRegistrationManageServiceImpl useRegistrationManageService;
@Resource @Resource
private JgChangeVehicleRegistrationUnitServiceImpl changeVehicleRegistrationUnitService;
@Resource
private JgCertificateChangeRecordServiceImpl certificateChangeRecordService; private JgCertificateChangeRecordServiceImpl certificateChangeRecordService;
@Resource @Resource
private JgCertificateChangeRecordEqServiceImpl certificateChangeRecordEqService; private JgCertificateChangeRecordEqServiceImpl certificateChangeRecordEqService;
...@@ -187,10 +189,75 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -187,10 +189,75 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
return this.baseMapper.alreadyExist(value) > 0; return this.baseMapper.alreadyExist(value) > 0;
} }
public static void main(String[] args) {
System.out.println(Boolean.parseBoolean("false"));
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean claim(Map<String, Object> paramMap) { public Boolean claim(String claimOneself, Map<String, Object> paramMap) {
List<String> records = new ArrayList<>();
try {
boolean isOneSelf = Boolean.parseBoolean(claimOneself);
HashMap<Object, Object> completeDataSanHuanMap = JSON.parseObject(toJSONString(paramMap.get("completeDataSanHuan")), HashMap.class);
// 自己认领
if (isOneSelf) {
records = this.claimOneselfMet(isOneSelf, completeDataSanHuanMap);
}
// 帮别人认领 + 单位变更登记到自己名下
if (!isOneSelf) {
HashMap<String, Object> gasCylinderChangeMap = JSON.parseObject(toJSONString(paramMap.get("gasCylinderChange")), HashMap.class);
this.claimOthersMet(isOneSelf, completeDataSanHuanMap, gasCylinderChangeMap);
}
} catch (Exception exception) {
this.handleClaimFailed(records);
throw new BadRequest(exception.getMessage());
}
return Boolean.TRUE;
}
/**
* 帮别人认领 + 单位变更登记到自己名下
*
* @param completeDataSanHuanMap 认领表单信息
* @param gasCylinderChangeMap 车用气瓶单位变更登记表单信息
* @return result
*/
private Boolean claimOthersMet(Boolean isOneSelf, HashMap<?, ?> completeDataSanHuanMap, HashMap<String, Object> gasCylinderChangeMap) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// 认领设备及证管理信息完善
List<String> records = this.claimOneselfMet(isOneSelf, completeDataSanHuanMap);
// 发起车用气瓶单位变更登记
List<Map<String, Object>> equList = changeVehicleRegistrationUnitService.getBaseMapper().getEquList(records)
.stream()
.peek(x -> x.put("carNumber", completeDataSanHuanMap.get("carNumber")))
.collect(Collectors.toList());
gasCylinderChangeMap.put("useUnitCreditCode", String.format("%s_%s", completeDataSanHuanMap.get("useUnitName"), completeDataSanHuanMap.get("useUnitCreditCode")));
gasCylinderChangeMap.put("dataList", equList);
gasCylinderChangeMap.put("submit", "1");
gasCylinderChangeMap.put("formType", "add");
gasCylinderChangeMap.put("businessCode", ApplicationFormTypeEnum.DWBG.getBusinessCode());
gasCylinderChangeMap.put("receiveOrgCode", gasCylinderChangeMap.get("receiveOrgCode"));
gasCylinderChangeMap.put("receiveCompanyCode", gasCylinderChangeMap.get("receiveOrgCode"));
changeVehicleRegistrationUnitService.saveMessage(new JSONObject(gasCylinderChangeMap), reginParams);
// 保存字典值 原三环使用单位
DictionarieValueModel dictionarieValueModel = new DictionarieValueModel();
dictionarieValueModel.setDictCode("OLD_USE_UNIT");
dictionarieValueModel.setDictDataValue((String) completeDataSanHuanMap.get("useUnitCreditCode"));
dictionarieValueModel.setDictDataKey((String) completeDataSanHuanMap.get("useUnitName"));
Systemctl.dictionarieClient.createValue(dictionarieValueModel);
return Boolean.TRUE;
}
/**
* 认领 设备 证 。。。
*
* @param isOneSelf 是否自己认领
* @param paramMap 入参
* @return 设备record集合
*/
private List<String> claimOneselfMet(Boolean isOneSelf, Map<?, ?> paramMap) {
// ShCar表的seq // ShCar表的seq
String shCarSequenceNbr = String.valueOf(paramMap.get("sequenceNbr")); String shCarSequenceNbr = String.valueOf(paramMap.get("sequenceNbr"));
if (ValidationUtil.isEmpty(shCarSequenceNbr)) { if (ValidationUtil.isEmpty(shCarSequenceNbr)) {
...@@ -220,6 +287,19 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -220,6 +287,19 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
throw new BadRequest("设备代码已存在系统中!"); throw new BadRequest("设备代码已存在系统中!");
} }
}); });
// 0.3 出厂编号/产品编号的唯一校验
Set<String> factoryNumSet = equList.stream().map(equ -> {
JSONObject jsonObject = JSON.parseObject(toJSONString(equ));
return jsonObject.getString("factoryNum");
}).collect(Collectors.toSet());
if (factoryNumSet.size() < equList.size())
throw new BadRequest("出厂编号/产品编码重复!");
factoryNumSet.forEach(factoryNum -> {
Integer useFlag = commonService.checkFactoryNumUniquenessForVehicleCylinder(factoryNum, null);
if (useFlag > 0) {
throw new BadRequest("出厂编号/产品编码已存在系统中!");
}
});
try { try {
...@@ -227,28 +307,24 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -227,28 +307,24 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
paramMap.remove("sequenceNbr"); paramMap.remove("sequenceNbr");
// 1. 生成设备信息 + 保存es // 1. 生成设备信息 + 保存es
this.claimGenEquInfo(useRegistrationCode, paramMap, equList, reginParams); this.claimGenEquInfo(useRegistrationCode, paramMap, equList, reginParams, isOneSelf);
// 2. 生成车用气瓶使用登记证单据( JgVehicleInformation JgVehicleInformationEq )信息 // 2. 生成车用气瓶使用登记证单据( JgVehicleInformation JgVehicleInformationEq )信息
JgVehicleInformation jgVehicleInformation = this.claimGenVehicleInfoAbout(paramMap, equList, reginParams); JgVehicleInformation jgVehicleInformation = this.claimGenVehicleInfoAbout(paramMap, equList, reginParams, isOneSelf);
// 3. 生成 使用登记证管理表信息(JgUseRegistrationManage )证变更记录表信息 (JgCertificateChangeRecord)证变更记录对应设备表信息 (JgCertificateChangeRecordEq) // 3. 生成 使用登记证管理表信息(JgUseRegistrationManage )证变更记录表信息 (JgCertificateChangeRecord)证变更记录对应设备表信息 (JgCertificateChangeRecordEq)
this.claimGenCertificateManageAndChange(jgVehicleInformation, equList); this.claimGenCertificateManageAndChange(jgVehicleInformation, equList, reginParams, isOneSelf);
// 4. 修改三环车辆表的认领状态为已认领 // 4. 修改三环车辆表的认领状态为已认领
ShCar shCar = ShCar.builder().claimedFlag("1").build(); ShCar shCar = ShCar.builder().claimedFlag("1").build();
shCar.setSequenceNbr(shCarSequenceNbr); shCar.setSequenceNbr(shCarSequenceNbr);
this.baseMapper.updateById(shCar); this.baseMapper.updateById(shCar);
return equList.stream().map(x -> (String) JSON.parseObject(toJSONString(x)).get("record")).collect(Collectors.toList());
return Boolean.TRUE;
} catch (Exception e) { } catch (Exception e) {
log.error("三环系统数据认领失败,使用登记证代码:{}", paramMap.get("useRegistrationCode")); log.error("三环系统数据认领失败,使用登记证代码:{}", paramMap.get("useRegistrationCode"));
log.error("失败原因:{}", e.getMessage()); log.error("失败原因:{}", e.getMessage());
this.handleClaimFailed(equList);
throw new BadRequest("认领时出现异常,请联系管理员!"); throw new BadRequest("认领时出现异常,请联系管理员!");
} }
} }
/** /**
...@@ -257,10 +333,12 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -257,10 +333,12 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
* @param jgVehicleInformation 车用气瓶使用登记证单据 * @param jgVehicleInformation 车用气瓶使用登记证单据
* @param equList 设备集合 * @param equList 设备集合
*/ */
private void claimGenCertificateManageAndChange(JgVehicleInformation jgVehicleInformation, JSONArray equList) { private void claimGenCertificateManageAndChange(JgVehicleInformation jgVehicleInformation, JSONArray equList, ReginParams reginParams, Boolean isOneSelf) {
AgencyUserModel result = Privilege.agencyUserClient.queryByUserId(RequestContext.getExeUserId()).getResult(); AgencyUserModel result = Privilege.agencyUserClient.queryByUserId(RequestContext.getExeUserId()).getResult();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
String changeContent = jgVehicleInformation.getUseUnitName() + "的" + result.getRealName() + "办理了【" + BusinessTypeEnum.JG_VEHICLE_GAS_APPLICATION.getName() + "】," + "单号【" + jgVehicleInformation.getApplyNo() + "】,申请日期" + simpleDateFormat.format(new Date()); String actor = isOneSelf ? jgVehicleInformation.getUseUnitName() + "的" + result.getRealName() + "办理了"
: reginParams.getCompany().getCompanyName() + "的" + reginParams.getUserModel().getRealName() + "认领了原三环系统中原" + jgVehicleInformation.getUseUnitName() + "的设备,并办理了";
String changeContent = actor + "【" + BusinessTypeEnum.JG_VEHICLE_GAS_APPLICATION.getName() + "】," + "单号【" + jgVehicleInformation.getApplyNo() + "】,申请日期" + simpleDateFormat.format(new Date());
// 3.1 生成使用登记证管理表信息(JgUseRegistrationManage ) // 3.1 生成使用登记证管理表信息(JgUseRegistrationManage )
Map<String, String> equType = new HashMap<>(); Map<String, String> equType = new HashMap<>();
...@@ -336,7 +414,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -336,7 +414,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
* *
* @param equList 设备集合 * @param equList 设备集合
*/ */
public void claimGenEquInfo(String useRegistrationCode, Map<String, Object> paramMap, JSONArray equList, ReginParams reginParams) { public void claimGenEquInfo(String useRegistrationCode, Map<?, ?> paramMap, JSONArray equList, ReginParams reginParams, Boolean isOneSelf) {
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
// 保存设备后 后续业务需要的设备信息 // 保存设备后 后续业务需要的设备信息
for (int i = 0; i < equList.size(); i++) { for (int i = 0; i < equList.size(); i++) {
...@@ -356,12 +434,17 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -356,12 +434,17 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
useInfo.setDataSource("jg_his_sh"); useInfo.setDataSource("jg_his_sh");
useInfo.setIsIntoManagement(Boolean.TRUE); useInfo.setIsIntoManagement(Boolean.TRUE);
useInfo.setEquState("1"); useInfo.setEquState("1");
if (CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType())) { if (isOneSelf) {
useInfo.setUseUnitName(company.getCompanyName().split("_")[1]); if (CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType())) {
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]); useInfo.setUseUnitName(company.getCompanyName().split("_")[1]);
useInfo.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
} else {
useInfo.setUseUnitName(company.getCompanyName());
useInfo.setUseUnitCreditCode(company.getCompanyCode());
}
} else { } else {
useInfo.setUseUnitName(company.getCompanyName()); useInfo.setUseUnitName((String) paramMap.get("useUnitName"));
useInfo.setUseUnitCreditCode(company.getCompanyCode()); useInfo.setUseUnitCreditCode((String) paramMap.get("useUnitCreditCode"));
} }
useInfo.setORegUnit((String) paramMap.get("oRegUnit")); useInfo.setORegUnit((String) paramMap.get("oRegUnit"));
useInfo.setORegDate((String) paramMap.get("oRegDate")); useInfo.setORegDate((String) paramMap.get("oRegDate"));
...@@ -466,7 +549,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -466,7 +549,7 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
* @param equList 设备集合 * @param equList 设备集合
* @return 车用气瓶使用登记证单据 * @return 车用气瓶使用登记证单据
*/ */
public JgVehicleInformation claimGenVehicleInfoAbout(Map<String, Object> paramMap, JSONArray equList, ReginParams reginParams) { public JgVehicleInformation claimGenVehicleInfoAbout(Map<?, ?> paramMap, JSONArray equList, ReginParams reginParams, Boolean isOneSelf) {
// 车用气瓶登记表seq // 车用气瓶登记表seq
Long vehicleInformationSeq = sequence.nextId(); Long vehicleInformationSeq = sequence.nextId();
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
...@@ -483,13 +566,19 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -483,13 +566,19 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
vehicleInformation.setSequenceNbr(vehicleInformationSeq); vehicleInformation.setSequenceNbr(vehicleInformationSeq);
vehicleInformation.setApplyNo(applyNo); vehicleInformation.setApplyNo(applyNo);
// 使用单位信息 // 使用单位信息
if (CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType())) { if (isOneSelf) {
vehicleInformation.setUseUnitName(company.getCompanyName().split("_")[1]); if (CompanyTypeEnum.INDIVIDUAL.getName().equals(company.getCompanyType())) {
vehicleInformation.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]); vehicleInformation.setUseUnitName(company.getCompanyName().split("_")[1]);
vehicleInformation.setUseUnitCreditCode(company.getCompanyCode().split("_")[1]);
} else {
vehicleInformation.setUseUnitName(company.getCompanyName());
vehicleInformation.setUseUnitCreditCode(company.getCompanyCode());
}
} else { } else {
vehicleInformation.setUseUnitName(company.getCompanyName()); vehicleInformation.setUseUnitName((String) paramMap.get("useUnitName"));
vehicleInformation.setUseUnitCreditCode(company.getCompanyCode()); vehicleInformation.setUseUnitCreditCode((String) paramMap.get("useUnitCreditCode"));
} }
// 接收单位信息 // 接收单位信息
if (!StringUtils.isEmpty(vehicleInformation.getReceiveOrgCode())) { if (!StringUtils.isEmpty(vehicleInformation.getReceiveOrgCode())) {
String[] splitReceiveOrgCode = vehicleInformation.getReceiveOrgCode().split("_"); String[] splitReceiveOrgCode = vehicleInformation.getReceiveOrgCode().split("_");
...@@ -558,10 +647,9 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -558,10 +647,9 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
/** /**
* 认领过程中报错,回滚第一步的es数据 * 认领过程中报错,回滚第一步的es数据
*/ */
public void handleClaimFailed(JSONArray equList) { public void handleClaimFailed(List<String> records) {
if (!equList.isEmpty()) { if (!records.isEmpty()) {
equList.forEach(equ -> { records.forEach(record -> {
String record = JSON.parseObject(toJSONString(equ)).getString("record");
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(record); Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(record);
if (!ObjectUtils.isEmpty(data)) { if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(record); esEquipmentCategory.deleteById(record);
......
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