Commit f5d77132 authored by suhuiguang's avatar suhuiguang

feat(综合搜索):2次需求变更增加字段

1.、是否球馆、发证日期
parent fe6ce699
...@@ -13,11 +13,8 @@ import org.springframework.data.elasticsearch.annotations.FieldType; ...@@ -13,11 +13,8 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -99,6 +96,12 @@ public class ESEquipmentInfo { ...@@ -99,6 +96,12 @@ public class ESEquipmentInfo {
private String USE_ORG_CODE; private String USE_ORG_CODE;
/** /**
* 使用登记证-发证日期
*/
@Field(type = FieldType.Date, format = DateFormat.date)
private LocalDate issueDate;
/**
* 96333电梯码 * 96333电梯码
*/ */
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
...@@ -208,8 +211,7 @@ public class ESEquipmentInfo { ...@@ -208,8 +211,7 @@ public class ESEquipmentInfo {
private LocalDate USC_DATE; private LocalDate USC_DATE;
/** /**
* * 创建日期
*创建日期
*/ */
@Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second) @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)
private LocalDateTime createDate; private LocalDateTime createDate;
...@@ -236,8 +238,8 @@ public class ESEquipmentInfo { ...@@ -236,8 +238,8 @@ public class ESEquipmentInfo {
/** /**
* 制造日期 * 制造日期
*/ */
@Field(type = FieldType.Text) @Field(type = FieldType.Date, format = DateFormat.date)
private String PRODUCE_DATE; private LocalDate PRODUCE_DATE;
/** /**
* 设备来源 * 设备来源
...@@ -248,7 +250,7 @@ public class ESEquipmentInfo { ...@@ -248,7 +250,7 @@ public class ESEquipmentInfo {
/** /**
* 是否车用气瓶 * 是否车用气瓶
*/ */
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String WHETHER_VEHICLE_CYLINDER; private String WHETHER_VEHICLE_CYLINDER;
/** /**
...@@ -332,6 +334,13 @@ public class ESEquipmentInfo { ...@@ -332,6 +334,13 @@ public class ESEquipmentInfo {
private String produceUnitCreditCode; private String produceUnitCreditCode;
/** /**
* 设计日期
*/
@Field(type = FieldType.Date, format = DateFormat.date)
private LocalDate designDate;
/**
* 下次检验日期-冗余字段 * 下次检验日期-冗余字段
*/ */
@Field(type = FieldType.Date, format = DateFormat.date) @Field(type = FieldType.Date, format = DateFormat.date)
...@@ -350,6 +359,14 @@ public class ESEquipmentInfo { ...@@ -350,6 +359,14 @@ public class ESEquipmentInfo {
private String unitType; private String unitType;
/** /**
* 是否球罐
* 1:是
* 0:不是
*/
@Field(type = FieldType.Keyword)
private String whetherSphericalTank;
/**
* 最新一条检验信息 * 最新一条检验信息
*/ */
@Field(type = FieldType.Nested) @Field(type = FieldType.Nested)
...@@ -451,6 +468,7 @@ public class ESEquipmentInfo { ...@@ -451,6 +468,7 @@ public class ESEquipmentInfo {
// 处理科学计数法(避免1.23E-4这样的输出) // 处理科学计数法(避免1.23E-4这样的输出)
return bd.stripTrailingZeros().doubleValue(); return bd.stripTrailingZeros().doubleValue();
} }
private void resetFields() { private void resetFields() {
this.strValue = null; this.strValue = null;
this.longValue = null; this.longValue = null;
......
...@@ -70,7 +70,7 @@ public class DataRefreshListener { ...@@ -70,7 +70,7 @@ public class DataRefreshListener {
private void processEvent(DataRefreshEvent event) { private void processEvent(DataRefreshEvent event) {
// 1.记录 message // 1.记录 message
List<TzsDataRefreshMessage> messages = createMsg(event); List<TzsDataRefreshMessage> messages = createMsg(event);
// 2.调用更新处理 // 2.调用更新处理-异步
dataRefreshService.ifPresent(service -> service.doDispatch(event.getDataType(), messages)); dataRefreshService.ifPresent(service -> service.doDispatch(event.getDataType(), messages));
} }
......
...@@ -19,4 +19,12 @@ public interface IIdxBizJgInspectionDetectionInfoService { ...@@ -19,4 +19,12 @@ public interface IIdxBizJgInspectionDetectionInfoService {
boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList); boolean saveOrUpdateBatch(List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfoList);
List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record); List<IdxBizJgInspectionDetectionInfo> queryInspectionListByRecord(String record);
/**
* 查询指定设备的-最新的检验信息-按照检验类型分组
* @param record 设备唯一标识
* @return 最新的检验信息-按照检验类型分组
*/
List<IdxBizJgInspectionDetectionInfo> queryLastedGroupByInspectType(String record);
} }
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -62,6 +63,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -62,6 +63,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -1518,25 +1520,35 @@ public class DataHandlerServiceImpl { ...@@ -1518,25 +1520,35 @@ public class DataHandlerServiceImpl {
IdxBizJgUseInfo useInfo = useInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record).select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getCreateDate)); IdxBizJgUseInfo useInfo = useInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record).select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getCreateDate));
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoServiceImpl.getOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>() IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoServiceImpl.getOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>()
.eq(IdxBizJgDesignInfo::getRecord, record) .eq(IdxBizJgDesignInfo::getRecord, record)
.select(IdxBizJgDesignInfo::getRecord, IdxBizJgDesignInfo::getDesignUnitName, IdxBizJgDesignInfo::getDesignUnitCreditCode)); .select(IdxBizJgDesignInfo::getRecord, IdxBizJgDesignInfo::getDesignUnitName, IdxBizJgDesignInfo::getDesignUnitCreditCode,
IdxBizJgDesignInfo::getDesignDate));
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.getOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>() IdxBizJgFactoryInfo factoryInfo = factoryInfoService.getOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>()
.eq(IdxBizJgFactoryInfo::getRecord, record) .eq(IdxBizJgFactoryInfo::getRecord, record)
.select(IdxBizJgFactoryInfo::getRecord, IdxBizJgFactoryInfo::getProduceUnitCreditCode)); .select(IdxBizJgFactoryInfo::getRecord, IdxBizJgFactoryInfo::getProduceUnitCreditCode));
IdxBizJgRegisterInfo registerInfo = registerInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
.eq(IdxBizJgRegisterInfo::getRecord, record)
.select(IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getWhetherSphericalTank, IdxBizJgRegisterInfo::getUseOrgCode));
// 检验信息按照不同检验类型,存最新的一条
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = iIdxBizJgInspectionDetectionInfoService.queryLastedGroupByInspectType(record);
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = iIdxBizJgInspectionDetectionInfoService.queryNewestDetailByRecord(record); IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = iIdxBizJgInspectionDetectionInfoService.queryNewestDetailByRecord(record);
IdxBizJgMaintenanceRecordInfo lastMaintenanceRecordInfo = maintenanceRecordInfoService.queryNewestDetailByRecord(record); IdxBizJgMaintenanceRecordInfo lastMaintenanceRecordInfo = maintenanceRecordInfoService.queryNewestDetailByRecord(record);
try { 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.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.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); esEquipmentInfo.setCreateDate(useInfo.getCreateDate() != null ? useInfo.getCreateDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() : null);
} catch (Exception e) { } catch (Exception e) {
log.error("时区转换失败:{}", record, e); log.error("时区转换失败:{}", record, e);
} }
esEquipmentInfo.setUSE_ORG_CODE(registerInfo.getUseOrgCode());
esEquipmentInfo.setIssueDate(getIssueDate(registerInfo.getUseOrgCode()));
esEquipmentInfo.setWhetherSphericalTank(registerInfo.getWhetherSphericalTank());
esEquipmentInfo.setDesignUnitCreditCode(designInfo.getDesignUnitCreditCode()); esEquipmentInfo.setDesignUnitCreditCode(designInfo.getDesignUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT(lastMaintenanceRecordInfo.getMeUnitCreditCode()); esEquipmentInfo.setMAINTAIN_UNIT(lastMaintenanceRecordInfo.getMeUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT_NAME(lastMaintenanceRecordInfo.getMeUnitName()); esEquipmentInfo.setMAINTAIN_UNIT_NAME(lastMaintenanceRecordInfo.getMeUnitName());
esEquipmentInfo.setDesignUnitName(designInfo.getDesignUnitName()); esEquipmentInfo.setDesignUnitName(designInfo.getDesignUnitName());
esEquipmentInfo.setProduceUnitCreditCode(factoryInfo.getProduceUnitCreditCode()); esEquipmentInfo.setProduceUnitCreditCode(factoryInfo.getProduceUnitCreditCode());
esEquipmentInfo.setInspections(inspectionDetectionInfo.getSequenceNbr() != null ? Collections.singletonList(BeanUtil.copyProperties(inspectionDetectionInfo, ESEquipmentInfo.Inspection.class)) : new ArrayList<>()); esEquipmentInfo.setInspections(BeanUtil.copyToList(inspectionDetectionInfos, ESEquipmentInfo.Inspection.class));
esEquipmentInfo.setMaintenances(lastMaintenanceRecordInfo.getSequenceNbr() != null ? Collections.singletonList(BeanUtil.copyProperties(lastMaintenanceRecordInfo, ESEquipmentInfo.Maintenance.class)) : new ArrayList<>()); 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, categoryEs.getEQU_LIST_CODE()));
} catch (Exception e) { } catch (Exception e) {
...@@ -1574,4 +1586,18 @@ public class DataHandlerServiceImpl { ...@@ -1574,4 +1586,18 @@ public class DataHandlerServiceImpl {
} }
return registerInfoList.size(); return registerInfoList.size();
} }
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);
}
} }
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jg.biz.core.BaseService; import com.yeejoin.amos.boot.module.jg.biz.core.BaseService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
...@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service; ...@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -72,4 +74,9 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB ...@@ -72,4 +74,9 @@ public class IdxBizJgInspectionDetectionInfoServiceImpl extends BaseService<IdxB
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public List<IdxBizJgInspectionDetectionInfo> queryLastedGroupByInspectType(String record) {
return this.getBaseMapper().selectLastedGroupByInspectType(record);
}
} }
\ No newline at end of file
...@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper; ...@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 安全追溯-检验检测信息表 Mapper 接口 * 安全追溯-检验检测信息表 Mapper 接口
...@@ -11,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -11,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface IdxBizJgInspectionDetectionInfoMapper extends BaseMapper<IdxBizJgInspectionDetectionInfo> { public interface IdxBizJgInspectionDetectionInfoMapper extends BaseMapper<IdxBizJgInspectionDetectionInfo> {
List<IdxBizJgInspectionDetectionInfo> selectLastedGroupByInspectType(@Param("record") String record);
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgInspectionDetectionInfoMapper">
<select id="selectLastedGroupByInspectType"
resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo">
SELECT
DISTINCT ON ("INSPECT_TYPE") *
FROM
idx_biz_jg_inspection_detection_info
WHERE
"RECORD" = #{record}
ORDER BY "INSPECT_TYPE", "INSPECT_DATE" DESC, "SEQUENCE_NBR" DESC
</select>
</mapper>
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