Commit 046d6d48 authored by 刘林's avatar 刘林

fix(jg):导入功能修改

parent a5aded56
...@@ -12,6 +12,7 @@ import java.util.Map; ...@@ -12,6 +12,7 @@ import java.util.Map;
public class DictParamsConverter implements Converter<String> { public class DictParamsConverter implements Converter<String> {
public static final Map<String, String> dictMap = new HashMap<>(); public static final Map<String, String> dictMap = new HashMap<>();
public static final Map<String, String> reverseEquipmentMap = new HashMap<>();
static { static {
// 填充映射关系 // 填充映射关系
...@@ -77,6 +78,7 @@ public class DictParamsConverter implements Converter<String> { ...@@ -77,6 +78,7 @@ public class DictParamsConverter implements Converter<String> {
dictMap.put("其他控制方式", "4"); dictMap.put("其他控制方式", "4");
dictMap.put("直接顶升", "1"); dictMap.put("直接顶升", "1");
dictMap.put("间接顶升", "2"); dictMap.put("间接顶升", "2");
dictMap.forEach((key, value) -> reverseEquipmentMap.put(value, key));
} }
@Override @Override
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
public class EquCategoryConverter implements Converter<String> { public class EquCategoryConverter implements Converter<String> {
public static final Map<String, String> equipmentMap = new HashMap<>(); public static final Map<String, String> equipmentMap = new HashMap<>();
public static final Map<String, String> reverseEquipmentMap = new HashMap<>();
static { static {
// 填充映射关系 // 填充映射关系
equipmentMap.put("承压蒸汽锅炉", "1100"); equipmentMap.put("承压蒸汽锅炉", "1100");
...@@ -56,6 +56,7 @@ public class EquCategoryConverter implements Converter<String> { ...@@ -56,6 +56,7 @@ public class EquCategoryConverter implements Converter<String> {
equipmentMap.put("长输管道", "8100"); equipmentMap.put("长输管道", "8100");
equipmentMap.put("公用管道", "8200"); equipmentMap.put("公用管道", "8200");
equipmentMap.put("工业管道", "8300"); equipmentMap.put("工业管道", "8300");
equipmentMap.forEach((key, value) -> reverseEquipmentMap.put(value, key));
} }
@Override @Override
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
public class EquDefineConverter implements Converter<String> { public class EquDefineConverter implements Converter<String> {
private static final Map<String, String> equipmentMap = new HashMap<>(); private static final Map<String, String> equipmentMap = new HashMap<>();
public static final Map<String, String> reverseEquipmentMap = new HashMap<>();
static { static {
// 填充映射关系 // 填充映射关系
equipmentMap.put("有机热载体气相炉", "1310"); equipmentMap.put("有机热载体气相炉", "1310");
...@@ -87,6 +87,7 @@ public class EquDefineConverter implements Converter<String> { ...@@ -87,6 +87,7 @@ public class EquDefineConverter implements Converter<String> {
equipmentMap.put("工艺管道", "8310"); equipmentMap.put("工艺管道", "8310");
equipmentMap.put("动力管道", "8320"); equipmentMap.put("动力管道", "8320");
equipmentMap.put("制冷管道", "8330"); equipmentMap.put("制冷管道", "8330");
equipmentMap.forEach((key, value) -> reverseEquipmentMap.put(value, key));
} }
@Override @Override
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
public class EquListConverter implements Converter<String> { public class EquListConverter implements Converter<String> {
public static final Map<String, String> equipmentMap = new HashMap<>(); public static final Map<String, String> equipmentMap = new HashMap<>();
public static final Map<String, String> reverseEquipmentMap = new HashMap<>();
static { static {
// 填充映射关系 // 填充映射关系
equipmentMap.put("起重机械", "4000"); equipmentMap.put("起重机械", "4000");
...@@ -23,6 +23,7 @@ public class EquListConverter implements Converter<String> { ...@@ -23,6 +23,7 @@ public class EquListConverter implements Converter<String> {
equipmentMap.put("大型游乐设施", "6000"); equipmentMap.put("大型游乐设施", "6000");
equipmentMap.put("客运索道", "9000"); equipmentMap.put("客运索道", "9000");
equipmentMap.put("电梯", "3000"); equipmentMap.put("电梯", "3000");
equipmentMap.forEach((key, value) -> reverseEquipmentMap.put(value, key));
} }
@Override @Override
......
...@@ -11,6 +11,7 @@ import lombok.Data; ...@@ -11,6 +11,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.List;
@Data @Data
...@@ -45,6 +46,27 @@ public class EquipInfoExcelDto extends BaseDto { ...@@ -45,6 +46,27 @@ public class EquipInfoExcelDto extends BaseDto {
@ExcelProperty(value = "设备品种", converter = EquDefineConverter.class) @ExcelProperty(value = "设备品种", converter = EquDefineConverter.class)
private String equDefine; private String equDefine;
/**
* 保留导入的"设备种类"原始名称(未转换前的值)
*/
@ApiModelProperty(value = "设备种类名称(原始)")
@ExcelIgnore
private String equListName;
/**
* 保留导入的"设备类别"原始名称(未转换前的值)
*/
@ApiModelProperty(value = "设备类别名称(原始)")
@ExcelIgnore
private String equCategoryName;
/**
* 保留导入的"设备品种"原始名称(未转换前的值)
*/
@ApiModelProperty(value = "设备品种名称(原始)")
@ExcelIgnore
private String equDefineName;
@ApiModelProperty(value = "单位内编号") @ApiModelProperty(value = "单位内编号")
@ExcelProperty(value = "单位内编号") @ExcelProperty(value = "单位内编号")
@NotBlank(message = "单位内编号不能为空") @NotBlank(message = "单位内编号不能为空")
...@@ -201,6 +223,46 @@ public class EquipInfoExcelDto extends BaseDto { ...@@ -201,6 +223,46 @@ public class EquipInfoExcelDto extends BaseDto {
@ExcelProperty(value = "制造国") @ExcelProperty(value = "制造国")
private String produceCountry; private String produceCountry;
//--------------------------------------------------------------------检验信息
@ApiModelProperty(value = "检验机构名称")
@ExcelProperty(value = "检验机构名称")
private String inspectOrgName;
@ApiModelProperty(value = "检验机构统一信用代码")
@ExcelProperty(value = "检验机构统一信用代码")
private String inspectOrgCode;
@ApiModelProperty(value = "检验类型")
@ExcelProperty(value = "检验类型")
private String inspectType;
@ApiModelProperty(value = "检验结论")
@ExcelProperty(value = "检验结论")
private String inspectConclusion;
@ApiModelProperty(value = "检验日期")
@ExcelProperty(value = "检验日期")
@DateTimeFormat("yyyy-MM-dd")
private String inspectDate;
@ApiModelProperty(value = "下次检验日期")
@ExcelProperty(value = "下次检验日期")
@DateTimeFormat("yyyy-MM-dd")
private String nextInspectDate;
@ApiModelProperty(value = "检验人员名称")
@ExcelProperty(value = "检验人员名称")
private String inspectStaff;
@ApiModelProperty(value = "检验人员身份证号")
@ExcelProperty(value = "检验人员身份证号")
private String inspectStaffIDNumber;
@ApiModelProperty(value = "检验报告编号")
@ExcelProperty(value = "检验报告编号")
private String inspectReportNo;
//--------------------------------------------------------起重机械----技术参数 //--------------------------------------------------------起重机械----技术参数
@ExcelProperty(value = "额定起重量(t)") @ExcelProperty(value = "额定起重量(t)")
@ApiModelProperty(value = "额定起重量(t)") @ApiModelProperty(value = "额定起重量(t)")
...@@ -1047,4 +1109,19 @@ public class EquipInfoExcelDto extends BaseDto { ...@@ -1047,4 +1109,19 @@ public class EquipInfoExcelDto extends BaseDto {
@ExcelProperty(value = "控制方式", converter = DictParamsConverter.class) @ExcelProperty(value = "控制方式", converter = DictParamsConverter.class)
@ApiModelProperty(value = "控制方式") @ApiModelProperty(value = "控制方式")
private String CONTROL_MODE; private String CONTROL_MODE;
@ExcelIgnore
@ApiModelProperty(value = "附件信息")
private List fileData;
@ExcelIgnore
@ApiModelProperty(value = "设备来源")
private String DataSourceDesc;
/**
* "管道级别"
*/
@ApiModelProperty(value = "管道级别")
@ExcelIgnore
private String deviceLevel_GD;
} }
\ No newline at end of file
...@@ -60,6 +60,86 @@ public class DataDockController { ...@@ -60,6 +60,86 @@ public class DataDockController {
} }
/** /**
* 历史-台套类设备导入字段校验
* @param file 导入文件
* @return 导入数据
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/checkHisSetEquipImportData")
@ApiOperation(httpMethod = "POST", value = "历史-台套类设备导入字段校验", notes = "历史-台套类设备导入字段校验")
public Object checkSetEquipImportData(@RequestParam MultipartFile file) {
// 校验文件是否为空
if (file.isEmpty()) {
return ResponseHelper.buildResponse("文件不能为空");
}
// 校验文件类型为 Excel
String contentType = file.getContentType();
String fileExtension = FilenameUtils.getExtension(file.getOriginalFilename());
// 校验 Excel 文件的 MIME type 和扩展名
if (!("application/vnd.ms-excel".equals(contentType) || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) || !("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension))) {
return ResponseHelper.buildResponse("文件类型必须是 Excel 文件");
}
return ResponseHelper.buildResponse(dataDockService.checkSetEquipImportData("his", file));
}
/**
* 新设备台套类设备导入字段校验
* @param file 导入文件
* @return 导入数据
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/checkNewSetEquipImportData")
@ApiOperation(httpMethod = "POST", value = "新设备台套类设备导入字段校验", notes = "新设备台套类设备导入字段校验")
public Object checkNewSetEquipImportData(@RequestParam MultipartFile file) {
// 校验文件是否为空
if (file.isEmpty()) {
return ResponseHelper.buildResponse("文件不能为空");
}
// 校验文件类型为 Excel
String contentType = file.getContentType();
String fileExtension = FilenameUtils.getExtension(file.getOriginalFilename());
// 校验 Excel 文件的 MIME type 和扩展名
if (!("application/vnd.ms-excel".equals(contentType) || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) || !("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension))) {
return ResponseHelper.buildResponse("文件类型必须是 Excel 文件");
}
return ResponseHelper.buildResponse(dataDockService.checkSetEquipImportData("new", file));
}
/**
* 新设备台套类设备导入字段校验
* @param file 导入文件
* @return 导入数据
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/checkBlackSetEquipImportData")
@ApiOperation(httpMethod = "POST", value = "新设备台套类设备导入字段校验", notes = "新设备台套类设备导入字段校验")
public Object checkBlackSetEquipImportData(@RequestParam MultipartFile file) {
// 校验文件是否为空
if (file.isEmpty()) {
return ResponseHelper.buildResponse("文件不能为空");
}
// 校验文件类型为 Excel
String contentType = file.getContentType();
String fileExtension = FilenameUtils.getExtension(file.getOriginalFilename());
// 校验 Excel 文件的 MIME type 和扩展名
if (!("application/vnd.ms-excel".equals(contentType) || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) || !("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension))) {
return ResponseHelper.buildResponse("文件类型必须是 Excel 文件");
}
return ResponseHelper.buildResponse(dataDockService.checkSetEquipImportData("black", file));
}
/**
* 气瓶批量保存
**/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/saveSetEquipImportData")
@ApiOperation(httpMethod = "POST", value = "台套类设备导入字段保存", notes = "台套类设备导入字段保存")
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<?> saveSetEquipImportData(@RequestBody Map<String, Object> paramMap) {
return ResponseHelper.buildResponse(dataDockService.saveSetEquipImportData(paramMap));
}
/**
* 工业管道批量检查 * 工业管道批量检查
**/ **/
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
...@@ -740,7 +740,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -740,7 +740,7 @@ public class CommonServiceImpl implements ICommonService {
Iterator<Map<String, Object>> iterator = resourceJson.get(businessType).iterator(); Iterator<Map<String, Object>> iterator = resourceJson.get(businessType).iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map<String, Object> item = iterator.next(); Map<String, Object> item = iterator.next();
if (item.get(CODE).equals(PL_DR) || item.get(CODE).equals(DW_LR)) { if (item.get(CODE).equals(DW_LR)) {
iterator.remove(); iterator.remove();
} }
} }
......
...@@ -28,6 +28,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ExcelImportErrorLogDto; ...@@ -28,6 +28,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ExcelImportErrorLogDto;
import com.yeejoin.amos.boot.module.jg.api.converter.DictParamsConverter; import com.yeejoin.amos.boot.module.jg.api.converter.DictParamsConverter;
import com.yeejoin.amos.boot.module.jg.api.converter.EquCategoryConverter; import com.yeejoin.amos.boot.module.jg.api.converter.EquCategoryConverter;
import com.yeejoin.amos.boot.module.jg.api.converter.EquDefineConverter; import com.yeejoin.amos.boot.module.jg.api.converter.EquDefineConverter;
import com.yeejoin.amos.boot.module.jg.api.converter.EquListConverter;
import com.yeejoin.amos.boot.module.jg.api.dto.*; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*; import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
...@@ -79,8 +80,8 @@ import java.util.concurrent.CompletableFuture; ...@@ -79,8 +80,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl.toCamelCase;
@Slf4j @Slf4j
@Service @Service
...@@ -141,6 +142,15 @@ public class DataDockServiceImpl { ...@@ -141,6 +142,15 @@ public class DataDockServiceImpl {
private final JgVehicleInformationMapper jgVehicleInformationMapper; private final JgVehicleInformationMapper jgVehicleInformationMapper;
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper; private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private final ExcelImportErrorLogDao excelImportErrorLogDao; private final ExcelImportErrorLogDao excelImportErrorLogDao;
// 设备分类表单id
public static final String EQUIP_CLASS_FORM_ID = "equipClass";
// 设备基本信息表单id
public static final String EQUIP_INFO_FORM_ID = "equipInfo";
// 设备技术参数表单id
public static final String EQUIP_PARAMS_FORM_ID = "equipParams";
private static final String ATTACHMENT_UPLOAD = "attachmentUpload";
// 模版上传集合
public static final String EQU_LISTS = "equLists";
/** /**
* 西安数据对接-保存设备信息 * 西安数据对接-保存设备信息
...@@ -169,6 +179,8 @@ public class DataDockServiceImpl { ...@@ -169,6 +179,8 @@ public class DataDockServiceImpl {
public void saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark) { public void saveEquipmentDataInTransaction(Map<String, Object> equ, String dataSource, String remark) {
String record = UUID.randomUUID().toString(); String record = UUID.randomUUID().toString();
try { try {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
// transactionTemplate.execute(status -> { // transactionTemplate.execute(status -> {
String equList = String.valueOf(equ.get("equList")); String equList = String.valueOf(equ.get("equList"));
String isCompleteXa = String.valueOf(equ.get("isCompleteXa")); String isCompleteXa = String.valueOf(equ.get("isCompleteXa"));
...@@ -181,6 +193,10 @@ public class DataDockServiceImpl { ...@@ -181,6 +193,10 @@ public class DataDockServiceImpl {
saveRegisterInfo(equ, record, equList); saveRegisterInfo(equ, record, equList);
saveSupervisionInfo(equ, record); saveSupervisionInfo(equ, record);
saveOtherInfo(equ, record, equList); saveOtherInfo(equ, record, equList);
saveInspectInfo(equ, record);
if ("安装改造维修单位".equals(company.getCompanyType())){
saveConstructionInfo(equ, record, company);
}
// 保存技术参数 // 保存技术参数
saveTechParams(equ, record, equList); saveTechParams(equ, record, equList);
// 保存到ES // 保存到ES
...@@ -196,6 +212,24 @@ public class DataDockServiceImpl { ...@@ -196,6 +212,24 @@ public class DataDockServiceImpl {
} }
} }
/**
* 保存施工信息表
*
* @param equ
* @param record
*/
private void saveConstructionInfo(Map<String, Object> equ, String record,CompanyBo company) {
log.error("数据===>{}", JSONObject.toJSONString(equ));
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgConstructionInfo.class);
if (!ValidationUtil.isEmpty(constructionInfo)) {
constructionInfo.setRecord(record);
constructionInfo.setRecDate(new Date());
constructionInfo.setUscUnitCreditCode(company.getCompanyCode());
constructionInfo.setUscUnitName(company.getCompanyName());
idxBizJgConstructionInfoService.save(constructionInfo);
}
}
public Integer writeOrgBranchCode2YanChang(String remark) { public Integer writeOrgBranchCode2YanChang(String remark) {
List<String> records = idxBizJgUseInfoService.lambdaQuery().select(IdxBizJgUseInfo::getRecord).eq(IdxBizJgUseInfo::getRemark, remark).list().stream().map(IdxBizJgUseInfo::getRecord).collect(Collectors.toList()); List<String> records = idxBizJgUseInfoService.lambdaQuery().select(IdxBizJgUseInfo::getRecord).eq(IdxBizJgUseInfo::getRemark, remark).list().stream().map(IdxBizJgUseInfo::getRecord).collect(Collectors.toList());
...@@ -322,8 +356,6 @@ public class DataDockServiceImpl { ...@@ -322,8 +356,6 @@ public class DataDockServiceImpl {
useInfo.setDataSource(dataSource); useInfo.setDataSource(dataSource);
useInfo.setIsNotEs("1"); useInfo.setIsNotEs("1");
useInfo.setIsIntoManagement(Boolean.FALSE); useInfo.setIsIntoManagement(Boolean.FALSE);
useInfo.setUseUnitCreditCode(Objects.toString(equ.get("useUnitCode"), "").trim());
useInfo.setUseUnitName(Objects.toString(equ.get("useUnit"), "").trim());
useInfo.setRemark(remark); useInfo.setRemark(remark);
//useInfo.setEquState(EquimentEnum.ZAIYONG.getCode()+""); //useInfo.setEquState(EquimentEnum.ZAIYONG.getCode()+"");
useInfo.setProjectContraptionId(Objects.toString(equ.get("projectContraptionId"), "")); useInfo.setProjectContraptionId(Objects.toString(equ.get("projectContraptionId"), ""));
...@@ -401,59 +433,63 @@ public class DataDockServiceImpl { ...@@ -401,59 +433,63 @@ public class DataDockServiceImpl {
if (ObjectUtils.isEmpty(supervisionInfo)) return; if (ObjectUtils.isEmpty(supervisionInfo)) return;
supervisionInfo.setRecord(record); supervisionInfo.setRecord(record);
supervisionInfo.setRecDate(new Date()); supervisionInfo.setRecDate(new Date());
if (!ValidationUtil.isEmpty(equ.get("orgBranchCode"))){
supervisionInfo.setOrgBranchCode(String.valueOf(equ.get("orgBranchCode")));
supervisionInfo.setOrgBranchName(String.valueOf(equ.get("orgBranchName")));
} else {
// 获取符合条件的公司 Map
Map<String, Map<String, String>> countyMap;
try {
countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult())
.orElse(Collections.emptyList())
.stream()
.filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId())))
.collect(Collectors.toMap(
CompanyModel::getCompanyCode,
v -> Stream.of(new AbstractMap.SimpleEntry<>("companyName", v.getCompanyName()),
new AbstractMap.SimpleEntry<>("orgCode", v.getOrgCode()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(a, b) -> a
));
} catch (Exception e) {
countyMap = Collections.emptyMap();
}
String companyCode = "1".equals(equ.get("equCodeType"))
? String.valueOf(equ.get("equCode"))
: String.valueOf(equ.get("originalEquCode"));
// 获取符合条件的公司 Map companyCode = companyCode.trim();
Map<String, Map<String, String>> countyMap; if (companyCode.length() > 9) {
try { companyCode = companyCode.substring(4, 10);
countyMap = Optional.ofNullable(Privilege.companyClient.queryAgencyList("county").getResult())
.orElse(Collections.emptyList())
.stream()
.filter(v -> "1442687786065854466".equals(String.valueOf(v.getParentId())))
.collect(Collectors.toMap(
CompanyModel::getCompanyCode,
v -> Stream.of(new AbstractMap.SimpleEntry<>("companyName", v.getCompanyName()),
new AbstractMap.SimpleEntry<>("orgCode", v.getOrgCode()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(a, b) -> a
));
} catch (Exception e) {
countyMap = Collections.emptyMap();
}
String companyCode = "1".equals(equ.get("equCodeType"))
? String.valueOf(equ.get("equCode"))
: String.valueOf(equ.get("originalEquCode"));
companyCode = companyCode.trim();
if (companyCode.length() > 9) {
companyCode = companyCode.substring(4, 10);
}
Map<String, String> companyInfo = countyMap.get(companyCode);
if (companyInfo != null) {
String companyName = companyInfo.get("companyName");
String orgCode = companyInfo.get("orgCode");
if (companyName != null && !companyName.trim().isEmpty()) {
supervisionInfo.setOrgBranchCode(orgCode);
supervisionInfo.setOrgBranchName(companyName);
} }
} else { Map<String, String> companyInfo = countyMap.get(companyCode);
// 通过 useUnitCode 查询属地监管部门 if (companyInfo != null) {
String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim(); String companyName = companyInfo.get("companyName");
CompanyModel companyModel = Privilege.companyClient.queryByCompanyCode(useUnitCode).getResult(); String orgCode = companyInfo.get("orgCode");
if (companyName != null && !companyName.trim().isEmpty()) {
if (companyModel != null) { supervisionInfo.setOrgBranchCode(orgCode);
String orgCode = companyModel.getOrgCode(); supervisionInfo.setOrgBranchName(companyName);
if (orgCode != null && orgCode.contains("*")) {
String superOrgCode = orgCode.substring(0, orgCode.lastIndexOf("*"));
supervisionInfo.setOrgBranchCode(superOrgCode);
Optional.ofNullable(Privilege.companyClient.queryByOrgcode(superOrgCode).getResult())
.map(result -> JSON.parseObject(JSON.toJSONString(result)).getString("compnay"))
.map(json -> JSON.parseObject(json, CompanyModel.class))
.map(CompanyModel::getCompanyName)
.ifPresent(supervisionInfo::setOrgBranchName);
} }
} else { } else {
supervisionInfo.setOrgBranchCode("50*52"); // 通过 useUnitCode 查询属地监管部门
supervisionInfo.setOrgBranchName("西安市市场监督管理局"); String useUnitCode = String.valueOf(equ.get("useUnitCode")).trim();
CompanyModel companyModel = Privilege.companyClient.queryByCompanyCode(useUnitCode).getResult();
if (companyModel != null) {
String orgCode = companyModel.getOrgCode();
if (orgCode != null && orgCode.contains("*")) {
String superOrgCode = orgCode.substring(0, orgCode.lastIndexOf("*"));
supervisionInfo.setOrgBranchCode(superOrgCode);
Optional.ofNullable(Privilege.companyClient.queryByOrgcode(superOrgCode).getResult())
.map(result -> JSON.parseObject(JSON.toJSONString(result)).getString("compnay"))
.map(json -> JSON.parseObject(json, CompanyModel.class))
.map(CompanyModel::getCompanyName)
.ifPresent(supervisionInfo::setOrgBranchName);
}
} else {
supervisionInfo.setOrgBranchCode("50*52");
supervisionInfo.setOrgBranchName("西安市市场监督管理局");
}
} }
} }
idxBizJgSupervisionInfoService.save(supervisionInfo); idxBizJgSupervisionInfoService.save(supervisionInfo);
...@@ -678,7 +714,7 @@ public class DataDockServiceImpl { ...@@ -678,7 +714,7 @@ public class DataDockServiceImpl {
List<EquipInfoExcelDto> equipInfoExcelDtos; List<EquipInfoExcelDto> equipInfoExcelDtos;
try { try {
// 1, 数据读取 + 格式、类型异常检查 // 1, 数据读取 + 格式、类型异常检查
equipInfoExcelDtos = this.checkData(file); equipInfoExcelDtos = this.checkData(file, remark);
} catch (Exception e) { } catch (Exception e) {
throw new BadRequest(String.format("参数校验失败,详细请看返回信息:%s", e.getMessage())); throw new BadRequest(String.format("参数校验失败,详细请看返回信息:%s", e.getMessage()));
} }
...@@ -688,6 +724,17 @@ public class DataDockServiceImpl { ...@@ -688,6 +724,17 @@ public class DataDockServiceImpl {
return Boolean.TRUE; return Boolean.TRUE;
} }
public Object checkSetEquipImportData(String remark, MultipartFile file) {
List<EquipInfoExcelDto> equipInfoExcelDtos;
try {
// 1, 数据读取 + 格式、类型异常检查
equipInfoExcelDtos = this.checkData(file, remark);
} catch (Exception e) {
throw new BadRequest(String.format("参数校验失败,详细请看返回信息:%s", e.getMessage()));
}
return equipInfoExcelDtos;
}
/** /**
* excel 文件读取,字段校验 * excel 文件读取,字段校验
* *
...@@ -695,7 +742,7 @@ public class DataDockServiceImpl { ...@@ -695,7 +742,7 @@ public class DataDockServiceImpl {
* @return 设备数据 * @return 设备数据
* @throws Exception 异常信息 * @throws Exception 异常信息
*/ */
public List<EquipInfoExcelDto> checkData(MultipartFile file) { public List<EquipInfoExcelDto> checkData(MultipartFile file, String remark) {
List<EquipInfoExcelDto> dataList = new ArrayList<>(); List<EquipInfoExcelDto> dataList = new ArrayList<>();
resultError.clear(); resultError.clear();
useInnerCodeList.clear(); useInnerCodeList.clear();
...@@ -723,7 +770,7 @@ public class DataDockServiceImpl { ...@@ -723,7 +770,7 @@ public class DataDockServiceImpl {
@Override @Override
public void invoke(EquipInfoExcelDto data, AnalysisContext context) { public void invoke(EquipInfoExcelDto data, AnalysisContext context) {
// 数据检查 // 数据检查
checkExcelData(sheetName, data, context, sheetError); checkExcelData(sheetName, data, context, sheetError, remark);
// if (!ValidationUtil.isEmpty(data.getUseInnerCode())) { // if (!ValidationUtil.isEmpty(data.getUseInnerCode())) {
// useInnerCodeList.add(data.getUseInnerCode()); // useInnerCodeList.add(data.getUseInnerCode());
// } // }
...@@ -768,7 +815,7 @@ public class DataDockServiceImpl { ...@@ -768,7 +815,7 @@ public class DataDockServiceImpl {
* @param data excel数据 * @param data excel数据
* @param context * @param context
*/ */
public void checkExcelData(String sheetName, EquipInfoExcelDto data, AnalysisContext context, Map<String, Object> sheetError) { public void checkExcelData(String sheetName, EquipInfoExcelDto data, AnalysisContext context, Map<String, Object> sheetError, String remark) {
ReadRowHolder readRowHolder = context.readRowHolder(); ReadRowHolder readRowHolder = context.readRowHolder();
int rowIndex = readRowHolder.getRowIndex() + 1; int rowIndex = readRowHolder.getRowIndex() + 1;
StringBuffer rowError = new StringBuffer(); StringBuffer rowError = new StringBuffer();
...@@ -794,7 +841,7 @@ public class DataDockServiceImpl { ...@@ -794,7 +841,7 @@ public class DataDockServiceImpl {
log.info("解析第{}行数据:{}", rowIndex, JSON.toJSONString(data)); log.info("解析第{}行数据:{}", rowIndex, JSON.toJSONString(data));
// 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息 // 通用字段检查 每一个sheet页都有的基本信息,设计信息,制造信息和使用信息
this.commonFieldCheck(data, rowError); this.commonFieldCheck(data, rowError, remark);
// 起重机械----技术参数 检查 // 起重机械----技术参数 检查
if (isQZJX) { if (isQZJX) {
...@@ -846,8 +893,7 @@ public class DataDockServiceImpl { ...@@ -846,8 +893,7 @@ public class DataDockServiceImpl {
* @param data 源数据 * @param data 源数据
* @param rowError 错误集合 * @param rowError 错误集合
*/ */
private void commonFieldCheck(EquipInfoExcelDto data, StringBuffer rowError) { private void commonFieldCheck(EquipInfoExcelDto data, StringBuffer rowError, String remark) {
boolean isYLRQ = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.YLRQ.getCode().equals(data.getEquList());// 是否压力容器 boolean isYLRQ = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.YLRQ.getCode().equals(data.getEquList());// 是否压力容器
boolean isYLGD = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.YLGD.getCode().equals(data.getEquList());// 是否压力管道 boolean isYLGD = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.YLGD.getCode().equals(data.getEquList());// 是否压力管道
boolean isDT = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.DT.getCode().equals(data.getEquList());// 是否电梯 boolean isDT = !ObjectUtils.isEmpty(data.getEquList()) && EquipmentClassifityEnum.DT.getCode().equals(data.getEquList());// 是否电梯
...@@ -857,6 +903,10 @@ public class DataDockServiceImpl { ...@@ -857,6 +903,10 @@ public class DataDockServiceImpl {
// 基本信息 // 基本信息
checkNotBlank(data.getEquList(), "设备种类不能为空;", rowError); checkNotBlank(data.getEquList(), "设备种类不能为空;", rowError);
checkNotBlank(data.getEquCategory(), "设备类别不能为空;", rowError); checkNotBlank(data.getEquCategory(), "设备类别不能为空;", rowError);
data.setEquListName(EquListConverter.reverseEquipmentMap.get(data.getEquList()));
data.setEquCategoryName(EquCategoryConverter.reverseEquipmentMap.get(data.getEquCategory()));
data.setEquDefineName(Optional.ofNullable(data.getEquDefine()).map(EquDefineConverter.reverseEquipmentMap::get).orElse(""));
data.setDeviceLevel_GD(Optional.ofNullable(data.getDeviceLevel_YLGD()).map(DictParamsConverter.reverseEquipmentMap::get).orElse(""));
// checkNotBlank(data.getUseInnerCode(), "单位内编号不能为空;", rowError); // checkNotBlank(data.getUseInnerCode(), "单位内编号不能为空;", rowError);
// if (useInnerCodeList.contains(data.getUseInnerCode())) { // if (useInnerCodeList.contains(data.getUseInnerCode())) {
// rowError.append("单位内编号不能重复;"); // rowError.append("单位内编号不能重复;");
...@@ -892,14 +942,16 @@ public class DataDockServiceImpl { ...@@ -892,14 +942,16 @@ public class DataDockServiceImpl {
checkNotBlank(data.getPipeName(), "管道名称不能为空;", rowError); checkNotBlank(data.getPipeName(), "管道名称不能为空;", rowError);
checkNotBlank(data.getProjectContraption(), "工程(装置)名称不能为空;", rowError); checkNotBlank(data.getProjectContraption(), "工程(装置)名称不能为空;", rowError);
checkNotBlank(data.getProjectContraptionNo(), "工程(装置)编号不能为空;", rowError); checkNotBlank(data.getProjectContraptionNo(), "工程(装置)编号不能为空;", rowError);
// 使用登记证编号校验 if (remark.equals("his")){
List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos = idxBizJgRegisterInfoServiceImpl.getBaseMapper().selectList(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getUseOrgCode, data.getUseOrgCode()).notLike(IdxBizJgRegisterInfo::getUseOrgCode, "管")); // 使用登记证编号校验
if (!idxBizJgRegisterInfos.isEmpty()) { List<IdxBizJgRegisterInfo> idxBizJgRegisterInfos = idxBizJgRegisterInfoServiceImpl.getBaseMapper().selectList(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getUseOrgCode, data.getUseOrgCode()).notLike(IdxBizJgRegisterInfo::getUseOrgCode, "管"));
rowError.append("使用登记证编号已存在系统中;"); if (!idxBizJgRegisterInfos.isEmpty()) {
} rowError.append("使用登记证编号已存在系统中;");
List<IdxBizJgProjectContraption> projectContraptions = idxBizJgProjectContraptionService.lambdaQuery().eq(IdxBizJgProjectContraption::getEquList, EquipmentClassifityEnum.YLGD.getCode()).eq(IdxBizJgProjectContraption::getUseRegistrationCode, data.getUseOrgCode()).eq(IdxBizJgProjectContraption::getProjectContraption, data.getProjectContraption()).eq(IdxBizJgProjectContraption::getProjectContraptionNo, data.getProjectContraptionNo()).list(); }
if (!projectContraptions.isEmpty()) { List<IdxBizJgProjectContraption> projectContraptions = idxBizJgProjectContraptionService.lambdaQuery().eq(IdxBizJgProjectContraption::getEquList, EquipmentClassifityEnum.YLGD.getCode()).eq(IdxBizJgProjectContraption::getUseRegistrationCode, data.getUseOrgCode()).eq(IdxBizJgProjectContraption::getProjectContraption, data.getProjectContraption()).eq(IdxBizJgProjectContraption::getProjectContraptionNo, data.getProjectContraptionNo()).list();
rowError.append("使用登记证编号已存在系统中;"); if (!projectContraptions.isEmpty()) {
rowError.append("使用登记证编号已存在系统中;");
}
} }
// 同一工程装置下管道编号不能重复 // 同一工程装置下管道编号不能重复
if (!ValidationUtil.isEmpty(data.getProjectContraption())) { if (!ValidationUtil.isEmpty(data.getProjectContraption())) {
...@@ -993,21 +1045,23 @@ public class DataDockServiceImpl { ...@@ -993,21 +1045,23 @@ public class DataDockServiceImpl {
data.setInformationManageCode(""); data.setInformationManageCode("");
} }
} }
checkNotBlank(data.getUseOrgCode(), "使用登记证编号不能为空;", rowError); if (remark.equals("his")){
if (!StringUtils.isEmpty(data.getUseOrgCode())) { checkNotBlank(data.getUseOrgCode(), "使用登记证编号不能为空;", rowError);
if (!this.useOrgCodeRegularMatching(data)) { if (!StringUtils.isEmpty(data.getUseOrgCode())) {
rowError.append("使用登记证编号格式不正确;"); if (!this.useOrgCodeRegularMatching(data)) {
} rowError.append("使用登记证编号格式不正确;");
if (!isYLGD && useOrgCodeList.contains(data.getUseOrgCode())) { }
rowError.append("使用登记证编号不能重复;"); if (!isYLGD && useOrgCodeList.contains(data.getUseOrgCode())) {
} rowError.append("使用登记证编号不能重复;");
try { }
idxBizJgRegisterInfoServiceImpl.checkUseRegistrationCode(data.getUseOrgCode(), "set"); try {
} catch (Exception e) { idxBizJgRegisterInfoServiceImpl.checkUseRegistrationCode(data.getUseOrgCode(), "set");
rowError.append(e.getMessage()); } catch (Exception e) {
} rowError.append(e.getMessage());
if (!isYLGD && commonService.useRegistrationCertificateAccountUnique(data.getUseOrgCode(), null)) { }
rowError.append("使用登记证编号已存在系统中;"); if (!isYLGD && commonService.useRegistrationCertificateAccountUnique(data.getUseOrgCode(), null)) {
rowError.append("使用登记证编号已存在系统中;");
}
} }
} }
// 使用信息 // 使用信息
...@@ -1075,6 +1129,7 @@ public class DataDockServiceImpl { ...@@ -1075,6 +1129,7 @@ public class DataDockServiceImpl {
data.setFactoryIsComplete("1"); data.setFactoryIsComplete("1");
} }
} }
data.setDataSourceDesc("his".equals(remark) ? "历史设备" : "new".equals(remark) ? "新设备" : "历史无证设备");
} }
/** /**
...@@ -1413,28 +1468,77 @@ public class DataDockServiceImpl { ...@@ -1413,28 +1468,77 @@ public class DataDockServiceImpl {
private void DTTechnicalParamsCheck(EquipInfoExcelDto data, StringBuffer rowError) { private void DTTechnicalParamsCheck(EquipInfoExcelDto data, StringBuffer rowError) {
} }
private void batchSaveHisEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos, LinkedHashMap equipmentInfoForm) {
String[] keys = {
"PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG", "DESIGN_DOC", "DESIGN_STANDARD",
"OTHER_ACCESSORIES_DES", "PRODUCT_QUALITY_YIELD_PROVE", "FACTORY_STANDARD",
"INS_USE_MAINTAIN_EXPLAIN", "OTHER_ACCESSORIES_FACT",
"BOILER_ENERGY_EFFICIENCY_CERTIFICATE", "FACT_SUPERVISION_INSPECTION_REPORT","INSPECT_REPORT"
};
String[] parts = Optional.ofNullable(equipmentInfoForm.get("orgBranchCode"))
.map(String::valueOf)
.map(s -> s.split("_", 2))
.orElse(new String[0]);
String orgBranchCode = parts.length > 0 ? parts[0] : "";
String orgBranchName = parts.length > 1 ? parts[1] : "";
String equList = String.valueOf(equipmentInfoForm.get("EQU_LIST"));
String equCategory = String.valueOf(equipmentInfoForm.get("EQU_CATEGORY"));
String dataSource = "new".equals(equipmentInfoForm.get("DATA_SOURCE"))
? "jg_pl"
: "his".equals(equipmentInfoForm.get("DATA_SOURCE"))
? "jg_his_pl"
: "jg_black_pl";
Arrays.stream(equipInfoExcelDtos.toArray(new EquipInfoExcelDto[0])).forEach(equ -> {
if (!equ.getEquList().equals(equList) || !equ.getEquCategory().equals(equCategory)){
throw new BadRequest("设备种类或设备类型与模板上传不一致,请核对后进行上传!");
}
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(JSON.toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
equMap.put("orgBranchName", orgBranchName);
equMap.put("orgBranchCode", orgBranchCode);
}
this.saveEquipmentDataInTransaction(equMap, dataSource, remark);
});
}
/** /**
* 批量异步保存设备数据 * 批量异步保存设备数据
* *
* @param equipInfoExcelDtos * @param equipInfoExcelDtos
*/ */
public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos) { public void batchSaveEquipmentData(String remark, List<EquipInfoExcelDto> equipInfoExcelDtos) {
String[] keys = {
"PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG", "DESIGN_DOC", "DESIGN_STANDARD",
"OTHER_ACCESSORIES_DES", "PRODUCT_QUALITY_YIELD_PROVE", "FACTORY_STANDARD",
"INS_USE_MAINTAIN_EXPLAIN", "OTHER_ACCESSORIES_FACT",
"BOILER_ENERGY_EFFICIENCY_CERTIFICATE", "FACT_SUPERVISION_INSPECTION_REPORT","INSPECT_REPORT"
};
Arrays.stream(equipInfoExcelDtos.toArray(new EquipInfoExcelDto[0])).forEach(equ -> {
List<Map<String, Object>> fileDataList = (List<Map<String, Object>>) equ.getFileData();
Map<String, Object> equMap = (Map<String, Object>) JSON.parseObject(JSON.toJSONString(equ), Map.class);
for (String key : keys) {
String camelKey = toCamelCase(key.toLowerCase());
equMap.put(camelKey, getUrlByKey(fileDataList, key));
}
this.saveEquipmentDataInTransaction(equMap, "jg_his", remark);
});
}
equipInfoExcelDtos.forEach(equ -> this.saveEquipmentDataInTransaction((Map<String, Object>) JSON.parseObject(JSON.toJSONString(equ), Map.class), "jg_his", remark)); private String getUrlByKey(List<Map<String, Object>> dataList, String key) {
// int batchSize = 1000; if (dataList == null || dataList.isEmpty()) {
// int totalSize = equipInfoExcelDtos.size(); return null;
// for (int i = 0; i < totalSize; i += batchSize) { }
// List<EquipInfoExcelDto> batch = equipInfoExcelDtos.subList(i, Math.min(totalSize, i + batchSize)); for (Map<String, Object> item : dataList) {
// try { if (key.equals(item.get("key"))) {
// CompletableFuture.allOf(batch.stream().map(equ -> CompletableFuture.runAsync( return JSON.toJSONString(item.get("value"));
// () -> this.saveEquipmentDataInTransaction((Map<String, Object>) JSON.parseObject(JSON.toJSONString(equ), Map.class), "jg_his", remark) }
// ) }
// ).toArray(CompletableFuture[]::new)).join(); return null;
// } catch (Exception e) {
// log.error("数据上传,保存设备数据失败: {}", e.getMessage());
// throw new BadRequest("数据上传,保存设备数据失败!");
// }
// }
} }
/** /**
...@@ -1553,6 +1657,28 @@ public class DataDockServiceImpl { ...@@ -1553,6 +1657,28 @@ public class DataDockServiceImpl {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object saveSetEquipImportData(Map<String, Object> paramMap) {
if (paramMap == null) {
throw new IllegalArgumentException("参数Map不能为空");
}
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
LinkedHashMap attachmentUpload = (LinkedHashMap) checkAndCast(paramMap.get(ATTACHMENT_UPLOAD));
List<EquipInfoExcelDto> equipInfoExcelDtos = JSON.parseArray(JSON.toJSONString(attachmentUpload.get(EQU_LISTS)), EquipInfoExcelDto.class);
// 2, 保存设备数据
this.batchSaveHisEquipmentData("", equipInfoExcelDtos,equipmentInfoForm);
return Boolean.TRUE;
}
private Object checkAndCast(Object obj) {
if (obj instanceof LinkedHashMap) {
return obj;
} else {
throw new ClassCastException("对象类型不匹配");
}
}
@Transactional(rollbackFor = Exception.class)
public Object savePipingData(Map<String, Object> paramMap) { public Object savePipingData(Map<String, Object> paramMap) {
// 获取数据 // 获取数据
JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class); JSONObject equipInfo = JSON.parseObject(toJSONString(paramMap.get("equipInfo")), JSONObject.class);
......
...@@ -1195,7 +1195,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1195,7 +1195,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (!ObjectUtils.isEmpty(type) && "PL_DR".equals(type)) { if (!ObjectUtils.isEmpty(type) && "PL_DR".equals(type)) {
if (EquipmentClassifityEnum.YLRQ.getCode().equals(equList)) { if (EquipmentClassifityEnum.YLRQ.getCode().equals(equList)) {
return this.baseMapper.queryAllEquCategoriesUnderTheEquList(equList).stream() return this.baseMapper.queryAllEquCategoriesUnderTheEquList(equList).stream()
.filter(x -> "2300".equals(x.getDictDataKey())) .filter(x -> !"2200".equals(x.getDictDataKey()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (EquipmentClassifityEnum.YLGD.getCode().equals(equList) && "his".equals(dataSource)) { if (EquipmentClassifityEnum.YLGD.getCode().equals(equList) && "his".equals(dataSource)) {
......
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