Commit 549b47c1 authored by suhuiguang's avatar suhuiguang

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

1.、是否球馆、发证日期
parent c4577724
......@@ -3,37 +3,35 @@ 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;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
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.IdxBizJgDesignInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgFactoryInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgMaintenanceRecordInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
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.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;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.alibaba.fastjson.JSON.toJSONString;
@Component
@RequiredArgsConstructor
@Slf4j
public class EquipRefreshHandler implements IDataRefreshHandler {
public class EquipmentRefreshHandler implements IDataRefreshHandler {
private final IdxBizJgUseInfoServiceImpl useInfoService;
private final IdxBizJgFactoryInfoServiceImpl factoryInfoService;
......@@ -43,6 +41,10 @@ public class EquipRefreshHandler implements IDataRefreshHandler {
private final IdxBizJgMaintenanceRecordInfoServiceImpl maintenanceRecordInfoService;
private final IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoServiceImpl;
private final StatisticsDataUpdateService statisticsDataUpdateService;
private final IdxBizJgRegisterInfoServiceImpl registerInfoService;
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageServiceImpl;
@Override
......@@ -66,25 +68,33 @@ public class EquipRefreshHandler implements IDataRefreshHandler {
IdxBizJgUseInfo useInfo = useInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record).select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getCreateDate));
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoServiceImpl.getOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>()
.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>()
.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));
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.setUSE_ORG_CODE(registerInfo.getUseOrgCode());
esEquipmentInfo.setIssueDate(getIssueDate(registerInfo.getUseOrgCode()));
esEquipmentInfo.setWhetherSphericalTank(registerInfo.getWhetherSphericalTank());
esEquipmentInfo.setDesignUnitCreditCode(designInfo.getDesignUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT(lastMaintenanceRecordInfo.getMeUnitCreditCode());
esEquipmentInfo.setMAINTAIN_UNIT_NAME(lastMaintenanceRecordInfo.getMeUnitName());
esEquipmentInfo.setDesignUnitName(designInfo.getDesignUnitName());
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.setTechParams(this.buildTechParamByEquList(record, categoryEs.getEQU_LIST_CODE()));
esEquipmentDao.save(esEquipmentInfo);
......@@ -97,4 +107,17 @@ public class EquipRefreshHandler implements IDataRefreshHandler {
private List<ESEquipmentInfo.TechParam> buildTechParamByEquList(String record, String equListCode) {
return StringUtils.isNotEmpty(equListCode) ? statisticsDataUpdateService.getTechParams(equListCode, record) : new ArrayList<>();
}
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);
}
}
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