Commit ecd08578 authored by 刘林's avatar 刘林

Merge branch 'refs/heads/develop_tzs_register_update' into develop_tzs_register

# Conflicts: # amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/controller/IdxBizJqEquipmentRegisterController.java # amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/IIdxBizJgRegisterInfoService.java # amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/IdxBizJgRegisterInfoServiceImpl.java
parents 33f5cddc c63cbf91
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("系统异常");
}
}
}
......@@ -18,4 +18,6 @@ public interface IIdxBizJgUseInfoService {
IdxBizJgUseInfo getOneData(String record);
List<IdxBizJgUseInfo> getUseInfoListByEquIds(List<String> equIds);
boolean saveBatch(List<IdxBizJgUseInfo> useInfoList);
}
......@@ -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