Commit 4e2d1c0a authored by 韩桐桐's avatar 韩桐桐

fix(openapi/jg):西安数据对接接口调整

parent 03202891
......@@ -44,7 +44,7 @@ public class OpenApiControllerAop {
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany","/bizToken/applyToken",
"/openapi/bizToken/getAppId","/lift/upload","/lift/status","/lift/run","/lift/fault",
"/lift/video/preview","/cylinderPage/serviceProvider","/cylinderPage/getTableInfo",
"/cylinderPage/initCylinderNum","/openapi/appId/setAppId","/openapi/xi-an/importData"};
"/cylinderPage/initCylinderNum","/openapi/appId/setAppId"};
// 获取请求路径
for(String uri : url) {
if(request.getRequestURI().indexOf(uri) != -1) {
......
......@@ -26,15 +26,12 @@ public class XiAnDataDockController {
}
/**
* 批量导入设备数据的接口
*
* @param file 上传的文件
* @return ResponseModel 封装的响应数据
* 西安除电梯外七大类设备批量导入
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/importData")
@ApiOperation(httpMethod = "POST", value = "设备批量导入", notes = "导入多个设备的数据文件")
public Object importPressureData(@RequestParam("file") MultipartFile file) {
@ApiOperation(httpMethod = "POST", value = "西安除电梯外七大类设备批量导入", notes = "西安除电梯外七大类设备批量导入")
public Object importPressureData(@RequestParam MultipartFile file) {
// 校验文件是否为空
if (file.isEmpty()) {
return ResponseHelper.buildResponse("文件不能为空");
......
......@@ -71,6 +71,10 @@ public class DictParamsConverter implements Converter<String> {
dictMap.put("GC1", "6002");
dictMap.put("GC2", "6003");
dictMap.put("GC3", "6004");
dictMap.put("压缩天然气", "COMPRESSED_NATURAL_GAS");
dictMap.put("液化天然气", "LIQUEFIED_NATURAL_GAS");
dictMap.put("液化石油气", "LIQUEFIED_PETROLEUM_GAS");
dictMap.put("氢气", "HYDROGEN");
}
@Override
......
......@@ -254,11 +254,11 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ExcelProperty(value = "额定乘员数(人)")
@ApiModelProperty(value = "额定乘员数(人)")
private String aa;
private String ratedMembers;
@ExcelProperty(value = "额定提升速度(m/min)")
@ApiModelProperty(value = "额定提升速度(m/min)")
private String ratedMembers;
private String ratedLiftingSpeed;
@ExcelProperty(value = "自由端高度(m)")
@ApiModelProperty(value = "自由端高度(m)")
......@@ -565,7 +565,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "单瓶容积(L)")
private String singleBottleVolume;
@ExcelProperty(value = "充装介质")
@ExcelProperty(value = "充装介质",converter = DictParamsConverter.class)
@ApiModelProperty(value = "充装介质")
private String chargingMedium;
......
......@@ -14,7 +14,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
@FeignClient(name = "TZS-JG-htt", path = "/jg", configuration = {FeignConfiguration.class})
@FeignClient(name = "TZS-JG", path = "/jg", configuration = {FeignConfiguration.class})
public interface TzsJgServiceFeignClient {
/**
......@@ -100,6 +100,6 @@ public interface TzsJgServiceFeignClient {
* @param factoryNum
* @return
*/
@RequestMapping(value = "/common/checkEquCodeUniqueness", method = RequestMethod.GET)
@RequestMapping(value = "/common/checkFactoryNumUniquenessForVehicleCylinder", method = RequestMethod.GET)
Integer checkFactoryNumUniquenessForVehicleCylinder(@RequestParam("factoryNum") String factoryNum);
}
......@@ -18,6 +18,7 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -78,11 +79,19 @@ public class XiAnDataDockServiceImpl {
public void batchSaveEquipmentData(List<XiAnEquipInfoExcelDto> equipInfoExcelDtos) {
int batchSize = 1000;
int totalSize = equipInfoExcelDtos.size();
// 主线程中获取登录信息传递到异步线程中
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
String token = RequestContext.getToken();
List<CompletableFuture<Void>> futures = new ArrayList<>();
for (int i = 0; i < totalSize; i += batchSize) {
List<XiAnEquipInfoExcelDto> batch = equipInfoExcelDtos.subList(i, Math.min(totalSize, i + batchSize));
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
try {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
jgServiceFeignClient.saveEquipmentData(batch);
} catch (Exception e) {
log.error("西安数据上传,保存设备数据失败: ", e);
......@@ -192,8 +201,10 @@ public class XiAnDataDockServiceImpl {
try {
log.info("解析第{}行数据:{}", rowIndex, JSON.toJSONString(data));
// 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息
this.commonFieldCheck(data, rowError);
// 起重机械----技术参数 检查
if (isQZJX) {
this.QZJXTechnicalParamsCheck(data, rowError);
......@@ -296,31 +307,51 @@ public class XiAnDataDockServiceImpl {
boolean isGasCylinder = !ObjectUtils.isEmpty(data.getEquCategory()) && "2300".equals(data.getEquCategory());// 是否气瓶
boolean isFixedGasCylinder = !ObjectUtils.isEmpty(data.getEquCategory()) && "2100".equals(data.getEquCategory());//是否固定式压力容器
boolean isOxygenChamber = !ObjectUtils.isEmpty(data.getEquCategory()) && "2400".equals(data.getEquCategory());//是否氧舱
boolean isMobilePressureVessel = !ObjectUtils.isEmpty(data.getEquCategory()) && "2100".equals(data.getEquCategory());//是否移动式压力容器
boolean isMobilePressureVessel = !ObjectUtils.isEmpty(data.getEquCategory()) && "2200".equals(data.getEquCategory());//是否移动式压力容器
boolean isSpecialGasCylinder = isGasCylinder && !ObjectUtils.isEmpty(data.getEquDefine()) && "23T0".equals(data.getEquDefine());// 是否特种气瓶
boolean isCarGasCylinder = isSpecialGasCylinder && (ObjectUtils.isEmpty(data.getWhetherVehicleCylinder()) && "1".equals(data.getWhetherVehicleCylinder()));// 是否车用气瓶
if (isGasCylinder) {
// 不是车用气瓶
if (!isCarGasCylinder) {
boolean isCarGasCylinder = isSpecialGasCylinder && (!ObjectUtils.isEmpty(data.getWhetherVehicleCylinder()) && "1".equals(data.getWhetherVehicleCylinder()));// 是否车用气瓶
if (isGasCylinder) { // 是气瓶
if (!isSpecialGasCylinder) { // 不是特种气瓶
data.setWhetherVehicleCylinder("");
data.setWhetherSphericalTank("");
checkNotBlank(data.getInformationSituation(), "信息化管理情况不能为空;", rowError);
if (!ObjectUtils.isEmpty(data.getInformationSituation())) {
checkNotBlank(data.getInformationManageCode(), "二维码或者电子标签编号不能为空;", rowError);
}
}
if (isSpecialGasCylinder) {
if (isSpecialGasCylinder) { // 是特种气瓶
checkNotBlank(data.getWhetherVehicleCylinder(), "是否车用气瓶不能为空;", rowError);
if (!isCarGasCylinder) {// 不是车用气瓶
checkNotBlank(data.getInformationSituation(), "信息化管理情况不能为空;", rowError);
if (!ObjectUtils.isEmpty(data.getInformationSituation())) {
checkNotBlank(data.getInformationManageCode(), "二维码或者电子标签编号不能为空;", rowError);
}
}
if (isCarGasCylinder) { // 是车用气瓶
data.setInformationSituation("");
data.setInformationManageCode("");
checkFactoryNumUniqueness(data, rowError);// 校验出厂编号/产品编码唯一性
}
}
}
if (isFixedGasCylinder) {
if (isFixedGasCylinder) { // 是固定式压力容器
checkNotBlank(data.getWhetherSphericalTank(), "是否球罐不能为空;", rowError);
data.setWhetherSkidMountedPressureVessel("0");
data.setInformationSituation("");
data.setInformationManageCode("");
}
// 是车用气瓶 或者 是氧舱 或者 是固定式压力容器 或者 是移动式压力容器
if (isCarGasCylinder || isOxygenChamber || isMobilePressureVessel || isFixedGasCylinder) {
if (isMobilePressureVessel) {// 是移动式压力容器
data.setWhetherVehicleCylinder("");
data.setWhetherSphericalTank("");
data.setInformationSituation("");
data.setInformationManageCode("");
}
if (isOxygenChamber) {//是氧舱
data.setWhetherVehicleCylinder("");
data.setWhetherSphericalTank("");
data.setInformationSituation("");
data.setInformationManageCode("");
}
checkFactoryNumUniqueness(isCarGasCylinder, data, rowError);
}
// 使用信息
checkNotBlank(data.getUseUnitCode(), "使用单位统一社会信用代码不能为空;", rowError);
......@@ -390,14 +421,12 @@ public class XiAnDataDockServiceImpl {
*
* @param data
*/
private void checkFactoryNumUniqueness(boolean isCarGasCylinder, XiAnEquipInfoExcelDto data, StringBuilder rowError) {
if (isCarGasCylinder) {
// 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
if (jgServiceFeignClient.checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum()) > 0) {
private void checkFactoryNumUniqueness(XiAnEquipInfoExcelDto data, StringBuilder rowError) {
Integer count = jgServiceFeignClient.checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum());
if (count > 0) {
rowError.append("出厂编号/产品编码系统中已存在!");
}
}
}
/**
* 根据设备代码检查唯一性
......@@ -419,7 +448,6 @@ public class XiAnDataDockServiceImpl {
* @param rowError
*/
private void QZJXTechnicalParamsCheck(XiAnEquipInfoExcelDto data, StringBuilder rowError) {
}
/**
......
......@@ -627,14 +627,14 @@ public class CommonController extends BaseController {
return ResponseHelper.buildResponse(commonService.getLatestJgUseRegistrationManage(company.getCompanyCode(), equDefineCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/checkEquCodeUniqueness")
@ApiOperation(httpMethod = "GET", value = "检查设备代码的唯一性", notes = "检查设备代码的唯一性")
public Boolean checkEquCodeUniqueness(@RequestParam("equCode") String equCode) {
return commonService.checkEquCodeUniqueness(equCode);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/checkFactoryNumUniquenessForVehicleCylinder")
@ApiOperation(httpMethod = "GET", value = "车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)", notes = "车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)")
public Integer checkFactoryNumUniquenessForVehicleCylinder(@RequestParam("factoryNum") String factoryNum) {
......
......@@ -32,10 +32,10 @@ public class XiAnDataDockController {
* @param equLists 设备数据集合
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/saveEquipmentData")
@ApiOperation(httpMethod = "POST", value = "设备批量导入", notes = "导入多个设备的数据文件")
public ResponseModel<?> saveEquipmentData(@RequestBody List<Map<?,?>> equLists) {
public ResponseModel<?> saveEquipmentData(@RequestBody List<Map<?,?>> equLists) throws Exception {
return ResponseHelper.buildResponse(xiAnDataDockService.saveEquipmentData(equLists));
}
}
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
......@@ -31,8 +31,6 @@ import static com.alibaba.fastjson.JSON.toJSONString;
public class XiAnDataDockServiceImpl {
@Autowired
CodeUtil codeUtil;
@Autowired
private ESEquipmentCategory esEquipmentCategory;
@Autowired
private CategoryOtherInfoMapper categoryOtherInfoMapper;
......@@ -48,20 +46,6 @@ public class XiAnDataDockServiceImpl {
private IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
private IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
// @Autowired
// private EquipTechParamLiftingMapper equipTechParamLiftingMapper;
// @Autowired
// private EquipTechParamVehicleMapper equipTechParamVehicleMapper;
// @Autowired
// private EquipTechParamBoilerMapper equipTechParamBoilerMapper;
// @Autowired
// private EquipTechParamVesselMapper equipTechParamVesselMapper;
// @Autowired
// private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
// @Autowired
// private EquipTechParamRidesMapper equipTechParamRidesMapper;
// @Autowired
// private EquipTechParamRopewayMapper equipTechParamRopewayMapper;
@Autowired
IIdxBizJgTechParamsVehicleService iIdxBizJgTechParamsVehicleService;
......@@ -102,6 +86,7 @@ public class XiAnDataDockServiceImpl {
}
private void saveEquipmentDataInTransaction(Map<?, ?> equ) {
try {
transactionTemplate.execute(status -> {
String record = UUID.randomUUID().toString();
String equList = String.valueOf(equ.get("equList"));
......@@ -118,6 +103,12 @@ public class XiAnDataDockServiceImpl {
saveEquInfoToEs(record);
return null;
});
} catch (Exception e) {
e.printStackTrace();
log.error("西安数据:保存时出现异常,对应数据:{}", JSONObject.toJSONString(equ));
log.error("异常信息:{}", e.getMessage());
log.error("异常原因:{}", e.getMessage());
}
}
/**
......
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