放开参数来源限制

This commit is contained in:
zjh 2026-04-28 15:50:16 +08:00
parent 783737a2f9
commit ea263b7681
4 changed files with 63 additions and 41 deletions

View File

@ -1,12 +1,9 @@
package com.xdap.self_development.job; package com.xdap.self_development.job;
import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.common.BusinessDatabase;
import com.xdap.self_development.domain.pojo.ClassificationAttributePojo;
import com.xdap.self_development.domain.pojo.EnginePartsCollectionPojo;
import com.xdap.self_development.domain.view.CalculationParameterView; import com.xdap.self_development.domain.view.CalculationParameterView;
import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.CommonException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -58,7 +55,7 @@ public class ParameterValueCalculationTimer {
} }
// 每天凌晨执行一次 // 每天凌晨执行一次
@Scheduled(cron = "0 0 0 * * ?") // @Scheduled(cron = "0 0 0 * * ?")
@Transactional @Transactional
public void dailyCalculate() { public void dailyCalculate() {
@ -91,39 +88,39 @@ public class ParameterValueCalculationTimer {
} }
// 2.从中台更新参数值 // 2.从中台更新参数值
for (CalculationParameterView parameter : parameterValues) { // for (CalculationParameterView parameter : parameterValues) {
if (Objects.equals(parameter.getParameterSource(), "TC分类表")) { // if (Objects.equals(parameter.getParameterSource(), "TC分类表")) {
tcParameters++; // tcParameters++;
try { // try {
EnginePartsCollectionPojo enginePartsCollection = bd.getBusinessDatabase() // EnginePartsCollectionPojo enginePartsCollection = bd.getTCDatabase()
.eq("ztj", parameter.getProductNumber()) // .eq("ztj", parameter.getProductNumber())
.eq("lbjmc", parameter.getPartsName()) // .eq("lbjmc", parameter.getPartsName())
.doQueryFirst(EnginePartsCollectionPojo.class); // .doQueryFirst(EnginePartsCollectionPojo.class);
if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) { // if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) {
log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应零部件零部件名{}", // log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应零部件零部件名{}",
parameter.getProductNumber(), parameter.getParameterName(), parameter.getPartsName()); // parameter.getProductNumber(), parameter.getParameterName(), parameter.getPartsName());
failedToUpdateFromTC++; // failedToUpdateFromTC++;
continue; // continue;
} // }
ClassificationAttributePojo classificationAttribute = bd.getBusinessDatabase() // ClassificationAttributePojo classificationAttribute = bd.getTCDatabase()
.eq("pitemId", enginePartsCollection.getLbjth()) // .eq("pitemId", enginePartsCollection.getLbjth())
.eq("idattrtbutehame", parameter.getParameterName()) // .eq("idattrtbutehame", parameter.getParameterName())
.doQueryFirst(ClassificationAttributePojo.class); // .doQueryFirst(ClassificationAttributePojo.class);
if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) { // if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) {
String originalValue = parameter.getParameterValue(); // String originalValue = parameter.getParameterValue();
parameter.setParameterValue(classificationAttribute.getFieldvalue()); // parameter.setParameterValue(classificationAttribute.getFieldvalue());
log.debug("机型【{}】的参数【{}】从中台更新值:{} -> {}",parameter.getProductNumber(), parameter.getParameterName(), originalValue, classificationAttribute.getFieldvalue()); // log.debug("机型【{}】的参数【{}】从中台更新值:{} -> {}",parameter.getProductNumber(), parameter.getParameterName(), originalValue, classificationAttribute.getFieldvalue());
updatedFromTC++; // updatedFromTC++;
} else { // } else {
log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应值",parameter.getProductNumber(), parameter.getParameterName()); // log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应值",parameter.getProductNumber(), parameter.getParameterName());
failedToUpdateFromTC++; // failedToUpdateFromTC++;
} // }
} catch (Exception e) { // } catch (Exception e) {
log.error("机型【{}】的参数【{}】从中台更新值失败:{}",parameter.getProductNumber(), parameter.getParameterName(), e.getMessage(), e); // log.error("机型【{}】的参数【{}】从中台更新值失败:{}",parameter.getProductNumber(), parameter.getParameterName(), e.getMessage(), e);
failedToUpdateFromTC++; // failedToUpdateFromTC++;
} // }
} // }
} // }
log.info("从中台更新参数完成,共处理{}个TC参数成功{}个,失败{}个", tcParameters, updatedFromTC, failedToUpdateFromTC); log.info("从中台更新参数完成,共处理{}个TC参数成功{}个,失败{}个", tcParameters, updatedFromTC, failedToUpdateFromTC);

