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

View File

@ -1,10 +1,8 @@
package com.xdap.self_development.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.metadata.data.ReadCellData;
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.pojo.Parameter;
import com.xdap.self_development.service.TemplateService;
@ -61,22 +59,10 @@ public class SheetDataListener implements ReadListener<Parameter> {
@Override
public void invoke(Parameter data, AnalysisContext context) {
// 如果sheet无效直接返回不处理数据
// if (!validSheet) {
// 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) {
currentSheetName = context.readSheetHolder().getSheetName();
}

View File

@ -10,11 +10,11 @@ import lombok.NoArgsConstructor;
import java.sql.Timestamp;
@SQLQuery(value = {
@SQL(view = "getMaxOrder",
sql = "SELECT order_num as maxOrder FROM yfsjglpt_model_template ORDER BY order_num desc"),
@SQL(view = "getLatestTemplateOrder",
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 = "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",

View File

@ -1,6 +1,6 @@
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.UpdateParameterForm;
import com.xdap.self_development.pojo.Parameter;
@ -10,7 +10,7 @@ import com.xdap.self_development.pojo.view.TemplateInfoView;
import java.util.List;
public interface ParameterService {
PageQueryResult<Parameter> getParameterByCondition(ParameterPageForm form);
MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form);
TemplateInfoView maintenanceParameters(UpdateParameterForm form);

View File

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

View File

@ -1,9 +1,7 @@
package com.xdap.self_development.service.impl;
import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.api.moudle.user.vo.LoginUserVo;
import com.xdap.runtime.service.RuntimeAppContextService;
import com.xdap.runtime.service.RuntimeUserService;
import com.xdap.self_development.common.MyPageResult;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.config.BusinessDatabase;
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.Template;
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.TemplateInfoView;
import com.xdap.self_development.service.ModelRoleService;
import com.xdap.self_development.service.ParameterService;
import com.xdap.self_development.utils.FormulaValidator;
import com.xdap.self_development.utils.ParameterOperation;
@ -41,7 +37,7 @@ public class ParameterServiceImpl implements ParameterService {
private UserPermissionGetter permissionGetter;
@Override
public PageQueryResult<Parameter> getParameterByCondition(ParameterPageForm form) {
public MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form) {
Template template = bd.getBusinessDatabase()
.rowid("id", form.getTemplateRowId())
.doQueryFirst(Template.class);
@ -60,8 +56,7 @@ public class ParameterServiceImpl implements ParameterService {
// .setVar("createdBy", permissionGetter.getCurrentUserId())
// .doQuery(Parameter.class).stream().map(Parameter::getId).collect(Collectors.toList()));
// List<String> parameterIds = new ArrayList<>(objects);
return bd.getBusinessDatabase()
PageQueryResult<Parameter> parameterPageQueryResult = bd.getBusinessDatabase()
.viewQueryMode(true)
.view("selectParametersByTId")
.setVar("templateId", template.getId())
@ -70,6 +65,11 @@ public class ParameterServiceImpl implements ParameterService {
.like("parts_name", form.getPartsName())
.like("parameter_type", form.getParameterType())
.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
@ -380,6 +380,9 @@ public class ParameterServiceImpl implements ParameterService {
private String handleParameterChange(String name, String originalParameter, String updatedParameter) {
StringBuilder sb = new StringBuilder();
if ((originalParameter == null && updatedParameter.isEmpty())) {
return sb.toString();
}
if (!Objects.equals(originalParameter, updatedParameter)) {
if (originalParameter == null || originalParameter.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.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson2.JSON;
import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.self_development.common.MyResponse;
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.exception.CommonException;
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.utils.FormulaValidator;
import lombok.Getter;
@ -29,7 +31,6 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@Slf4j
@ -75,7 +76,7 @@ public class TemplateServiceImpl implements TemplateService {
public void updateTemplate(UpdateTemplateForm form) {
Template template = bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getLatestTemplate")
.view("getLatestTemplateOrder")
.eq("template_name", form.getTemplateName())
.doQueryFirst(Template.class);
@ -83,12 +84,12 @@ public class TemplateServiceImpl implements TemplateService {
if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
List<Long> sorted = bd.getBusinessDatabase()
.groupBy("order_num")
.orderBy("order_num", "asc")
.orderBy("order_num", "desc")
.doQuery(Template.class)
.stream().map(Template::getOrderNum)
.collect(Collectors.toList());
Long num = sorted.get(form.getOrderNum());
Long num = sorted.get(form.getOrderNum() - 1);
if (num == null) {
num = sorted.get(sorted.size() - 1);
}
@ -104,17 +105,17 @@ public class TemplateServiceImpl implements TemplateService {
if (updateTemplateId.isEmpty()) {
bd.getBusinessDatabase()
.in("id", updateTemplateId)
.update("order_num", template.getOrderNum())
.in("id", originalTemplateId)
.update("order_num", System.currentTimeMillis())
.doUpdate(Template.class);
} else {
bd.getBusinessDatabase()
.in("id", updateTemplateId)
.update("order_num", num)
.update("order_num", template.getOrderNum())
.doUpdate(Template.class);
bd.getBusinessDatabase()
.in("id", originalTemplateId)
.update("order_num", form.getOrderNum())
.update("order_num", num)
.doUpdate(Template.class);
}
return;
@ -246,13 +247,18 @@ public class TemplateServiceImpl implements TemplateService {
return;
}
if (problems.getFlag()) {
return;
}
// 验证公式
for (Parameter data : dataList) {
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(), "公式计算")) {
Map<String, Object> validationResult = FormulaValidator.validateFormulaDetailed(
data.getNumberOrFormula());