Commit 6365c013 authored by suhuiguang's avatar suhuiguang

1.管道刷历史数据

parent 0a13d7b5
package com.yeejoin.amos.boot.module.jg.api.mapper; package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/** /**
* 安装告知设备关系表 Mapper 接口 * 安装告知设备关系表 Mapper 接口
...@@ -11,4 +13,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -11,4 +13,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface JgInstallationNoticeEqMapper extends CustomBaseMapper<JgInstallationNoticeEq> { public interface JgInstallationNoticeEqMapper extends CustomBaseMapper<JgInstallationNoticeEq> {
/**
* 查询安装告知完成但是纳管状态非已纳管的管道
*
* @return List<JgInstallationNoticeEq> 管道record数组
*/
List<JgInstallationNoticeEq> selectErrorRecordOfInIntoManage();
} }
...@@ -52,4 +52,11 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat ...@@ -52,4 +52,11 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat
List<Map<String, Object>> getDeviceListByProjectContraption(@Param("projectContraptionSeq") String projectContraptionSeq); List<Map<String, Object>> getDeviceListByProjectContraption(@Param("projectContraptionSeq") String projectContraptionSeq);
List<Map<String, Object>> getPipelineEquInfoByRecords(@Param("records") List<String> records); List<Map<String, Object>> getPipelineEquInfoByRecords(@Param("records") List<String> records);
/**
* 安装使用登记查询关联的安装告知
* @param useRegisterId 使用登记id
* @return 登记关联的告知
*/
JgInstallationNotice selectNoticeDataByUseRegisterId(@Param("useRegisterId") String useRegisterId );
} }
...@@ -121,4 +121,5 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> { ...@@ -121,4 +121,5 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
* @return List<Map<String, Object>> * @return List<Map<String, Object>>
*/ */
List<Map<String, Object>> selectPieLineListByOfCanReg(@Param("projectContraptionSeq") String projectContraptionSeq); List<Map<String, Object>> selectPieLineListByOfCanReg(@Param("projectContraptionSeq") String projectContraptionSeq);
} }
...@@ -2,4 +2,18 @@ ...@@ -2,4 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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.jg.api.mapper.JgInstallationNoticeEqMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper">
<select id="selectErrorRecordOfInIntoManage" resultType="com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq">
SELECT
ne.equ_id
FROM
"tzs_jg_installation_notice" n,
tzs_jg_installation_notice_eq ne,
"idx_biz_jg_use_info" u
WHERE
n.notice_status = '6616'
and ne.equip_transfer_id = n.sequence_nbr
and ne.equ_id = u."RECORD"
and (u."IS_INTO_MANAGEMENT" = false or u."IS_INTO_MANAGEMENT" is null)
and n.project_contraption <![CDATA[<>]]> ''
</select>
</mapper> </mapper>
...@@ -315,6 +315,25 @@ ...@@ -315,6 +315,25 @@
</where> </where>
</select> </select>
<select id="selectNoticeDataByUseRegisterId" resultType="com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice">
SELECT
n.sequence_nbr,
n.project_contraption,
n.project_contraption_id,
ne.equ_id as remark
FROM
"tzs_jg_installation_notice" n,
tzs_jg_installation_notice_eq ne
WHERE
n.notice_status = '6616'
and ne.equip_transfer_id = n.sequence_nbr
and ne.equ_id = (
select
re.equ_id
from
tzs_jg_use_registration_eq re
where
re.equip_transfer_id = #{useRegisterId} limit 1
)
</select>
</mapper> </mapper>
...@@ -69,4 +69,21 @@ public class DataHandlerController extends BaseController { ...@@ -69,4 +69,21 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(true); return ResponseHelper.buildResponse(true);
} }
@ApiOperation(httpMethod = "PUT", value = "安装告知缺少装置id、装置未创建、安装告知完成但是设备状态为未纳管数据处理", notes = "历史数据处理")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/v3/projectContraption/notice")
public ResponseModel<Boolean> projectContraptionNoticeDataDealV3(){
dataHandlerService.projectContraptionNoticeDataDeal();
return ResponseHelper.buildResponse(true);
}
@ApiOperation(httpMethod = "PUT", value = "使用登记缺少装置id数据处理", notes = "历史数据处理,依赖/v3/projectContraption/notice作为基础数据")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/v3/projectContraption/useRegister")
public ResponseModel<Boolean> projectContraptionUseRegisterDataDealV3(){
dataHandlerService.projectContraptionUseRegisterDataDeal();
return ResponseHelper.buildResponse(true);
}
} }
...@@ -13,13 +13,13 @@ import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; ...@@ -13,13 +13,13 @@ import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.entity.*; 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.enums.PipelineEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.BaseUnitLicenceMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -27,6 +27,8 @@ import org.springframework.util.StopWatch; ...@@ -27,6 +27,8 @@ import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
...@@ -86,8 +88,9 @@ public class DataHandlerServiceImpl { ...@@ -86,8 +88,9 @@ public class DataHandlerServiceImpl {
@Resource @Resource
TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper; TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
@Autowired
private BaseUnitLicenceMapper baseUnitLicenceMapper; @Resource
private JgInstallationNoticeEqMapper jgInstallationNoticeEqMapper;
/** /**
...@@ -522,4 +525,178 @@ public class DataHandlerServiceImpl { ...@@ -522,4 +525,178 @@ public class DataHandlerServiceImpl {
} }
}); });
} }
@Transactional(rollbackFor = Exception.class)
public void projectContraptionNoticeDataDeal() {
// 1.安装告知完成但是设备状态未非已纳管状态:设备的idx_biz_jg_use_info表的IS_INTO_MANAGEMENT刷为已纳管, es的IS_INTO_MANAGEMENT刷为已纳管
List<JgInstallationNoticeEq> eqs = jgInstallationNoticeEqMapper.selectErrorRecordOfInIntoManage();
log.info("处理前:1.安装告知完成但是设备状态未非已纳管状态的设备数量:{}", eqs.size());
for(JgInstallationNoticeEq eq : eqs){
// 使用信息表刷已纳管
useInfoService.lambdaUpdate()
.set(IdxBizJgUseInfo::getIsIntoManagement, true)
.eq(IdxBizJgUseInfo::getRecord, eq.getEquId())
.update();
// es刷已纳管
Optional<ESEquipmentCategoryDto> equInfosWithEs = esEquipmentCategory.findById(eq.getEquId());
equInfosWithEs.ifPresent(equInfoEs -> {
equInfoEs.setIS_INTO_MANAGEMENT(true);
esEquipmentCategory.save(equInfoEs);
});
}
// 2.安装告知非已作废,但是缺少装置的数据处理:创建装置(计算管道长度)、写入安装告知表project_contraption_id、写入设备es的装置id,设备使用信息表的projectContraptionId
List<JgInstallationNotice> noticeList = getErrorInstallNoticeData();
log.info("处理前:2.安装告知非已作废,但是缺少装置id安装告知单据数量:{}", noticeList.size());
List<IdxBizJgProjectContraption> projectContraptionList = new ArrayList<>();
Map<Long, List<String>> projectContraptionIdRecordsMap = new HashMap<>();
for(JgInstallationNotice installationNotice : noticeList){
List<JgInstallationNoticeEq> noticeEqs = installationNoticeEqService.list(new LambdaQueryWrapper<JgInstallationNoticeEq>().eq(JgInstallationNoticeEq::getEquipTransferId, installationNotice.getSequenceNbr()).select(JgInstallationNoticeEq::getEquId));
List<String> records = noticeEqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toList());
List<IdxBizJgUseInfo> useInfos = useInfoService.lambdaQuery()
.in(IdxBizJgUseInfo::getRecord, records)
.list();
//技术参数表
List<IdxBizJgTechParamsPipeline> idxBizJgTechParamsPipelines = useInfos.isEmpty() ? new ArrayList<>() : techParamsPipelineService
.lambdaQuery()
.in(IdxBizJgTechParamsPipeline::getRecord, records)
.list();
double pipeLengthSum = idxBizJgTechParamsPipelines.stream()
.filter(Objects::nonNull)
.filter(pip -> Objects.nonNull(pip.getPipeLength()))
.mapToDouble(pipeline -> Double.parseDouble(pipeline.getPipeLength()))
.sum();
BigDecimal pipeLengthSumBig = new BigDecimal(String.valueOf(pipeLengthSum)).setScale(3, RoundingMode.HALF_UP);
IdxBizJgRegisterInfo registerInfo = registerInfoService.lambdaQuery()
.eq(IdxBizJgRegisterInfo::getRecord, useInfos
.stream().findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.lambdaQuery()
.eq(IdxBizJgFactoryInfo::getRecord, useInfos
.stream()
.findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
Long sequenceNbr = sequence.nextId();
installationNotice.setProjectContraptionId(sequenceNbr + "");
projectContraptionIdRecordsMap.put(sequenceNbr, records);
IdxBizJgProjectContraption idxBizJgProjectContraption = IdxBizJgProjectContraption.builder()
.projectContraption(installationNotice.getProjectContraption())
.projectContraptionNo(installationNotice.getProjectContraption())
.uscUnitCreditCode(installationNotice.getInstallUnitCreditCode())
.uscUnitName(installationNotice.getInstallUnitName())
.equList(installationNotice.getEquListCode())
.equListName(installationNotice.getEquList())
.equCategory(installationNotice.getEquCategoryCode())
.equCategoryName(ObjectUtils.isEmpty(installationNotice.getEquCategoryCode()) ? null : equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, installationNotice.getEquCategoryCode())).getName())
.equDefine(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine())
.equDefineName(ObjectUtils.isEmpty(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine()) ? null : equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, (ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine()))).getName())
.content(null)
.pipelineLength(pipeLengthSumBig.doubleValue())
.productPhoto(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getProductPhoto())
.productQualificationCertificate(ObjectUtils.isEmpty(factoryInfo) ? null : factoryInfo.getProductQualityYieldProve())
.otherAccessories(installationNotice.getOtherAccessories())
.orgCode(installationNotice.getOrgBranchCode())
.orgName(installationNotice.getOrgBranchName())
.province(installationNotice.getProvince())
.provinceName(installationNotice.getProvinceName())
.city(installationNotice.getCity())
.cityName(installationNotice.getCityName())
.county(installationNotice.getCounty())
.countyName(installationNotice.getCountyName())
.street(installationNotice.getStreet())
.streetName(installationNotice.getStreetName())
.address(installationNotice.getAddress())
.startLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getStartePosition())
.endLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getEndPosition())
.supervisoryCode(installationNotice.getSupervisoryCode())
.isIntoManagement(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()).equals(installationNotice.getNoticeStatus()))
.dataSource("jg")
.build();
idxBizJgProjectContraption.setSequenceNbr(sequenceNbr);
idxBizJgProjectContraption.setRecDate(new Date());
idxBizJgProjectContraption.setIsDelete(Boolean.FALSE);
projectContraptionList.add(idxBizJgProjectContraption);
}
if(!noticeList.isEmpty()){
installationNoticeService.updateBatchById(noticeList);
}
if(!projectContraptionList.isEmpty()){
projectContraptionService.saveBatch(projectContraptionList);
}
projectContraptionIdRecordsMap.forEach((k,v)->{
Iterable<ESEquipmentCategoryDto> equipmentCategories = esEquipmentCategory.findAllById(v);
equipmentCategories.forEach(e-> e.setProjectContraptionId(k + ""));
esEquipmentCategory.saveAll(equipmentCategories);
});
List<JgInstallationNoticeEq> eqsAfter = jgInstallationNoticeEqMapper.selectErrorRecordOfInIntoManage();
log.info("处理后:3.安装告知完成但是设备状态未非已纳管状态的设备数量:{}", eqsAfter.size());
List<JgInstallationNotice> noticeListAfter = getErrorInstallNoticeData();
log.info("处理后:4.安装告知非已作废,但是缺少装置id安装告知单据数量:{}", noticeListAfter.size());
}
private List<JgInstallationNotice> getErrorInstallNoticeData() {
return installationNoticeService.list(new LambdaQueryWrapper<JgInstallationNotice>()
.ne(JgInstallationNotice::getNoticeStatus, FlowStatusEnum.TO_BE_DISCARD.getCode())
.ne(JgInstallationNotice::getProjectContraption, "")
.isNull(JgInstallationNotice::getProjectContraptionId));
}
/**
* 刷使用登记缺少装置id的管道的登记数据:1.填充装置id;2.已完成状状态清除装置表的安装单位信息字段,补充使用信息字段
*/
@Transactional(rollbackFor = Exception.class)
public void projectContraptionUseRegisterDataDeal(){
// 查询使用登记:非作废状态 有装置名称但是缺少装置id的使用登记单据进行数据处理
List<JgUseRegistration> useRegistrations = getUseRegisterOfError();
log.info("处理前:1.使用登记装置id历史数据填充,存在缺少装置id的单据数量:{}", useRegistrations.size());
// 循环按照使用登记的eq表关联安装告知eq表,在安装告知主表查询装置id
for(JgUseRegistration useRegistration : useRegistrations){
// 登记的关联的告知单据
JgInstallationNotice installationNotice = installationNoticeService.getBaseMapper().selectNoticeDataByUseRegisterId(useRegistration.getSequenceNbr() + "");
if(installationNotice != null && StringUtils.isNotEmpty(installationNotice.getProjectContraptionId())){
// 1.填充装置id
useRegistration.setProjectContraptionId(installationNotice.getProjectContraptionId());
// 2.已完成状状态清除装置表的安装单位信息字段,填充使用信息数据,
if(FlowStatusEnum.TO_BE_FINISHED.getName().equals(useRegistration.getStatus())){
IdxBizJgUseInfo useInfo = getIdxBizJgUseInfo(installationNotice.getRemark());
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BaseEntity::getSequenceNbr, installationNotice.getProjectContraptionId());
updateWrapper.set(IdxBizJgProjectContraption::getUscUnitCreditCode ,null);
updateWrapper.set(IdxBizJgProjectContraption::getUscUnitName,null);
updateWrapper.set(IdxBizJgProjectContraption::getUseRegistrationCode, useRegistration.getUseRegistrationCode());
updateWrapper.set(IdxBizJgProjectContraption::getProvince, useInfo.getProvince());
updateWrapper.set(IdxBizJgProjectContraption::getProvinceName, useInfo.getProvinceName());
updateWrapper.set(IdxBizJgProjectContraption::getCity, useInfo.getCity());
updateWrapper.set(IdxBizJgProjectContraption::getCityName, useInfo.getCityName());
updateWrapper.set(IdxBizJgProjectContraption::getCounty, useInfo.getCounty());
updateWrapper.set(IdxBizJgProjectContraption::getCountyName, useInfo.getCountyName());
updateWrapper.set(IdxBizJgProjectContraption::getStreet, useInfo.getFactoryUseSiteStreet());
updateWrapper.set(IdxBizJgProjectContraption::getStreetName, useInfo.getStreetName());
updateWrapper.set(IdxBizJgProjectContraption::getAddress, useInfo.getAddress());
projectContraptionService.update(null, updateWrapper);
}
}
}
List<JgUseRegistration> useRegistrationsAfter = getUseRegisterOfError();
log.info("处理后:2.使用登记装置id历史数据填充,存在缺少装置id的单据数量:{}", useRegistrationsAfter.size());
}
private IdxBizJgUseInfo getIdxBizJgUseInfo(String record) {
return useInfoService.getOneData(record);
}
/**
* 查询非作废状态的装置名称不为空,装置id为空或者null的使用登记数据
* @return 符合条件列表
*/
private List<JgUseRegistration> getUseRegisterOfError() {
return useRegistrationService.getBaseMapper().selectList(new LambdaQueryWrapper<JgUseRegistration>()
.ne(JgUseRegistration::getStatus, FlowStatusEnum.TO_BE_DISCARD.getName())
.ne(JgUseRegistration::getProjectContraption, "")
.isNull(JgUseRegistration::getProjectContraptionId)
.select(BaseEntity::getSequenceNbr, JgUseRegistration::getProjectContraption, JgUseRegistration::getUseRegistrationCode));
}
} }
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