Merge remote-tracking branch 'origin/master'

This commit is contained in:
ys.git 2025-12-19 15:14:20 +08:00
commit cef63e5d10
8 changed files with 54 additions and 44 deletions

View File

@ -0,0 +1,13 @@
package com.xdap.self_development.common;
import lombok.Data;
import java.util.List;
@Data
public class MyPageResult<T> {
private Long count;
private List<T> result;
private String status;
}

View File

@ -1,8 +1,7 @@
package com.xdap.self_development.controller; package com.xdap.self_development.controller;
import com.definesys.mpaas.common.http.Response; import com.definesys.mpaas.common.http.Response;
import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.self_development.common.MyPageResult;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.controller.form.ParameterPageForm; import com.xdap.self_development.controller.form.ParameterPageForm;
import com.xdap.self_development.controller.form.UpdateParameterForm; import com.xdap.self_development.controller.form.UpdateParameterForm;
import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.CommonException;
@ -32,7 +31,7 @@ public class ParameterController {
throw new CommonException(error.getDefaultMessage()); throw new CommonException(error.getDefaultMessage());
}); });
} }
PageQueryResult<Parameter> list = parameterService.getParameterByCondition(form); MyPageResult<Parameter> list = parameterService.getParameterByCondition(form);
return Response.ok().data(list); return Response.ok().data(list);
} }

View File

