Commit 22fe4a13 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_tzs_register
parents 517f3745 01bec276
package com.yeejoin.amos.boot.module.jg.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class ChargingMediumConverter implements Converter<String> {
private static final Map<String, String> EXCEL_TO_JAVA_MAP = new HashMap<>();
private static final Map<String, String> JAVA_TO_EXCEL_MAP = new HashMap<>();
static {
EXCEL_TO_JAVA_MAP.put("液化天然气", "LIQUEFIED_NATURAL_GAS");
EXCEL_TO_JAVA_MAP.put("液化石油气", "LIQUEFIED_PETROLEUM_GAS");
EXCEL_TO_JAVA_MAP.put("压缩天然气", "COMPRESSED_NATURAL_GAS");
JAVA_TO_EXCEL_MAP.put("LIQUEFIED_NATURAL_GAS", "液化天然气");
JAVA_TO_EXCEL_MAP.put("LIQUEFIED_PETROLEUM_GAS", "液化石油气");
JAVA_TO_EXCEL_MAP.put("COMPRESSED_NATURAL_GAS", "压缩天然气");
}
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
return EXCEL_TO_JAVA_MAP.getOrDefault(cellData.getStringValue(), "COMPRESSED_NATURAL_GAS");
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData(JAVA_TO_EXCEL_MAP.getOrDefault(o, "压缩天然气"));
}
}
package com.yeejoin.amos.boot.module.jg.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class EquCodeTypeConverter implements Converter<String> {
private static final String HAVE = "有";
private static final String NOT = "无";
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (HAVE.equals(cellValue)) {
return "1";
} else if (NOT.equals(cellValue)) {
return "2";
}
return null;
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("1")) {
return new CellData(HAVE);
} else if (o.equals("2")) {
return new CellData(NOT);
}
return new CellData("");
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class ImportedConverter implements Converter<String> {
private static final String WHETHER = "是";
private static final String NOT = "否";
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
// Excel中对应的CellData属性类型
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (WHETHER.equals(cellValue)) {
return "1";
} else if (NOT.equals(cellValue)) {
return "0";
}
return null;
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("1")) {
return new CellData(WHETHER);
} else if (o.equals("0")) {
return new CellData(NOT);
}
return new CellData("");
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class NondestructConverter implements Converter<String> {
private static final String CI_FEN = "磁粉";
private static final String SHE_XIAN = "射线";
private static final String CHAO_SENG = "超声";
private static final String SHEN_TOU = "渗透";
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
// Excel中对应的CellData属性类型
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (CI_FEN.equals(cellValue)) {
return "5988";
} else if (SHE_XIAN.equals(cellValue)) {
return "5986";
} else if (CHAO_SENG.equals(cellValue)) {
return "5987";
}
return "5989";
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("5988")) {
return new CellData(CI_FEN);
} else if (o.equals("5986")) {
return new CellData(SHE_XIAN);
} else if (o.equals("5987")) {
return new CellData(CHAO_SENG);
}
return new CellData(SHEN_TOU);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class VehicleCylinderConverter implements Converter<String> {
private static final String WHETHER = "是";
private static final String NOT = "否";
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
// Excel中对应的CellData属性类型
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (WHETHER.equals(cellValue)) {
return "0";
} else if (NOT.equals(cellValue)) {
return "1";
}
return null;
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("0")) {
return new CellData(WHETHER);
} else if (o.equals("1")) {
return new CellData(NOT);
}
return new CellData("");
}
}
\ No newline at end of file
......@@ -8,12 +8,20 @@ import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -136,4 +144,45 @@ public class IdxBizJqEquipmentRegisterController extends BaseController {
JSONObject jsonObject = new JSONObject(queryMap);
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.queryEquipCanUsedByVesselPage(jsonObject));
}
/**
* 压力容器设备批量导入
*/
@PostMapping("/importPressureVesselData")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "压力容器设备批量导入")
public ResponseModel<String> importPressureVesselData(@RequestParam(value = "file") MultipartFile file,
@RequestParam Map<String, Object> paramMap) {
HashMap<String, Object> colorMap = new HashMap<>();
colorMap.put("EQU_LIST_CODE", "2000");
colorMap.put("EQU_LIST", "压力容器");
colorMap.put("EQU_CATEGORY", "气瓶");
colorMap.put("EQU_CATEGORY_CODE", "2300");
colorMap.put("EQU_DEFINE", "特种气瓶(内装填料气瓶、纤维缠绕气瓶、低温绝热气瓶)");
colorMap.put("EQU_DEFINE_CODE", "23T0");
return ResponseHelper.buildResponse(idxBizJgRegisterInfoService.importPressureVesselData(file, colorMap));
}
/**
* 压力容器设备模版下载
*/
@GetMapping("/pressureVesselTemplate")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "压力容器设备模版下载")
public void pressureVesselTemplate(HttpServletResponse response) throws Exception {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("压力容器设备导入模版.xlsx", "UTF-8"));
response.setContentType("application/vnd.ms-excel");
Resource resource = new ClassPathResource("templates/pressureVesselTemplate.xlsx");
try (OutputStream outputStream = response.getOutputStream();
InputStream inputStream = resource.getInputStream()) {
byte[] bytes = new byte[1024 * 1024];
int len;
while ((len = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
}
} catch (IOException e) {
throw new Exception("系统异常");
}
}
}
......@@ -184,4 +184,6 @@ public interface ICommonService {
* @return CompanyBo
*/
CompanyBo getOneCompany(String companyCode);
Integer checkFactoryNumUniquenessForVehicleCylinder(String factoryNum,String sequenceNbr);
}
......@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
......@@ -35,4 +35,6 @@ public interface IIdxBizJgRegisterInfoService {
Page<JSONObject> queryForUnitEquipmentPage(JSONObject jsonObject);
Page<JSONObject> queryEquipCanUsedByVesselPage(JSONObject jsonObject);
String importPressureVesselData(MultipartFile file, Map<String, Object> paramMap);
}
......@@ -19,4 +19,6 @@ public interface IIdxBizJgUseInfoService extends IService<IdxBizJgUseInfo> {
IdxBizJgUseInfo getOneData(String record);
List<IdxBizJgUseInfo> getUseInfoListByEquIds(List<String> equIds);
boolean saveBatch(List<IdxBizJgUseInfo> useInfoList);
}
......@@ -1762,6 +1762,11 @@ public class CommonServiceImpl implements ICommonService {
return companyBo == null ? new CompanyBo() : companyBo;
}
@Override
public Integer checkFactoryNumUniquenessForVehicleCylinder(String factoryNum, String sequenceNbr) {
return commonMapper.checkFactoryNumUniquenessForVehicleCylinder(factoryNum, sequenceNbr);
}
/**
* 根据设备列表代码选择对应的 PDF 模板
*
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -12,10 +13,12 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipInfoCylinderExcelDto;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.biz.config.PressureVesselListener;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
......@@ -48,6 +51,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -164,6 +168,17 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Value("${add.equip.dict.code.suffix:CATEGORY_LIST_ADD}")
private String equipAddDictCodeSuffix;
@Autowired
private IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgTechParamsVesselServiceImpl idxBizJgTechParamsVesselService;
@Autowired
private IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
/**
* 将对象的属性由驼峰转为纯大写下划线格式
*
......@@ -1439,12 +1454,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
/**
* 设置安装告知使用的设备不能包括正在进行中的流程
*
* @param boolMust
* @param companyCode
*/
private void setRepeatUsedCheckFilterParam(BoolQueryBuilder boolMust, String companyCode, String bizType) {
Set<String> records = EquipUsedCheckStrategyContext.getUsedStrategy(bizType).getEquipInFlow(companyCode);
if(records.size() >0){
if (records.size() > 0) {
boolMust.mustNot(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
}
}
......@@ -1478,7 +1494,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
*
* @return code
*/
private String getRegCode() {
public String getRegCode() {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "ZC");
queryWrapper.eq("name", "未注册");
......@@ -1874,4 +1890,40 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
});
return result;
}
@Override
public String importPressureVesselData(MultipartFile file, Map<String, Object> paramMap) {
try {
PressureVesselListener pressureVesselListener = new PressureVesselListener();
injectDependencies(pressureVesselListener, paramMap);
EasyExcel.read(file.getInputStream(), EquipInfoCylinderExcelDto.class, pressureVesselListener)
.headRowNumber(4)
.sheet()
.doRead();
return pressureVesselListener.getResult();
} catch (Exception e) {
return (e.getCause() instanceof BadRequest) ? "模版数据填写有误:" + e.getCause().getMessage() : "导入时出现异常:" + e.getMessage();
}
}
// 注入依赖
private void injectDependencies(PressureVesselListener listener, Map<String, Object> paramMap) {
listener.setIdxBizJgRegisterInfoService(idxBizJgRegisterInfoService);
listener.setJgInstallationNoticeService(jgInstallationNoticeService);
listener.setIdxBizJgUseInfoService(idxBizJgUseInfoService);
listener.setIdxBizJgDesignInfoService(idxBizJgDesignInfoService);
listener.setIdxBizJgFactoryInfoService(idxBizJgFactoryInfoService);
listener.setIdxBizJgTechParamsVesselService(idxBizJgTechParamsVesselService);
listener.setIdxBizJgInspectionDetectionInfoService(idxBizJgInspectionDetectionInfoService);
listener.setCommonService(commonService);
listener.setTzsJgRegistrationInfoMapper(tzsJgRegistrationInfoMapper);
listener.setTzsJgRegistrationInfoMapper(tzsJgRegistrationInfoMapper);
listener.setEsEquipmentCategory(esEquipmentCategory);
listener.setCategoryOtherInfoMapper(categoryOtherInfoMapper);
listener.setSuperviseInfoMapper(superviseInfoMapper);
listener.setParamMap(paramMap);
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
listener.setCompany(company);
}
}
\ No newline at end of file
......@@ -34,4 +34,9 @@ public class IdxBizJgUseInfoServiceImpl extends BaseService<IdxBizJgUseInfoDto,I
queryWrapper.lambda().in(IdxBizJgUseInfo::getRecord, equIds);
return list(queryWrapper);
}
@Override
public boolean saveBatch(List<IdxBizJgUseInfo> useInfoList) {
return super.saveBatch(useInfoList);
}
}
\ No newline at end of file
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