Commit 4197d376 authored by 刘林's avatar 刘林

fix(Statistics):监管接口迁移

parent 879293f0
package com.yeejoin.amos.boot.module.statistcs.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FourColorCountDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.JGDPStatisticsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -17,7 +18,6 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
......@@ -351,4 +351,134 @@ public class JGDPStatisticsController {
}
return ResponseHelper.buildResponse(statisticsService.getBusinessType(dpFilterParamForDetailDto));
}
/**
* 查询设备注册列表
*
* @param map
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "设备注册信息分页查询", notes = "设备注册信息分页查询")
public ResponseModel<Page<JSONObject>> queryForPage(@RequestParam Map<String, Object> map) {
JSONObject jsonObject = new JSONObject(map);
return ResponseHelper.buildResponse(statisticsService.queryForEquipmentRegisterPage(jsonObject));
}
/**
* 查询设备注册信息详情
*
* @param record
* @return 返回由页签的key包裹详情对象
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{record}")
@ApiOperation(httpMethod = "GET", value = "根据record查询设备注册信息详情", notes = "根据record查询设备注册信息详情")
public ResponseModel<Object> selectOne(@PathVariable String record, @RequestParam(required = false) String isCopy) {
return ResponseHelper.buildResponse(statisticsService.getEquipmentRegisterByRecord(record, isCopy));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/equOnJgServiceOperationRecords")
@ApiOperation(httpMethod = "GET", value = "查询设备在jg业务中的记录", notes = "查询设备在jg业务中的记录")
public ResponseModel<List<Map<String, String>>> equOnJgServiceOperationRecords(@RequestParam(value = "record") String record) {
return ResponseHelper.buildResponse(statisticsService.equOnJgServiceOperationRecords(record));
}
/**
* 设备问题列表分页查询
*
* @param current 当前页
* @param size 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/equipId/page")
@ApiOperation(httpMethod = "GET",value = "设备问题列表分页查询", notes = "设备问题列表分页查询")
public ResponseModel<Page<SafetyProblemTracingDto>> queryProblemPageByEquipId(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size, @RequestParam(value = "record") String equipId) {
Page<SafetyProblemTracingDto> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(statisticsService.queryProblemPageByEquipId(page, equipId));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个安全追溯问题", notes = "根据sequenceNbr查询单个安全追溯问题")
public ResponseModel<SafetyProblemTracingDto> selectSafetyProblem(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(statisticsService.selectSafetyProblem(sequenceNbr));
}
/**
* 根据问题ID及问题类型查询关联设备列表
*
* @param problemId 问题Id
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据问题ID及问题类型查询关联设备列表", notes = "根据问题ID及问题类型查询关联设备列表")
@GetMapping(value = "/equip/list")
public ResponseModel<Page<Map<String, Object>>> queryEquipListProblemById(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size, @RequestParam(value = "sequenceNbr") String problemId) {
Page<Map<String, Object>> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(statisticsService.queryEquipListByProblemId(page, problemId));
}
/**
* 根据问题ID及问题类型查询关联企业
*
* @param problemId 问题Id
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "根据问题ID及问题类型查询关联企业", notes = "根据问题ID及问题类型查询关联企业")
@GetMapping(value = "/unit/list")
public ResponseModel<Page<Map<String, Object>>> queryPrincipalUnitByProblemId(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size, @RequestParam(value = "sequenceNbr") String problemId) {
Page<Map<String, Object>> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(statisticsService.queryPrincipalUnitByProblemId(page, problemId));
}
/**
* 根据sequenceNbr查询---大屏使用
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/detail/dp")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询---大屏使用", notes = "根据sequenceNbr查询---大屏使用")
public ResponseModel<Object> getRegistrationDetail(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(statisticsService.getRegistrationDetail(sequenceNbr));
}
/**
* 根据sequenceNbr查询使用登记证对应设备列表---使用登记证详情用
* 分页接口
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/detail/equList")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询使用登记证对应设备列表---使用登记证详情用", notes = "根据sequenceNbr查询使用登记证对应设备列表---使用登记证详情用")
public ResponseModel<Page<JSONObject>> certificateEquList(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(statisticsService.certificateEquList(current, size, sequenceNbr));
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto;
import com.yeejoin.amos.boot.module.common.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.common.api.enums.NoticBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipBizCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FourColorCountDataDto;
import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.FourColorCountItemEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.FourColorEnum;
import com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgCertificateChangeRecord;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.statistics.api.mapper.JGStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
......@@ -33,16 +50,27 @@ import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
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 java.io.IOException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
......@@ -51,6 +79,7 @@ import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray;
/**
* 大屏统计实现类
......@@ -101,6 +130,41 @@ public class JGDPStatisticsServiceImpl {
*/
private final static String REGION_NAME = "regionName";
// 设备分类表单id
private static final String EQUIP_CLASS_FORM_ID = "equipClass";
// 设备基本信息表单id
private static final String EQUIP_INFO_FORM_ID = "equipInfo";
// 设备技术参数表单id
private static final String EQUIP_PARAMS_FORM_ID = "equipParams";
private static final String EQUSTATE = "EQU_STATE";
private static final String CONSTRUCTIONTYPE = "CONSTRUCTION_TYPE";
// 设备代码
private static final String EQU_CODE = "EQU_CODE";
// 96333识别码
private static final String SEQUENCE_NBR = "SEQUENCE_NBR";
private static final String FACTORY_NUM = "FACTORY_NUM";
// 设备种类
public static final String EQU_LIST = "EQU_LIST";
// 设备类别
public static final String EQU_CATEGORY = "EQU_CATEGORY";
// 设备品种
public static final String EQU_DEFINE = "EQU_DEFINE";
// 是否车用气瓶
public static final String WHETHER_VEHICLE_CYLINDER = "WHETHER_VEHICLE_CYLINDER";
// 是否撬装式压力容器
public static final String WHETHER_SKID_MOUNTED_PRESSURE_VESSEL = "WHETHER_SKID_MOUNTED_PRESSURE_VESSEL";
// 设备纳管 纳管:true 未纳管:false
public static final String IS_INTO_MANAGEMENT = "IS_INTO_MANAGEMENT";
// 设备来源 jg:新设备录入 jg_his:历史数据录入
public static final String DATA_SOURCE = "DATA_SOURCE";
// 设备来源名称 jg:新设备 jg_his:历史数据
public static final String DATA_SOURCE_NAME = "DATA_SOURCE_NAME";
public static final String USE_PLACE_CODE = "USE_PLACE_CODE";
public static final String EQU_CATEGORY_CODE = "EQU_CATEGORY_CODE";
public static final String PROJECT_CONTRAPTION = "PROJECT_CONTRAPTION";// 工程装置名称
@Value("classpath:/json/registrationBasic.json")
private Resource registrationBasicJson;
private JgUseRegistrationMapper useRegistrationMapper;
......@@ -124,7 +188,81 @@ public class JGDPStatisticsServiceImpl {
private StCommonServiceImpl stCommonService;
public JGDPStatisticsServiceImpl(JgUseRegistrationMapper useRegistrationMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper, ZLStatisticsMapper zlStatisticsMapper, JGStatisticsMapper jgStatisticsMapper, JgUseRegistrationManageMapper jgUseRegistrationManageMapper, StCommonServiceImpl stCommonService) {
private RedisUtils redisUtils;
private SafetyProblemTracingMapper safetyProblemTracingMapper;
private JgCertificateChangeRecordMapper jgCertificateChangeRecordMapper;
private IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private EquipmentCategoryMapper equipmentCategoryMapper;
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
private IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
private IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
private IdxBizJgTechParamsRopewayMapper idxBizJgTechParamsRopewayMapper;
private IdxBizJgTechParamsBoilerMapper idxBizJgTechParamsBoilerMapper;
private IdxBizJgConstructionInfoMapper idxBizJgConstructionInfoMapper;
private IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
private IdxBizJgMaintenanceRecordInfoMapper idxBizJgMaintenanceRecordInfoMapper;
private IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper;
private IdxBizJgMainPartsMapper idxBizJgMainPartsMapper;
private IdxBizJgProtectionDevicesMapper idxBizJgProtectionDevicesMapper;
private IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper;
private IdxBizJgTechParamsVehicleMapper idxBizJgTechParamsVehicleMapper;
private IdxBizJgTechParamsRidesMapper idxBizJgTechParamsRidesMapper;
private IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
private IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
private IdxBizJgTechParamsLiftingMapper idxBizJgTechParamsLiftingMapper;
public JGDPStatisticsServiceImpl(JgUseRegistrationMapper useRegistrationMapper, JgEnableDisableMapper enableDisableMapper,
JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient,
TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper,
TzsUserInfoMapper userInfoMapper, ZLStatisticsMapper zlStatisticsMapper,
JGStatisticsMapper jgStatisticsMapper,
JgUseRegistrationManageMapper jgUseRegistrationManageMapper,
StCommonServiceImpl stCommonService, RedisUtils redisUtils,
JgCertificateChangeRecordMapper jgCertificateChangeRecordMapper,
IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper,
EquipmentCategoryMapper equipmentCategoryMapper,
IdxBizJgUseInfoMapper idxBizJgUseInfoMapper,
IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper,
IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper,
IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper,
IdxBizJgTechParamsRopewayMapper idxBizJgTechParamsRopewayMapper,
IdxBizJgConstructionInfoMapper idxBizJgConstructionInfoMapper,
IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper,
IdxBizJgMaintenanceRecordInfoMapper idxBizJgMaintenanceRecordInfoMapper,
IdxBizJgInspectionDetectionInfoMapper idxBizJgInspectionDetectionInfoMapper,
IdxBizJgMainPartsMapper idxBizJgMainPartsMapper,
IdxBizJgProtectionDevicesMapper idxBizJgProtectionDevicesMapper,
IdxBizJgTechParamsLiftingMapper iIdxBizJgTechParamsLiftingMapper,
IdxBizJgTechParamsVehicleMapper idxBizJgTechParamsVehicleMapper,
IdxBizJgTechParamsRidesMapper idxBizJgTechParamsRidesMapper,
IdxBizJgTechParamsBoilerMapper idxBizJgTechParamsBoilerMapper,
IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper,
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper,
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper,
SafetyProblemTracingMapper safetyProblemTracingMapper) {
this.useRegistrationMapper = useRegistrationMapper;
this.enableDisableMapper = enableDisableMapper;
this.scrapCancelMapper = scrapCancelMapper;
......@@ -136,6 +274,28 @@ public class JGDPStatisticsServiceImpl {
this.jgStatisticsMapper = jgStatisticsMapper;
this.jgUseRegistrationManageMapper = jgUseRegistrationManageMapper;
this.stCommonService = stCommonService;
this.redisUtils = redisUtils;
this.safetyProblemTracingMapper = safetyProblemTracingMapper;
this.jgCertificateChangeRecordMapper = jgCertificateChangeRecordMapper;
this.equipmentCategoryMapper = equipmentCategoryMapper;
this.idxBizJgUseInfoMapper = idxBizJgUseInfoMapper;
this.idxBizJgDesignInfoMapper = idxBizJgDesignInfoMapper;
this.idxBizJgSupervisionInfoMapper = idxBizJgSupervisionInfoMapper;
this.idxBizJgTechParamsRopewayMapper = idxBizJgTechParamsRopewayMapper;
this.idxBizJgTechParamsBoilerMapper = idxBizJgTechParamsBoilerMapper;
this.idxBizJgFactoryInfoMapper = idxBizJgFactoryInfoMapper;
this.idxBizJgRegisterInfoMapper = idxBizJgRegisterInfoMapper;
this.idxBizJgConstructionInfoMapper = idxBizJgConstructionInfoMapper;
this.idxBizJgOtherInfoMapper = idxBizJgOtherInfoMapper;
this.idxBizJgMaintenanceRecordInfoMapper = idxBizJgMaintenanceRecordInfoMapper;
this.idxBizJgInspectionDetectionInfoMapper = idxBizJgInspectionDetectionInfoMapper;
this.idxBizJgMainPartsMapper = idxBizJgMainPartsMapper;
this.idxBizJgProtectionDevicesMapper = idxBizJgProtectionDevicesMapper;
this.idxBizJgTechParamsVehicleMapper = idxBizJgTechParamsVehicleMapper;
this.idxBizJgTechParamsRidesMapper = idxBizJgTechParamsRidesMapper;
this.idxBizJgTechParamsVesselMapper = idxBizJgTechParamsVesselMapper;
this.idxBizJgTechParamsPipelineMapper = idxBizJgTechParamsPipelineMapper;
this.idxBizJgTechParamsLiftingMapper = iIdxBizJgTechParamsLiftingMapper;
}
private List<LegendDataDto> buildLegendDataList() {
......@@ -1683,4 +1843,1346 @@ public class JGDPStatisticsServiceImpl {
return jgStatisticsMapper.selectNoticeDetailList(page,orgCode, time, dpFilterParamDto);
}
}
public List<Map<String, String>> equOnJgServiceOperationRecords(String record) {
return commonMapper.equOnJgServiceOperationRecords(record).stream()
.map(x -> {
Map<String, String> map = new HashMap<>();
map.put("operatingTime", x.get("recDate"));
String content = String.format("%s 创建人:%s 单号【%s】 审批单位:%s",
x.get("businessType"), x.get("recUserName"), x.get("applyNo"), x.get("approvalUnit"));
map.put("content", content);
map.put("routePath", x.get("routePath"));
return map;
})
.collect(Collectors.toList());
}
/**
* 设备注册信息分页查询
*
* @param map
* @return
*/
public Page<JSONObject> queryForEquipmentRegisterPage(JSONObject map) {
if (map.containsKey("flag") && !map.containsKey("USE_UNIT_CREDIT_CODE")) {
return new Page<>();
}
Integer pageNumber = ObjectUtils.isEmpty(map.getInteger("number")) ? 1 : map.getInteger("number");
Integer size = ObjectUtils.isEmpty(map.getInteger("size")) ? 20 : map.getInteger("size");
Page<JSONObject> result = new Page<>(pageNumber, size);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 获取当前登录人单位类型
JSONObject company = getCompanyType();
if (ValidationUtil.isEmpty(company)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
String companyCode = company.getString("companyCode").contains("_") ?
company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType");
// 根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (ObjectUtils.isEmpty(map.getString(SEQUENCE_NBR)) && ObjectUtils.isEmpty(map.getString("useUnitCreditCode"))) {
if (!ValidationUtil.isEmpty(type) && type.contains("使用单位")) {
if (ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
// 默认条件【STATUS==="" || null】
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.should(QueryBuilders.matchQuery("STATUS", "已认领"));
meBuilder.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("STATUS")));
meBuilder.should(QueryBuilders.boolQuery().must(QueryBuilders.matchPhraseQuery("STATUS", "")));
meBuilder.minimumShouldMatch(1);
boolMust.must(meBuilder);
// DATA_SOURCE 为“jg”开头的数据(从监管新加或复制的设备)
// 20240314 提出的监管业务不要让企业用户选到之前一码通认领或补录的设备,让从监管业务中去新增
BoolQueryBuilder dBuilder = QueryBuilders.boolQuery();
if (map.containsKey("DATA_SOURCE") && !ObjectUtils.isEmpty(map.get("DATA_SOURCE"))) {
if ("jg_his".equals(map.get("DATA_SOURCE"))) {// 只查历史,前缀jg_his
dBuilder.must(QueryBuilders.prefixQuery("DATA_SOURCE", "jg_his"));
} else if (!"jg_his".equals(map.getString("DATA_SOURCE"))) {// 只查新增,前缀为jg且前缀不为jg_his
dBuilder.must(QueryBuilders.prefixQuery("DATA_SOURCE", "jg"));
dBuilder.mustNot(QueryBuilders.prefixQuery("DATA_SOURCE", "jg_his"));
}
} else {
// 查所有,前缀jg
dBuilder.must(QueryBuilders.prefixQuery("DATA_SOURCE", "jg"));
}
boolMust.must(dBuilder);
// 通用匹配规则,其他条件构建
if (!ObjectUtils.isEmpty(map.getString(SEQUENCE_NBR))) {
BoolQueryBuilder seqBuilder = QueryBuilders.boolQuery();
String param = map.getString(SEQUENCE_NBR);
List<String> strings = Arrays.asList(param.split(","));
seqBuilder.must(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", strings));
boolMust.must(seqBuilder);
}
if (!ObjectUtils.isEmpty(map.getString(IS_INTO_MANAGEMENT))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String param = QueryParser.escape(map.getString(IS_INTO_MANAGEMENT));
pBuilder.must(QueryBuilders.matchQuery(IS_INTO_MANAGEMENT, param));
boolMust.must(pBuilder);
}
if (!ObjectUtils.isEmpty(map.getString(EQU_CATEGORY))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String param = QueryParser.escape(map.getString(EQU_CATEGORY));
pBuilder.must(QueryBuilders.matchPhraseQuery(EQU_CATEGORY, "*" + param + "*"));
boolMust.must(pBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String param = QueryParser.escape(map.getString("USE_PLACE"));
pBuilder.must(QueryBuilders.matchPhraseQuery("USE_PLACE", "*" + param + "*"));
boolMust.must(pBuilder);
}
// 设备状态
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE"))) {
BoolQueryBuilder esBuilder = QueryBuilders.boolQuery();
String param = QueryParser.escape(map.getLong("EQU_STATE").toString());
esBuilder.must(QueryBuilders.matchQuery("EQU_STATE", param));
boolMust.must(esBuilder);
}
// 使用单位 //安装改造维修单位
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) && !ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder ubuilder = QueryBuilders.boolQuery();
String useCode = QueryParser.escape(map.getString("USE_UNIT_CREDIT_CODE"));
useCode = useCode.contains("_") ? useCode.split("_")[0] : useCode;
ubuilder.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", useCode));
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
ubuilder.must(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + QueryParser.escape(uscCode) + "*"));
boolMust.must(ubuilder);
} else {
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) || !ObjectUtils.isEmpty(map.getString("useUnitCreditCode"))) {
BoolQueryBuilder uuccBuilder = QueryBuilders.boolQuery();
String uucc = !ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) ? map.getString("USE_UNIT_CREDIT_CODE") : map.getString("useUnitCreditCode");
String param = QueryParser.escape(uucc);
param = param.contains("_") ? param.split("_")[0] : param;
uuccBuilder.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", param));
boolMust.must(uuccBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder uuccBuilder = QueryBuilders.boolQuery();
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
uuccBuilder.must(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + QueryParser.escape(uscCode) + "*"));
boolMust.must(uuccBuilder);
}
}
// 监管码
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
BoolQueryBuilder scBuilder = QueryBuilders.boolQuery();
String param = map.getString("SUPERVISORY_CODE");
List<String> strings = Arrays.asList(param.split(","));
scBuilder.must(QueryBuilders.termsQuery("SUPERVISORY_CODE", strings));
boolMust.must(scBuilder);
}
// 设备种类编码
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
BoolQueryBuilder elcBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("EQU_LIST_CODE"));
elcBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST_CODE", test));
boolMust.must(elcBuilder);
}
// 设备类别编码
if (!ObjectUtils.isEmpty(map.getString("EQU_DEFINE_CODE"))) {
BoolQueryBuilder elcBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("EQU_DEFINE_CODE"));
elcBuilder.must(QueryBuilders.matchPhraseQuery("EQU_DEFINE_CODE", test));
boolMust.must(elcBuilder);
}
// 设备种类名称
if (!ObjectUtils.isEmpty(map.getString(EQU_LIST))) {
BoolQueryBuilder elBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(EQU_LIST));
elBuilder.must(QueryBuilders.matchPhraseQuery(EQU_LIST, "*" + test + "*"));
boolMust.must(elBuilder);
}
// 设备类别
if (!ObjectUtils.isEmpty(map.getString(EQU_CATEGORY_CODE))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(EQU_CATEGORY_CODE));
pBuilder.must(QueryBuilders.termQuery(EQU_CATEGORY_CODE, test));
boolMust.must(pBuilder);
}
// 是否车用气瓶
if (!ObjectUtils.isEmpty(map.getString(WHETHER_VEHICLE_CYLINDER))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(WHETHER_VEHICLE_CYLINDER));
pBuilder.must(QueryBuilders.termQuery(WHETHER_VEHICLE_CYLINDER, test));
boolMust.must(pBuilder);
}
// 是否撬装式压力容器
if (!ObjectUtils.isEmpty(map.getString(WHETHER_SKID_MOUNTED_PRESSURE_VESSEL)) && !"0".equals(map.getString(WHETHER_SKID_MOUNTED_PRESSURE_VESSEL))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(WHETHER_SKID_MOUNTED_PRESSURE_VESSEL));
pBuilder.must(QueryBuilders.termQuery(WHETHER_SKID_MOUNTED_PRESSURE_VESSEL, test));
boolMust.must(pBuilder);
}
// 设备代码模糊查询
if (!ObjectUtils.isEmpty(map.getString(EQU_CODE))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(EQU_CODE));
pBuilder.must(QueryBuilders.wildcardQuery(EQU_CODE, "*" + QueryParser.escape(test.toLowerCase()) + "*"));
boolMust.must(pBuilder);
}
// 单位内部编号模糊查询
if (!ObjectUtils.isEmpty(map.getString("USE_INNER_CODE"))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("USE_INNER_CODE"));
pBuilder.must(QueryBuilders.wildcardQuery("USE_INNER_CODE", "*" + QueryParser.escape(test.toLowerCase()) + "*"));
boolMust.must(pBuilder);
}
// 出厂编号/产品编码模糊查询
if (!ObjectUtils.isEmpty(map.getString(FACTORY_NUM))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(FACTORY_NUM));
pBuilder.must(QueryBuilders.wildcardQuery(FACTORY_NUM, "*" + QueryParser.escape(test.toLowerCase()) + "*"));
boolMust.must(pBuilder);
}
// 制造单位(生产单位)名称模糊查询
if (!ObjectUtils.isEmpty(map.getString("PRODUCE_UNIT_NAME"))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("PRODUCE_UNIT_NAME"));
pBuilder.must(QueryBuilders.wildcardQuery("PRODUCE_UNIT_NAME", "*" + QueryParser.escape(test.toLowerCase()) + "*"));
boolMust.must(pBuilder);
}
// 模糊查询
if (!ObjectUtils.isEmpty(map.getString(USE_PLACE_CODE))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString(USE_PLACE_CODE));
pBuilder.must(QueryBuilders.wildcardQuery(USE_PLACE_CODE, "*" + QueryParser.escape(test.toLowerCase()) + "*"));
boolMust.must(pBuilder);
}
// 工程装置名称模糊查询
if (!ObjectUtils.isEmpty(map.getString(PROJECT_CONTRAPTION))) {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
pBuilder.must(QueryBuilders.termsQuery("PROJECT_CONTRAPTION.keyword", map.getString(PROJECT_CONTRAPTION)));
boolMust.must(pBuilder);
}
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
builder.from((pageNumber - 1) * size);
builder.size(size);
request.source(builder);
List<JSONObject> list = new LinkedList<>();
long totle = 0;
if (log.isDebugEnabled()) {
log.debug("查询es 的查询条件: {}", request);
}
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
if (!ValidationUtil.isEmpty(dto2.get(CONSTRUCTIONTYPE))) {
// 转化施工类型
String constructionType = dto2.get(CONSTRUCTIONTYPE).toString();
if (!ValidationUtil.isEmpty(constructionType)) {
List<String> constructionTypeList = Arrays.asList(constructionType.split(","));
List<String> statusList = new ArrayList<>();
for (String cType : constructionTypeList) {
Integer integer = Integer.valueOf(cType);
String status = ConstructionEnum.getName.get(integer);
statusList.add(status);
}
dto2.put(CONSTRUCTIONTYPE, Joiner.on(",").join(statusList));
}
}
if (!ValidationUtil.isEmpty(dto2.get(EQUSTATE))) {
Integer integer = Integer.valueOf(dto2.get(EQUSTATE).toString());
String status = EquimentEnum.getName.get(integer);
dto2.put(EQUSTATE, status);
}
if (!ValidationUtil.isEmpty(dto2.get(DATA_SOURCE))) {
String s = dto2.get(DATA_SOURCE).toString();
dto2.put(DATA_SOURCE, s);
dto2.put(DATA_SOURCE_NAME, Arrays.stream(EquipSourceEnum.values())
.filter(e -> s.startsWith(e.getCode()))
.map(EquipSourceEnum::getName)
.findFirst()
.orElse(EquipSourceEnum.jg.getName()));
}
dto2.put("record", dto2.get(SEQUENCE_NBR));
list.add(dto2);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 获取当前登录人单位类型
*
* @return
*/
public JSONObject getCompanyType() {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
JSONObject object = new JSONObject();
if (!ValidationUtil.isEmpty(company)) {
object.put("level", company.getLevel());
object.put("orgCode", company.getOrgCode());
object.put("companyName", company.getCompanyName());
object.put("companyCode", company.getCompanyCode());
object.put("companyType", company.getCompanyType());
}
return object;
}
/**
* 查询设备注册信息详情
*
* @param record
* @return
*/
public Map<String, Map<String, Object>> getEquipmentRegisterByRecord(String record, String isCopy) {
Map<String, Map<String, Object>> resultMap = new HashMap<>();
// 设备种类
Map<String, Object> equIpClassMap = this.getEquIpClassMap(record, "");
// 设备注册信息
Map<String, Object> equipInfoMap = this.getEquipInfoMap(record, "");
if (!ValidationUtil.isEmpty(equIpClassMap)) {
resultMap.put(EQUIP_CLASS_FORM_ID, equIpClassMap);
}
if (!ValidationUtil.isEmpty(equipInfoMap)) {
resultMap.put(EQUIP_INFO_FORM_ID, equipInfoMap);
}
// 设备参数
if (equIpClassMap.containsKey(EQU_LIST) && !ValidationUtil.isEmpty(equIpClassMap.get(EQU_LIST).toString())) {
Map<String, Object> equipParamsMap = this.getEquipParamsMap(record, "", equIpClassMap.get(EQU_LIST).toString());
if (!ValidationUtil.isEmpty(equipParamsMap)) {
// 给技术参数中添加设备种类,标记技术参数属于那个设备
equipParamsMap.put(EQU_LIST, String.valueOf(equIpClassMap.get(EQU_LIST)));
equipParamsMap.put(EQU_CATEGORY, String.valueOf(equIpClassMap.get(EQU_CATEGORY)));
equipParamsMap.put(EQU_DEFINE, String.valueOf(equIpClassMap.get(EQU_DEFINE)));
resultMap.put(EQUIP_PARAMS_FORM_ID, equipParamsMap);
}
}
// 处理复制设备信息
if ("1".equals(isCopy)) {
equipInfoMap.put("EQU_CODE_TYPE", "1");
equipInfoMap.put("SUPERVISORY_CODE", null);
equipInfoMap.put("CAR_NUMBER", null);
equIpClassMap.put("CAR_NUMBER", null);
}
return resultMap;
}
/**
* 查询设备种类信息
*
* @param record 设备Id
* @param fieldType 返回字段类型【CamelCase:驼峰命名,“”:纯大写加下划线】
* @return
*/
private Map<String, Object> getEquIpClassMap(String record, String fieldType) {
Map<String, Object> objMap = new HashMap<>();
// 注册登记
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(registerInfo)) {
String equList = registerInfo.getEquList();// 设备种类
String equCategory = registerInfo.getEquCategory();// 设备类别
String equDefine = registerInfo.getEquDefine();// 设备品种
List<EquipmentCategory> categoryList0 = this.getEquipmentCategoryList(equList, null);
List<EquipmentCategory> categoryList1 = this.getEquipmentCategoryList(equCategory, null);
List<EquipmentCategory> categoryList2 = this.getEquipmentCategoryList(equDefine, null);
Map<String, Object> registerInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
registerInfoMap = Bean.BeantoMap(registerInfo);
registerInfoMap.put("registerinfoSeq", registerInfo.getSequenceNbr());
registerInfoMap.put("sequenceNbr", registerInfo.getSequenceNbr());
registerInfoMap.put("productPhoto", JSON.parseArray(registerInfo.getProductPhoto()));
registerInfoMap.put("useRegistrationCode", registerInfo.getUseOrgCode());
if (CollectionUtils.isNotEmpty(categoryList0)) {
registerInfoMap.put("equListDesc", categoryList0.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList1)) {
registerInfoMap.put("equCategoryDesc", categoryList1.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList2)) {
registerInfoMap.put("equDefineDesc", categoryList2.get(0).getName());
}
} else {
String[] fields = {"PRODUCT_PHOTO"};
registerInfoMap = convertCamelToUnderscore(registerInfo, fields);
registerInfoMap.put("REGISTERINFO_SEQ", registerInfo.getSequenceNbr());
registerInfoMap.put(SEQUENCE_NBR, registerInfo.getSequenceNbr());
if (CollectionUtils.isNotEmpty(categoryList1)) {
registerInfoMap.put("EQU_CATEGORY_DESC", categoryList1.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList2)) {
registerInfoMap.put("EQU_DEFINE_DESC", categoryList2.get(0).getName());
}
}
if (!registerInfoMap.isEmpty()) {
Map<String, Object> filterMap = registerInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
return objMap;
}
public List<EquipmentCategory> getEquipmentCategoryList(String code, String type) {
List<EquipmentCategory> result = new ArrayList<>();
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory::getCode, code);
EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(type)) {
if (!ValidationUtil.isEmpty(equipmentCategory)) {
result.add(equipmentCategory);
}
} else {
LambdaQueryWrapper<EquipmentCategory> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(EquipmentCategory::getParentId, equipmentCategory.getId());
List<EquipmentCategory> equipmentCategories = equipmentCategoryMapper.selectList(wrapper2);
if (!ValidationUtil.isEmpty(equipmentCategories)) {
result = equipmentCategories;
}
}
return result;
}
/**
* 将对象的属性由驼峰转为纯大写下划线格式
*
* @param object
* @return
* @throws IllegalAccessException
*/
public static Map<String, Object> convertCamelToUnderscore(Object object, String[] strToJsonArrayFields) {
Map<String, Object> result = new HashMap<>();
Class<?> clazz = object.getClass();
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
String fieldName = field.getName();
String underscoreFieldName = com.baomidou.mybatisplus.core.toolkit.StringUtils.camelToUnderline(fieldName).toUpperCase();
Object value;
try {
value = field.get(object);
// 需要转为jsonArray的字段
if (!ValidationUtil.isEmpty(strToJsonArrayFields) && Arrays.asList(strToJsonArrayFields).contains(underscoreFieldName)) {
value = JSON.parseArray((String) field.get(object));
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
if (!ValidationUtil.isEmpty(value)) {
result.put(underscoreFieldName.toUpperCase(), value);
}
}
return result;
}
/**
* 查询设备基本信息
*
* @param record 设备Id
* @param fieldType 返回字段类型【CamelCase:驼峰命名,“”:纯大写加下划线】
* @return
*/
private Map<String, Object> getEquipInfoMap(String record, String fieldType) {
Map<String, Object> objMap = new HashMap<>();
String province = "";
String city = "";
String county = "";
String street = "";
String fullAddress = "";
// 设备问题信息(大屏二级页面使用)
LambdaQueryWrapper<SafetyProblemTracing> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SafetyProblemTracing::getSourceId, record);
lambdaQueryWrapper.orderByDesc(SafetyProblemTracing::getRecDate);
List<SafetyProblemTracing> safetyProblemTracings = safetyProblemTracingMapper.selectList(lambdaQueryWrapper);
if (!ObjectUtils.isEmpty(safetyProblemTracings)) {
objMap.put("problemStatus", ProblemStatusEnum.getNameByDesc.get(safetyProblemTracings.get(0).getProblemStatus()));
objMap.put("problemTime", safetyProblemTracings.get(0).getProblemTime());
}
// 使用信息
IdxBizJgUseInfo useInfo = idxBizJgUseInfoMapper.selectOne(new QueryWrapper<IdxBizJgUseInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(useInfo)) {
if (!ValidationUtil.isEmpty(useInfo.getProvince()) && !ValidationUtil.isEmpty(useInfo.getProvinceName())) {
province = useInfo.getProvince() + "_" + useInfo.getProvinceName();
fullAddress += useInfo.getProvinceName();
}
if (!ValidationUtil.isEmpty(useInfo.getCity()) && !ValidationUtil.isEmpty(useInfo.getCityName())) {
city = useInfo.getCity() + "_" + useInfo.getCityName();
fullAddress += useInfo.getCityName();
}
if (!ValidationUtil.isEmpty(useInfo.getCounty()) && !ValidationUtil.isEmpty(useInfo.getCountyName())) {
county = useInfo.getCounty() + "_" + useInfo.getCountyName();
fullAddress += useInfo.getCountyName();
}
if (!ValidationUtil.isEmpty(useInfo.getFactoryUseSiteStreet()) && !ValidationUtil.isEmpty(useInfo.getStreetName())) {
street = useInfo.getFactoryUseSiteStreet() + "_" + useInfo.getStreetName();
fullAddress += useInfo.getStreetName();
}
if (!ValidationUtil.isEmpty(useInfo.getAddress())) {
fullAddress += useInfo.getAddress();
}
Map<String, Object> useInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
useInfoMap = Bean.BeantoMap(useInfo);
if (!ValidationUtil.isEmpty(province)) {
useInfoMap.put("province", province);
}
if (!ValidationUtil.isEmpty(city)) {
useInfoMap.put("city", city);
}
if (!ValidationUtil.isEmpty(county)) {
useInfoMap.put("county", county);
}
if (!ValidationUtil.isEmpty(street)) {
useInfoMap.put("street", street);
}
if (!ValidationUtil.isEmpty(fullAddress)) {
useInfoMap.put("fullAddress", fullAddress);
}
useInfoMap.put("useinfoSeq", useInfo.getSequenceNbr());
if (!ValidationUtil.isEmpty(useInfo.getLongitudeLatitude())) {
useInfoMap.put("longitudeLatitude", JSON.parseObject(useInfo.getLongitudeLatitude()));
useInfoMap.put("useLongitudeLatitude", JSON.parseObject(useInfo.getLongitudeLatitude()));
}
if (!ValidationUtil.isEmpty(useInfo.getAddress())) {
useInfoMap.put("useAddress", useInfo.getAddress());
}
} else {
useInfoMap = convertCamelToUnderscore(useInfo, null);
if (!ValidationUtil.isEmpty(province)) {
useInfoMap.put("PROVINCE", province);
}
if (!ValidationUtil.isEmpty(city)) {
useInfoMap.put("CITY", city);
}
if (!ValidationUtil.isEmpty(county)) {
useInfoMap.put("COUNTY", county);
}
if (!ValidationUtil.isEmpty(street)) {
useInfoMap.put("STREET", street);
}
if (!ValidationUtil.isEmpty(fullAddress)) {
useInfoMap.put("FULLADDRESS", fullAddress);
}
useInfoMap.put("USEINFO_SEQ", useInfo.getSequenceNbr());
useInfoMap.put("USE_PLACE", useInfo.getUsePlace());
if (!ValidationUtil.isEmpty(useInfo.getLongitudeLatitude())) {
useInfoMap.put("LONGITUDE_LATITUDE", JSON.parseObject(useInfo.getLongitudeLatitude()));
useInfoMap.put("USE_LONGITUDE_LATITUDE", JSON.parseObject(useInfo.getLongitudeLatitude()));
}
if (!ValidationUtil.isEmpty(useInfo.getAddress())) {
useInfoMap.put("USE_ADDRESS", useInfo.getAddress());
useInfoMap.put("FULL_ADDRESS", useInfo.getAddress());
}
}
if (!useInfoMap.isEmpty()) {
Map<String, Object> filterMap = useInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 设计制造
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoMapper.selectOne(new QueryWrapper<IdxBizJgDesignInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(designInfo)) {
Map<String, Object> designInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
designInfoMap = Bean.BeantoMap(designInfo);
designInfoMap.put("designinfoSeq", designInfo.getSequenceNbr());
designInfoMap.put("designDoc", JSON.parseArray(designInfo.getDesignDoc()));
designInfoMap.put("designStandard", JSON.parseArray(designInfo.getDesignStandard()));
if (!ObjectUtils.isEmpty(designInfoMap.get("otherAccessoriesDes"))) {
designInfoMap.put("otherAccessoriesDes", JSON.parse(String.valueOf(designInfoMap.get("otherAccessoriesDes"))));
}
} else {
String[] fields = {"DESIGN_DOC", "DESIGN_STANDARD", "OTHER_ACCESSORIES_DES"};
designInfoMap = convertCamelToUnderscore(designInfo, fields);
designInfoMap.put("DESIGNINFO_SEQ", designInfo.getSequenceNbr());
}
if (!designInfoMap.isEmpty()) {
Map<String, Object> filterMap = designInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 制造信息
IdxBizJgFactoryInfo factoryInfo = idxBizJgFactoryInfoMapper.selectOne(new QueryWrapper<IdxBizJgFactoryInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(factoryInfo)) {
Map<String, Object> factoryInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
factoryInfoMap = Bean.BeantoMap(factoryInfo);
String imported = factoryInfo.getImported();
if ("0".equals(imported)) {
factoryInfoMap.put("importedDesc", "否");
} else if ("1".equals(imported)) {
factoryInfoMap.put("importedDesc", "是");
}
factoryInfoMap.put("factoryinfoSeq", factoryInfo.getSequenceNbr());
factoryInfoMap.put("factoryStandard", JSON.parseArray(factoryInfo.getFactoryStandard()));
factoryInfoMap.put("productQualityYieldProve", JSON.parseArray(factoryInfo.getProductQualityYieldProve()));
factoryInfoMap.put("insUseMaintainExplain", JSON.parseArray(factoryInfo.getInsUseMaintainExplain()));
factoryInfoMap.put("factSupervisionInspectionReport", JSON.parseArray(factoryInfo.getFactSupervisionInspectionReport()));
factoryInfoMap.put("boilerEnergyEfficiencyCertificate", JSON.parseArray(factoryInfo.getBoilerEnergyEfficiencyCertificate()));
if (!ObjectUtils.isEmpty(factoryInfoMap.get("otherAccessoriesFact"))) {
factoryInfoMap.put("otherAccessoriesFact", JSON.parse(String.valueOf(factoryInfoMap.get("otherAccessoriesFact"))));
}
} else {
String[] fields = {"FACTORY_STANDARD", "PRODUCT_QUALITY_YIELD_PROVE", "INS_USE_MAINTAIN_EXPLAIN",
"OTHER_ACCESSORIES_FACT", "FACT_SUPERVISION_INSPECTION_REPORT", "BOILER_ENERGY_EFFICIENCY_CERTIFICATE"};
factoryInfoMap = convertCamelToUnderscore(factoryInfo, fields);
String imported = factoryInfo.getImported();
if ("0".equals(imported)) {
factoryInfoMap.put("IMPORTED_DESC", "否");
} else if ("1".equals(imported)) {
factoryInfoMap.put("IMPORTED_DESC", "是");
}
factoryInfoMap.put("FACTORYINFO_SEQ", factoryInfo.getSequenceNbr());
}
if (!factoryInfoMap.isEmpty()) {
Map<String, Object> filterMap = factoryInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 施工信息 【一对多,暂时只取最新一条数据】
IdxBizJgConstructionInfo constructionInfo = this.queryConstructionNewestDetailByRecord(record);
if (!ValidationUtil.isEmpty(constructionInfo)) {
Map<String, Object> constructionInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
constructionInfoMap = Bean.BeantoMap(constructionInfo);
constructionInfoMap.put("constructioninfoSeq", constructionInfo.getSequenceNbr());
} else {
constructionInfoMap = convertCamelToUnderscore(constructionInfo, null);
constructionInfoMap.put("CONSTRUCTIONINFO_SEQ", constructionInfo.getSequenceNbr());
}
if (!constructionInfoMap.isEmpty()) {
Map<String, Object> filterMap = constructionInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 注册登记
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(registerInfo)) {
String equCategory = registerInfo.getEquCategory();// 设备类别
String equDefine = registerInfo.getEquDefine();// 设备品种
List<EquipmentCategory> categoryList1 = this.getEquipmentCategoryList(equCategory, null);
List<EquipmentCategory> categoryList2 = this.getEquipmentCategoryList(equDefine, null);
Map<String, Object> registerInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
registerInfoMap = Bean.BeantoMap(registerInfo);
registerInfoMap.put("registerinfoSeq", registerInfo.getSequenceNbr());
registerInfoMap.put("sequenceNbr", registerInfo.getSequenceNbr());
registerInfoMap.put("productPhoto", JSON.parseArray(registerInfo.getProductPhoto()));
if (CollectionUtils.isNotEmpty(categoryList1)) {
registerInfoMap.put("equCategoryDesc", categoryList1.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList2)) {
registerInfoMap.put("equDefineDesc", categoryList2.get(0).getName());
}
if (!ObjectUtils.isEmpty(registerInfoMap.get("otherAccessoriesReg"))) {
registerInfoMap.put("otherAccessoriesReg", JSON.parse(String.valueOf(registerInfoMap.get("otherAccessoriesReg"))));
}
} else {
String[] fields = {"PRODUCT_PHOTO", "OTHER_ACCESSORIES_REG"};
registerInfoMap = convertCamelToUnderscore(registerInfo, fields);
registerInfoMap.put("REGISTERINFO_SEQ", registerInfo.getSequenceNbr());
registerInfoMap.put(SEQUENCE_NBR, registerInfo.getSequenceNbr());
if (CollectionUtils.isNotEmpty(categoryList1)) {
registerInfoMap.put("EQU_CATEGORY_DESC", categoryList1.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList2)) {
registerInfoMap.put("EQU_DEFINE_DESC", categoryList2.get(0).getName());
}
}
if (!registerInfoMap.isEmpty()) {
Map<String, Object> filterMap = registerInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 维保备案【一对多,暂时只取最新一条数据】
IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = this.queryMaintenanceNewestDetailByRecord(record);
if (!ValidationUtil.isEmpty(maintenanceRecordInfo)) {
Map<String, Object> maintenanceRecordInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
maintenanceRecordInfoMap = Bean.BeantoMap(maintenanceRecordInfo);
maintenanceRecordInfoMap.put("repairInform", JSON.parse(maintenanceRecordInfo.getRepairInform()));
maintenanceRecordInfoMap.put("maintenancerecordinfoSeq", maintenanceRecordInfo.getSequenceNbr());
} else {
String[] toArrayFields = {"repairInform"};
maintenanceRecordInfoMap = convertCamelToUnderscore(maintenanceRecordInfo, toArrayFields);
maintenanceRecordInfoMap.put("MAINTENANCERECORDINFO_SEQ", maintenanceRecordInfo.getSequenceNbr());
}
if (!maintenanceRecordInfoMap.isEmpty()) {
Map<String, Object> filterMap = maintenanceRecordInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 监督管理
IdxBizJgSupervisionInfo supervisionInfo = idxBizJgSupervisionInfoMapper.selectOne(new QueryWrapper<IdxBizJgSupervisionInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(supervisionInfo)) {
Map<String, Object> supervisionInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
supervisionInfoMap = Bean.BeantoMap(supervisionInfo);
supervisionInfoMap.put("supervisioninfoSeq", supervisionInfo.getSequenceNbr());
} else {
supervisionInfoMap = convertCamelToUnderscore(supervisionInfo, null);
supervisionInfoMap.put("SUPERVISIONINFO_SEQ", supervisionInfo.getSequenceNbr());
}
if (!supervisionInfoMap.isEmpty()) {
Map<String, Object> filterMap = supervisionInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 其他信息
IdxBizJgOtherInfo otherInfo = idxBizJgOtherInfoMapper.selectOne(new QueryWrapper<IdxBizJgOtherInfo>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(otherInfo)) {
Map<String, Object> otherInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
otherInfoMap = Bean.BeantoMap(otherInfo);
otherInfoMap.put("otherinfoSeq", otherInfo.getSequenceNbr());
} else {
otherInfoMap = convertCamelToUnderscore(otherInfo, null);
otherInfoMap.put("OTHERINFO_SEQ", otherInfo.getSequenceNbr());
}
Map<String, Object> filterMap = otherInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
// 检验检测【一对多,暂时只取最新一条数据】
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = this.queryInspectionNewestDetailByRecord(record);
if (!ValidationUtil.isEmpty(inspectionDetectionInfo)) {
Map<String, Object> inspectionDetectionInfoMap;
if (!ValidationUtil.isEmpty(fieldType)) {
inspectionDetectionInfoMap = Bean.BeantoMap(inspectionDetectionInfo);
inspectionDetectionInfoMap.put("inspectiondetectioninfoSeq", inspectionDetectionInfo.getSequenceNbr());
inspectionDetectionInfoMap.put("inspectReport", JSON.parseArray(inspectionDetectionInfo.getInspectReport()));
} else {
String[] fields = {"INSPECT_REPORT"};
inspectionDetectionInfoMap = convertCamelToUnderscore(inspectionDetectionInfo, fields);
inspectionDetectionInfoMap.put("INSPECTIONDETECTIONINFO_SEQ", inspectionDetectionInfo.getSequenceNbr());
}
if (!inspectionDetectionInfoMap.isEmpty()) {
Map<String, Object> filterMap = inspectionDetectionInfoMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
objMap.put("completedBusinessTypes", judgeTheBusinessAccordingByRecord(record, objMap));
// 账号类型(用于车用气瓶流程页面-》监管审核-》打开设备详情 时隐藏保存按钮)
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
objMap.put("accountType", reginParams.getCompany().getCompanyType());
return objMap;
}
//查询最新的记录
public IdxBizJgConstructionInfo queryConstructionNewestDetailByRecord(String record) {
IdxBizJgConstructionInfo result = new IdxBizJgConstructionInfo();
QueryWrapper<IdxBizJgConstructionInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(IdxBizJgConstructionInfo::getRecord,record).orderByDesc(IdxBizJgConstructionInfo::getUscDate);
List<IdxBizJgConstructionInfo> constructionInfoList = idxBizJgConstructionInfoMapper.selectList(queryWrapper);
if(!ValidationUtil.isEmpty(constructionInfoList)){
BeanUtils.copyProperties(constructionInfoList.get(0),result);;
}
return result;
}
//查询最新的记录
public IdxBizJgMaintenanceRecordInfo queryMaintenanceNewestDetailByRecord(String record) {
IdxBizJgMaintenanceRecordInfo result = new IdxBizJgMaintenanceRecordInfo();
QueryWrapper<IdxBizJgMaintenanceRecordInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(IdxBizJgMaintenanceRecordInfo::getRecord,record).orderByDesc(IdxBizJgMaintenanceRecordInfo::getInformEnd);
List<IdxBizJgMaintenanceRecordInfo> maintenanceRecordInfoList = idxBizJgMaintenanceRecordInfoMapper.selectList(queryWrapper);
if(!ValidationUtil.isEmpty(maintenanceRecordInfoList)){
BeanUtils.copyProperties(maintenanceRecordInfoList.get(0),result);
}
return result;
}
//查询最新的记录
public IdxBizJgInspectionDetectionInfo queryInspectionNewestDetailByRecord(String record) {
IdxBizJgInspectionDetectionInfo result = new IdxBizJgInspectionDetectionInfo();
QueryWrapper<IdxBizJgInspectionDetectionInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(IdxBizJgInspectionDetectionInfo::getRecord,record).orderByDesc(IdxBizJgInspectionDetectionInfo::getInspectDate);
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList = idxBizJgInspectionDetectionInfoMapper.selectList(queryWrapper);
if (!ValidationUtil.isEmpty(inspectionDetectionInfoList)) {
BeanUtils.copyProperties(inspectionDetectionInfoList.get(0), result);
}
return result;
}
/**
* 根据record判断设备完成了哪些业务(安装告知/维保备案/使用登记)
*
* @return
*/
public String judgeTheBusinessAccordingByRecord(String record, Map<String, Object> objMap) {
String business = "";
// 安装告知
Map<String, Object> installDetail = useRegistrationMapper.getiInstallDetail(record);
if (!ObjectUtils.isEmpty(installDetail)) {
business = business + ",安装告知";
objMap.putAll(installDetail);
objMap.put("insOtherAccessories", JSON.parse(Optional.ofNullable(installDetail.get("insOtherAccessories")).orElse("").toString()));
objMap.put("installProxyStatementAttachment", JSON.parse(Optional.ofNullable(installDetail.get("installProxyStatementAttachment")).orElse("").toString()));
objMap.put("installContractAttachment", JSON.parse(Optional.ofNullable(installDetail.get("installContractAttachment")).orElse("").toString()));
}
// 维保备案
Map<String, Object> maintenanceDetail = useRegistrationMapper.getMaintenanceDetail(record);
if (!ObjectUtils.isEmpty(maintenanceDetail)) {
business = business + ",维保备案";
objMap.putAll(maintenanceDetail);
objMap.put("maintenanceContract", JSON.parse(Optional.ofNullable(maintenanceDetail.get("maintenanceContract")).orElse("").toString()));
objMap.put("maintOtherAccessories", JSON.parse(Optional.ofNullable(maintenanceDetail.get("maintOtherAccessories")).orElse("").toString()));
}
// 使用登记
Map<String, Object> useRegistrationDetail = useRegistrationMapper.getUseRegistrationDetail(record);
if (!ObjectUtils.isEmpty(useRegistrationDetail)) {
business = business + ",使用登记";
objMap.putAll(useRegistrationDetail);
}
return business;
}
/**
* 查询设备技术参数
*
* @param record 设备Id
* @param fieldType 返回字段类型【CamelCase:驼峰命名,“”:纯大写加下划线】
* @return
*/
private Map<String, Object> getEquipParamsMap(String record, String fieldType, String equipCode) {
Map<String, Object> objMap = new HashMap<>();
if (EquipmentClassifityEnum.DT.getCode().equals(equipCode)) {
// 电梯
IdxBizJgTechParamsElevator elevator = idxBizJgTechParamsElevatorMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsElevator>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(elevator)) {
Map<String, Object> elevatorMap;
if (!ValidationUtil.isEmpty(fieldType)) {
elevatorMap = Bean.BeantoMap(elevator);
elevatorMap.put("elevatorSeq", elevator.getSequenceNbr());
elevatorMap.put("explosionproofSignComplete", JSON.parseArray(elevator.getExplosionproofSignComplete()));
} else {
String[] fields = {"EXPLOSIONPROOF_SIGN_COMPLETE"};
elevatorMap = convertCamelToUnderscore(elevator, fields);
elevatorMap.put("ELEVATOR_SEQ", elevator.getSequenceNbr());
}
if (!elevatorMap.isEmpty()) {
Map<String, Object> filterMap = elevatorMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
} else if (EquipmentClassifityEnum.CC.getCode().equals(equipCode)) {
// 厂车
IdxBizJgTechParamsVehicle vehicle = idxBizJgTechParamsVehicleMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsVehicle>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(vehicle)) {
Map<String, Object> vehicleMap;
if (!ValidationUtil.isEmpty(fieldType)) {
vehicleMap = Bean.BeantoMap(vehicle);
vehicleMap.put("vehicleSeq", vehicle.getSequenceNbr());
} else {
vehicleMap = convertCamelToUnderscore(vehicle, null);
vehicleMap.put("VEHICLE_SEQ", vehicle.getSequenceNbr());
}
if (!vehicleMap.isEmpty()) {
Map<String, Object> filterMap = vehicleMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 主要零部件
List<Map<String, Object>> mainPartsMapsByRecord = this.getMainPartsMapsByRecord(record, fieldType);
objMap.put("subForm_sey164b51a", mainPartsMapsByRecord);
objMap.put("subForm_tef7yf5fbr", mainPartsMapsByRecord);
} else if (EquipmentClassifityEnum.KYSD.getCode().equals(equipCode)) {
// 索道
IdxBizJgTechParamsRopeway ropeway = idxBizJgTechParamsRopewayMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsRopeway>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(ropeway)) {
Map<String, Object> ropewayMap;
if (!ValidationUtil.isEmpty(fieldType)) {
ropewayMap = Bean.BeantoMap(ropeway);
ropewayMap.put("ropewaySeq", ropeway.getSequenceNbr());
} else {
ropewayMap = convertCamelToUnderscore(ropeway, null);
ropewayMap.put("ROPEWAY_SEQ", ropeway.getSequenceNbr());
}
Map<String, Object> filterMap = ropewayMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
// 主要零部件
List<Map<String, Object>> mainPartsMapsByRecord = this.getMainPartsMapsByRecord(record, fieldType);
objMap.put("subForm_5fi0jewuyh", mainPartsMapsByRecord);
} else if (EquipmentClassifityEnum.YLSS.getCode().equals(equipCode)) {
// 游乐设施
IdxBizJgTechParamsRides rides = idxBizJgTechParamsRidesMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsRides>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(rides)) {
Map<String, Object> ridesMap;
if (!ValidationUtil.isEmpty(fieldType)) {
ridesMap = Bean.BeantoMap(rides);
ridesMap.put("ridesSeq", rides.getSequenceNbr());
} else {
ridesMap = convertCamelToUnderscore(rides, null);
ridesMap.put("RIDES_SEQ", rides.getSequenceNbr());
}
if (!ridesMap.isEmpty()) {
Map<String, Object> filterMap = ridesMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
} else if (EquipmentClassifityEnum.GL.getCode().equals(equipCode)) {
// 锅炉
IdxBizJgTechParamsBoiler boiler = idxBizJgTechParamsBoilerMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsBoiler>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(boiler)) {
Map<String, Object> boilerMap;
if (!ValidationUtil.isEmpty(fieldType)) {
boilerMap = Bean.BeantoMap(boiler);
boilerMap.put("boilerSeq", boiler.getSequenceNbr());
} else {
boilerMap = convertCamelToUnderscore(boiler, null);
boilerMap.put("BOILER_SEQ", boiler.getSequenceNbr());
}
if (!boilerMap.isEmpty()) {
Map<String, Object> filterMap = boilerMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 安全附件
List<Map<String, Object>> protectionDevicesMapsByRecord = this.getProtectionDevicesMapsByRecord(record, fieldType);
objMap.put("subForm_1hh88r4m69", protectionDevicesMapsByRecord);
} else if (EquipmentClassifityEnum.YLRQ.getCode().equals(equipCode)) {
// 压力容器
IdxBizJgTechParamsVessel vessel = idxBizJgTechParamsVesselMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsVessel>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(vessel)) {
Map<String, Object> vesselMap;
if (!ValidationUtil.isEmpty(fieldType)) {
vesselMap = Bean.BeantoMap(vessel);
vesselMap.put("vesselSeq", vessel.getSequenceNbr());
} else {
vesselMap = convertCamelToUnderscore(vessel, null);
vesselMap.put("VESSEL_SEQ", vessel.getSequenceNbr());
}
if (!vesselMap.isEmpty()) {
Map<String, Object> filterMap = vesselMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 主要零部件和安全附件
List<Map<String, Object>> mainPartsMapsByRecord = this.getMainPartsMapsByRecord(record, fieldType);
List<Map<String, Object>> protectionDevicesMapsByRecord = this.getProtectionDevicesMapsByRecord(record, fieldType);
objMap.put("subForm_fie04854f2", mainPartsMapsByRecord);
objMap.put("subForm_d4xdzhsgdj", protectionDevicesMapsByRecord);
} else if (EquipmentClassifityEnum.YLGD.getCode().equals(equipCode)) {
// 压力管道
IdxBizJgTechParamsPipeline pipeline = idxBizJgTechParamsPipelineMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsPipeline>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(pipeline)) {
Map<String, Object> pipelineMap;
if (!ValidationUtil.isEmpty(fieldType)) {
pipelineMap = Bean.BeantoMap(pipeline);
pipelineMap.put("pipelineSeq", pipeline.getSequenceNbr());
} else {
pipelineMap = convertCamelToUnderscore(pipeline, null);
pipelineMap.put("PIPELINE_SEQ", pipeline.getSequenceNbr());
pipelineMap.put("STARTE_POSITION", JSONObject.parseObject(pipeline.getStartePosition()));
}
Map<String, Object> filterMap = pipelineMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
// 主要零部件
List<Map<String, Object>> mainPartsMapsByRecord = this.getMainPartsMapsByRecord(record, fieldType);
objMap.put("subForm_9n7nu55z8r", mainPartsMapsByRecord);
} else if (EquipmentClassifityEnum.QZJX.getCode().equals(equipCode)) {
// 起重机械
IdxBizJgTechParamsLifting lifting = idxBizJgTechParamsLiftingMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsLifting>().eq("RECORD", record));
if (!ValidationUtil.isEmpty(lifting)) {
Map<String, Object> liftingMap;
if (!ValidationUtil.isEmpty(fieldType)) {
liftingMap = Bean.BeantoMap(lifting);
liftingMap.put("liftingSeq", lifting.getSequenceNbr());
} else {
liftingMap = convertCamelToUnderscore(lifting, null);
liftingMap.put("LIFTING_SEQ", lifting.getSequenceNbr());
}
if (!liftingMap.isEmpty()) {
Map<String, Object> filterMap = liftingMap.entrySet()
.stream()
.filter(e -> e.getValue() != null && e.getValue() != "")
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
objMap.putAll(filterMap);
}
}
// 主要零部件和安全附件
List<Map<String, Object>> mainPartsMapsByRecord = this.getMainPartsMapsByRecord(record, fieldType);
List<Map<String, Object>> protectionDevicesMapsByRecord = this.getProtectionDevicesMapsByRecord(record, fieldType);
objMap.put("subForm_bqirdyvztt", mainPartsMapsByRecord);
objMap.put("subForm_29yy3pdzhl", protectionDevicesMapsByRecord);
objMap.put("subForm_h5h4x0zhur", protectionDevicesMapsByRecord);
}
return objMap;
}
/**
* 查询指定设备的主要零部件【一对多,查出多条数据】
*
* @param record
* @param fieldType
* @return
*/
private List<Map<String, Object>> getMainPartsMapsByRecord(String record, String fieldType) {
List<Map<String, Object>> resultListMap = new ArrayList<>();
List<IdxBizJgMainParts> mainParts = this.queryMainPartsListByRecord(record);
if (!ValidationUtil.isEmpty(mainParts)) {
if (!ValidationUtil.isEmpty(fieldType)) {
for (IdxBizJgMainParts mainPart : mainParts) {
Map<String, Object> mainPartsMap = null;
mainPartsMap = Bean.BeantoMap(mainPart);
mainPartsMap.put("mainpartsSeq", mainPart.getSequenceNbr());
resultListMap.add(mainPartsMap);
}
} else {
for (IdxBizJgMainParts mainPart : mainParts) {
Map<String, Object> mainPartsMap = null;
mainPartsMap = convertCamelToUnderscore(mainPart, null);
mainPartsMap.put("MAINPARTS_SEQ", mainPart.getSequenceNbr());
resultListMap.add(mainPartsMap);
}
}
}
return resultListMap;
}
/**
* 查询指定设备的安全附件【一对多,查出多条数据】
*
* @param record
* @param fieldType
* @return
*/
private List<Map<String, Object>> getProtectionDevicesMapsByRecord(String record, String fieldType) {
List<Map<String, Object>> resultListMap = new ArrayList<>();
List<IdxBizJgProtectionDevices> protectionDevices = this.queryProtectionListByRecord(record);
if (!ValidationUtil.isEmpty(protectionDevices)) {
if (!ValidationUtil.isEmpty(fieldType)) {
for (IdxBizJgProtectionDevices protectionDevice : protectionDevices) {
Map<String, Object> protectionDeviceMap = null;
protectionDeviceMap = Bean.BeantoMap(protectionDevice);
protectionDeviceMap.put("protectiondevicesSeq", protectionDevice.getSequenceNbr());
resultListMap.add(protectionDeviceMap);
}
} else {
for (IdxBizJgProtectionDevices protectionDevice : protectionDevices) {
Map<String, Object> protectionDeviceMap = null;
protectionDeviceMap = convertCamelToUnderscore(protectionDevice, null);
protectionDeviceMap.put("PROTECTIONDEVICES_SEQ", protectionDevice.getSequenceNbr());
resultListMap.add(protectionDeviceMap);
}
}
}
return resultListMap;
}
public List<IdxBizJgProtectionDevices> queryProtectionListByRecord(String record) {
QueryWrapper<IdxBizJgProtectionDevices> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(IdxBizJgProtectionDevices::getRecord,record).orderByDesc(IdxBizJgProtectionDevices::getRecDate);
return idxBizJgProtectionDevicesMapper.selectList(queryWrapper);
}
public List<IdxBizJgMainParts> queryMainPartsListByRecord(String record) {
QueryWrapper<IdxBizJgMainParts> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(IdxBizJgMainParts::getRecord,record).orderByDesc(IdxBizJgMainParts::getRecDate);
return idxBizJgMainPartsMapper.selectList(queryWrapper);
}
public Page<SafetyProblemTracingDto> queryProblemPageByEquipId(Page<SafetyProblemTracingDto> page, String equipId) {
SafetyProblemTracingDto problemModel = new SafetyProblemTracingDto();
problemModel.setSourceId(equipId);
return safetyProblemTracingMapper.queryForSafetyProblemTracingPage(page, problemModel);
}
/**
* 根据ID查询
*/
public SafetyProblemTracingDto selectSafetyProblem(Long sequenceNbr) {
SafetyProblemTracingDto entity = new SafetyProblemTracingDto();
LambdaQueryWrapper<SafetyProblemTracing> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SafetyProblemTracing::getSequenceNbr, sequenceNbr);
SafetyProblemTracing problem = safetyProblemTracingMapper.selectOne(queryWrapper);
BeanUtil.copyProperties(problem, entity);
Map<String, String> problemStatusObj = new HashMap<>();
problemStatusObj.put("problemStatusCode", entity.getProblemStatusCode());
entity.setProblemStatusObj(problemStatusObj);
return entity;
}
public Page<Map<String, Object>> queryEquipListByProblemId(Page<Map<String, Object>> page, String problemId) {
LambdaQueryWrapper<SafetyProblemTracing> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SafetyProblemTracing::getSequenceNbr, problemId);
SafetyProblemTracing problem = safetyProblemTracingMapper.selectOne(queryWrapper);
Page<Map<String, Object>> list = new Page<>();
if (problem.getSourceTypeCode().equals(SafetyProblemSourceTypeEnum.EQUIP.getCode())) {
list = safetyProblemTracingMapper.queryEquipListByProblemId(page, problemId);
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("USE_UNIT_CREDIT_CODE", problem.getPrincipalUnitCode());
jsonObject.put("number", page.getCurrent());
jsonObject.put("size", page.getSize());
Page<JSONObject> result = this.queryForEquipmentRegisterPage(jsonObject);
List<Map<String, Object>> finalList = Lists.newArrayList();
result.getRecords().forEach(item -> {
Map<String, Object> map = new HashMap<>();
map.put("record", item.get("SEQUENCE_NBR"));
map.put("equList", item.get("EQU_LIST"));
map.put("equListCode", item.get("EQU_LIST_CODE"));
map.put("equCategory", item.get("EQU_CATEGORY"));
map.put("useUnitName", item.get("USE_UNIT_NAME"));
map.put("code96333", item.get("CODE96333"));
map.put("supervisoryCode", item.get("SUPERVISORY_CODE"));
map.put("problemStatus", item.get("problemStatus"));
if (SafetyProblemStatusEnum.UNHANDLED.getCode().equals(item.get("problemStatus"))) {
map.put("problemStatusColor", SafetyProblemStatusEnum.UNHANDLED.getColor());
map.put("problemStatusName", "异常");
} else {
map.put("problemStatusColor", SafetyProblemStatusEnum.HANDLED.getColor());
map.put("problemStatusName", "正常");
}
finalList.add(map);
});
BeanUtils.copyProperties(result, list);
list.setRecords(finalList);
}
return list;
}
public Page<Map<String, Object>> queryPrincipalUnitByProblemId(Page<Map<String, Object>> page, String problemId) {
LambdaQueryWrapper<SafetyProblemTracing> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SafetyProblemTracing::getSequenceNbr, problemId);
SafetyProblemTracing problem = safetyProblemTracingMapper.selectOne(queryWrapper);
return safetyProblemTracingMapper.queryPrincipalUnitByProblemId(page, problemId, problem.getSourceTypeCode());
}
/**
* 根据sequenceNbr查询---大屏使用
*
* @param sequenceNbr 主键
* @return
*/
public Object getRegistrationDetail(String sequenceNbr) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<FormValue> jsonData = getJsonData(registrationBasicJson);
HashMap<String, Object> result = new HashMap<>();
// 基本信息
JgUseRegistrationManage jgUseRegistrationManage = jgUseRegistrationManageMapper.selectById(sequenceNbr);
Map<String, Object> objectMap = Bean.BeantoMap(jgUseRegistrationManage);
jsonData.forEach(f -> {
Object o = objectMap.get(f.getKey());
if (!ObjectUtils.isEmpty(o)) {
f.setValue(o.toString());
if ("auditPassDate".equals(f.getKey())){
f.setValue(simpleDateFormat.format(jgUseRegistrationManage.getAuditPassDate()));
}
}
});
// 流水信息
List<JgCertificateChangeRecord> changeRecordList = jgCertificateChangeRecordMapper.selectList(new LambdaQueryWrapper<JgCertificateChangeRecord>()
.eq(JgCertificateChangeRecord::getUseRegistrationCode, jgUseRegistrationManage.getUseRegistrationCode())
.or().eq(JgCertificateChangeRecord::getCertificateNo, jgUseRegistrationManage.getCertificateNo())
.orderByDesc(JgCertificateChangeRecord::getCreateDate));
List<Map<String, String>> collect = changeRecordList.stream()
.map(x -> {
Map<String, String> map = new HashMap<>();
map.put("operatingTime", simpleDateFormat.format(x.getRecDate()));
map.put("operater", x.getChangeContent());
map.put("label", simpleDateFormat.format(x.getRecDate()));
return map;
}).collect(Collectors.toList());
HashMap<String, Object> map = new HashMap<>();
map.put("datas", collect);
map.put("title", "使用登记证流水");
map.put("renderType", "timeline");
result.put("title", objectMap.get("useUnitName"));
result.put("keyParams", jsonData);
result.put("infoRecords", map);
return result;
}
private List<FormValue> getJsonData(Resource resource) {
String json;
try {
json = IOUtils.toString(resource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
}
return parseArray(json, FormValue.class);
}
/**
* 根据sequenceNbr查询使用登记证对应设备列表---使用登记证详情用
* 分页接口
*
* @param sequenceNbr 主键
* @return
*/
public Page<JSONObject> certificateEquList(int current, int size, String sequenceNbr) {
return queryEquForPageByCertificateSeqList("",Collections.singletonList(Long.parseLong(sequenceNbr)), current, size);
}
/**
* 根据证的sequenceNbr集合,批量查询证下面的所有设备
*
* @param enableType 启用停用业务使用 - 过滤设备状态 (1:在用 2:停用) 对应枚举:EquimentEnum
* @param sequenceNbrList 证的sequenceNbr集合
* @param current 分页-当前页
* @param size 分页-分页数
* @return 查询结果
*/
public Page<JSONObject> queryEquForPageByCertificateSeqList(String enableType,List<Long> sequenceNbrList, int current, int size) {
List<JgUseRegistrationManage> jgUseRegistrationManageList = jgUseRegistrationManageMapper.selectList(new LambdaQueryWrapper<JgUseRegistrationManage>()
.in(JgUseRegistrationManage::getSequenceNbr, sequenceNbrList)
.eq(JgUseRegistrationManage::getIsDelete, 0));
if (ValidationUtil.isEmpty(jgUseRegistrationManageList)) {
return new Page<>();
}
List<JSONObject> list = new LinkedList<>();
long totle = 0;
Page<JSONObject> result = new Page<>(Optional.of(current).orElse(1), Optional.of(size).orElse(10));
Set<String> useOrgCodes = jgUseRegistrationManageList.stream().map(JgUseRegistrationManage::getUseRegistrationCode).collect(Collectors.toSet());
// es中通过查询【使用登记证编号】所有设备
SearchRequest request = new SearchRequest("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery("USE_ORG_CODE", useOrgCodes);
boolQuery.must(termsQuery);
// 设备状态 对应枚举EquimentEnum
if (!ObjectUtils.isEmpty(enableType)) {
BoolQueryBuilder elcBuilder = QueryBuilders.boolQuery();
elcBuilder.must(QueryBuilders.matchPhraseQuery("EQU_STATE", QueryParser.escape(enableType)));
boolQuery.must(elcBuilder);
}
builder.query(boolQuery);
builder.from((current - 1) * size);
builder.size(size);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto = jsonObject.getJSONObject("sourceAsMap");
dto.put("record", dto.get("SEQUENCE_NBR"));
dto.put("equipAddress", dto.get("USE_PLACE") + "/" + dto.get("ADDRESS"));
list.add(dto);
}
totle = Objects.requireNonNull(response.getInternalResponse().hits().getTotalHits()).value;
} catch (Exception e) {
e.printStackTrace();
}
result.setRecords(list);
result.setTotal(totle);
return result;
}
}
[
{
"key": "useRegistrationCode",
"label": "使用登记证编号",
"type": "text"
},
{
"key": "useUnitName",
"label": "使用单位名称",
"type": "text"
},
{
"key": "useUnitAddress",
"label": "使用单位地址",
"type": "text"
},
{
"key": "receiveOrgName",
"label": "登记机关",
"type": "text"
},
{
"key": "equList",
"label": "设备种类",
"type": "text"
},
{
"key": "equCategory",
"label": "设备类别",
"type": "text"
},
{
"key": "equDefine",
"label": "设备品种",
"type": "text"
},
{
"key": "equUseAddress",
"label": "设备使用地址",
"type": "text"
},
{
"key": "certificateStatus",
"label": "使用登记证状态",
"type": "text"
},
{
"key": "auditPassDate",
"label": "办理日期",
"type": "text"
}
]
\ 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