Commit c198fe2c authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_bugfix' into develop_tzs_register

# Conflicts: # amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/DataHandlerServiceImpl.java
parent d77df820
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 com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -19,10 +21,12 @@ import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PieLineEquipContraptionDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.DataHandlerMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
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.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import lombok.extern.slf4j.Slf4j;
......@@ -39,11 +43,13 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE_NAME;
......@@ -121,6 +127,14 @@ public class DataHandlerServiceImpl {
@Autowired
private JgInstallationNoticeMapper jgInstallationNoticeMapper;
@Resource
private JgVehicleInformationServiceImpl jgVehicleInformationService;
@Resource
private DataHandlerMapper dataHandlerMapper;
@Resource
private CategoryOtherInfoMapper categoryOtherInfoMapper;
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
......@@ -997,4 +1011,78 @@ public class DataHandlerServiceImpl {
}
return true;
}
/**
* 将历史导入的普通气瓶和正常导入的普通气瓶刷入设备状态
*
* @return result
*/
public String ordinaryGasCylinderWriteEquState() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// 所有的历史导入的普通气瓶 dataSource = 'jg_his' + 过滤出做了报废注销启用停用的业务设备 设备状态为 在用 (EquimentEnum.ZAIYONG.getCode())
List<String> allHisRecords = dataHandlerMapper.selectOrdinaryHisGasCylinder();
useInfoService.lambdaUpdate().in(IdxBizJgUseInfo::getRecord, allHisRecords).set(IdxBizJgUseInfo::getEquState, EquimentEnum.ZAIYONG.getCode()).update();
allHisRecords.forEach(record -> {
Optional<ESEquipmentCategoryDto> categoryDto = esEquipmentCategory.findById(record);
categoryDto.ifPresent(categoryEs -> {
categoryEs.setEQU_STATE(EquimentEnum.ZAIYONG.getCode());
esEquipmentCategory.save(categoryEs);
});
});
// 所有的正常导入的普通气瓶 dataSource = 'jg' + 过滤出做了使用登记业务的设备 设备状态为 未登记 (EquimentEnum.WEIDENGJI.getCode())
List<String> allRecords = dataHandlerMapper.selectOrdinaryGasCylinder();
useInfoService.lambdaUpdate().in(IdxBizJgUseInfo::getRecord, allRecords).set(IdxBizJgUseInfo::getEquState, EquimentEnum.WEIDENGJI.getCode()).update();
allRecords.forEach(record -> {
Optional<ESEquipmentCategoryDto> categoryDto = esEquipmentCategory.findById(record);
categoryDto.ifPresent(categoryEs -> {
categoryEs.setEQU_STATE(EquimentEnum.WEIDENGJI.getCode());
esEquipmentCategory.save(categoryEs);
});
});
stopWatch.stop();
return String.format("刷入数据%s条,耗时:%s秒", allHisRecords.size() + allRecords.size(), stopWatch.getTotalTimeSeconds());
}
public void initFormUrl() {
jgVehicleInformationService.initFormUrl();
useRegistrationService.initFormUrl();
}
public void synchronizeEqData2ES(String records, Boolean isAgw, Boolean isIntoManagement) {
if (records == null || records.isEmpty()) {
return;
}
String[] recordArr = records.trim().split(",");
for (String record : recordArr) {
Map<String, Object> map = categoryOtherInfoMapper.selectDataById(record);
categoryOtherInfoMapper.updateEsStatus(record);
ESEquipmentCategoryDto dto = JSON.parseObject(toJSONString(map), ESEquipmentCategoryDto.class);
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(record);
if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(record);
}
if (!ObjectUtils.isEmpty(dto)) {
long time = Timestamp.valueOf(map.get("REC_DATE").toString().substring(0, 19)).getTime();
dto.setREC_DATE(time);
// 需要安装的设备 安装告知审批通过 清除设备的USC_UNIT_CREDIT_CODE安装单位信息
// 使用单位编辑 防止更新设备时将安改维单位信息更新到es中
if (!isAgw) {
dto.setUSC_UNIT_CREDIT_CODE(null);
dto.setUSC_UNIT_NAME(null);
}
if (map.get("NEXT_INSPECT_DATE") != null) {
Date nextInspectDate = (Date) map.get("NEXT_INSPECT_DATE");
dto.setNEXT_INSPECT_DATE(DateUtil.parse(DateUtil.format(nextInspectDate, DatePattern.NORM_DATE_PATTERN)).getTime());
}
dto.setIS_INTO_MANAGEMENT(isIntoManagement);
IdxBizJgUseInfo useInfo = useInfoService.lambdaQuery().eq(IdxBizJgUseInfo::getRecord, record).one();
dto.setUSE_PLACE_CODE(useInfo.getProvince() + "#" + useInfo.getCity() + "#" + useInfo.getCounty() + "#" + useInfo.getFactoryUseSiteStreet());
dto.setUSE_SITE_CODE(useInfo.getUsePlace());
esEquipmentCategory.save(dto);
}
}
}
}
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