上线版本2.0

This commit is contained in:
zjh 2026-02-03 11:01:50 +08:00
parent d4d5dc2e23
commit 133d7ed6b6
12 changed files with 283 additions and 31 deletions

View File

@ -33,12 +33,13 @@ public class DataEntryEngineModelController {
*
* @param modelId 机型ID
*/
@GetMapping("synchronizeParams")
@GetMapping("/synchronizeParams")
public Response synchronizeParams(
@NotBlank(message = "机型不能为空") String modelId
@NotBlank(message = "机型不能为空") String modelId,
@NotBlank(message = "用户不能为空") String userId
) {
entryEngineModelService.synchronizeParams(modelId);
return Response.ok().setMessage("同步成功");
Integer version = entryEngineModelService.synchronizeParams(modelId, userId);
return Response.ok().setMessage("同步成功").data(version);
}
/**

View File

@ -14,9 +14,9 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 发动机参数详情控制器
@ -51,8 +51,12 @@ public class EngineParamDetailController {
* @return 参数列表和模型映射
*/
@GetMapping("/selectParamListAndModel")
public Response selectParamListAndModel(@RequestParam(value = "modelID"/*, required = false*/) String modelID) {
Map<String, HashMap<String,List<String>>> list = engineParamDetailService.selectParamListAndModel(modelID);
public Response selectParamListAndModel(
@RequestParam(value = "modelID"/*, required = false*/) String modelID,
@RequestParam(required = false) Integer parameterVersion
) {
Map<String, Map<String, Set<String>>> list = engineParamDetailService.selectParamListAndModel(modelID, parameterVersion);
return Response.ok().data(list);
}

View File

@ -30,7 +30,7 @@ public class XdapDeptUsersController {
@NotBlank(message = "用户不能为空") String userId
) {
UserInfoView userInfo = xdapDeptUsersService.getUserInfo(userId);
return Response.ok(userInfo);
return Response.ok().data(userInfo);
}
/**

View File

@ -99,7 +99,7 @@ public class EngineParamDetailPojo {
*/
private String minorVersion;
/**
* 版本状态(0已通过1草稿审核中3已撤回4拒绝)
* 版本状态(0已通过1草稿2审核中3已撤回4拒绝)
*/
private Integer versionStatus;
/**

View File

@ -7,7 +7,6 @@ import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
@ -45,5 +44,5 @@ public interface DataEntryEngineModelService {
void delete(String modelId);
void synchronizeParams(@NotBlank(message = "机型不能为空") String modelId);
Integer synchronizeParams(String modelId, String userId);
}

View File

@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* <p>
@ -53,5 +54,5 @@ public interface EngineParamDetailService {
List<XdapUsers> selectPersonoByType(String subSystem, String dept, Integer type);
Map<String, HashMap<String, List<String>>> selectParamListAndModel(String modelID);
Map<String, Map<String, Set<String>>> selectParamListAndModel(String modelID, Integer parameterVersion);
}

View File

@ -188,6 +188,10 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
.eq("filled_by", userId)
.doQuery(EngineParamDetailPojo.class);
if (paramList.isEmpty()) {
throw new CommonException("没有找到您需要填写的参数");
}
//获取提交人
XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId);
String createBy = ObjectUtils.isNotEmpty(xdapUsers) ? xdapUsers.getUsername() : null;

View File

@ -412,11 +412,138 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ
.doUpdate(DataEntryEngineModelPojo.class);
}
private static EngineParamDetailPojo getEngineParamDetailPojo(ParameterPojo parameter, DataEntryEngineModelPojo model) {
EngineParamDetailPojo detailPojo = new EngineParamDetailPojo();
detailPojo.setEngineModelId(model.getId());
detailPojo.setSubsystemName(parameter.getSubsystemName());
detailPojo.setDepartment(parameter.getDepartment());
detailPojo.setPartsName(parameter.getPartsName());
detailPojo.setParameterId(parameter.getId());
detailPojo.setParameterName(parameter.getParameterName());
detailPojo.setParameterSource(parameter.getParameterSource());
detailPojo.setParameterType(parameter.getParameterType());
detailPojo.setIsDistributedFilled(parameter.getParameterSource().equals("数据平台手工录入") ? 0 : 2);
detailPojo.setIsDistributedRes(parameter.getParameterSource().equals("数据平台手工录入") ? 0 : 2);
detailPojo.setResponsiblePersonId(null);
detailPojo.setFilledBy(null);
detailPojo.setMajorVersion(model.getVersionNumber());
detailPojo.setCreationDate(new Date());
return detailPojo;
}
@Override
public void synchronizeParams(String modelId) {
bd.getBusinessDatabase()
@Transactional
public Integer synchronizeParams(String modelId, String userId) {
// TODO: 同步模板最新参数到机型
// 检查机型
DataEntryEngineModelPojo model = bd.getBusinessDatabase()
.eq("id", modelId)
.doQueryFirst(DataEntryEngineModelPojo.class);
if (model == null) {
throw new CommonException("机型不存在或已分发");
}
// 找到最新版本模板的参数
List<TemplatePojo> templates = bd.getBusinessDatabase()
.eq("status", "COMPLETE")
.doQuery(TemplatePojo.class);
if (templates.isEmpty()) {
throw new CommonException("没有找到完成状态的模板");
}
List<String> templateIds = templates.stream().map(TemplatePojo::getId).collect(Collectors.toList());
List<TemplateAndParameterPojo> templateAndParameters = bd.getBusinessDatabase()
.in("template_id", templateIds)
.doQuery(TemplateAndParameterPojo.class);
if (templateAndParameters.isEmpty()) {
throw new CommonException("没有找到模板对应的参数");
}
List<String> parameterIds = templateAndParameters.stream().map(TemplateAndParameterPojo::getParameterId).collect(Collectors.toList());
List<ParameterPojo> parameters = bd.getBusinessDatabase()
.in("id", parameterIds)
.doQuery(ParameterPojo.class);
if (parameters.isEmpty()) {
throw new CommonException("没有找到参数");
}
// 检查当前版本机型是否有参数正在审批中
List<EngineParamDetailPojo> paramsInApproval = bd.getBusinessDatabase()
.eq("engine_model_id", modelId)
.eq("major_version", model.getVersionNumber())
.eq("version_status", ParamValueVersionEnum.UNDER.getCode())
.doQuery(EngineParamDetailPojo.class);
if (!paramsInApproval.isEmpty()) {
throw new CommonException("当前版本机型有参数正在审批中,请等待审批完成");
}
// 获取当前机型版本对应的所有参数
List<EngineParamDetailPojo> modelParams = bd.getBusinessDatabase()
.eq("engine_model_id", model.getId())
.eq("major_version", model.getVersionNumber())
.doQuery(EngineParamDetailPojo.class);
List<String> modelParamIds = modelParams.stream()
.map(EngineParamDetailPojo::getParameterId)
.collect(Collectors.toList());
Map<String, EngineParamDetailPojo> modelParamMap = modelParams.stream()
.collect(Collectors.
toMap(EngineParamDetailPojo::getParameterId, pojo -> pojo)
);
// 过滤新批次模板的参数更新到机型参数中
// 统计需要插入的参数
List<EngineParamDetailPojo> toInsertParams = new ArrayList<>();
// 更新机型版本
model.setVersionNumber(model.getVersionNumber() + 1);
parameters.forEach(parameter -> {
// 检查老机型参数中是否存在新版本参数
// 存在则更新
if (modelParamIds.contains(parameter.getId())) {
// 拿到老参数
EngineParamDetailPojo detailPojo = modelParamMap.get(parameter.getId());
detailPojo.setId(null);
detailPojo.setSubsystemName(parameter.getSubsystemName());
detailPojo.setDepartment(parameter.getDepartment());
detailPojo.setPartsName(parameter.getPartsName());
detailPojo.setParameterName(parameter.getParameterName());
detailPojo.setParameterSource(parameter.getParameterSource());
detailPojo.setParameterType(parameter.getParameterType());
detailPojo.setIsDistributedFilled(parameter.getParameterSource().equals("数据平台手工录入") ? 0 : 2);
detailPojo.setIsDistributedRes(parameter.getParameterSource().equals("数据平台手工录入") ? 0 : 2);
detailPojo.setResponsiblePersonId(null);
detailPojo.setFilledBy(null);
detailPojo.setMajorVersion(model.getVersionNumber());
toInsertParams.add(detailPojo);
}
// 不存在则新增
else {
toInsertParams.add(getEngineParamDetailPojo(parameter, model));
}
});
// 更新机型
bd.getBusinessDatabase()
.eq("id", model.getId())
.update("version_number", model.getVersionNumber())
.update("distribute_status", DistributeStatusEnum.UNDISTRIBUTED.getCode())
.doUpdate(DataEntryEngineModelPojo.class);
// 更新新版本机型的参数
bd.getBusinessDatabase().doBatchInsert(toInsertParams);
// 更新待办已办完成状态
bd.getBusinessDatabase()
.update("is_delete", 1)
.eq("model_id", model.getId())
.doUpdate(TodoTaskPojo.class);
bd.getBusinessDatabase()
.update("is_delete", 1)
.eq("model_id", model.getId())
.doUpdate(InitiatedTaskPojo.class);
bd.getBusinessDatabase()
.update("is_delete", 1)
.eq("model_id", model.getId())
.doUpdate(CompletedTaskPojo.class);
return model.getVersionNumber();
}
/**

View File

@ -39,6 +39,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -175,6 +176,109 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
));
}
public Map<String, Set<String>> selectParamListByDetails(String modelID, Integer parameterVersion) {
if (parameterVersion == null) {
DataEntryEngineModelPojo engineModel = bd.getBusinessDatabase()
.eq("engine_model_id", modelID)
.doQueryFirst(DataEntryEngineModelPojo.class);
if (engineModel == null) {
throw new CommonException("未找到该型号的参数");
}
parameterVersion = engineModel.getVersionNumber();
}
List<EngineParamDetailPojo> pojoList = bd.getBusinessDatabase()
.eq("engine_model_id", modelID)
.eq("major_version", parameterVersion)
.eq("parameter_source", "数据平台手工录入")
.doQuery(EngineParamDetailPojo.class);
AtomicInteger seq = new AtomicInteger(1);
LinkedHashMap<String, Integer> subsystemOrderMap = pojoList.stream()
.sorted(Comparator
.comparing(EngineParamDetailPojo::getSubsystemName, Collator.getInstance(Locale.CHINA))
.thenComparing(EngineParamDetailPojo::getParameterName, Collator.getInstance(Locale.CHINA))
)
.map(EngineParamDetailPojo::getSubsystemName)
.distinct()
.collect(Collectors.toMap(
s -> s,
s -> seq.getAndIncrement(), // 每次获取当前值再自增从1开始
(o, n) -> o,
LinkedHashMap::new
));
Map<String, Set<String>> collect = pojoList.stream()
.collect(Collectors.groupingBy(
EngineParamDetailPojo::getSubsystemName,
Collectors.mapping(
EngineParamDetailPojo::getPartsName, // 提取 零部件名称字段
Collectors.toSet()
)
));
if (ObjectUtils.isNotEmpty(modelID)) {
subsystemOrderMap.put("整车参数", 0);
DataEntryEngineModelPojo dataEntryEngineModelPojo = bd.getBusinessDatabase()
.eq("id", modelID)
.doQueryFirst(DataEntryEngineModelPojo.class);
//状态代号
String productNumber = dataEntryEngineModelPojo.getProductNumber();
//板块
String plate = dataEntryEngineModelPojo.getPlate();
//平台
String platform = dataEntryEngineModelPojo.getPlatform();
//系列
String series = dataEntryEngineModelPojo.getSeries();
//细分市场
String marketSegment = dataEntryEngineModelPojo.getMarketSegment();
//项目名称
String projectName = dataEntryEngineModelPojo.getProjectName();
//项目编号
String projectNumber = dataEntryEngineModelPojo.getProjectNumber();
//品牌
String brand = dataEntryEngineModelPojo.getBrand();
//排放
String emission = dataEntryEngineModelPojo.getEmission();
String burnType = dataEntryEngineModelPojo.getBurnType();
String engineCapacity = dataEntryEngineModelPojo.getEngineCapacity();
Date productionDate = dataEntryEngineModelPojo.getProductionDate();
String manufacturerName = dataEntryEngineModelPojo.getManufacturerName();
String manufacturerAbbreviation = dataEntryEngineModelPojo.getManufacturerAbbreviation();
Set<String> strings = new HashSet<>();
if (dataEntryEngineModelPojo.getYcOrOth().equals("玉柴")) {
strings.add("状态代号:" + productNumber);
} else {
strings.add("产品编号:" + productNumber);
strings.add("品牌:" + brand);
strings.add("厂家全称:" + manufacturerName);
strings.add("厂家简称:" + manufacturerAbbreviation);
strings.add("生产日期:" + new SimpleDateFormat("yyyy-MM-dd").format(productionDate));
}
strings.add("产品型号:" + dataEntryEngineModelPojo.getModelName());
strings.add("板块:" + plate);
strings.add("平台:" + platform);
strings.add("系列:" + series);
strings.add("细分市场:" + marketSegment);
strings.add("项目名称:" + projectName);
strings.add("项目编号:" + projectNumber);
strings.add("排放:" + emission);
strings.add("燃烧类型:" + burnType);
strings.add("排量:" + engineCapacity);
collect.put("整车参数", strings);
}
// 保持顺序
return collect.entrySet().stream()
.sorted(Comparator.comparing(entry ->
subsystemOrderMap.getOrDefault(entry.getKey(), Integer.MAX_VALUE)
))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(oldValue, newValue) -> oldValue,
LinkedHashMap::new // 保持顺序
));
}
/**
* 查询参数列表和模型
* 根据模型ID获取参数列表和模型信息
@ -183,11 +287,14 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
* @return 参数列表和模型映射
*/
@Override
public Map<String, HashMap<String, List<String>>> selectParamListAndModel(String modelID) {
HashMap<String, HashMap<String, List<String>>> map = new HashMap<>();
public Map<String, Map<String, Set<String>>> selectParamListAndModel(String modelID, Integer parameterVersion) {
HashMap<String, Map<String, Set<String>>> map = new HashMap<>();
DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(modelID);
if (ObjectUtils.isEmpty(dataEntryEngineModelPojo)) {
throw new CommonException("未找到该机型");
}
String s = dataEntryEngineModelPojo.getProductNumber();
HashMap<String, List<String>> stringListMap = selectParamList(modelID,null);
Map<String, Set<String>> stringListMap = selectParamListByDetails(modelID, parameterVersion);
map.put(s, stringListMap);
return map;
}
@ -451,6 +558,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
*/
@Override
public void updateParamValue(List<EngineParamDetailPojo> engineParamDetailPojos, String currentUserId) {
// TODO:修改参数值
// 获取欲更新参数列表
List<String> detailIds = engineParamDetailPojos.stream()
.map(EngineParamDetailPojo::getId)
@ -459,6 +567,16 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
.in("id", detailIds)
.doQuery(EngineParamDetailPojo.class);
// 检查修改的参数是否都在审核中
EngineParamDetailPojo unEditParam = bd.getBusinessDatabase()
.in("id", detailIds)
.eq("version_status", ParamValueVersionEnum.UNDER.getCode())
.doQueryFirst(EngineParamDetailPojo.class);
if (ObjectUtils.isNotEmpty(unEditParam)) {
throw new CommonException("您修改参数中有正在审批中的,请在审批通过后再修改");
}
// 转换参数详情为map
Map<String, EngineParamDetailPojo> detailMap = details.stream()
.collect(Collectors.toMap(EngineParamDetailPojo::getId, pojo -> pojo));
@ -467,14 +585,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
for (EngineParamDetailPojo requestDetail : engineParamDetailPojos) {
EngineParamDetailPojo detail = detailMap.get(requestDetail.getId());
//查找参数是否已经在审批中
if (ObjectUtils.isNotEmpty(detail)
&& Objects.equals(ParamValueVersionEnum.UNDER.getCode(), detail.getVersionStatus())
) {
throw new CommonException("您修改参数中有正在审批中的,请查看审批流审批后再修改,零部件+参数名称:" +
requestDetail.getPartsName() + "-" + requestDetail.getParameterName());
}
//通过操作状态对应不同操作新增和更新都新增数据为小版本且为草稿状态
if (requestDetail.getOperation().equals(String.valueOf(ParamOperationEnum.UPDATE))) {
bd.getBusinessDatabase()

View File

@ -3,6 +3,7 @@ package com.xdap.self_development.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xdap.motor.utils.StringUtils;
import com.xdap.self_development.common.BusinessDatabase;
@ -396,6 +397,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
// 使用EasyExcel写入
try (OutputStream outputStream = response.getOutputStream()) {
EasyExcel.write(outputStream)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.sheet("机型参数对比")
.head(getCustomHeader(models, modelNames)) // 自定义表头
.doWrite(excelData);
@ -731,7 +733,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
}
DataEntryEngineModelPojo tempModel = engineModelService.selectBymodelId(model.getModelId());
if (tempModel != null) {
modelNames.put(model.getModelId(), tempModel.getModelName());
modelNames.put(model.getModelId() + "-V" + model.getParameterVersion(), tempModel.getModelName() + "-V" + model.getParameterVersion());
}
}
return modelNames;
@ -766,7 +768,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
List<EngineParamDetailPojo> allPojos = objectMapper.readValue(cachedData,
objectMapper.getTypeFactory().constructCollectionType(List.class, EngineParamDetailPojo.class));
// 筛选数据优化抽取为独立方法
// 筛选数据
List<EngineParamDetailPojo> filteredPojos = filterEngineParams(allPojos, subsystemParts, request);
// 处理筛选后的数据
@ -824,7 +826,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
String paramName = pojo.getParameterName();
String paramValue = pojo.getParameterValue() == null ? "" : pojo.getParameterValue();
parameterValues.computeIfAbsent(paramName, k -> new HashMap<>()).put(modelId, paramValue);
parameterValues.computeIfAbsent(paramName, k -> new HashMap<>()).put(modelId + "-" + pojo.getMajorVersion(), paramValue);
// 只在首次添加时存储子系统和零部件信息
parameterSubsystemParts.computeIfAbsent(paramName, k -> new String[]{
@ -856,7 +858,8 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
Map<String, String> values = entry.getValue();
for (ModelItem model : models) {
String modelId = model != null ? model.getModelId() : "";
row.add(values.getOrDefault(modelId, ""));
String paramVersion = model != null ? model.getParameterVersion() : "";
row.add(values.getOrDefault(modelId + "-" + paramVersion, ""));
}
excelData.add(row);
@ -874,7 +877,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
// 动态添加机型表头
for (ModelItem model : models) {
String modelName = model == null ? "未知机型" : modelNames.getOrDefault(model.getModelId(), "未知机型");
String modelName = model == null ? "未知机型" : modelNames.getOrDefault(model.getModelId() + "-V" + model.getParameterVersion(), "未知机型");
header.add(Collections.singletonList(modelName));
}
return header;

View File

@ -344,7 +344,6 @@ public class TodoTaskServiceImpl implements TodoTaskService {
@Override
public void rejectTodo(RejectTodoRequest request) {
// TODO拒绝分发
TodoTaskPojo todoTaskPojo = bd.getBusinessDatabase()
.eq("id", request.getTodoId())
.doQueryFirst(TodoTaskPojo.class);

View File

@ -133,6 +133,7 @@ public class YcTaskResultServiceImpl implements YcTaskResultService {
List<CompletedTaskPojo> completedTaskPojos = new ArrayList<>();
if (ObjectUtils.isEmpty(ycGetTodoTaskRequest.getUsername())) {
List<CompletedTaskPojo> list = bd.getBusinessDatabase()
.eq("is_delete", 0)
.gteq("creation_date", ycGetTodoTaskRequest.getCreateDateStart())
.lteq("creation_date", ycGetTodoTaskRequest.getCreateDateEnd() == null ? new Date() : ycGetTodoTaskRequest.getCreateDateEnd())
.doQuery(CompletedTaskPojo.class);
@ -147,6 +148,7 @@ public class YcTaskResultServiceImpl implements YcTaskResultService {
Date createDateEnd = safeParseDateParam(ycGetTodoTaskRequest.getCreateDateEnd(), new Date());
List<CompletedTaskPojo> result = bd.getBusinessDatabase()
.eq("owner_id", user.getId())
.eq("is_delete", 0)
.gteq("creation_date", ycGetTodoTaskRequest.getCreateDateStart())
.lteq("creation_date", createDateEnd)
.doQuery(CompletedTaskPojo.class);
@ -207,6 +209,7 @@ public class YcTaskResultServiceImpl implements YcTaskResultService {
long total = 0;
if (ObjectUtils.isEmpty(ycGetTodoTaskRequest.getUsername())) {
List<InitiatedTaskPojo> list = bd.getBusinessDatabase()
.eq("is_delete", 0)
.gteq("creation_date", ycGetTodoTaskRequest.getCreateDateStart())
.lteq("creation_date", ycGetTodoTaskRequest.getCreateDateEnd() == null ? new Date() : ycGetTodoTaskRequest.getCreateDateEnd())
.doQuery(InitiatedTaskPojo.class);
@ -224,6 +227,7 @@ public class YcTaskResultServiceImpl implements YcTaskResultService {
Date createDateEnd = safeParseDateParam(ycGetTodoTaskRequest.getCreateDateEnd(), new Date());
PageQueryResult<InitiatedTaskPojo> result = bd.getBusinessDatabase()
.eq("created_by_id", user.getId())
.eq("is_delete", 0)
.gteq("creation_date", ycGetTodoTaskRequest.getCreateDateStart())
.lteq("creation_date", createDateEnd)
.doPageQuery(page, pageSize, InitiatedTaskPojo.class);