Commit a69f5f88 authored by 韩桐桐's avatar 韩桐桐

feat(jg):向新增的工程装置表刷入数据

parent 82b91c9f
......@@ -34,4 +34,11 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(dataHandlerService.deviceListInFormWithInstallNotice());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "向新增的工程装置表刷入数据", notes = "向新增的工程装置表刷入数据")
@GetMapping(value = "/projectContraption/writeData")
public ResponseModel<Boolean> writeData2ProjectContraption() {
return ResponseHelper.buildResponse(dataHandlerService.writeData2ProjectContraption());
}
}
......@@ -4,18 +4,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
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.mapper.EquipmentCategoryMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -28,13 +31,45 @@ public class DataHandlerServiceImpl {
@Resource
private ObjectMapper objectMapper;
@Autowired
@Resource
private JgRegistrationHistoryServiceImpl registrationHistoryService;
@Autowired
@Resource
private JgInstallationNoticeServiceImpl installationNoticeService;
@Resource
private JgUseRegistrationServiceImpl useRegistrationService;
@Resource
private IdxBizJgUseInfoServiceImpl useInfoService;
@Resource
private SnowflakeIdUtil sequence;
@Resource
private IdxBizJgProjectContraptionServiceImpl projectContraptionService;
@Resource
private IdxBizJgTechParamsPipelineServiceImpl techParamsPipelineService;
@Resource
private EquipmentCategoryMapper equipmentCategoryMapper;
@Resource
private IdxBizJgRegisterInfoServiceImpl registerInfoService;
@Resource
private IdxBizJgSupervisionInfoServiceImpl supervisionInfoService;
@Resource
private IdxBizJgFactoryInfoServiceImpl factoryInfoService;
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
*
* @return result
*/
@Transactional(rollbackFor = Exception.class)
public Boolean deviceListInFormWithInstallNotice() {
List<JgInstallationNotice> noticeList = installationNoticeService.list(new LambdaQueryWrapper<JgInstallationNotice>()
......@@ -85,4 +120,140 @@ public class DataHandlerServiceImpl {
.eq(JgRegistrationHistory::getIsDelete, false)
);
}
/**
* 向新增的工程装置表刷入数据
*
* @return result
*/
@Transactional(rollbackFor = Exception.class)
public Boolean writeData2ProjectContraption() {
Set<String> projectContraptions = useInfoService.lambdaQuery()
.select(IdxBizJgUseInfo::getProjectContraption)
.groupBy(IdxBizJgUseInfo::getProjectContraption)
.list().stream()
.filter(Objects::nonNull)
.map(IdxBizJgUseInfo::getProjectContraption)
.filter(Objects::nonNull)
.filter(StringUtils::hasText)
.collect(Collectors.toSet());
log.info("查询到的工程装置集合: {}", projectContraptions);
List<IdxBizJgProjectContraption> projectContraptionList = new ArrayList<>();
Iterator<String> iterator = projectContraptions.iterator();
while (iterator.hasNext()) {
String projectContraption = iterator.next();
boolean isLast = !iterator.hasNext();
Long sequenceNbr = sequence.nextId();
JgInstallationNotice installationNotice = installationNoticeService.lambdaQuery()
.eq(JgInstallationNotice::getProjectContraption, projectContraption)
.eq(JgInstallationNotice::getNoticeStatus, FlowStatusEnum.TO_BE_FINISHED.getCode())
.list().stream()
.findFirst().orElse(null);
JgUseRegistration useRegistration = useRegistrationService.lambdaQuery()
.eq(JgUseRegistration::getProjectContraption, projectContraption)
.eq(JgUseRegistration::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName())
.list().stream()
.findFirst().orElse(null);
List<IdxBizJgUseInfo> useInfos = useInfoService.lambdaQuery()
.eq(IdxBizJgUseInfo::getProjectContraption, projectContraption)
.list();
List<IdxBizJgTechParamsPipeline> idxBizJgTechParamsPipelines = 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)
.useUnitCreditCode(ObjectUtils.isEmpty(useRegistration) ? null : useRegistration.getUseUnitCreditCode())
.useUnitName(ObjectUtils.isEmpty(useRegistration) ? null : useRegistration.getUseUnitName())
.uscUnitCreditCode(ObjectUtils.isEmpty(useRegistration) ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitCreditCode()) : null)
.uscUnitName(ObjectUtils.isEmpty(useRegistration) ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitName()) : null)
.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())
.useRegistrationCode(ObjectUtils.isEmpty(useRegistration) ? null : useRegistration.getUseRegistrationCode())
.isIntoManagement(Boolean.TRUE)
.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();
installationNoticeService.lambdaUpdate()
.set(JgInstallationNotice::getProjectContraptionId, sequenceNbr)
.eq(JgInstallationNotice::getProjectContraption, projectContraption)
.update();
useRegistrationService.lambdaUpdate()
.set(JgUseRegistration::getProjectContraptionId, sequenceNbr)
.eq(JgUseRegistration::getProjectContraption, projectContraption)
.update();
}
return Boolean.TRUE;
}
}
......@@ -3,8 +3,7 @@ package com.yeejoin.amos.boot.module.ymt.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import lombok.experimental.Accessors;
/**
......@@ -16,6 +15,9 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("idx_biz_jg_project_contraption")
public class IdxBizJgProjectContraption extends BaseEntity {
......
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