@ -1,10 +1,8 @@
package com.xdap.self_development.listener; package com.xdap.self_development.listener;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.metadata.data.ReadCellData; import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.common.MyResponse;
import com.xdap.self_development.pojo.Parameter; import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.service.TemplateService; import com.xdap.self_development.service.TemplateService;
@ -61,22 +59,10 @@ public class SheetDataListener implements ReadListener<Parameter> {
@Override @Override
public void invoke(Parameter data, AnalysisContext context) { public void invoke(Parameter data, AnalysisContext context) {
// 如果sheet无效直接返回不处理数据 // 如果sheet无效直接返回不处理数据
// if (!validSheet) { // if (!validSheet) {
// return; // return;
// } // }
if (data.getSubsystemName() == null) {
problems.setFlag(true);
problems.getErrors().add("模板导入失败:"+currentSheetName +"模板的参数"+data.getParameterName()+"的子系统字段为空");
}
if (data.getPartsName() == null || data.getPartsName().isEmpty()) {
data.setPartsName("/");
}
if (currentSheetName == null) { if (currentSheetName == null) {
currentSheetName = context.readSheetHolder().getSheetName(); currentSheetName = context.readSheetHolder().getSheetName();
} }

View File

@ -10,11 +10,11 @@ import lombok.NoArgsConstructor;
import java.sql.Timestamp; import java.sql.Timestamp;
@SQLQuery(value = { @SQLQuery(value = {
@SQL(view = "getMaxOrder", @SQL(view = "getLatestTemplateOrder",
sql = "SELECT order_num as maxOrder FROM yfsjglpt_model_template ORDER BY order_num desc"), sql = "SELECT ranked.order_num, ranked.id, ranked.template_name, ranked.version, ranked.status, ranked.created_time , ranked.published_time, xu.username AS 'createBy' FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'APPROVING' THEN 2 ELSE 3 END, version DESC) AS rn FROM yfsjglpt_model_template t WHERE status IN ('COMPLETE', 'DRAFT', 'APPROVING') ) ranked LEFT JOIN xdap_users xu ON xu.id = ranked.create_by WHERE rn = 1 ORDER BY CASE status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num desc"),
// 查找每个模板的最新版本并且优先级按照已发布审核中草稿状态转变只有这三种状态 // 查找每个模板的最新版本并且优先级按照已发布审核中草稿状态转变只有这三种状态
@SQL(view = "getLatestTemplate", @SQL(view = "getLatestTemplate",
sql = "SELECT ranked.order_num, ranked.id, ranked.template_name, ranked.version, ranked.status, ranked.created_time , ranked.published_time, xu.username AS 'createBy' FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'APPROVING' THEN 2 ELSE 3 END, version DESC) AS rn FROM yfsjglpt_model_template t WHERE status IN ('COMPLETE', 'DRAFT', 'APPROVING') ) ranked LEFT JOIN xdap_users xu ON xu.id = ranked.create_by WHERE rn = 1 ORDER BY CASE status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num desc" sql = "SELECT ROW_NUMBER() OVER (ORDER BY CASE ranked.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num DESC) AS order_num, ranked.id, ranked.template_name, ranked.version , ranked.status, ranked.created_time, ranked.published_time, xu.username AS \"createBy\" FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'APPROVING' THEN 2 ELSE 3 END, version DESC) AS rn FROM yfsjglpt_model_template t WHERE status IN ('COMPLETE', 'DRAFT', 'APPROVING') ) ranked LEFT JOIN xdap_users xu ON xu.id = ranked.create_by WHERE rn = 1 ORDER BY CASE ranked.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num DESC"
), ),
// 获取所有模板的最新版本号包括所有状态 // 获取所有模板的最新版本号包括所有状态
@SQL(view = "getNewTemplate", @SQL(view = "getNewTemplate",

View File

@ -1,6 +1,6 @@
package com.xdap.self_development.service; package com.xdap.self_development.service;
import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.self_development.common.MyPageResult;
import com.xdap.self_development.controller.form.ParameterPageForm; import com.xdap.self_development.controller.form.ParameterPageForm;
import com.xdap.self_development.controller.form.UpdateParameterForm; import com.xdap.self_development.controller.form.UpdateParameterForm;
import com.xdap.self_development.pojo.Parameter; import com.xdap.self_development.pojo.Parameter;
@ -10,7 +10,7 @@ import com.xdap.self_development.pojo.view.TemplateInfoView;
import java.util.List; import java.util.List;
public interface ParameterService { public interface ParameterService {
PageQueryResult<Parameter> getParameterByCondition(ParameterPageForm form); MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form);
TemplateInfoView maintenanceParameters(UpdateParameterForm form); TemplateInfoView maintenanceParameters(UpdateParameterForm form);

View File

@ -105,6 +105,9 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
// List<TodoAndReportView> approvalList = new ArrayList<>(); // List<TodoAndReportView> approvalList = new ArrayList<>();
// Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy()))); // Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy())));
// List<String> ids = new ArrayList<>(flowIds); // List<String> ids = new ArrayList<>(flowIds);
if (form.getSysParts() == null) {
form.setSysParts("");
}
PageQueryResult<TodoAndReportView> result = bd.getBusinessDatabase() PageQueryResult<TodoAndReportView> result = bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("getAllReportApproval") .view("getAllReportApproval")

View File

@ -1,9 +1,7 @@
package com.xdap.self_development.service.impl; package com.xdap.self_development.service.impl;
import com.definesys.mpaas.query.db.PageQueryResult; import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.api.moudle.user.vo.LoginUserVo; import com.xdap.self_development.common.MyPageResult;
import com.xdap.runtime.service.RuntimeAppContextService;
import com.xdap.runtime.service.RuntimeUserService;
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.form.ParameterForm; import com.xdap.self_development.controller.form.ParameterForm;
@ -14,10 +12,8 @@ import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.RevisionRecord; import com.xdap.self_development.pojo.RevisionRecord;
import com.xdap.self_development.pojo.Template; import com.xdap.self_development.pojo.Template;
import com.xdap.self_development.pojo.TemplateAndParameter; import com.xdap.self_development.pojo.TemplateAndParameter;
import com.xdap.self_development.pojo.view.MenuParamView;
import com.xdap.self_development.pojo.view.ParametersView; import com.xdap.self_development.pojo.view.ParametersView;
import com.xdap.self_development.pojo.view.TemplateInfoView; import com.xdap.self_development.pojo.view.TemplateInfoView;
import com.xdap.self_development.service.ModelRoleService;
import com.xdap.self_development.service.ParameterService; import com.xdap.self_development.service.ParameterService;
import com.xdap.self_development.utils.FormulaValidator; import com.xdap.self_development.utils.FormulaValidator;
import com.xdap.self_development.utils.ParameterOperation; import com.xdap.self_development.utils.ParameterOperation;
@ -41,7 +37,7 @@ public class ParameterServiceImpl implements ParameterService {
private UserPermissionGetter permissionGetter; private UserPermissionGetter permissionGetter;
@Override @Override
public PageQueryResult<Parameter> getParameterByCondition(ParameterPageForm form) { public MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form) {
Template template = bd.getBusinessDatabase() Template template = bd.getBusinessDatabase()
.rowid("id", form.getTemplateRowId()) .rowid("id", form.getTemplateRowId())
.doQueryFirst(Template.class); .doQueryFirst(Template.class);
@ -60,8 +56,7 @@ public class ParameterServiceImpl implements ParameterService {
// .setVar("createdBy", permissionGetter.getCurrentUserId()) // .setVar("createdBy", permissionGetter.getCurrentUserId())
// .doQuery(Parameter.class).stream().map(Parameter::getId).collect(Collectors.toList())); // .doQuery(Parameter.class).stream().map(Parameter::getId).collect(Collectors.toList()));
// List<String> parameterIds = new ArrayList<>(objects); // List<String> parameterIds = new ArrayList<>(objects);
PageQueryResult<Parameter> parameterPageQueryResult = bd.getBusinessDatabase()
return bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("selectParametersByTId") .view("selectParametersByTId")
.setVar("templateId", template.getId()) .setVar("templateId", template.getId())
@ -70,6 +65,11 @@ public class ParameterServiceImpl implements ParameterService {
.like("parts_name", form.getPartsName()) .like("parts_name", form.getPartsName())
.like("parameter_type", form.getParameterType()) .like("parameter_type", form.getParameterType())
.doPageQuery(form.getPageNumber(), form.getPageSize(), Parameter.class); .doPageQuery(form.getPageNumber(), form.getPageSize(), Parameter.class);
MyPageResult<Parameter> myPageResult = new MyPageResult<>();
myPageResult.setCount(parameterPageQueryResult.getCount());
myPageResult.setResult(parameterPageQueryResult.getResult());
myPageResult.setStatus(template.getStatus());
return myPageResult;
} }
@Override @Override
@ -380,6 +380,9 @@ public class ParameterServiceImpl implements ParameterService {
private String handleParameterChange(String name, String originalParameter, String updatedParameter) { private String handleParameterChange(String name, String originalParameter, String updatedParameter) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if ((originalParameter == null && updatedParameter.isEmpty())) {
return sb.toString();
}
if (!Objects.equals(originalParameter, updatedParameter)) { if (!Objects.equals(originalParameter, updatedParameter)) {
if (originalParameter == null || originalParameter.isEmpty()) { if (originalParameter == null || originalParameter.isEmpty()) {
if (updatedParameter == null || updatedParameter.isEmpty()) { if (updatedParameter == null || updatedParameter.isEmpty()) {

View File

@ -2,7 +2,6 @@ package com.xdap.self_development.service.impl;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson2.JSON;
import com.definesys.mpaas.query.db.PageQueryResult; import com.definesys.mpaas.query.db.PageQueryResult;
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;
@ -10,7 +9,10 @@ import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.form.*; import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.listener.SheetDataListener; import com.xdap.self_development.listener.SheetDataListener;
import com.xdap.self_development.pojo.*; import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.RevisionRecord;
import com.xdap.self_development.pojo.Template;
import com.xdap.self_development.pojo.TemplateAndParameter;
import com.xdap.self_development.service.TemplateService; import com.xdap.self_development.service.TemplateService;
import com.xdap.self_development.utils.FormulaValidator; import com.xdap.self_development.utils.FormulaValidator;
import lombok.Getter; import lombok.Getter;
@ -29,7 +31,6 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service @Service
@Slf4j @Slf4j
@ -75,7 +76,7 @@ public class TemplateServiceImpl implements TemplateService {
public void updateTemplate(UpdateTemplateForm form) { public void updateTemplate(UpdateTemplateForm form) {
Template template = bd.getBusinessDatabase() Template template = bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("getLatestTemplate") .view("getLatestTemplateOrder")
.eq("template_name", form.getTemplateName()) .eq("template_name", form.getTemplateName())
.doQueryFirst(Template.class); .doQueryFirst(Template.class);
@ -83,12 +84,12 @@ public class TemplateServiceImpl implements TemplateService {
if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) { if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
List<Long> sorted = bd.getBusinessDatabase() List<Long> sorted = bd.getBusinessDatabase()
.groupBy("order_num") .groupBy("order_num")
.orderBy("order_num", "asc") .orderBy("order_num", "desc")
.doQuery(Template.class) .doQuery(Template.class)
.stream().map(Template::getOrderNum) .stream().map(Template::getOrderNum)
.collect(Collectors.toList()); .collect(Collectors.toList());
Long num = sorted.get(form.getOrderNum()); Long num = sorted.get(form.getOrderNum() - 1);
if (num == null) { if (num == null) {
num = sorted.get(sorted.size() - 1); num = sorted.get(sorted.size() - 1);
} }
@ -104,17 +105,17 @@ public class TemplateServiceImpl implements TemplateService {
if (updateTemplateId.isEmpty()) { if (updateTemplateId.isEmpty()) {
bd.getBusinessDatabase() bd.getBusinessDatabase()
.in("id", updateTemplateId) .in("id", originalTemplateId)
.update("order_num", template.getOrderNum()) .update("order_num", System.currentTimeMillis())
.doUpdate(Template.class); .doUpdate(Template.class);
} else { } else {
bd.getBusinessDatabase() bd.getBusinessDatabase()
.in("id", updateTemplateId) .in("id", updateTemplateId)
.update("order_num", num) .update("order_num", template.getOrderNum())
.doUpdate(Template.class); .doUpdate(Template.class);
bd.getBusinessDatabase() bd.getBusinessDatabase()
.in("id", originalTemplateId) .in("id", originalTemplateId)
.update("order_num", form.getOrderNum()) .update("order_num", num)
.doUpdate(Template.class); .doUpdate(Template.class);
} }
return; return;
@ -246,13 +247,18 @@ public class TemplateServiceImpl implements TemplateService {
return; return;
} }
if (problems.getFlag()) {
return;
}
// 验证公式 // 验证公式
for (Parameter data : dataList) { for (Parameter data : dataList) {
data.setCreatedBy(createBy); data.setCreatedBy(createBy);
if (data.getSubsystemName() == null) {
problems.setFlag(true);
problems.getErrors().add("模板导入失败:" + sheetName + "模板的参数" + data.getParameterName() + "的子系统字段为空");
return;
}
if (data.getPartsName() == null || data.getPartsName().isEmpty()) {
data.setPartsName("/");
}
if (Objects.equals(data.getParameterSource(), "公式计算")) { if (Objects.equals(data.getParameterSource(), "公式计算")) {
Map<String, Object> validationResult = FormulaValidator.validateFormulaDetailed( Map<String, Object> validationResult = FormulaValidator.validateFormulaDetailed(
data.getNumberOrFormula()); data.getNumberOrFormula());