View File

@ -25,4 +25,6 @@ public interface TcDataQueryService {
Map<String, List<EngineParamDetailPojo>> tcDataSelectByVersion(AnalysisVerRequest analysisRequest); Map<String, List<EngineParamDetailPojo>> tcDataSelectByVersion(AnalysisVerRequest analysisRequest);
List<EngineParamDetailPojo> tcDataSelectAllByproductNumberBatch(List<DataEntryEngineModelPojo> engineModelPojos); List<EngineParamDetailPojo> tcDataSelectAllByproductNumberBatch(List<DataEntryEngineModelPojo> engineModelPojos);
List<EngineParamDetailPojo> selectTCFromDB(String modelId, List<String> subsystemParts);
} }

View File

@ -307,7 +307,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
List<EngineParamDetailPojo> pojoList = bd.getBusinessDatabase() List<EngineParamDetailPojo> pojoList = bd.getBusinessDatabase()
.eq("engine_model_id", modelID) .eq("engine_model_id", modelID)
.eq("major_version", parameterVersion) .eq("major_version", parameterVersion)
.eq("parameter_source", "数据平台手工录入")
.doQuery(EngineParamDetailPojo.class); .doQuery(EngineParamDetailPojo.class);
if (userId == null || userId.isEmpty()) { if (userId == null || userId.isEmpty()) {
return pojoList; return pojoList;
@ -529,8 +528,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
MpaasQuery query = bd.getBusinessDatabase() MpaasQuery query = bd.getBusinessDatabase()
.eq("engine_model_id", model.getId()) .eq("engine_model_id", model.getId())
.in("subsystem_name", subsystemSet) .in("subsystem_name", subsystemSet)
.in("parts_name", typeSet) .in("parts_name", typeSet);
.eq("parameter_source", "数据平台手工录入");
//若传入填写人则查询填写人需要填写的参数 //若传入填写人则查询填写人需要填写的参数
if (ObjectUtils.isNotEmpty(request.getFilledById())) { if (ObjectUtils.isNotEmpty(request.getFilledById())) {
@ -556,7 +554,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
.eq("engine_model_id", model.getId()) .eq("engine_model_id", model.getId())
.in("subsystem_name", subsystemSet) .in("subsystem_name", subsystemSet)
.in("parts_name", typeSet) .in("parts_name", typeSet)
.eq("parameter_source", "数据平台手工录入")
.eq("filled_by", request.getFilledById()) .eq("filled_by", request.getFilledById())
.eq("major_version", model.getVersionNumber()) .eq("major_version", model.getVersionNumber())
.doQuery(EngineParamDetailPojo.class) .doQuery(EngineParamDetailPojo.class)

View File

@ -700,6 +700,32 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
return result; return result;
} }
@Override
public List<EngineParamDetailPojo> selectTCFromDB(String modelId, List<String> subsystemParts) {
DataEntryEngineModelPojo model = engineModelService.selectBymodelId(modelId);
if (model == null) {
throw new CommonException("查询失败:机型不存在");
}
Set<String> subsystemSet = new HashSet<>();
Set<String> partsNameSet = new HashSet<>();
subsystemParts.forEach(subsystemType -> {
if (subsystemType.split("-").length != 2) {
throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/”");
}
String subsystem = subsystemType.split("-")[0];
String partsName = subsystemType.split("-")[1];
subsystemSet.add(subsystem);
partsNameSet.add(partsName);
});
return bd.getBusinessDatabase()
.eq("engine_model_id", model.getId())
.in("subsystem_name", subsystemSet)
.in("parts_name", partsNameSet)
.doQuery(EngineParamDetailPojo.class);
}
private void setupResponse(HttpServletResponse response, String fileName) throws IOException { private void setupResponse(HttpServletResponse response, String fileName) throws IOException {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");