1.7问题修改-查询分析优化、模板导入变动记录、其他小问题
This commit is contained in:
parent
8ae2f19837
commit
7a7dd75536
@ -7,15 +7,14 @@ import com.xdap.runtime.service.RuntimeAppContextService;
|
|||||||
import com.xdap.self_development.common.MyResponse;
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.common.UserPermissionGetter;
|
import com.xdap.self_development.common.UserPermissionGetter;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
|
import com.xdap.self_development.controller.request.ModelComparisonExportRequest;
|
||||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||||
import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
|
import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,16 +44,29 @@ public class DeleteController {
|
|||||||
private String clientId;
|
private String clientId;
|
||||||
@Value("${apaas.token.clientSecred}")
|
@Value("${apaas.token.clientSecred}")
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
@GetMapping("/getUserId")
|
@GetMapping("/getUserId")
|
||||||
public Response getUserId() {
|
public Response getUserId() {
|
||||||
return Response.ok().data(runtimeAppContextService.getCurrentUserId());
|
return Response.ok().data(runtimeAppContextService.getCurrentUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/timer")
|
@PostMapping("/timer")
|
||||||
public Response timer() {
|
public Response timer(
|
||||||
MyResponse myResponse = timer.dailyCalculate();
|
@RequestBody ModelComparisonExportRequest request
|
||||||
return Response.ok().data(myResponse);
|
) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String modelId : request.getModelIds()) {
|
||||||
|
try {
|
||||||
|
String redisKey = request.getUserID() + ":" + modelId + ":" + "ComparisonExport";
|
||||||
|
String cachedData = redisTemplate.opsForValue().get(redisKey);
|
||||||
|
sb.append(cachedData).append("\n");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除缓存失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.ok().data(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/exportCompare")
|
@PostMapping("/exportCompare")
|
||||||
|
|||||||
@ -29,4 +29,6 @@ public interface TcDataQueryService {
|
|||||||
void modelComparisonExport(ModelComparisonExportRequest request, HttpServletResponse response);
|
void modelComparisonExport(ModelComparisonExportRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
Map<String, List<EngineParamDetailPojo>> tcDataSelectByVersion(AnalysisVerRequest analysisRequest);
|
Map<String, List<EngineParamDetailPojo>> tcDataSelectByVersion(AnalysisVerRequest analysisRequest);
|
||||||
|
|
||||||
|
List<EngineParamDetailPojo> tcDataSelectAllByproductNumberBatch(List<DataEntryEngineModelPojo> engineModelPojos);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -81,7 +82,7 @@ public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParame
|
|||||||
@Override
|
@Override
|
||||||
public AnalysisModelParamterViewAndParam showReport(ReportRequest request) {
|
public AnalysisModelParamterViewAndParam showReport(ReportRequest request) {
|
||||||
|
|
||||||
return showReport1(request);
|
return showReport2(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +156,102 @@ public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParame
|
|||||||
return andParam;
|
return andParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AnalysisModelParamterViewAndParam showReport2(@RequestBody ReportRequest request) {
|
||||||
|
|
||||||
|
// 查询所有符合条件的机型
|
||||||
|
List<DataEntryEngineModelPojo> queryResult = businessDatabase.getBusinessDatabase()
|
||||||
|
.like("model_name", request.getModelName())
|
||||||
|
.like("plate", request.getPlate())
|
||||||
|
.like("platform", request.getPlatform())
|
||||||
|
.like("series", request.getSeries())
|
||||||
|
.like("project_name", request.getProjectName())
|
||||||
|
.like("project_number", request.getProjectNumber())
|
||||||
|
.like("emission", request.getEmission())
|
||||||
|
.like("burn_type", request.getBurnType())
|
||||||
|
.doQuery(DataEntryEngineModelPojo.class);
|
||||||
|
|
||||||
|
// 过滤发动机排量
|
||||||
|
Double engineCapacityMin = request.getEngineCapacityMin();
|
||||||
|
Double engineCapacityMax = request.getEngineCapacityMax();
|
||||||
|
List<DataEntryEngineModelPojo> engineModelPojos = queryResult;
|
||||||
|
if (ObjectUtils.isNotEmpty(engineCapacityMin) && ObjectUtils.isNotEmpty(engineCapacityMax)) {
|
||||||
|
engineModelPojos = queryResult.stream().filter(dataEntryEngineModelPojo -> {
|
||||||
|
String engineCapacity = dataEntryEngineModelPojo.getEngineCapacity();
|
||||||
|
Double ec = extractDisplacement(engineCapacity);
|
||||||
|
if (ec == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (Double.compare(ec, engineCapacityMin) >= 0 && Double.compare(ec, engineCapacityMax) < 0);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engineModelPojos.isEmpty()) {
|
||||||
|
return new AnalysisModelParamterViewAndParam();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查询 EngineParamDetailPojo
|
||||||
|
Set<String> modelIds = engineModelPojos.stream()
|
||||||
|
.map(DataEntryEngineModelPojo::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
List<EngineParamDetailPojo> allEngineParamDetails = businessDatabase.getBusinessDatabase()
|
||||||
|
.in("engine_model_id", modelIds)
|
||||||
|
.doQuery(EngineParamDetailPojo.class);
|
||||||
|
|
||||||
|
// 按 modelId 分组
|
||||||
|
Map<String, List<EngineParamDetailPojo>> engineParamDetailMap = allEngineParamDetails.stream()
|
||||||
|
.collect(Collectors.groupingBy(EngineParamDetailPojo::getEngineModelId));
|
||||||
|
|
||||||
|
// 批量查询 TC 数据
|
||||||
|
List<EngineParamDetailPojo> allTcData = tcDataQueryService.tcDataSelectAllByproductNumberBatch(engineModelPojos);
|
||||||
|
|
||||||
|
// 按 modelId 分组
|
||||||
|
Map<String, List<EngineParamDetailPojo>> tcDataMap = allTcData.stream()
|
||||||
|
.collect(Collectors.groupingBy(EngineParamDetailPojo::getEngineModelId));
|
||||||
|
|
||||||
|
// 构建结果
|
||||||
|
AnalysisModelParamterViewAndParam andParam = new AnalysisModelParamterViewAndParam();
|
||||||
|
List<AnalysisModelParamterView> analysisModelParamterViews = new ArrayList<>();
|
||||||
|
Set<String> allParamNames = new HashSet<>();
|
||||||
|
|
||||||
|
for (DataEntryEngineModelPojo engineModelPojo : engineModelPojos) {
|
||||||
|
AnalysisModelParamterView analysisModelParamterView = new AnalysisModelParamterView();
|
||||||
|
analysisModelParamterView.setModelID(engineModelPojo.getId());
|
||||||
|
analysisModelParamterView.setModelName(engineModelPojo.getModelName());
|
||||||
|
BeanUtils.copyProperties(engineModelPojo, analysisModelParamterView);
|
||||||
|
|
||||||
|
// 获取 EngineParamDetailPojo 列表
|
||||||
|
List<EngineParamDetailPojo> pojoList = engineParamDetailMap.getOrDefault(engineModelPojo.getId(), Collections.emptyList());
|
||||||
|
|
||||||
|
// 过滤版本号
|
||||||
|
Integer versionNumber = engineModelPojo.getVersionNumber();
|
||||||
|
pojoList = pojoList.stream()
|
||||||
|
.filter(x -> x.getMajorVersion() == versionNumber)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 添加 TC 数据
|
||||||
|
List<EngineParamDetailPojo> tcData = tcDataMap.getOrDefault(engineModelPojo.getId(), Collections.emptyList());
|
||||||
|
pojoList.addAll(tcData);
|
||||||
|
|
||||||
|
// 过滤非数字参数值
|
||||||
|
pojoList = pojoList.stream()
|
||||||
|
.filter(x -> ObjectUtils.isNotEmpty(x.getParameterValue()) && isNumber(x.getParameterValue()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
analysisModelParamterView.setPojos(pojoList);
|
||||||
|
analysisModelParamterViews.add(analysisModelParamterView);
|
||||||
|
|
||||||
|
// 收集所有参数名
|
||||||
|
pojoList.stream()
|
||||||
|
.map(EngineParamDetailPojo::getParameterName)
|
||||||
|
.forEach(allParamNames::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
andParam.setParamList(new ArrayList<>(allParamNames));
|
||||||
|
andParam.setPojos(analysisModelParamterViews);
|
||||||
|
return andParam;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证所有数值类型
|
* 验证所有数值类型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -573,7 +573,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
|
|||||||
TodoTaskPojo todoTaskPojo = new TodoTaskPojo();
|
TodoTaskPojo todoTaskPojo = new TodoTaskPojo();
|
||||||
todoTaskPojo.setCreatedById(userID);
|
todoTaskPojo.setCreatedById(userID);
|
||||||
todoTaskPojo.setDocumentNo(UUID.randomUUID().toString());
|
todoTaskPojo.setDocumentNo(UUID.randomUUID().toString());
|
||||||
todoTaskPojo.setProcessTitle("分发填写人");
|
todoTaskPojo.setProcessTitle("填写参数");
|
||||||
todoTaskPojo.setCurrentNode("待维护");
|
todoTaskPojo.setCurrentNode("待维护");
|
||||||
todoTaskPojo.setStatusCode(null);
|
todoTaskPojo.setStatusCode(null);
|
||||||
todoTaskPojo.setModelName(modelPojo.getModelName());
|
todoTaskPojo.setModelName(modelPojo.getModelName());
|
||||||
|
|||||||
@ -529,7 +529,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
|
|||||||
|
|
||||||
// 导出成功后删除Redis中的数据
|
// 导出成功后删除Redis中的数据
|
||||||
// for (String modelId : modelIds) {
|
// for (String modelId : modelIds) {
|
||||||
// String redisKey = userID + ":" + modelId + ":" + "ComparisonExport";
|
// String redisKey = userID + ":" + modelId + ":" + "ComparisonExportComparisonExport";
|
||||||
// redisTemplate.delete(redisKey);
|
// redisTemplate.delete(redisKey);
|
||||||
// log.info("已删除Redis中的数据,KEY: {}", redisKey);
|
// log.info("已删除Redis中的数据,KEY: {}", redisKey);
|
||||||
// }
|
// }
|
||||||
@ -667,6 +667,123 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
|
|||||||
return valueBySubSysName;
|
return valueBySubSysName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EngineParamDetailPojo> tcDataSelectAllByproductNumberBatch(List<DataEntryEngineModelPojo> engineModelPojos) {
|
||||||
|
// 收集所有 productNumber
|
||||||
|
Set<String> productNumbers = engineModelPojos.stream()
|
||||||
|
.map(DataEntryEngineModelPojo::getProductNumber)
|
||||||
|
.filter(ObjectUtils::isNotEmpty)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
if (productNumbers.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 一次性查询所有参数模板 TC 参数数据
|
||||||
|
List<Parameter> parameters = engineParamDetailService.selectAllAndTcByNewVersion();
|
||||||
|
List<Parameter> collect = parameters.stream()
|
||||||
|
.filter(x -> "TC分类表".equals(x.getParameterSource()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (collect.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按 partsName 分组
|
||||||
|
Map<String, List<Parameter>> stringListMap = collect.stream()
|
||||||
|
.collect(Collectors.groupingBy(Parameter::getPartsName));
|
||||||
|
|
||||||
|
Set<String> partsNames = stringListMap.keySet();
|
||||||
|
|
||||||
|
// 一次性查询所有 EnginePartsCollection
|
||||||
|
List<EnginePartsCollection> allPartsCollections = bd.getTCDatabase()
|
||||||
|
.in("ztj", productNumbers)
|
||||||
|
.in("lbjmc", partsNames)
|
||||||
|
.doQuery(EnginePartsCollection.class);
|
||||||
|
|
||||||
|
// 按 productNumber 和 partsName 分组
|
||||||
|
Map<String, Map<String, List<EnginePartsCollection>>> partsCollectionsMap = allPartsCollections.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
EnginePartsCollection::getZtj,
|
||||||
|
Collectors.groupingBy(EnginePartsCollection::getLbjmc)
|
||||||
|
));
|
||||||
|
|
||||||
|
// 收集所有图号
|
||||||
|
Set<String> allLbjths = allPartsCollections.stream()
|
||||||
|
.map(EnginePartsCollection::getLbjth)
|
||||||
|
.filter(ObjectUtils::isNotEmpty)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
if (allLbjths.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 一次性查询所有 ClassificationAttribute
|
||||||
|
List<ClassificationAttribute> allClassifications = bd.getTCDatabase()
|
||||||
|
.in("pitemId", allLbjths)
|
||||||
|
.doQuery(ClassificationAttribute.class);
|
||||||
|
|
||||||
|
// 按 pitemId 分组
|
||||||
|
Map<String, List<ClassificationAttribute>> classificationMap = allClassifications.stream()
|
||||||
|
.collect(Collectors.groupingBy(ClassificationAttribute::getPitemId));
|
||||||
|
|
||||||
|
// 构建结果
|
||||||
|
List<EngineParamDetailPojo> result = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DataEntryEngineModelPojo engineModelPojo : engineModelPojos) {
|
||||||
|
String productNumber = engineModelPojo.getProductNumber();
|
||||||
|
if (ObjectUtils.isEmpty(productNumber)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<EnginePartsCollection>> partsMap = partsCollectionsMap.get(productNumber);
|
||||||
|
if (partsMap == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String partsName : partsNames) {
|
||||||
|
List<Parameter> parameterList = stringListMap.get(partsName);
|
||||||
|
if (parameterList == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> parametersOnPartsName = parameterList.stream()
|
||||||
|
.map(Parameter::getParameterName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<EnginePartsCollection> partsCollections = partsMap.get(partsName);
|
||||||
|
if (partsCollections == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> lbjths = partsCollections.stream()
|
||||||
|
.map(EnginePartsCollection::getLbjth)
|
||||||
|
.filter(ObjectUtils::isNotEmpty)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (String lbjth : lbjths) {
|
||||||
|
List<ClassificationAttribute> classifications = classificationMap.get(lbjth);
|
||||||
|
if (classifications == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClassificationAttribute classificationAttribute : classifications) {
|
||||||
|
if (parametersOnPartsName.contains(classificationAttribute.getIdattrtbutehame())) {
|
||||||
|
EngineParamDetailPojo engineParamDetailPojo = new EngineParamDetailPojo();
|
||||||
|
engineParamDetailPojo.setEngineModelId(engineModelPojo.getId());
|
||||||
|
engineParamDetailPojo.setPartsName(partsName);
|
||||||
|
engineParamDetailPojo.setParameterName(classificationAttribute.getIdattrtbutehame());
|
||||||
|
engineParamDetailPojo.setParameterValue(classificationAttribute.getFieldvalue());
|
||||||
|
result.add(engineParamDetailPojo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|||||||
@ -371,17 +371,19 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
.doUpdate(newParam);
|
.doUpdate(newParam);
|
||||||
|
|
||||||
// 记录修改记录
|
// 记录修改记录
|
||||||
revisionRecords.add(new RevisionRecord(
|
if (!datils.isEmpty()) {
|
||||||
targetTemplate.getTemplateName(),
|
revisionRecords.add(new RevisionRecord(
|
||||||
targetTemplate.getVersion(),
|
targetTemplate.getTemplateName(),
|
||||||
newParam.getParameterNumber(),
|
targetTemplate.getVersion(),
|
||||||
datils,
|
newParam.getParameterNumber(),
|
||||||
targetTemplate.getId(),
|
datils,
|
||||||
existingParam.getId(),
|
targetTemplate.getId(),
|
||||||
Timestamp.valueOf(LocalDateTime.now()),
|
existingParam.getId(),
|
||||||
newParam.getId(),
|
Timestamp.valueOf(LocalDateTime.now()),
|
||||||
targetTemplate.getReturnNum()
|
newParam.getId(),
|
||||||
));
|
targetTemplate.getReturnNum()
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
newParam.setId(null);
|
newParam.setId(null);
|
||||||
bd.getBusinessDatabase().doInsert(newParam);
|
bd.getBusinessDatabase().doInsert(newParam);
|
||||||
|
|||||||
@ -228,7 +228,7 @@ public class TodoTaskServiceImpl implements TodoTaskService {
|
|||||||
TodoTaskPojo todoTaskPojo = new TodoTaskPojo();
|
TodoTaskPojo todoTaskPojo = new TodoTaskPojo();
|
||||||
todoTaskPojo.setCreatedById(userID);
|
todoTaskPojo.setCreatedById(userID);
|
||||||
todoTaskPojo.setDocumentNo(UUID.randomUUID().toString());
|
todoTaskPojo.setDocumentNo(UUID.randomUUID().toString());
|
||||||
todoTaskPojo.setProcessTitle("分发责任人");
|
todoTaskPojo.setProcessTitle("分发参数填写人");
|
||||||
todoTaskPojo.setCurrentNode("待分解");
|
todoTaskPojo.setCurrentNode("待分解");
|
||||||
todoTaskPojo.setCurrentProcessor(JSON.toJSONString(Arrays.asList(engineParamDetailDTO.getResPersonId())));
|
todoTaskPojo.setCurrentProcessor(JSON.toJSONString(Arrays.asList(engineParamDetailDTO.getResPersonId())));
|
||||||
todoTaskPojo.setStatusCode(null/*String.valueOf(ParamValueVersionEnum.DRAFT.getCode())*/);
|
todoTaskPojo.setStatusCode(null/*String.valueOf(ParamValueVersionEnum.DRAFT.getCode())*/);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user