修改:参数变更问题修改

This commit is contained in:
zjh 2025-12-22 08:33:03 +08:00
parent 43247d411a
commit 4e342d2417
16 changed files with 90 additions and 75 deletions

View File

@ -1,6 +1,5 @@
package com.xdap.self_development.controller;
import com.alibaba.excel.EasyExcel;
import com.definesys.mpaas.common.http.Response;
import com.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.motor.entity.SnowflakeIdWorker;
@ -9,17 +8,16 @@ import com.xdap.self_development.common.MyResponse;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.feign.ApaasMyTokenFeign;
import com.xdap.self_development.pojo.ClassificationAttribute;
import com.xdap.self_development.pojo.EnginePartsCollection;
import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -48,6 +46,11 @@ public class DeleteController {
@Value("${apaas.token.clientSecred}")
private String clientSecret;
@GetMapping("/getUserId")
public Response getUserId() {
return Response.ok().data(runtimeAppContextService.getCurrentUserId());
}
@GetMapping("/timer")
public Response timer() {
MyResponse myResponse = timer.dailyCalculate();

View File

@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
@Data
public class ApprovalAndParameterForm {
// @NotBlank(message = "流程不能为空")
// private String flowId;
private String flowId;
@NotBlank(message = "模板不能为空")
private String templateId;

View File

@ -20,7 +20,6 @@ public class BenchmarkingReportPageForm {
private String projectName;
private String projectNumber;
private String status;
private String sysParts;
@NotBlank(message = "上传用户不能为空")
private String createBy;

View File

@ -20,7 +20,9 @@ public class SaveBenchmarkingReportForm {
private String marketSegment;
private String projectName;
private String projectNumber;
private String sysParts;
private String subsystem;
private String partsName;
@NotBlank(message = "发起人不能为空")
private String userId;

View File

@ -22,7 +22,9 @@ public class UpdateBenchmarkingReportForm {
private String marketSegment;
private String projectName;
private String projectNumber;
private String sysParts;
private String subsystem;
private String partsName;
private String fileUrl;

View File

@ -19,6 +19,7 @@ public class ApprovalFlow extends MpaasBasePojo {
private String templateId;
private String currentNode; // 节点PROOFREAD, REVIEW, COUNTERSIGN, APPROVE
private String flowStatus; //DRAFT(草稿)APPROVING审批中COMPLETE(已完成)RETURNED(已撤回)REJECTED(已拒绝)
private String returnNum;
private String proofreadUsers; // 校对人员
private String reviewUsers; // 审核人员

View File

@ -34,7 +34,9 @@ public class BenchmarkingReport extends MpaasBasePojo {
private String marketSegment;
private String projectName;
private String projectNumber;
private String sysParts;
private String subsystem;
private String partsName;
private String createBy;
private Integer isDelete;

View File

@ -28,10 +28,13 @@ public class RevisionRecord extends MpaasBasePojo {
private Timestamp createTime;
private String parameterId;
private String returnNum;
public RevisionRecord(String templateName, Integer version,
Integer parameterNumber, String modifyDetails,
String templateId, String preTemplateId,
Timestamp createTime, String parameterId) {
Timestamp createTime, String parameterId,
String returnNum) {
this.templateName = templateName;
this.version = version;
this.parameterNumber = parameterNumber;
@ -40,5 +43,6 @@ public class RevisionRecord extends MpaasBasePojo {
this.preTemplateId = preTemplateId;
this.createTime = createTime;
this.parameterId = parameterId;
this.returnNum = returnNum;
}
}

View File

@ -37,7 +37,7 @@ public class Template extends MpaasBasePojo {
private Timestamp publishedTime;
private Long orderNum;
private String createBy;
private String returnNum;
@Column(type = ColumnType.CALCULATE)
private Integer maxOrder;

View File

@ -6,7 +6,7 @@ import lombok.Data;
@SQLQuery(value = {
@SQL(view = "getParameterAndChange",
sql = "SELECT p.*, r.pre_template_id, r.modify_details FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY parameter_id ORDER BY create_time DESC) AS rn FROM yfsjglpt_model_revision_record ) r LEFT JOIN yfsjglpt_model_parameter p ON r.parameter_id = p.id WHERE r.rn = 1 and r.template_id = #templateId order by r.create_time desc ")
sql = "SELECT p.*, r.pre_template_id, r.modify_details FROM ( SELECT *, row_number() OVER (PARTITION BY parameter_id ORDER BY create_time DESC) AS rn FROM yfsjglpt_model_revision_record ) r LEFT JOIN yfsjglpt_model_parameter p ON r.parameter_id = p.id WHERE r.rn = 1 AND r.template_id = #templateId AND r.return_num <= #returnNum ORDER BY r.create_time DESC")
})
@Data
public class TemplateChangeView {

View File

@ -8,8 +8,12 @@ import lombok.Data;
import java.sql.Timestamp;
@SQLQuery(value = {
@SQL(view = "getAllReportApprovalByParts",
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and br.subsystem = #subsystem and br.parts_name in (#partsName) ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"),
@SQL(view = "getAllReportApprovalBySub",
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and br.subsystem = #subsystem ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"),
@SQL(view = "getAllReportApproval",
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') or br.sys_parts = #sysParts ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC")
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC")
})
@Data
public class TodoAndReportView {

View File

@ -102,12 +102,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
@Override
public PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
// 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")
@ -123,26 +117,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
.setVar("projectName", form.getProjectName())
.setVar("projectNumber", form.getProjectNumber())
.setVar("status", form.getStatus())
.setVar("sysParts", form.getSysParts())
.doPageQuery(form.getPageNumber(), form.getPageSize(), TodoAndReportView.class);
// List<TodoAndReportView> todoList = bd.getBusinessDatabase()
// .viewQueryMode(true)
// .view("getTodoAndReport")
// .setVar("ids", ids)
// .setVar("createBy", form.getCreateBy())
// .setVar("title", form.getTitle())
// .setVar("manufacturerName", form.getManufacturerName())
// .setVar("modelName", form.getModelName())
// .setVar("productNumber", form.getProductNumber())
// .setVar("module", form.getModule())
// .setVar("plate", form.getPlate())
// .setVar("platform", form.getPlatform())
// .setVar("series", form.getSeries())
// .setVar("marketSegment", form.getMarketSegment())
// .setVar("projectName", form.getProjectName())
// .setVar("projectNumber", form.getProjectNumber())
// .setVar("status", form.getStatus())
// .doQuery(TodoAndReportView.class);
setCurrentApprovers(result);
return result;
}
@ -230,13 +205,12 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
}
@Override
@Transactional
@Transactional(rollbackFor = CommonException.class)
public void handleReportApproval(HandleApprovalRequest request) {
ApprovalFlow flow = bd.getBusinessDatabase()
.eq("id", request.getFlowId())
.eq("flow_type", 2)
.doQueryFirst(ApprovalFlow.class);
if (flow == null || !"APPROVING".equals(flow.getFlowStatus())) {
throw new CommonException("流程不存在或已结束");
}
@ -408,7 +382,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
}
}
@Transactional(rollbackFor = CommonException.class)
public void processApprovalLogic(ApprovalFlow flow, HandleApprovalRequest request, String currentNode) {
// 记录审批结果
ApprovalRecord record = new ApprovalRecord();

View File

@ -319,7 +319,8 @@ public class ParameterServiceImpl implements ParameterService {
newTemplate.getId(),
null,
Timestamp.valueOf(LocalDateTime.now()),
newParameter.getId()
newParameter.getId(),
newTemplate.getReturnNum()
));
}
@ -363,7 +364,8 @@ public class ParameterServiceImpl implements ParameterService {
newTemplate.getId(),
baseTemplate.getId(),
Timestamp.valueOf(LocalDateTime.now()),
updatedParameter.getId()
updatedParameter.getId(),
newTemplate.getReturnNum()
));
}
@ -420,7 +422,8 @@ public class ParameterServiceImpl implements ParameterService {
newTemplate.getId(),
baseTemplate.getId(),
Timestamp.valueOf(LocalDateTime.now()),
deletedParameter.getId()
deletedParameter.getId(),
newTemplate.getReturnNum()
));
}
}

View File

@ -93,6 +93,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
flow.setFlowType(1); // 设置为模板审批流程
flow.setExplanation(request.getExplanation());
flow.setReturnNum(template.getReturnNum());
bd.getBusinessDatabase().doInsert(flow);
// 新增待办
@ -263,24 +264,36 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
@Override
public PageQueryResult<TemplateChangeView> getTemplateChanges(ApprovalAndParameterForm form) {
PageQueryResult<TemplateChangeView> results = bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getParameterAndChange")
.setVar("templateId", form.getTemplateId())
.doPageQuery(form.getPageNumber(), form.getPageSize(), TemplateChangeView.class);
// results.getResult().forEach(item -> {
// if (item.getPreTemplateId() != null) {
// Parameter parameter = bd.getBusinessDatabase()
// .viewQueryMode(true)
// .view("selectParametersByTemplateId")
// .setVar("templateId", item.getPreTemplateId())
// .eq("parameter_number", item.getParameterNumber())
// .doQueryFirst(Parameter.class);
// BeanUtils.copyProperties(parameter, item);
// }
// });
return results;
Template template = bd.getBusinessDatabase()
.eq("id", form.getTemplateId())
.doQueryFirst(Template.class);
if (form.getFlowId() == null) {
return bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getParameterAndChange")
.setVar("templateId", form.getTemplateId())
.setVar("returnNum", template.getReturnNum())
.doPageQuery(form.getPageNumber(), form.getPageSize(), TemplateChangeView.class);
} else {
ApprovalFlow approvalFlow = bd.getBusinessDatabase()
.eq("id", form.getFlowId())
.doQueryFirst(ApprovalFlow.class);
if (approvalFlow == null) {
return bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getParameterAndChange")
.setVar("templateId", form.getTemplateId())
.setVar("returnNum", template.getReturnNum())
.doPageQuery(form.getPageNumber(), form.getPageSize(), TemplateChangeView.class);
} else {
return bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getParameterAndChangeByApprovalId")
.setVar("templateId", form.getTemplateId())
.setVar("returnNum", approvalFlow.getReturnNum())
.doPageQuery(form.getPageNumber(), form.getPageSize(), TemplateChangeView.class);
}
}
}
@Override
@ -559,6 +572,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
bd.getBusinessDatabase()
.rowid("id", template.getRowId())
.update("status", template.getStatus())
.update("return_num", template.getReturnNum() + 1)
.doUpdate(Template.class);
// 清除所有待办
clearAllTodo(flow, userId);

View File

@ -186,13 +186,15 @@ public class TemplateServiceImpl implements TemplateService {
List<Parameter> list;
if (form.isTemplateEmpty()) {
list = bd.getBusinessDatabase()
.viewQueryMode(true)
.view("selectParametersByTId")
.setVar("templateId", templateDB.getId())
.select("parameterName", "parameterNumber")
.orderBy("parameterNumber", "asc")
.doQuery(Parameter.class);
// list = bd.getBusinessDatabase()
// .viewQueryMode(true)
// .view("selectParametersByTId")
// .setVar("templateId", templateDB.getId())
// .select("parameterName", "parameterNumber")
// .orderBy("parameterNumber", "asc")
// .doQuery(Parameter.class);
list = new ArrayList<>();
list.add(new Parameter());
} else {
list = bd.getBusinessDatabase()
.viewQueryMode(true)
@ -359,7 +361,8 @@ public class TemplateServiceImpl implements TemplateService {
finalLastTemplate.getId(),
null,
Timestamp.valueOf(LocalDateTime.now()),
parameter.getId()
parameter.getId(),
finalLastTemplate.getReturnNum()
);
})
.collect(Collectors.toList());
@ -448,7 +451,8 @@ public class TemplateServiceImpl implements TemplateService {
lastTemplate.getId(),
null,
Timestamp.valueOf(LocalDateTime.now()),
parameter.getId()
parameter.getId(),
lastTemplate.getReturnNum()
);
})
.collect(Collectors.toList());
@ -473,7 +477,8 @@ public class TemplateServiceImpl implements TemplateService {
lastTemplate.getId(),
parameterChange.getOriginal().getId(),
Timestamp.valueOf(LocalDateTime.now()),
parameterChange.getUpdated().getId()
parameterChange.getUpdated().getId(),
lastTemplate.getReturnNum()
);
bd.getBusinessDatabase().doInsert(record);
});

View File

@ -14,6 +14,7 @@ CREATE TABLE `yfsjglpt_model_approval_flow`
`created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`flow_type` int(11) NOT NULL DEFAULT '1' COMMENT '流程类型:1模板审批流程,2对标审批流程',
`explanation` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`return_num` int(11) DEFAULT 0 COMMENT '退回次数',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@ -59,7 +60,7 @@ CREATE TABLE `yfsjglpt_model_benchmarking_report`
`create_by` varchar(64) COLLATE utf8mb4_general_ci NOT NULL COMMENT '上传人',
`file_path` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件地址',
`status` varchar(20) COLLATE utf8mb4_general_ci DEFAULT 'DRAFT' COMMENT '状态 DRAFT(草稿)、APPROVING审批中、COMPLETE(已完成)、RETURNED(已撤回)、REJECTED(已拒绝)',
`sys_parts` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '子系统和零部件',
`is_delete` int(11) DEFAULT 0 COMMENT '删除标志',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@ -120,6 +121,7 @@ CREATE TABLE `yfsjglpt_model_template`
`published_time` timestamp NULL DEFAULT NULL,
`order_num` int NOT NULL DEFAULT '1',
`create_by` varchar(10) COLLATE utf8mb4_general_ci NOT NULL,
`return_num` int(11) DEFAULT 0 COMMENT '退回次数',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_template_version` (`template_name`, `version`),
KEY `idx_template_name` (`template_name`),
@ -145,6 +147,7 @@ CREATE TABLE `yfsjglpt_model_revision_record`
`pre_template_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`parameter_id` varchar(64) COLLATE utf8mb4_general_ci NOT NULL,
`return_num` int(11) DEFAULT 0 COMMENT '退回次数',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4