Commit 77aaeed3 authored by liufan's avatar liufan

优化:设备详情查询接口返回的属性名应为纯大写下划线分隔的格式以及附件对象应为json数组对象格式的问题

parent 139a4db5
......@@ -3,11 +3,11 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.RedisUtils;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESElavtorRepository;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgDesignInfoService;
......@@ -38,7 +38,6 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgTechParamsElevatorMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.lucene.queryparser.classic.QueryParser;
......@@ -54,15 +53,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
......@@ -163,7 +163,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
/**
* 删除设备注册信息(批量删除)
*
* @param sequenceNbrList
* @param map
* @return
*/
public boolean batchDeleteByRecord(Map<String, Object> map) {
......@@ -204,63 +204,117 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//使用信息
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(useInfo)) {
Map<String, Object> useInfoMap = Bean.BeantoMap(useInfo);
Map<String, Object> useInfoMap = new HashMap<>();
String[] fields = null;
try {
useInfoMap = this.convertCamelToUnderscore(useInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
useInfoMap.put("USEINFO_SEQ", useInfo.getSequenceNbr());
objMap.putAll(useInfoMap);
}
//设计制造
IdxBizJgDesignInfo designInfo = iIdxBizJgDesignInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(designInfo)) {
Map<String, Object> designInfoMap = Bean.BeantoMap(designInfo);
Map<String, Object> designInfoMap = new HashMap<>();
String[] fields = {"DESIGN_DOC", "DESIGN_STANDARD"};
try {
designInfoMap = this.convertCamelToUnderscore(designInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
designInfoMap.put("DESIGNINFO_SEQ", designInfo.getSequenceNbr());
objMap.putAll(designInfoMap);
}
//制造信息
IdxBizJgFactoryInfo factoryInfo = iIdxBizJgFactoryInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(factoryInfo)) {
Map<String, Object> factoryInfoMap = Bean.BeantoMap(factoryInfo);
Map<String, Object> factoryInfoMap = new HashMap<>();
String[] fields = {"FACTORY_STANDARD", "PRODUCT_QUALITY_YIELD_PROVE", "INS_USE_MAINTAIN_EXPLAIN"};
try {
factoryInfoMap = this.convertCamelToUnderscore(factoryInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
factoryInfoMap.put("FACTORYINFO_SEQ", factoryInfo.getSequenceNbr());
objMap.putAll(factoryInfoMap);
}
//施工信息
IdxBizJgConstructionInfo constructionInfo = iIdxBizJgConstructionInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(constructionInfo)) {
Map<String, Object> constructionInfoMap = Bean.BeantoMap(constructionInfo);
Map<String, Object> constructionInfoMap = new HashMap<>();
String[] fields = null;
try {
constructionInfoMap = this.convertCamelToUnderscore(constructionInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
constructionInfoMap.put("CONSTRUCTIONINFO_SEQ", constructionInfo.getSequenceNbr());
objMap.putAll(constructionInfoMap);
}
//注册登记
IdxBizJgRegisterInfo registerInfo = this.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(registerInfo)) {
Map<String, Object> registerInfoMap = Bean.BeantoMap(registerInfo);
Map<String, Object> registerInfoMap = new HashMap<>();
String[] fields = {"PRODUCT_PHOTO"};
try {
registerInfoMap = this.convertCamelToUnderscore(registerInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
registerInfoMap.put("REGISTERINFO_SEQ", registerInfo.getSequenceNbr());
objMap.putAll(registerInfoMap);
}
//维保备案
IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = iIdxBizJgMaintenanceRecordInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(maintenanceRecordInfo)) {
Map<String, Object> maintenanceRecordInfoMap = Bean.BeantoMap(maintenanceRecordInfo);
Map<String, Object> maintenanceRecordInfoMap = new HashMap<>();
String[] fields = null;
try {
maintenanceRecordInfoMap = this.convertCamelToUnderscore(maintenanceRecordInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
maintenanceRecordInfoMap.put("MAINTENANCERECORDINFO_SEQ", maintenanceRecordInfo.getSequenceNbr());
objMap.putAll(maintenanceRecordInfoMap);
}
//监督管理
IdxBizJgSupervisionInfo supervisionInfo = iIdxBizJgSupervisionInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(supervisionInfo)) {
Map<String, Object> supervisionInfoMap = Bean.BeantoMap(supervisionInfo);
Map<String, Object> supervisionInfoMap = new HashMap<>();
String[] fields = null;
try {
supervisionInfoMap = this.convertCamelToUnderscore(supervisionInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
supervisionInfoMap.put("SUPERVISIONINFO_SEQ", supervisionInfo.getSequenceNbr());
objMap.putAll(supervisionInfoMap);
}
//其他信息
IdxBizJgOtherInfo otherInfo = iIdxBizJgOtherInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(otherInfo)) {
Map<String, Object> otherInfoMap = Bean.BeantoMap(otherInfo);
Map<String, Object> otherInfoMap = new HashMap<>();
String[] fields = null;
try {
otherInfoMap = this.convertCamelToUnderscore(otherInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
otherInfoMap.put("OTHERINFO_SEQ", otherInfo.getSequenceNbr());
objMap.putAll(otherInfoMap);
}
//检验检测
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = iIdxBizJgInspectionDetectionInfoService.getOneData(record);
if (!ValidationUtil.isEmpty(inspectionDetectionInfo)) {
Map<String, Object> inspectionDetectionInfoMap = Bean.BeantoMap(inspectionDetectionInfo);
Map<String, Object> inspectionDetectionInfoMap = new HashMap<>();
String[] fields = {"INSPECT_REPORT"};
try {
inspectionDetectionInfoMap = this.convertCamelToUnderscore(inspectionDetectionInfo, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
inspectionDetectionInfoMap.put("INSPECTIONDETECTIONINFO_SEQ", inspectionDetectionInfo.getSequenceNbr());
objMap.putAll(inspectionDetectionInfoMap);
}
......@@ -268,7 +322,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//电梯
IdxBizJgTechParamsElevator elevator = iIdxBizJgTechParamsElevatorService.getOneData(record);
if (!ValidationUtil.isEmpty(elevator)) {
Map<String, Object> elevatorMap = Bean.BeantoMap(elevator);
Map<String, Object> elevatorMap = new HashMap<>();
String[] fields = {"EXPLOSIONPROOF_SIGN_COMPLETE"};
try {
elevatorMap = this.convertCamelToUnderscore(elevator, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
elevatorMap.put("ELEVATOR_SEQ", elevator.getSequenceNbr());
objMap.putAll(elevatorMap);
}
......@@ -283,14 +343,26 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//主要零部件
IdxBizJgMainParts mainParts = iIdxBizJgMainPartsService.getOneData(record);
if (!ValidationUtil.isEmpty(mainParts)) {
Map<String, Object> mainPartsMap = Bean.BeantoMap(mainParts);
Map<String, Object> mainPartsMap = new HashMap<>();
String[] fields = null;
try {
mainPartsMap = this.convertCamelToUnderscore(mainParts, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
mainPartsMap.put("MAINPARTS_SEQ", mainParts.getSequenceNbr());
objMap.putAll(mainPartsMap);
}
//安全附件
IdxBizJgProtectionDevices protectionDevices = iIdxBizJgProtectionDevicesService.getOneData(record);
if (!ValidationUtil.isEmpty(protectionDevices)) {
Map<String, Object> protectionDevicesMap = Bean.BeantoMap(protectionDevices);
Map<String, Object> protectionDevicesMap = new HashMap<>();
String[] fields = null;
try {
protectionDevicesMap = this.convertCamelToUnderscore(protectionDevices, fields);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
protectionDevicesMap.put("PROTECTIONDEVICES_SEQ", protectionDevices.getSequenceNbr());
objMap.putAll(protectionDevicesMap);
}
......@@ -367,22 +439,22 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
// //查询 安装告知【可告知设备列表】【EQU_STATE===""】
if (!ObjectUtils.isEmpty(queryType) && ValidationUtil.equals(queryType, "AZ")) {
BoolQueryBuilder azBuilder = QueryBuilders.boolQuery();
azBuilder.mustNot(QueryBuilders.existsQuery("EQU_STATE"));
azBuilder.must(QueryBuilders.matchQuery("EQU_STATE", 9999));
boolMust.must(azBuilder);
}
//查询 维保备案【可绑定设备列表】【EQU_STATE==="" && INSPECT_REPORT!==9999(默认占位值)】
if (!ObjectUtils.isEmpty(queryType) && ValidationUtil.equals(queryType, "WB")) {
BoolQueryBuilder wbBuilder = QueryBuilders.boolQuery();
wbBuilder.mustNot(QueryBuilders.existsQuery("EQU_STATE"));
wbBuilder.mustNot(QueryBuilders.matchQuery("INSPECT_REPORT", 9999));
wbBuilder.must(QueryBuilders.matchQuery("EQU_STATE", 9999));
wbBuilder.mustNot(QueryBuilders.existsQuery("INSPECT_REPORT"));
boolMust.must(wbBuilder);
}
//查询 使用登记【可选设备列表】【EQU_STATUS==="" && INSPECT_REPORT!==9999(默认占位值) && USE_ORG_CODE!=="" 】
if (!ObjectUtils.isEmpty(queryType) && ValidationUtil.equals(queryType, "SY")) {
BoolQueryBuilder syBuilder = QueryBuilders.boolQuery();
syBuilder.mustNot(QueryBuilders.existsQuery("EQU_STATE"));
syBuilder.mustNot(QueryBuilders.matchQuery("INSPECT_REPORT", 9999));
syBuilder.mustNot(QueryBuilders.matchQuery("USE_ORG_CODE", ""));
syBuilder.must(QueryBuilders.matchQuery("EQU_STATE", 9999));
syBuilder.mustNot(QueryBuilders.existsQuery("INSPECT_REPORT"));
syBuilder.mustNot(QueryBuilders.existsQuery("USE_ORG_CODE"));
boolMust.must(syBuilder);
}
......@@ -455,7 +527,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String record = null;
LinkedHashMap equipmentInfoForm = (LinkedHashMap) map.get(EQUIPMENT_INFO_FORM_ID);
//操作类型
String operateType = ValidationUtil.isEmpty(String.valueOf(equipmentInfoForm.get("SEQUENCE_NBR"))) ? OPERATESAVE : OPERATEEDIT;
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get("SEQUENCE_NBR")) ? OPERATESAVE : OPERATEEDIT;
record = OPERATESAVE.equals(operateType) ? UUID.randomUUID().toString() : equipmentInfoForm.get("RECORD").toString();
//使用信息
......@@ -616,4 +688,27 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
}
/**
* 将对象的属性由驼峰转为纯大写下划线格式
*
* @param object
* @return
* @throws IllegalAccessException
*/
public static Map<String, Object> convertCamelToUnderscore(Object object, String[] strToJsonArrayFields) throws IllegalAccessException {
Map<String, Object> result = new HashMap<>();
Class<?> clazz = object.getClass();
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
String fieldName = field.getName();
String underscoreFieldName = StringUtils.camelToUnderline(fieldName).toUpperCase();
Object value = field.get(object);
//需要转为jsonArray的字段
if (!ValidationUtil.isEmpty(strToJsonArrayFields) && Arrays.asList(strToJsonArrayFields).contains(underscoreFieldName)) {
value = JSON.parseArray((String) field.get(object));
}
result.put(underscoreFieldName.toUpperCase(), value);
}
return result;
}
}
\ 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