Commit 039e4d92 authored by suhuiguang's avatar suhuiguang

fix(重要提醒):存量数据刷刷数据中质量登记

1.设备刷 2.装置刷
parent cf37f066
......@@ -219,4 +219,12 @@ public class DataHandlerController extends BaseController {
public ResponseModel<String> writeEstateUnitInfoInUseInfo() {
return ResponseHelper.buildResponse(dataHandlerService.writeEstateUnitInfoInUseInfo());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "put", value = "历史设备装置初始化数据质量等级", notes = "车用气瓶登记产权单位信息刷入useInfo表")
@PutMapping(value = "/initDataQualityScore")
public ResponseModel<String> initDataQualityScore(){
return ResponseHelper.buildResponse(dataHandlerService.initDataQualityScore());
}
}
......@@ -24,12 +24,16 @@ import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeEqDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
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.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.handler.strategy.ProblemHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgInspectionDetectionInfoService;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.dto.ProjectWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto;
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;
......@@ -93,7 +97,8 @@ public class DataHandlerServiceImpl {
private final DataHandlerMapper dataHandlerMapper;
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
private final CommonMapper commonMapper;
private final ProblemHandleStrategy equipmentStrategy;;
private final ProblemHandleStrategy equipmentStrategy;
;
private final SafetyProblemTracingServiceImpl safetyProblemTracingService;
private final JgChangeRegistrationUnitServiceImpl jgChangeRegistrationUnitService;
private final JgChangeRegistrationUnitEqServiceImpl jgChangeRegistrationUnitEqService;
......@@ -103,8 +108,9 @@ public class DataHandlerServiceImpl {
private final JgChangeRegistrationTransferMapper jgChangeRegistrationTransferMapper;
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageServiceImpl;
// 组织机构跟节点
private static final String ROOT_ORG_CODE = "50";
private static final String ROOT_ORG_CODE = "50";
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
......@@ -645,13 +651,13 @@ public class DataHandlerServiceImpl {
projectContraptionService.saveBatch(projectContraptionList);
}
// 更新设备es的装置id、使用信息的装置id
projectContraptionIdRecordsMap.forEach((k,v)->{
projectContraptionIdRecordsMap.forEach((k, v) -> {
IdxBizJgProjectContraption idxBizJgProjectContraption = projectContraptionService.getById(k);
Iterable<ESEquipmentCategoryDto> equipmentCategories = esEquipmentCategory.findAllById(v);
equipmentCategories.forEach(e-> e.setProjectContraptionId(k + ""));
equipmentCategories.forEach(e -> e.setProjectContraptionId(k + ""));
esEquipmentCategory.saveAll(equipmentCategories);
Collection<IdxBizJgUseInfo> useInfos = useInfoService.getUseInfoListByEquIds(v);
useInfos.forEach(u->{
useInfos.forEach(u -> {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, u.getRecord());
updateWrapper.set(IdxBizJgUseInfo::getProjectContraptionId, k);
......@@ -846,7 +852,7 @@ public class DataHandlerServiceImpl {
eqs.forEach(eq -> {
Optional<ESEquipmentCategoryDto> equInfosWithEs = esEquipmentCategory.findById(eq.getEquId());
equInfosWithEs.ifPresent(equInfoEs -> {
if(StringUtils.isNotEmpty(equInfoEs.getProjectContraptionId())){
if (StringUtils.isNotEmpty(equInfoEs.getProjectContraptionId())) {
IdxBizJgProjectContraption idxBizJgProjectContraption = projectContraptionService.getById(equInfoEs.getProjectContraptionId());
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, equInfoEs.getSEQUENCE_NBR());
......@@ -1050,9 +1056,9 @@ public class DataHandlerServiceImpl {
log.info("1.西安导入数据需补充使用单位代码的设备数量:{}", useInfos.size());
Map<String, String> companynameCodeMap = getCompanyNameCodeMap();
AtomicInteger i = new AtomicInteger();
useInfos.forEach(e->{
useInfos.forEach(e -> {
String companyCode = companynameCodeMap.get(e.getUseUnitName());
if(companyCode != null){
if (companyCode != null) {
i.getAndIncrement();
// 1.数据库更新
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
......@@ -1075,7 +1081,7 @@ public class DataHandlerServiceImpl {
private Map<String, String> getCompanyNameCodeMap() {
List<KeyValueDto> companyList = commonMapper.queryAllCompanyDict();
return companyList.stream().collect(Collectors.toMap(KeyValueDto::getStrKey, KeyValueDto::getStrValue, (k1, k2)->k1));
return companyList.stream().collect(Collectors.toMap(KeyValueDto::getStrKey, KeyValueDto::getStrValue, (k1, k2) -> k1));
}
public void restore() {
......@@ -1087,28 +1093,28 @@ public class DataHandlerServiceImpl {
String useUnitName = null;
String useUnitCreditCode = null;
Date date = null;
if("已完成".equals(status)){
if ("已完成".equals(status)) {
useUnitName = changeRegistrationUnit.getNewUseUnitName();
useUnitCreditCode = changeRegistrationUnit.getNewUseUnitCreditCode();
date = changeRegistrationUnit.getRecDate();
}else {
} else {
useUnitName = changeRegistrationUnit.getUseUnitName();
useUnitCreditCode = changeRegistrationUnit.getUseUnitCreditCode();
date = changeRegistrationUnit.getCreateDate();
}
LambdaQueryWrapper<JgChangeRegistrationUnitEq> unitEqWrapper = new LambdaQueryWrapper<>();
unitEqWrapper.eq(JgChangeRegistrationUnitEq::getUnitChangeRegistrationId,changeRegistrationUnit.getSequenceNbr());
unitEqWrapper.eq(JgChangeRegistrationUnitEq::getUnitChangeRegistrationId, changeRegistrationUnit.getSequenceNbr());
List<JgChangeRegistrationUnitEq> changeRegistrationUnitEqs = jgChangeRegistrationUnitEqService.list(unitEqWrapper);
Map<String, Map<String, Object>> resultMap = new HashMap<>();
for (JgChangeRegistrationUnitEq changeRegistrationUnitEq : changeRegistrationUnitEqs) {
String equipId = changeRegistrationUnitEq.getEquId();
if(StringUtils.isNotEmpty(equipId)){
if (StringUtils.isNotEmpty(equipId)) {
LambdaUpdateWrapper<UseInfo> queryWrapper2 = new LambdaUpdateWrapper<>();
queryWrapper2.set(UseInfo::getUseUnitName,useUnitName);
queryWrapper2.set(UseInfo::getUseUnitCreditCode,useUnitCreditCode);
queryWrapper2.set(UseInfo::getRecDate,date);
queryWrapper2.set(UseInfo::getUseUnitName, useUnitName);
queryWrapper2.set(UseInfo::getUseUnitCreditCode, useUnitCreditCode);
queryWrapper2.set(UseInfo::getRecDate, date);
queryWrapper2.eq(UseInfo::getRecord, equipId);
useInfoMapper.update(null,queryWrapper2);
useInfoMapper.update(null, queryWrapper2);
Map<String, Object> map1 = new HashMap<>();
map1.put("USE_UNIT_CREDIT_CODE", useUnitCreditCode);
map1.put("USE_UNIT_NAME", useUnitName);
......@@ -1128,25 +1134,26 @@ public class DataHandlerServiceImpl {
* 4.移装变更登记--tzs_jg_change_registration_transfer->tzs_jg_registration_history.change_data->>orgBranchCode
* 5.历史有证气瓶导入--tzs_jg_use_registration->supervision_org_code
* 6.历史有证压力管道-管道导入-工业管道--tzs_jg_use_registration->supervision_org_code
*
* @return 成功数量数量
*/
public Long saveSupervise2UseRegManage() {
log.info("存量数据刷属地监管部门到证管理表处理开始--->");
// 1|5|6 预处理,存量数据导入时缺少记录到tzs_jg_use_registration->supervision_org_code,先补充supervision_org_code到tzs_jg_use_registration
List<JgUseRegistrationDto> missingSupOrgCodeUses = useRegistrationService.getBaseMapper().selectMissingSupOrgCodeUseList();
missingSupOrgCodeUses.parallelStream().forEach(u->{
List<JgUseRegistrationDto> missingSupOrgCodeUses = useRegistrationService.getBaseMapper().selectMissingSupOrgCodeUseList();
missingSupOrgCodeUses.parallelStream().forEach(u -> {
// TODO 历史存量数据里有:610422_三原县市场监督管理局,需要转换为:50*73*123_三原县市场监督管理局, null则挂到根节点省上
if(StringUtils.isNotEmpty(u.getSupervisoryCode()) && u.getSupervisoryCode().split("_").length > 1){
if (StringUtils.isNotEmpty(u.getSupervisoryCode()) && u.getSupervisoryCode().split("_").length > 1) {
String[] orgCodeNameArray = u.getSupervisoryCode().split("_");
String orgCodeOrCompanyCode = orgCodeNameArray[0];
LambdaUpdateWrapper<JgUseRegistration> updateWrapper = new LambdaUpdateWrapper<>();
if(orgCodeOrCompanyCode.contains("*") || ROOT_ORG_CODE.equals(orgCodeOrCompanyCode)){
if (orgCodeOrCompanyCode.contains("*") || ROOT_ORG_CODE.equals(orgCodeOrCompanyCode)) {
updateWrapper.set(JgUseRegistration::getSupervisionOrgCode, orgCodeNameArray[0]);
} else {
// 把companyCode换成orgCode
String orgCode = commonMapper.getOrgCodeByCompanyCode(orgCodeOrCompanyCode);
updateWrapper.set(JgUseRegistration::getSupervisionOrgCode, orgCode == null ? ROOT_ORG_CODE: orgCode);
updateWrapper.set(JgUseRegistration::getSupervisionOrgCode, orgCode == null ? ROOT_ORG_CODE : orgCode);
}
updateWrapper.eq(JgUseRegistration::getSequenceNbr, u.getSequenceNbr());
useRegistrationService.update(updateWrapper);
......@@ -1161,38 +1168,38 @@ public class DataHandlerServiceImpl {
// 1|5|6 处理
AtomicReference<Long> dealNum = new AtomicReference<>(0L);
List<JgUseRegistrationDto> useRegistrations = useRegistrationService.getBaseMapper().getListOfPass();
useRegistrations.parallelStream().forEach(u->{
useRegistrations.parallelStream().forEach(u -> {
LambdaUpdateWrapper<JgUseRegistrationManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode,u.getUseRegistrationCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode,u.getSupervisionOrgCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName,u.getSupervisionOrgName());
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode, u.getUseRegistrationCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode, u.getSupervisionOrgCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName, u.getSupervisionOrgName());
dealNum.getAndSet(dealNum.get() + 1);
jgUseRegistrationManageServiceImpl.update(updateWrapper);
});
// 2 处理
List<JgVehicleInformation> vehicleUseRegs = jgVehicleInformationService.getBaseMapper().getListOfPass();
vehicleUseRegs.parallelStream().forEach(u->{
vehicleUseRegs.parallelStream().forEach(u -> {
LambdaUpdateWrapper<JgUseRegistrationManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode,u.getUseRegistrationCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode,u.getOrgBranchCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName,u.getOrgBranchName());
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode, u.getUseRegistrationCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode, u.getOrgBranchCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName, u.getOrgBranchName());
dealNum.getAndSet(dealNum.get() + 1);
jgUseRegistrationManageServiceImpl.update(updateWrapper);
});
// 3 处理
List<JgChangeVehicleRegistrationUnit> vehicleRegistrationUnits = jgChangeVehicleRegistrationUnitMapper.getListOfPass();
vehicleRegistrationUnits.parallelStream().forEach(u->{
vehicleRegistrationUnits.parallelStream().forEach(u -> {
LambdaUpdateWrapper<JgUseRegistrationManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode,u.getUseRegistCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode,u.getOrgBranchCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName,u.getOrgBranchName());
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode, u.getUseRegistCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgCode, u.getOrgBranchCode());
updateWrapper.set(JgUseRegistrationManage::getSuperviseOrgName, u.getOrgBranchName());
dealNum.getAndSet(dealNum.get() + 1);
jgUseRegistrationManageServiceImpl.update(updateWrapper);
});
// 4 处理
List<JgChangeRegistrationTransfer> transfers = jgChangeRegistrationTransferMapper.getListOfPass();
transfers.parallelStream().forEach(u->{
if(StringUtils.isNotEmpty(u.getRemark()) && u.getRemark().split("_").length > 1){
List<JgChangeRegistrationTransfer> transfers = jgChangeRegistrationTransferMapper.getListOfPass();
transfers.parallelStream().forEach(u -> {
if (StringUtils.isNotEmpty(u.getRemark()) && u.getRemark().split("_").length > 1) {
String[] orgCodeNameArray = u.getRemark().split("_");
LambdaUpdateWrapper<JgUseRegistrationManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(JgUseRegistrationManage::getUseRegistrationCode, u.getUseRegistrationCode());
......@@ -1208,6 +1215,7 @@ public class DataHandlerServiceImpl {
/**
* 历史安全追溯问题闭环【维保备案】【检验超期】--问题源都是设备
*
* @return 闭环问题数
*/
public String safeTraceabilityClosedLoop() {
......@@ -1258,13 +1266,125 @@ public class DataHandlerServiceImpl {
public String writeEstateUnitInfoInUseInfo() {
List<Map<String, Object>> vehicleUseRegs = jgVehicleInformationService.getBaseMapper().getVehicleInfoOfPassWithEquId();
vehicleUseRegs.parallelStream().forEach(u->{
vehicleUseRegs.parallelStream().forEach(u -> {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord,u.get("equId"));
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitName,u.get("estateUnitName"));
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitCreditCode,u.get("estateUnitCreditCode"));
updateWrapper.eq(IdxBizJgUseInfo::getRecord, u.get("equId"));
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitName, u.get("estateUnitName"));
updateWrapper.set(IdxBizJgUseInfo::getEstateUnitCreditCode, u.get("estateUnitCreditCode"));
useInfoService.update(updateWrapper);
});
return String.format("修正车用气瓶登记未更新产权信息数据:%s条。", vehicleUseRegs.size());
}
public String initDataQualityScore() {
StopWatch watch = new StopWatch();
watch.start();
long dealEquipNum = 0L;
Integer maxVersion = useInfoService.getBaseMapper().selectMaxVersion();
// 1.非管道数据刷数据质量等级
List<RefreshDataDto> refreshRecords = useInfoService.getBaseMapper().selectUseInfoOfOneVersion(maxVersion);
while (!refreshRecords.isEmpty()) {
dealEquipNum = refreshRecords.size() + dealEquipNum;
List<EquipWaitRefreshDataQualityScore> refreshDataQualityScores = new ArrayList<>();
refreshRecords.forEach(equip -> {
if (CylinderTypeEnum.CYLINDER.getCode().equals(equip.getEquCategory())) { // 气瓶更新逻辑
// 1.已纳管且有使用登记证的刷为:1----3级
if (equip.getIsIntoManagement() && StringUtils.isNotEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 1);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 2.已纳管且无使用登记证的刷为:3----1级
if (equip.getIsIntoManagement() && StringUtils.isEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 3);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 3.未纳管且有使用登记证为空
String whetherVehicleCylinder = StringUtils.isEmpty(equip.getWhetherVehicleCylinder()) ? "0" : equip.getWhetherVehicleCylinder();
// 3.1非车用气瓶逻辑 1
if ((!equip.getIsIntoManagement()) && StringUtils.isNotEmpty(equip.getUseOrgCode()) && "0".equals(whetherVehicleCylinder)) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 1);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 3.2车用气瓶逻辑, 单位内部编号、出场编号全有时刷为1;缺少任意一项时刷为2
if ((!equip.getIsIntoManagement()) && StringUtils.isNotEmpty(equip.getUseOrgCode()) && "1".equals(whetherVehicleCylinder)) {
if (StringUtils.isEmpty(equip.getUseInnerCode()) || StringUtils.isEmpty(equip.getFactoryNum())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 2);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
if (StringUtils.isNotEmpty(equip.getUseInnerCode()) && StringUtils.isNotEmpty(equip.getFactoryNum())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 1);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
}
// 4.未纳管且无使用登记证的刷为:3-1级
if ((!equip.getIsIntoManagement()) && StringUtils.isEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 3);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
} else { // 非气瓶外逻辑
// 1.已纳管且有使用登记证的刷为:1----3级
if (equip.getIsIntoManagement() && StringUtils.isNotEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 1);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 2.已纳管且无使用登记证的刷为:3----1级
if (equip.getIsIntoManagement() && StringUtils.isEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 3);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 3.未纳管且有使用登记证的刷为:1或者2,单位内部编号、出场编号全有时刷为1;缺少任意一项时刷为2
if ((!equip.getIsIntoManagement()) && StringUtils.isNotEmpty(equip.getUseOrgCode()) && (StringUtils.isEmpty(equip.getUseInnerCode()) || StringUtils.isEmpty(equip.getFactoryNum()))) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 2);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
if ((!equip.getIsIntoManagement()) && StringUtils.isNotEmpty(equip.getUseOrgCode()) && StringUtils.isNotEmpty(equip.getUseInnerCode()) && StringUtils.isNotEmpty(equip.getFactoryNum())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 1);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
// 4.未纳管且无使用登记证的刷为:3-1级
if ((!equip.getIsIntoManagement()) && StringUtils.isEmpty(equip.getUseOrgCode())) {
EquipWaitRefreshDataQualityScore waitRefreshDataQualityScore = new EquipWaitRefreshDataQualityScore(equip.getRecord(), 3);
refreshDataQualityScores.add(waitRefreshDataQualityScore);
}
}
});
// es 更新
refreshDataQualityScores.parallelStream().forEach(d -> {
this.updateEsDataQualityScore(d.getRecord(), d.getDataQualityScore());
});
// 数据库更新
if(!refreshDataQualityScores.isEmpty()){
useInfoService.getBaseMapper().updateDataQualityScoreBatch(refreshDataQualityScores, maxVersion + 1);
}
refreshRecords = useInfoService.getBaseMapper().selectUseInfoOfOneVersion(maxVersion);
}
// 2.管道逻辑
List<IdxBizJgProjectContraption> projectContraptionList = projectContraptionService.getBaseMapper().selectList(new LambdaQueryWrapper<IdxBizJgProjectContraption>().isNull(IdxBizJgProjectContraption::getProjectContraptionParentId).select(BaseEntity::getSequenceNbr, IdxBizJgProjectContraption::getUseRegistrationCode));
List<ProjectWaitRefreshDataQualityScore> projectWaitRefreshDataQualityScores = projectContraptionList.stream().map(p->{
ProjectWaitRefreshDataQualityScore projectWaitRefreshDataQualityScore = new ProjectWaitRefreshDataQualityScore();
projectWaitRefreshDataQualityScore.setProjectContraptionId(p.getSequenceNbr());
if(StringUtils.isNotEmpty(p.getUseRegistrationCode())){
projectWaitRefreshDataQualityScore.setDataQualityScore(1);
} else {
projectWaitRefreshDataQualityScore.setDataQualityScore(3);
}
return projectWaitRefreshDataQualityScore;
}).collect(Collectors.toList());
if(!projectWaitRefreshDataQualityScores.isEmpty()){
projectContraptionService.getBaseMapper().updateDataQualityScoreBatch(projectWaitRefreshDataQualityScores );
}
watch.stop();
log.info("耗时秒:{}", watch.getTotalTimeSeconds());
return "success";
}
private void updateEsDataQualityScore(String record, Integer dataQualityScore) {
// 1.es更新
Optional<ESEquipmentCategoryDto> categoryDto = esEquipmentCategory.findById(record);
categoryDto.ifPresent(categoryEs -> {
categoryEs.setDataQualityScore(dataQualityScore);
esEquipmentCategory.save(categoryEs);
});
}
}
package com.yeejoin.amos.boot.module.ymt.api.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class EquipWaitRefreshDataQualityScore {
private String record;
private Integer dataQualityScore;
}
package com.yeejoin.amos.boot.module.ymt.api.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
public class ProjectWaitRefreshDataQualityScore {
private Long projectContraptionId;
private Integer dataQualityScore;
}
package com.yeejoin.amos.boot.module.ymt.api.dto;
import lombok.Data;
@Data
public class RefreshDataDto {
private String record;
private Boolean isIntoManagement;
private String useInnerCode;
private String factoryNum;
private String useOrgCode;
private String equList;
private String equCategory;
private String equDefine;
private String whetherVehicleCylinder;
}
......@@ -305,5 +305,4 @@ public class IdxBizJgProjectContraption extends BaseEntity {
*/
@TableField("data_quality_score")
private String dataQualityScore;
}
......@@ -326,4 +326,11 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData {
*/
@TableField("\"DATA_QUALITY_SCORE\"")
private Integer dataQualityScore;
/**
* 刷库专用字段
*/
@TableField("\"VERSION\"")
private String version;
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ymt.api.dto.ProjectWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import org.apache.ibatis.annotations.Param;
......@@ -110,4 +111,5 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
List<Map<String, Object>> selectPipelineList(@Param("equIds") List<String> equIds);
void updateDataQualityScoreBatch(@Param("projectContraptions") List<ProjectWaitRefreshDataQualityScore> projectContraptions);
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipWaitRefreshDataQualityScore;
import com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
......@@ -15,4 +18,10 @@ public interface IdxBizJgUseInfoMapper extends BaseMapper<IdxBizJgUseInfo> {
void batchUpdateUseInfo(@Param("records") List<String> records, Integer code);
List<IdxBizJgUseInfo> selectXAList();
List<RefreshDataDto> selectUseInfoOfOneVersion(Integer version);
Integer selectMaxVersion();
void updateDataQualityScoreBatch(@Param("equips") List<EquipWaitRefreshDataQualityScore> refreshDataQualityScores, @Param("version") int version);
}
<?xml version="1.0" encoding="UTF-8"?>
<!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.ymt.api.mapper.IdxBizJgProjectContraptionMapper">
<select id="getDetail" resultType="java.util.Map">
SELECT
SEQUENCE_NBR,
......@@ -610,4 +609,10 @@
GROUP BY a.project_contraption_id
) GROUP BY project_contraption_id
</select>
<update id="updateDataQualityScoreBatch">
<foreach collection="projectContraptions" separator=";" item="projectContraption" open="" close="">
UPDATE idx_biz_jg_project_contraption SET data_quality_score = #{projectContraption.dataQualityScore} WHERE sequence_nbr = #{projectContraption.projectContraptionId}
</foreach>
</update>
</mapper>
......@@ -8,6 +8,11 @@
#{record}
</foreach>
</update>
<update id="updateDataQualityScoreBatch">
<foreach collection="equips" separator=";" item="equip" open="" close="">
UPDATE idx_biz_jg_use_info SET "DATA_QUALITY_SCORE" = #{equip.dataQualityScore} , "VERSION"=#{version} WHERE record = #{equip.record}
</foreach>
</update>
<select id="selectXAList" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo">
select
u."SEQUENCE_NBR",
......@@ -23,4 +28,31 @@
)
and u."USE_UNIT_NAME" <![CDATA[ <> ]]> ''
</select>
<select id="selectUseInfoOfOneVersion" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto">
SELECT
ui.record,
ui.is_into_management,
ui.use_inner_code,
fi.factory_num,
jri.use_org_code,
jri.equ_list,
jri.EQU_CATEGORY,
jri.EQU_DEFINE,
jri.WHETHER_VEHICLE_CYLINDER
from
"idx_biz_jg_use_info" ui
LEFT JOIN idx_biz_jg_register_info jri ON jri.RECORD = ui.RECORD
LEFT JOIN idx_biz_jg_factory_info fi on fi."RECORD" = ui."RECORD"
where
jri.EQU_LIST !='8000'
AND (ui.VERSION <![CDATA[ <> ]]> 1 or ui.VERSION is null)
and jri.EQU_CATEGORY <![CDATA[ <> ]]> ''
and ui.is_into_management is not null
limit 10000
</select>
<select id="selectMaxVersion" resultType="java.lang.Integer">
SELECT
COALESCE(MAX(version),0) as version
FROM "idx_biz_jg_use_info"
</select>
</mapper>
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