Commit 8238a720 authored by suhuiguang's avatar suhuiguang

feat(综合搜索):数据同步调整

1.查询设备详细接口优化
parent d9ba1282
......@@ -205,12 +205,18 @@ public class ESEquipmentInfo {
private String USC_UNIT_NAME;
/**
* 投用日期
* 安装日期
*/
@Field(type = FieldType.Date, format = DateFormat.date)
private LocalDate USC_DATE;
/**
* 投用日期
*/
@Field(type = FieldType.Date, format = DateFormat.date)
private LocalDate USE_DATE;
/**
* 创建日期
*/
@Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)
......@@ -271,9 +277,8 @@ public class ESEquipmentInfo {
*/
@Field(type = FieldType.Boolean)
private Boolean IS_INTO_MANAGEMENT;
/**
* 设备使用地点区域码610000#610100#610101
* 设备使用地点区域码610000#610100#610101#61010101d 到街道
*/
@Field(type = FieldType.Keyword)
private String USE_PLACE_CODE;
......
package com.yeejoin.amos.boot.module.jg.biz.refresh.handler;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.api.entity.TzsDataRefreshMessage;
import com.yeejoin.amos.boot.module.common.api.service.IDataRefreshHandler;
......@@ -14,9 +12,9 @@ import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationManage;
import com.yeejoin.amos.boot.module.jg.biz.refresh.StatisticsDataUpdateService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgMaintenanceRecordInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -26,8 +24,6 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import static com.alibaba.fastjson.JSON.toJSONString;
@Component
@RequiredArgsConstructor
@Slf4j
......@@ -45,8 +41,6 @@ public class EquipmentRefreshHandler implements IDataRefreshHandler {
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageServiceImpl;
@Override
public String supportType() {
return "equipment";
......@@ -62,48 +56,23 @@ public class EquipmentRefreshHandler implements IDataRefreshHandler {
case UPDATE:
String record = message.getDataId();
ESEquipmentInfo esEquipmentInfo = new ESEquipmentInfo();
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record);
ESEquipmentCategoryDto categoryEs = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
BeanUtil.copyProperties(categoryEs, esEquipmentInfo);
IdxBizJgUseInfo useInfo = useInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record)
.select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getCreateDate, IdxBizJgUseInfo::getDataQualityScore,
IdxBizJgUseInfo::getUSC_UNIT_CREDIT_CODE, IdxBizJgUseInfo::getUSC_UNIT_NAME));
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoServiceImpl.getOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>()
.eq(IdxBizJgDesignInfo::getRecord, record)
.select(IdxBizJgDesignInfo::getRecord, IdxBizJgDesignInfo::getDesignUnitName, IdxBizJgDesignInfo::getDesignUnitCreditCode, IdxBizJgDesignInfo::getDesignDate));
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.getOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>()
.eq(IdxBizJgFactoryInfo::getRecord, record)
.select(IdxBizJgFactoryInfo::getRecord, IdxBizJgFactoryInfo::getProduceUnitCreditCode));
IdxBizJgRegisterInfo registerInfo = registerInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
.eq(IdxBizJgRegisterInfo::getRecord, record)
.select(IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getWhetherSphericalTank,
IdxBizJgRegisterInfo::getUseOrgCode, IdxBizJgRegisterInfo::getCarNumber));
Map<String, Object> detail = useInfoService.getBaseMapper().queryDetail(record);
BeanUtil.copyProperties(detail, esEquipmentInfo, true);
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = iIdxBizJgInspectionDetectionInfoService.queryLastedGroupByInspectType(record);
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = iIdxBizJgInspectionDetectionInfoService.queryNewestDetailByRecord(record);
IdxBizJgMaintenanceRecordInfo lastMaintenanceRecordInfo = maintenanceRecordInfoService.queryNewestDetailByRecord(record);
try {
esEquipmentInfo.setDesignDate(designInfo.getDesignDate() != null ? designInfo.getDesignDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null);
esEquipmentInfo.setINSPECT_DATE(inspectionDetectionInfo.getSequenceNbr() != null ? inspectionDetectionInfo.getInspectDate() != null ? inspectionDetectionInfo.getInspectDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null : null);
esEquipmentInfo.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getSequenceNbr() != null ? inspectionDetectionInfo.getNextInspectDate() != null ? inspectionDetectionInfo.getNextInspectDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null : null);
esEquipmentInfo.setCreateDate(useInfo.getCreateDate() != null ? useInfo.getCreateDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
} catch (Exception e) {
log.error("时区转换失败:{}", record, e);
}
esEquipmentInfo.setUSC_UNIT_CREDIT_CODE(useInfo.getUSC_UNIT_CREDIT_CODE());
esEquipmentInfo.setUSC_UNIT_NAME(useInfo.getUSC_UNIT_NAME());
esEquipmentInfo.setDataQualityScore(useInfo.getDataQualityScore() != null ? useInfo.getDataQualityScore() : null);
esEquipmentInfo.setCarNumber(registerInfo.getCarNumber());
esEquipmentInfo.setUSE_ORG_CODE(registerInfo.getUseOrgCode());
esEquipmentInfo.setIssueDate(getIssueDate(registerInfo.getUseOrgCode()));
esEquipmentInfo.setWhetherSphericalTank(registerInfo.getWhetherSphericalTank());
esEquipmentInfo.setDesignUnitCreditCode(designInfo.getDesignUnitCreditCode());
esEquipmentInfo.setIssueDate(getIssueDate(esEquipmentInfo.getUSE_ORG_CODE()));
esEquipmentInfo.setMAINTAIN_UNIT(lastMaintenanceRecordInfo.getMeUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT_NAME(lastMaintenanceRecordInfo.getMeUnitName());
esEquipmentInfo.setDesignUnitName(designInfo.getDesignUnitName());
esEquipmentInfo.setProduceUnitCreditCode(factoryInfo.getProduceUnitCreditCode());
esEquipmentInfo.setInspections(BeanUtil.copyToList(inspectionDetectionInfos, ESEquipmentInfo.Inspection.class));
esEquipmentInfo.setMaintenances(lastMaintenanceRecordInfo.getSequenceNbr() != null ? Collections.singletonList(BeanUtil.copyProperties(lastMaintenanceRecordInfo, ESEquipmentInfo.Maintenance.class)) : new ArrayList<>());
esEquipmentInfo.setTechParams(this.buildTechParamByEquList(record, categoryEs.getEQU_LIST_CODE()));
esEquipmentInfo.setTechParams(this.buildTechParamByEquList(record, esEquipmentInfo.getEQU_LIST_CODE()));
esEquipmentDao.save(esEquipmentInfo);
break;
default:
......@@ -115,16 +84,16 @@ public class EquipmentRefreshHandler implements IDataRefreshHandler {
return StringUtils.isNotEmpty(equListCode) ? statisticsDataUpdateService.getTechParams(equListCode, record) : new ArrayList<>();
}
private LocalDate getIssueDate(String useRegistrationCode){
if(StringUtils.isEmpty(useRegistrationCode)){
return null;
private LocalDate getIssueDate(String useRegistrationCode) {
if (StringUtils.isEmpty(useRegistrationCode)) {
return null;
}
LambdaQueryWrapper<JgUseRegistrationManage> useRegistrationManageWrapper = new LambdaQueryWrapper<>();
useRegistrationManageWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode, useRegistrationCode)
.isNotNull(JgUseRegistrationManage::getUseRegistrationCode)
.eq(JgUseRegistrationManage::getCertificateStatus, "已登记")
.eq(BaseEntity::getIsDelete, false).select(BaseEntity::getSequenceNbr,JgUseRegistrationManage::getRegDate);
JgUseRegistrationManage manage = jgUseRegistrationManageServiceImpl.getBaseMapper().selectOne(useRegistrationManageWrapper);
return Optional.ofNullable(manage).map(JgUseRegistrationManage::getRegDate).map(d-> d.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()).orElse(null);
.eq(BaseEntity::getIsDelete, false).select(BaseEntity::getSequenceNbr, JgUseRegistrationManage::getRegDate);
JgUseRegistrationManage manage = jgUseRegistrationManageServiceImpl.getBaseMapper().selectOne(useRegistrationManageWrapper);
return Optional.ofNullable(manage).map(JgUseRegistrationManage::getRegDate).map(d -> d.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()).orElse(null);
}
}
......@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -137,7 +136,6 @@ public class DataHandlerServiceImpl {
private final IdxBizJgMaintenanceRecordInfoServiceImpl maintenanceRecordInfoService;
private static final String ROOT_ORG_CODE = "50";
private final IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoServiceImpl;
private final StatisticsDataUpdateService statisticsDataUpdateService;
......@@ -1511,54 +1509,31 @@ public class DataHandlerServiceImpl {
ESEquipmentInfo esEquipmentInfo = null;
try {
esEquipmentInfo = new ESEquipmentInfo();
Optional<ESEquipmentCategoryDto> categoryDto = esEquipmentCategory.findById(record);
// 兼容243 es 被删除逻辑
ESEquipmentCategoryDto categoryEs = categoryDto.orElseGet(() -> {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record);
return JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
});
BeanUtil.copyProperties(categoryEs, esEquipmentInfo);
IdxBizJgUseInfo useInfo = useInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record)
.select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getCreateDate, IdxBizJgUseInfo::getDataQualityScore,
IdxBizJgUseInfo::getUSC_UNIT_CREDIT_CODE, IdxBizJgUseInfo::getUSC_UNIT_NAME));
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoServiceImpl.getOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>()
.eq(IdxBizJgDesignInfo::getRecord, record)
.select(IdxBizJgDesignInfo::getRecord, IdxBizJgDesignInfo::getDesignUnitName, IdxBizJgDesignInfo::getDesignUnitCreditCode,
IdxBizJgDesignInfo::getDesignDate));
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.getOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>()
.eq(IdxBizJgFactoryInfo::getRecord, record)
.select(IdxBizJgFactoryInfo::getRecord, IdxBizJgFactoryInfo::getProduceUnitCreditCode));
IdxBizJgRegisterInfo registerInfo = registerInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
.eq(IdxBizJgRegisterInfo::getRecord, record)
.select(IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getWhetherSphericalTank,
IdxBizJgRegisterInfo::getUseOrgCode, IdxBizJgRegisterInfo::getCarNumber));
Map<String,Object> detail = useInfoService.getBaseMapper().queryDetail(record);
BeanUtil.copyProperties(detail, esEquipmentInfo, true);
Optional<ESEquipmentCategoryDto> esOptional = esEquipmentCategory.findById(record);
if(esOptional.isPresent()){
ESEquipmentCategoryDto dto = esOptional.get();
esEquipmentInfo.setUSC_UNIT_CREDIT_CODE(dto.getUSC_UNIT_CREDIT_CODE());
esEquipmentInfo.setUSC_UNIT_NAME(dto.getUSC_UNIT_NAME());
esEquipmentInfo.setIS_DO_BUSINESS(dto.getIS_DO_BUSINESS());
}
// 检验信息按照不同检验类型,存最新的一条
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = iIdxBizJgInspectionDetectionInfoService.queryLastedGroupByInspectType(record);
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = iIdxBizJgInspectionDetectionInfoService.queryNewestDetailByRecord(record);
IdxBizJgMaintenanceRecordInfo lastMaintenanceRecordInfo = maintenanceRecordInfoService.queryNewestDetailByRecord(record);
try {
esEquipmentInfo.setDesignDate(designInfo.getDesignDate() != null ? designInfo.getDesignDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null);
esEquipmentInfo.setINSPECT_DATE(inspectionDetectionInfo.getSequenceNbr() != null ? inspectionDetectionInfo.getInspectDate() != null ? inspectionDetectionInfo.getInspectDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null :null);
esEquipmentInfo.setNEXT_INSPECT_DATE(inspectionDetectionInfo.getSequenceNbr() != null ? inspectionDetectionInfo.getNextInspectDate() != null ? inspectionDetectionInfo.getNextInspectDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() : null :null);
esEquipmentInfo.setCreateDate(useInfo.getCreateDate() != null ? useInfo.getCreateDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
} catch (Exception e) {
log.error("时区转换失败:{}", record, e);
}
esEquipmentInfo.setUSC_UNIT_CREDIT_CODE(useInfo.getUSC_UNIT_CREDIT_CODE());
esEquipmentInfo.setUSC_UNIT_NAME(useInfo.getUSC_UNIT_NAME());
esEquipmentInfo.setDataQualityScore(useInfo.getDataQualityScore() != null ? useInfo.getDataQualityScore() : null);
esEquipmentInfo.setCarNumber(registerInfo.getCarNumber());
esEquipmentInfo.setUSE_ORG_CODE(registerInfo.getUseOrgCode());
esEquipmentInfo.setIssueDate(getIssueDate(registerInfo.getUseOrgCode()));
esEquipmentInfo.setWhetherSphericalTank(registerInfo.getWhetherSphericalTank());
esEquipmentInfo.setDesignUnitCreditCode(designInfo.getDesignUnitCreditCode());
esEquipmentInfo.setIssueDate(getIssueDate(esEquipmentInfo.getUSE_ORG_CODE()));
esEquipmentInfo.setMAINTAIN_UNIT(lastMaintenanceRecordInfo.getMeUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT_NAME(lastMaintenanceRecordInfo.getMeUnitName());
esEquipmentInfo.setDesignUnitName(designInfo.getDesignUnitName());
esEquipmentInfo.setProduceUnitCreditCode(factoryInfo.getProduceUnitCreditCode());
esEquipmentInfo.setInspections(BeanUtil.copyToList(inspectionDetectionInfos, ESEquipmentInfo.Inspection.class));
esEquipmentInfo.setMaintenances(lastMaintenanceRecordInfo.getSequenceNbr() != null ? Collections.singletonList(BeanUtil.copyProperties(lastMaintenanceRecordInfo, ESEquipmentInfo.Maintenance.class)) : new ArrayList<>());
esEquipmentInfo.setTechParams(this.buildTechParamByEquList(record, categoryEs.getEQU_LIST_CODE()));
esEquipmentInfo.setTechParams(this.buildTechParamByEquList(record, esEquipmentInfo.getEQU_LIST_CODE()));
} catch (Exception e) {
// 异常数据跳过
log.error("设备刷数据处理失败:{}", record, e);
......
......@@ -183,7 +183,7 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData {
private String phone;
/**
*
* 设备状态 @see com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum
*/
@TableField("\"EQU_STATE\"")
private String equState;
......
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 使用信息表 Mapper 接口
......@@ -28,4 +29,6 @@ public interface IdxBizJgUseInfoMapper extends BaseMapper<IdxBizJgUseInfo> {
void updateDataQualityScoreBatch(@Param("equips") List<EquipWaitRefreshDataQualityScore> refreshDataQualityScores, @Param("version") int version);
void updateVersionBatch(@Param("records") List<String> records, @Param("version") int version);
Map<String,Object> queryDetail(@Param("record") String record);
}
......@@ -64,6 +64,70 @@
COALESCE(MAX(version),0) as version
FROM "idx_biz_jg_use_info"
</select>
<select id="queryDetail" resultType="java.util.Map">
SELECT
ibjui."RECORD" AS "SEQUENCE_NBR",
ibjui."PROJECT_CONTRAPTION",
ibjui."PROJECT_CONTRAPTION_ID",
ibjsi."ORG_BRANCH_NAME",
ibjsi."ORG_BRANCH_CODE",
ibjui."REC_DATE",
ibjui."USE_UNIT_NAME",
ibjui."USE_UNIT_CREDIT_CODE",
ibjui."USC_UNIT_NAME",
ibjui."USC_UNIT_CREDIT_CODE",
ibjri."EQU_LIST" AS "EQU_LIST_CODE",
ibjri."EQU_DEFINE" AS "EQU_DEFINE_CODE",
ibjri."PRODUCT_NAME",
ibjri."BRAND_NAME",
ibjri."EQU_TYPE",
ibjri."EQU_CATEGORY" AS "EQU_CATEGORY_CODE",
tec2.NAME AS "EQU_DEFINE",
tec1.NAME AS "EQU_LIST",
tec.NAME AS "EQU_CATEGORY",
ibjri."USE_ORG_CODE",
ibjui."USE_INNER_CODE",
ibjui."DATA_SOURCE",
ibjoi."CODE96333",
ibjri."EQU_CODE",
ibjoi."SUPERVISORY_CODE",
ibjri."WHETHER_VEHICLE_CYLINDER",
ibjri."WHETHER_SKID_MOUNTED_PRESSURE_VESSEL",
ibjri."CYLINDER_CATEGORY",
ibjri."WHETHER_SPHERICAL_TANK",
ibjri."CAR_NUMBER",
concat_ws ( '/', ibjui."PROVINCE_NAME", ibjui."CITY_NAME", ibjui."COUNTY_NAME", ibjui."STREET_NAME" ) AS "USE_PLACE",
concat_ws ( '#', ibjui."PROVINCE", ibjui."CITY", ibjui."COUNTY", ibjui."FACTORY_USE_SITE_STREET" ) AS "USE_PLACE_CODE",
ibjui."ADDRESS",
ibjui."EQU_STATE",
ibjui."IS_INTO_MANAGEMENT",
ibjoi."CLAIM_STATUS" AS "STATUS",
ibjfi."FACTORY_NUM",
ibjfi."PRODUCE_UNIT_NAME",
ibjfi."PRODUCE_UNIT_CREDIT_CODE",
ibjfi."PRODUCE_DATE",
ibjui."CREATE_DATE" ,
ibjui."SAFETY_MANAGER" ,
ibjui."PHONE",
ibjui."USE_DATE",
ibjui."USE_PLACE" as USE_SITE_CODE,
ibjoi."INFORMATION_SITUATION",
di."DESIGN_UNIT_CREDIT_CODE",
di."DESIGN_UNIT_NAME",
di."DESIGN_DATE"
FROM
amos_tzs_biz.idx_biz_jg_use_info ibjui
LEFT JOIN amos_tzs_biz.idx_biz_jg_supervision_info ibjsi ON ibjui."RECORD" = ibjsi."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_register_info ibjri ON ibjui."RECORD" = ibjri."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_other_info ibjoi ON ibjui."RECORD" = ibjoi."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_factory_info ibjfi ON ibjui."RECORD" = ibjfi."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_design_info di ON di."RECORD" = ibjui."RECORD"
LEFT JOIN amos_tzs_biz.tz_equipment_category tec ON ibjri."EQU_CATEGORY" = tec.code
LEFT JOIN amos_tzs_biz.tz_equipment_category tec1 ON ibjri."EQU_LIST" = tec1.code
LEFT JOIN amos_tzs_biz.tz_equipment_category tec2 ON ibjri."EQU_DEFINE" = tec2.code
WHERE
ibjui."RECORD" = #{record}
</select>
<update id="updateVersionBatch">
<foreach collection="records" separator=";" item="record" open="" close="">
UPDATE idx_biz_jg_use_info SET "VERSION"=#{version} WHERE record = #{record}
......
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