Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
017ad491dc
@ -4,6 +4,7 @@ import com.definesys.mpaas.common.http.Response;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.pojo.BenchmarkingReport;
|
||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||
@ -50,6 +51,21 @@ public class BenchmarkingReportController {
|
||||
return Response.ok().setMessage("保存成功");
|
||||
}
|
||||
|
||||
// 修改对标报告并发起审批
|
||||
@PostMapping("/restartReportApproval")
|
||||
public Response restartReportApproval(
|
||||
@Valid UpdateBenchmarkingReportForm form,
|
||||
BindingResult bindingResult
|
||||
) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
bindingResult.getFieldErrors().forEach(error -> {
|
||||
throw new CommonException(error.getDefaultMessage());
|
||||
});
|
||||
}
|
||||
benchmarkingReportService.restartReportApproval(form);
|
||||
return Response.ok().setMessage("重新提交成功");
|
||||
}
|
||||
|
||||
// 筛选对标报告及待办
|
||||
@PostMapping("/getReportAndTodoByCondition")
|
||||
public Response getBenchmarkingReportByCondition(
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xdap.self_development.controller;
|
||||
|
||||
import com.definesys.mpaas.common.http.Response;
|
||||
import com.xdap.api.moudle.user.vo.LoginUserVo;
|
||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||
import com.xdap.runtime.service.RuntimeUserService;
|
||||
@ -42,11 +43,13 @@ public class DataEntryController {
|
||||
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
|
||||
String currentToken = runtimeAppContextService.getCurrentToken();
|
||||
String currentUserId = runtimeAppContextService.getCurrentUserId();
|
||||
LoginUserVo loginUserVo = runtimeUserService.queryLoginUserVo(currentUserId, currentTenantId, currentAppId);
|
||||
|
||||
map.put("currentAppId", currentAppId);
|
||||
map.put("currentTenantId", currentTenantId);
|
||||
map.put("currentToken", currentToken);
|
||||
map.put("currentUserId", currentUserId);
|
||||
map.put("loginUserVo", loginUserVo.toString());
|
||||
return Response.ok().data(map);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
package com.xdap.self_development.controller.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateBenchmarkingReportForm {
|
||||
@NotBlank(message = "原对标报告id不能为空")
|
||||
private String reportId;
|
||||
|
||||
@NotBlank(message = "标题不能为空")
|
||||
private String title;
|
||||
@NotBlank(message = "厂家名称不能为空")
|
||||
private String manufacturerName;
|
||||
@NotBlank(message = "产品型号不能为空")
|
||||
private String modelName;
|
||||
@NotBlank(message = "厂家简称不能为空")
|
||||
private String manufacturerAbbreviation;
|
||||
@NotBlank(message = "产品型号简称不能为空")
|
||||
private String modelAbbreviation;
|
||||
@NotBlank(message = "产品编号不能为空")
|
||||
private String productNumber;
|
||||
@NotBlank(message = "模块不能为空")
|
||||
private String module;
|
||||
@NotBlank(message = "板块不能为空")
|
||||
private String plate;
|
||||
@NotBlank(message = "平台不能为空")
|
||||
private String platform;
|
||||
@NotBlank(message = "系列不能为空")
|
||||
private String series;
|
||||
@NotBlank(message = "细分市场不能为空")
|
||||
private String marketSegment;
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
private String projectName;
|
||||
@NotBlank(message = "项目编号不能为空")
|
||||
private String projectNumber;
|
||||
|
||||
private String fileUrl;
|
||||
|
||||
@NotEmpty(message = "校对人员不能为空")
|
||||
private List<String> proofreadUsers;
|
||||
@NotEmpty(message = "审核人员不能为空")
|
||||
private List<String> reviewUsers;
|
||||
private List<String> countersignUsers; // 可选
|
||||
@NotEmpty(message = "批准人员不能为空")
|
||||
private List<String> approveUsers;
|
||||
@NotBlank(message = "发起人不能为空")
|
||||
private String createBy;
|
||||
private String explanation;
|
||||
}
|
||||
@ -13,5 +13,4 @@ public class MenuParamView {
|
||||
private String parameterName;
|
||||
private String parameterId;
|
||||
private String parameterPer;
|
||||
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import java.sql.Timestamp;
|
||||
@SQL(view = "getReportByUserIdAndIds",
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE 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 af.flow_type = 2 AND af.id NOT IN (#ids) AND af.create_by = #createBy"),
|
||||
@SQL(view = "getTodoAndReport",
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE 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 af.flow_type = 2 AND af.id IN (#ids)")
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE 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 af.flow_type = 2 AND (af.id IN (#ids) OR af.create_by = #createBy) 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 {
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xdap.self_development.service;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.pojo.BenchmarkingReport;
|
||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
||||
@ -16,6 +17,8 @@ public interface BenchmarkingReportService {
|
||||
List<TodoAndReportView> getBenchmarkingReportByCondition(@Valid BenchmarkingReportPageForm form);
|
||||
|
||||
void saveBenchmarkingReport(@Valid SaveBenchmarkingReportForm form);
|
||||
|
||||
void restartReportApproval(@Valid UpdateBenchmarkingReportForm form);
|
||||
|
||||
void handleReportApproval(@Valid HandleApprovalRequest request);
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import com.xdap.self_development.config.BusinessDatabase;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
||||
@ -64,8 +65,8 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
@Override
|
||||
@Transactional(rollbackFor = CommonException.class)
|
||||
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
||||
// 1. 创建对标报告并保存
|
||||
BenchmarkingReport report = new BenchmarkingReport();
|
||||
// 1. 创建对标报告并保存
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
@ -93,6 +94,37 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartReportApproval(UpdateBenchmarkingReportForm form) {
|
||||
BenchmarkingReport originalReport = bd.getBusinessDatabase()
|
||||
.eq("id", form.getReportId()).doQueryFirst(BenchmarkingReport.class);
|
||||
BeanUtils.copyProperties(form, originalReport);
|
||||
originalReport.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
originalReport.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
originalReport.setStatus("APPROVING");
|
||||
originalReport.setCreateBy(form.getCreateBy());
|
||||
bd.getBusinessDatabase().doUpdate(originalReport);
|
||||
|
||||
ApprovalFlow flow = new ApprovalFlow();
|
||||
flow.setTemplateId(originalReport.getId());
|
||||
flow.setCurrentNode("PROOFREAD");
|
||||
flow.setFlowStatus("APPROVING");
|
||||
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
||||
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
|
||||
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
|
||||
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
|
||||
flow.setCreateBy(form.getCreateBy());
|
||||
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
flow.setFlowType(2); // 设置为报告审批流程
|
||||
flow.setExplanation(form.getExplanation());
|
||||
bd.getBusinessDatabase().doInsert(flow);
|
||||
|
||||
form.getProofreadUsers().forEach(userId -> {
|
||||
redisTemplate.opsForSet().add(TODO_PREFIX + userId, flow.getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file, String userId) {
|
||||
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
|
||||
@ -126,35 +158,11 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
@Override
|
||||
public List<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
|
||||
List<TodoAndReportView> approvalList = new ArrayList<>();
|
||||
Set<String> flowIds = redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy());
|
||||
|
||||
if (flowIds != null && !flowIds.isEmpty()) {
|
||||
List<String> ids = new ArrayList<>(flowIds);
|
||||
List<TodoAndReportView> todoList =bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("getTodoAndReport")
|
||||
.setVar("ids", ids)
|
||||
.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(approvalList, todoList);
|
||||
|
||||
}
|
||||
|
||||
List<String> ids = (flowIds == null || flowIds.isEmpty()) ? new ArrayList<>(Collections.singleton("")) : new ArrayList<>(flowIds);
|
||||
List<TodoAndReportView> todoAndTemplateViews = bd.getBusinessDatabase()
|
||||
Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy())));
|
||||
List<String> ids = new ArrayList<>(flowIds);
|
||||
List<TodoAndReportView> todoList =bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("getReportByUserIdAndIds")
|
||||
.view("getTodoAndReport")
|
||||
.setVar("ids", ids)
|
||||
.setVar("createBy", form.getCreateBy())
|
||||
.setVar("title", form.getTitle())
|
||||
@ -170,8 +178,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
.setVar("projectNumber", form.getProjectNumber())
|
||||
.setVar("status", form.getStatus())
|
||||
.doQuery(TodoAndReportView.class);
|
||||
setCurrentApprovers(approvalList, todoAndTemplateViews);
|
||||
|
||||
setCurrentApprovers(approvalList, todoList);
|
||||
return approvalList;
|
||||
}
|
||||
|
||||
@ -200,32 +207,26 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
String currentNode = flow.getCurrentNode();
|
||||
// 验证当前用户是否有权限处理
|
||||
if (!hasPermission(flow, currentNode, request.getUserId())) {
|
||||
throw new CommonException("无权限处理或已被处理");
|
||||
throw new CommonException("无权限处理");
|
||||
}
|
||||
|
||||
if (!"COUNTERSIGN".equals(currentNode)) {
|
||||
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
||||
String lockValue = UUID.randomUUID().toString();
|
||||
boolean lockAcquired = redisLockUtil
|
||||
.tryLock(lockKey, lockValue, FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
||||
|
||||
if (!lockAcquired) {
|
||||
throw new CommonException("当前节点正在处理,请稍后重试");
|
||||
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
||||
String lockValue = UUID.randomUUID().toString();
|
||||
boolean lockAcquired = redisLockUtil
|
||||
.tryLock(lockKey, lockValue, FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
||||
if (!lockAcquired) {
|
||||
throw new CommonException("当前节点正在处理,请稍后重试");
|
||||
}
|
||||
try {
|
||||
String processedKey = NODE_PROCESSED_PREFIX + flow.getId() + ":" + currentNode;
|
||||
long processedCount = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
||||
.orElse(0L);
|
||||
if (processedCount > 0) {
|
||||
throw new CommonException("此节点已被他人处理");
|
||||
}
|
||||
|
||||
try {
|
||||
String processedKey = NODE_PROCESSED_PREFIX + flow.getId() + ":" + currentNode;
|
||||
long processedCount = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
||||
.orElse(0L);
|
||||
if (processedCount > 0) {
|
||||
throw new CommonException("此节点已被他人处理");
|
||||
}
|
||||
processApprovalLogic(flow, request, currentNode);
|
||||
} finally {
|
||||
redisLockUtil.unlock(lockKey, lockValue);
|
||||
}
|
||||
} else {
|
||||
processApprovalLogic(flow, request, currentNode);
|
||||
} finally {
|
||||
redisLockUtil.unlock(lockKey, lockValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +246,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
approvalFlowView.setExplanation(flow.getExplanation());
|
||||
approvalFlowView.setProofreadNodes(getNodeList(flowId, "PROOFREAD"));
|
||||
approvalFlowView.setReviewNodes(getNodeList(flowId, "REVIEW"));
|
||||
approvalFlowView.setCountersignNodes(getNodeList(flowId, "COUNTERSIGN"));
|
||||
approvalFlowView.setApproveNodes(getNodeList(flowId, "APPROVE"));
|
||||
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
@ -277,8 +277,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
return JSON.parseArray(flow.getProofreadUsers()).toJavaList(String.class).contains(userId);
|
||||
case "REVIEW":
|
||||
return JSON.parseArray(flow.getReviewUsers()).toJavaList(String.class).contains(userId);
|
||||
case "COUNTERSIGN":
|
||||
return flow.getCountersignUsers() != null && JSON.parseArray(flow.getCountersignUsers()).toJavaList(String.class).contains(userId);
|
||||
case "APPROVE":
|
||||
return JSON.parseArray(flow.getApproveUsers()).toJavaList(String.class).contains(userId);
|
||||
default:
|
||||
@ -369,12 +367,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
Long processedCount = redisTemplate.opsForSet().size(key);
|
||||
if (processedCount == null) processedCount = 0L;
|
||||
|
||||
// 会签节点需要所有人处理,其他节点只需1人
|
||||
if ("COUNTERSIGN".equals(node)) {
|
||||
return processedCount.equals((long) JSON.parseArray(flow.getCountersignUsers()).size());
|
||||
} else {
|
||||
return processedCount >= 1;
|
||||
}
|
||||
return processedCount >= 1;
|
||||
}
|
||||
|
||||
private String getNextNode(String currentNode, ApprovalFlow flow) {
|
||||
@ -382,9 +375,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
case "PROOFREAD":
|
||||
return "REVIEW";
|
||||
case "REVIEW":
|
||||
return flow.getCountersignUsers() != null && !JSON.parseArray(flow.getCountersignUsers()).isEmpty()
|
||||
? "COUNTERSIGN" : "APPROVE";
|
||||
case "COUNTERSIGN":
|
||||
return "APPROVE";
|
||||
case "APPROVE":
|
||||
return null; // 流程结束
|
||||
@ -416,18 +406,12 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
private void clearAllTodo(ApprovalFlow flow) {
|
||||
clearNodeTodo(flow, "PROOFREAD");
|
||||
clearNodeTodo(flow, "REVIEW");
|
||||
if (flow.getCountersignUsers() != null) {
|
||||
clearNodeTodo(flow, "COUNTERSIGN");
|
||||
}
|
||||
clearNodeTodo(flow, "APPROVE");
|
||||
}
|
||||
|
||||
private void clearProcessed(ApprovalFlow flow) {
|
||||
redisTemplate.delete(NODE_PROCESSED_PREFIX + flow.getId() + ":" + "PROOFREAD");
|
||||
redisTemplate.delete(NODE_PROCESSED_PREFIX + flow.getId() + ":" + "REVIEW");
|
||||
if (flow.getCountersignUsers() != null) {
|
||||
redisTemplate.delete(NODE_PROCESSED_PREFIX + flow.getId() + ":" + "COUNTERSIGN");
|
||||
}
|
||||
redisTemplate.delete(NODE_PROCESSED_PREFIX + flow.getId() + ":" + "APPROVE");
|
||||
}
|
||||
|
||||
@ -442,7 +426,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
switch (node) {
|
||||
case "PROOFREAD": return JSON.parseArray(flow.getProofreadUsers()).toJavaList(String.class);
|
||||
case "REVIEW": return JSON.parseArray(flow.getReviewUsers()).toJavaList(String.class);
|
||||
case "COUNTERSIGN": return JSON.parseArray(flow.getCountersignUsers()).toJavaList(String.class);
|
||||
case "APPROVE": return JSON.parseArray(flow.getApproveUsers()).toJavaList(String.class);
|
||||
default: return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -10,8 +10,10 @@ 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;
|
||||
@ -31,6 +33,8 @@ import java.util.stream.Collectors;
|
||||
public class ParameterServiceImpl implements ParameterService {
|
||||
@Resource
|
||||
private BusinessDatabase bd;
|
||||
@Resource
|
||||
private ModelRoleService modelRoleService;
|
||||
|
||||
@Override
|
||||
public PageQueryResult<Parameter> getParameterByCondition(ParameterPageForm form) {
|
||||
@ -42,6 +46,8 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
throw new CommonException("模板未找到");
|
||||
}
|
||||
|
||||
//todo 获取指定子系统下的用户的权限,权限应该为:参数的 parameterNumber
|
||||
|
||||
return bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("selectParametersByTemplateId")
|
||||
@ -83,8 +89,7 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
switch (benchmark.getLastTemplate().getStatus()) {
|
||||
// 如果最新版本为草稿状态,沿用该版本
|
||||
case "DRAFT":
|
||||
newVersionTemplate = benchmark.getLastTemplate();
|
||||
break;
|
||||
throw new CommonException("最新模板为草稿状态,暂时无法新建版本");
|
||||
// 如果最新版本为审核中,则不允许新建版本
|
||||
case "APPROVING":
|
||||
throw new CommonException("最新模板审核中,暂时无法新建版本");
|
||||
@ -191,19 +196,21 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
Template newTemplate)
|
||||
{
|
||||
Map<Integer, Parameter> parameterMap = createParameterMap(existingParameters);
|
||||
if (!existingParameters.isEmpty()) {
|
||||
// 清除原来的关联关系
|
||||
bd.getBusinessDatabase().eq("template_id", baseTemplate.getId()).doDelete(TemplateAndParameter.class);
|
||||
}
|
||||
// if (!existingParameters.isEmpty()) {
|
||||
// // 清除原来的关联关系
|
||||
// bd.getBusinessDatabase().eq("template_id", baseTemplate.getId()).doDelete(TemplateAndParameter.class);
|
||||
// }
|
||||
List<Parameter> newParameters = new ArrayList<>();
|
||||
List<RevisionRecord> revisionRecords = new ArrayList<>();
|
||||
|
||||
// 处理模板部分参数
|
||||
for (ParameterForm parameterForm : parameterForms) {
|
||||
if (parameterForm.getOperation() == null) {
|
||||
parameterForm.setOperation("");
|
||||
}
|
||||
ParameterOperation operation = ParameterOperation.fromCode(parameterForm.getOperation());
|
||||
|
||||
|
||||
switch (operation) {
|
||||
case INSERT:
|
||||
handleInsertOperation(parameterForm, newTemplate, newParameters, revisionRecords, baseTemplate);
|
||||
@ -220,6 +227,9 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理模板剩余的参数
|
||||
List<Parameter> unmatchedParameters = findUnmatchedParameters(parameterMap, parameterForms);
|
||||
newParameters.addAll(unmatchedParameters);
|
||||
return new ParameterProcessingResult(newParameters, revisionRecords);
|
||||
}
|
||||
|
||||
@ -391,6 +401,19 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Parameter> findUnmatchedParameters(
|
||||
Map<Integer, Parameter> parameterMap,
|
||||
List<ParameterForm> parameterForms) {
|
||||
Set<Integer> formNumbers = parameterForms.parallelStream()
|
||||
.map(ParameterForm::getParameterNumber)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
return parameterMap.entrySet().parallelStream()
|
||||
.filter(entry -> !formNumbers.contains(entry.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存所有数据
|
||||
*/
|
||||
|
||||
@ -99,17 +99,17 @@ CREATE TABLE yfsjglpt_model_dep_user_role(
|
||||
) COMMENT '部门或用户关联角色表';
|
||||
|
||||
|
||||
--角色权限关联表
|
||||
-- 角色权限关联表
|
||||
DROP TABLE IF EXISTS yc_datasource_0.yfsjglpt_model_role_permission;
|
||||
CREATE TABLE yc_datasource_0.yfsjglpt_model_role_permission(
|
||||
`id` VARCHAR(64) NOT NULL COMMENT 'ID',
|
||||
`role_id` VARCHAR(64) COMMENT '角色ID',
|
||||
`per_id` VARCHAR(64) COMMENT '权限路径ID',
|
||||
`is_enable` INT DEFAULT 1 COMMENT '是否启用;0:未启用;1:启用',
|
||||
`created_by` VARCHAR(64) COMMENT '创建人',
|
||||
`creation_date` DATETIME COMMENT '创建时间',
|
||||
`last_updated_by` VARCHAR(64) COMMENT '最后更新人',
|
||||
`last_update_date` DATETIME COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
`id` VARCHAR(64) NOT NULL COMMENT 'ID',
|
||||
`role_id` VARCHAR(64) COMMENT '角色ID',
|
||||
`per_id` VARCHAR(64) COMMENT '权限路径ID',
|
||||
`is_enable` INT DEFAULT 1 COMMENT '是否启用;0:未启用;1:启用',
|
||||
`created_by` VARCHAR(64) COMMENT '创建人',
|
||||
`creation_date` DATETIME COMMENT '创建时间',
|
||||
`last_updated_by` VARCHAR(64) COMMENT '最后更新人',
|
||||
`last_update_date` DATETIME COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '角色权限关联表';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user