Commit 7fb38b44 authored by 刘林's avatar 刘林

fix(jg):处理管道历史设备刷数据问题

parent c943f153
......@@ -48,5 +48,14 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(dataHandlerService.writeProjectContraptionId());
}
/**
* 向新增的工程装置表刷入数据(补充使用单位code为空的)
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "向新增的工程装置表刷入数据,条件是未做使用登记,使用单位code为空的", notes = "向新增的工程装置表刷入数据,条件是未做使用登记,使用单位code为空的")
@GetMapping(value = "/projectContraption/writeDataUseCodeIsNull")
public ResponseModel<Boolean> writeDataUseCodeIsNull2ProjectContraption() {
return ResponseHelper.buildResponse(dataHandlerService.writeDataUseCodeIsNull2ProjectContraption());
}
}
......@@ -331,4 +331,135 @@ public class DataHandlerServiceImpl {
stopWatch.stop();
return String.format("接口调用成功,更新数据:%s条,耗时:%s s", size.get(), stopWatch.getTotalTimeSeconds());
}
public Boolean writeDataUseCodeIsNull2ProjectContraption() {
List<IdxBizJgUseInfo> collect = useInfoService.lambdaQuery()
.select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getProjectContraption, IdxBizJgUseInfo::getUseUnitCreditCode, IdxBizJgUseInfo::getUseUnitName, IdxBizJgUseInfo::getIsIntoManagement)
.isNotNull(IdxBizJgUseInfo::getProjectContraption)
.ne(IdxBizJgUseInfo::getProjectContraption, "")
.eq(IdxBizJgUseInfo::getUseUnitCreditCode,null)
.groupBy(IdxBizJgUseInfo::getProjectContraption)
.list().stream()
.filter(Objects::nonNull)
.collect(Collectors.toList());
log.info("查询到的工程装置集合: {},总数:{}", JSON.toJSONString(collect), collect.size());
List<IdxBizJgProjectContraption> projectContraptionList = new ArrayList<>();
Iterator<IdxBizJgUseInfo> iterator = collect.iterator();
while (iterator.hasNext()) {
IdxBizJgUseInfo useInfo = iterator.next();
boolean isLast = !iterator.hasNext();
String record = useInfo.getRecord();
Boolean isIntoManagement = ObjectUtils.isEmpty(useInfo.getIsIntoManagement()) ? Boolean.FALSE : useInfo.getIsIntoManagement();
String projectContraption = useInfo.getProjectContraption();
Long sequenceNbr = sequence.nextId();
List<String> installNotSeqs = installationNoticeEqService.lambdaQuery()
.eq(JgInstallationNoticeEq::getEquId, record)
.list().stream()
.filter(Objects::nonNull)
.map(JgInstallationNoticeEq::getEquipTransferId)
.collect(Collectors.toList());
JgInstallationNotice installationNotice = installNotSeqs.isEmpty() ? null : installationNoticeService.lambdaQuery()
.in(JgInstallationNotice::getSequenceNbr, installNotSeqs)
.list().stream()
.findFirst().orElse(null);
List<IdxBizJgUseInfo> useInfos = useInfoService.lambdaQuery()
.eq(IdxBizJgUseInfo::getProjectContraption, projectContraption)
.list();
//技术参数表
List<IdxBizJgTechParamsPipeline> idxBizJgTechParamsPipelines = useInfos.isEmpty() ? new ArrayList<>() : techParamsPipelineService
.lambdaQuery()
.in(IdxBizJgTechParamsPipeline::getRecord, useInfos.stream()
.map(IdxBizJgUseInfo::getRecord)
.collect(Collectors.toList()))
.list();
double pipeLengthSum = idxBizJgTechParamsPipelines.stream()
.filter(Objects::nonNull)
.filter(pip -> Objects.nonNull(pip.getPipeLength()))
.mapToDouble(pipeline -> Double.parseDouble(pipeline.getPipeLength()))
.sum();
IdxBizJgRegisterInfo registerInfo = registerInfoService.lambdaQuery()
.eq(IdxBizJgRegisterInfo::getRecord, useInfos
.stream().findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgSupervisionInfo supervisionInfo = supervisionInfoService.lambdaQuery()
.eq(IdxBizJgSupervisionInfo::getRecord, useInfos
.stream()
.findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.lambdaQuery()
.eq(IdxBizJgFactoryInfo::getRecord, useInfos
.stream()
.findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgProjectContraption idxBizJgProjectContraption = IdxBizJgProjectContraption.builder()
.projectContraption(projectContraption)
.projectContraptionNo(projectContraption)
.uscUnitCreditCode(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitCreditCode())
.uscUnitName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitName())
.equList(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquListCode())
.equListName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquList())
.equCategory(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquCategoryCode())
.equCategoryName(ObjectUtils.isEmpty(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquCategoryCode()) ? null : equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, (ObjectUtils.isEmpty(installationNotice) ? null : 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(pipeLengthSum)
.productPhoto(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getProductPhoto())
.otherAccessories(null)
.orgCode(ObjectUtils.isEmpty(supervisionInfo) ? null : supervisionInfo.getOrgBranchCode())
.orgName(ObjectUtils.isEmpty(supervisionInfo) ? null : supervisionInfo.getOrgBranchName())
.productQualificationCertificate(ObjectUtils.isEmpty(factoryInfo) ? null : factoryInfo.getProductQualityYieldProve())
.province(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getProvince())
.provinceName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getProvinceName())
.city(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCity())
.cityName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCityName())
.county(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCounty())
.countyName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCountyName())
.street(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getStreet())
.streetName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getStreetName())
.address(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getAddress())
.startLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getStartePosition())
.endLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getEndPosition())
.supervisoryCode(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getSupervisoryCode())
.isIntoManagement(isIntoManagement)
.dataSource("jg")
.build();
idxBizJgProjectContraption.setSequenceNbr(sequenceNbr);
idxBizJgProjectContraption.setRecDate(new Date());
idxBizJgProjectContraption.setIsDelete(Boolean.FALSE);
projectContraptionList.add(idxBizJgProjectContraption);
if (projectContraptionList.size() % 1000 == 0 || isLast) {
projectContraptionService.saveBatch(projectContraptionList);
projectContraptionList.clear();
}
useInfoService.lambdaUpdate()
.set(IdxBizJgUseInfo::getProjectContraptionId, sequenceNbr)
.eq(IdxBizJgUseInfo::getProjectContraption, projectContraption)
.update();
if (!installNotSeqs.isEmpty()) {
installationNoticeService.lambdaUpdate()
.set(JgInstallationNotice::getProjectContraptionId, sequenceNbr)
.in(JgInstallationNotice::getSequenceNbr, installNotSeqs)
.eq(JgInstallationNotice::getProjectContraption, projectContraption)
.update();
}
}
return Boolean.TRUE;
}
}
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