修改:机型和分析常用参数增删改

This commit is contained in:
zjh 2025-12-08 17:02:12 +08:00
parent 98e0d131b6
commit 4eb4451376
21 changed files with 389 additions and 85 deletions

View File

@ -1,9 +1,11 @@
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.xdap.self_development.controller.form.ModelCommon; import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.controller.form.ModelCommonParameterInsertForm; import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.pojo.AnalysisCommonParameters;
import com.xdap.self_development.service.CommonParameterService; import com.xdap.self_development.service.CommonParameterService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -17,6 +19,13 @@ public class CommonParameterController {
@Resource @Resource
private CommonParameterService commonParameterService; private CommonParameterService commonParameterService;
// 全部子系统和参数
@GetMapping("/getSystemAndPara")
public Response getSystemAndPara() {
List<ModelCommonItem> list = commonParameterService.getSystemAndPara();
return Response.ok().data(list);
}
// 查询机型参数常用 // 查询机型参数常用
@GetMapping("/getModelCommon") @GetMapping("/getModelCommon")
public Response getModelCommonParameter( public Response getModelCommonParameter(
@ -28,24 +37,69 @@ public class CommonParameterController {
// 新增机型参数常用 // 新增机型参数常用
@PostMapping("/insertModelCommon") @PostMapping("/insertModelCommon")
public Response insertModelCommonParameter( public Response insertModelCommonParameter(
@Valid @RequestBody ModelCommonParameterInsertForm form @Valid @RequestBody ModelCommonParameterInsertForm form,
BindingResult bindingResult
) { ) {
if (bindingResult.hasErrors()) {
bindingResult.getFieldErrors().forEach(error -> {
throw new CommonException(error.getDefaultMessage());
});
}
commonParameterService.insertModelCommonParameter(form); commonParameterService.insertModelCommonParameter(form);
return Response.ok().setMessage("新增成功"); return Response.ok().setMessage("新增成功");
} }
// 修改机型参数常用 // 修改机型参数常用
@PostMapping("/updateModelCommon") @PostMapping("/updateModelCommon")
public Response updateModelCommonParameter( public Response updateModelCommonParameter(
@Valid @RequestBody ModelCommonParameterInsertForm form @Valid @RequestBody ModelCommonParameterUpdateForm form,
BindingResult bindingResult
) { ) {
if (bindingResult.hasErrors()) {
bindingResult.getFieldErrors().forEach(error -> {
throw new CommonException(error.getDefaultMessage());
});
}
commonParameterService.updateModelCommonParameter(form); commonParameterService.updateModelCommonParameter(form);
return Response.ok().setMessage("修改成功"); return Response.ok().setMessage("修改成功");
} }
// 查询数据分析常用 // 查询数据分析常用
@GetMapping("/getAnalysisCommonParameter")
public Response getAnalysisCommonParameter(
@NotBlank @RequestParam String userId
) {
List<AnalysisCommonParameters> list = commonParameterService.getAnalysisCommonParameter(userId);
return Response.ok().data(list);
}
// 新增数据分析常用 // 新增数据分析常用
@PostMapping("/insertAnalysisCommon")
public Response insertAnalysisCommonParameter(
@Valid @RequestBody AnalysisCommonParameterInsertForm form,
BindingResult bindingResult
) {
if (bindingResult.hasErrors()) {
bindingResult.getFieldErrors().forEach(error -> {
throw new CommonException(error.getDefaultMessage());
});
}
commonParameterService.insertAnalysisCommonParameter(form);
return Response.ok().setMessage("新增成功");
}
// 修改数据分析常用 // 修改数据分析常用
@PostMapping("/updateAnalysisCommon")
public Response updateAnalysisCommonParameter(
@Valid @RequestBody AnalysisCommonParameterUpdateForm form,
BindingResult bindingResult
) {
if (bindingResult.hasErrors()) {
bindingResult.getFieldErrors().forEach(error -> {
throw new CommonException(error.getDefaultMessage());
});
}
commonParameterService.updateAnalysisCommonParameter(form);
return Response.ok().setMessage("修改成功");
}
} }

View File

@ -78,7 +78,7 @@ public class PermissionController {
} }
} }
//参数查询 // 根据子系统获取参数
@GetMapping("/getAllParameters") @GetMapping("/getAllParameters")
public Response getAllParameters( public Response getAllParameters(
@NotBlank String subsystem @NotBlank String subsystem

View File

@ -0,0 +1,24 @@
package com.xdap.self_development.controller.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AnalysisCommonParameterInsertForm {
private String modelName;
private String plate;
private String platform;
private String series;
private String projectName;
private String projectNumber;
private Long emission;
private Long displacementMin;
private Long displacementMax;
private String combustionType;
@NotBlank(message = "创建者不能为空")
private String userId;
@NotBlank(message = "常用名不能为空")
private String commonName;
}

View File

@ -0,0 +1,26 @@
package com.xdap.self_development.controller.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AnalysisCommonParameterUpdateForm {
private String modelName;
private String plate;
private String platform;
private String series;
private String projectName;
private String projectNumber;
private Long emission;
private Long displacementMin;
private Long displacementMax;
private String combustionType;
@NotBlank(message = "创建者不能为空")
private String userId;
@NotBlank(message = "常用名不能为空")
private String commonName;
@NotBlank(message = "常用不能为空")
private String commonId;
}

View File

@ -7,5 +7,6 @@ import java.util.List;
@Data @Data
public class ModelCommon { public class ModelCommon {
private String commonName; private String commonName;
private List<ModelCommonItem> subsystems; private String commonId;
List<ModelCommonItem> subsystems;
} }

View File

@ -3,12 +3,16 @@ package com.xdap.self_development.controller.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
@Data @Data
public class ModelCommonParameterInsertForm { public class ModelCommonParameterInsertForm {
@NotBlank(message = "创建者不能为空") @NotBlank(message = "创建者不能为空")
private String userId; private String userId;
@NotNull(message = "常用不能为空") @NotBlank(message = "常用名不能为空")
private ModelCommon common; private String commonName;
@NotEmpty(message = "参数不能为空")
private List<ModelCommonItem> subsystems;
} }

View File

@ -0,0 +1,18 @@
package com.xdap.self_development.controller.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class ModelCommonParameterUpdateForm {
@NotBlank(message = "创建者不能为空")
private String userId;
@NotBlank(message = "常用不能为空")
private String commonId;
@NotEmpty(message = "参数不能为空")
private List<ModelCommonItem> subsystems;
}

View File

@ -13,15 +13,17 @@ import lombok.EqualsAndHashCode;
public class AnalysisCommonParameters extends MpaasBasePojo { public class AnalysisCommonParameters extends MpaasBasePojo {
@RowID(sequence = "analysis_common_parameters_s", type = RowIDType.UUID) @RowID(sequence = "analysis_common_parameters_s", type = RowIDType.UUID)
private String id; private String id;
private String modelName; private String modelName;
private String plate; private String plate;
private String platform; private String platform;
private String series; private String series;
private String projectName; private String projectName;
private String projectNumber; private String projectNumber;
private String emission; private Long emission;
private String displacementMin; private Long displacementMin;
private String displacementMax; private Long displacementMax;
private String combustionType; private String combustionType;
private String userId;
private String commonId;
} }

View File

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

View File

@ -0,0 +1,19 @@
package com.xdap.self_development.pojo;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Table("yfsjglpt_common_parameter")
public class CommonParameter extends MpaasBasePojo {
@RowID(sequence = "common_parameters_s", type = RowIDType.UUID)
private String id;
private String commonName;
private Integer commonType;
private String createBy;
}

View File

@ -17,9 +17,8 @@ public class ModelCommonParameters extends MpaasBasePojo {
private String id; private String id;
private String subsystem; private String subsystem;
private String parameterId; private String parameterId;
private String userId;
// 唯一性 private String commonId;
private String commonName;
@Column(type = ColumnType.CALCULATE) @Column(type = ColumnType.CALCULATE)
private String parameterName; private String parameterName;

View File

@ -9,12 +9,14 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@SQLQuery(value = { @SQLQuery(value = {
@SQL(view = "getAllSubsystemAndPara",
sql = "SELECT DISTINCT mp.subsystem_name, mp.parameter_name, mp.id FROM yfsjglpt_model_parameter mp INNER JOIN yfsjglpt_model_parameter_and_template mpat ON mp.id = mpat.parameter_id INNER JOIN yfsjglpt_model_template mt ON mpat.template_id = mt.id INNER JOIN ( SELECT template_name, MAX(version) AS max_version FROM yfsjglpt_model_template WHERE status = 'COMPLETE' GROUP BY template_name ) latest ON mt.template_name = latest.template_name AND mt.version = latest.max_version WHERE mt.status = 'COMPLETE' ORDER BY mp.subsystem_name, mp.parameter_name, mp.id"),
@SQL(view = "getAllSubsystem", @SQL(view = "getAllSubsystem",
sql = "SELECT DISTINCT mp.subsystem_name FROM yfsjglpt_model_parameter mp INNER JOIN yfsjglpt_model_parameter_and_template mpat ON mp.id = mpat.parameter_id INNER JOIN yfsjglpt_model_template mt ON mpat.template_id = mt.id INNER JOIN ( SELECT template_name, MAX(version) AS max_version FROM yfsjglpt_model_template WHERE status = 'COMPLETE' GROUP BY template_name ) latest ON mt.template_name = latest.template_name AND mt.version = latest.max_version WHERE mt.status = 'COMPLETE' ORDER BY mp.subsystem_name"), sql = "SELECT DISTINCT mp.subsystem_name FROM yfsjglpt_model_parameter mp INNER JOIN yfsjglpt_model_parameter_and_template mpat ON mp.id = mpat.parameter_id INNER JOIN yfsjglpt_model_template mt ON mpat.template_id = mt.id INNER JOIN ( SELECT template_name, MAX(version) AS max_version FROM yfsjglpt_model_template WHERE status = 'COMPLETE' GROUP BY template_name ) latest ON mt.template_name = latest.template_name AND mt.version = latest.max_version WHERE mt.status = 'COMPLETE' ORDER BY mp.subsystem_name"),
@SQL(view = "selectParametersByTemplateId", sql = @SQL(view = "selectParametersByTemplateId",
"select p.* from yfsjglpt_model_parameter p left join yfsjglpt_model_parameter_and_template tap on p.id = tap.parameter_id where tap.template_id = #templateId"), sql = "select p.* from yfsjglpt_model_parameter p left join yfsjglpt_model_parameter_and_template tap on p.id = tap.parameter_id where tap.template_id = #templateId"),
@SQL(view = "selectMaxNumber", sql = @SQL(view = "selectMaxNumber",
"SELECT max(parameter_number) AS max_number FROM yfsjglpt_model_parameter p LEFT JOIN yfsjglpt_model_parameter_and_template tap ON p.id = tap.parameter_id WHERE tap.template_id = #templateId") sql = "SELECT max(parameter_number) AS max_number FROM yfsjglpt_model_parameter p LEFT JOIN yfsjglpt_model_parameter_and_template tap ON p.id = tap.parameter_id WHERE tap.template_id = #templateId")
}) })
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data

View File

@ -27,7 +27,7 @@ public class Template extends MpaasBasePojo {
private String id; private String id;
private String templateName; private String templateName;
private Integer version; private Integer version;
//DRAFT(草稿)APPROVING审批中COMPLETE(已完成)RETURNED(已撤回)REJECTED(已拒绝) //DRAFT(草稿)APPROVING审批中COMPLETE(已完成)
private String status; private String status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp createdTime; private Timestamp createdTime;

View File

@ -13,7 +13,7 @@ import java.util.List;
@SQL(view = "getApprovalByUserIdAndIds", @SQL(view = "getApprovalByUserIdAndIds",
sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id WHERE t.template_name like CONCAT('%',#templateName, '%') and t.status like CONCAT('%',#status, '%') and af.flow_type = 1 and af.id NOT IN (#ids) AND af.create_by = #createBy"), sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id WHERE t.template_name like CONCAT('%',#templateName, '%') and t.status like CONCAT('%',#status, '%') and af.flow_type = 1 and af.id NOT IN (#ids) AND af.create_by = #createBy"),
@SQL(view = "getTodoAndTemplate", @SQL(view = "getTodoAndTemplate",
sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\" , xu.username AS \"username\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id LEFT JOIN xdap_users xu ON xu.id = af.create_by WHERE t.template_name LIKE CONCAT('%', #templateName, '%') AND t.status LIKE CONCAT('%', #status, '%') AND t.created_time LIKE CONCAT('%', #createdTime, '%') AND xu.username LIKE CONCAT('%', #username, '%') AND af.flow_type = 1 AND (af.id IN (#ids) OR af.create_by = #createBy) ORDER BY CASE t.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'REJECTED' THEN 4 ELSE 5 END ASC") sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", af.flow_status AS \"status\" , af.create_by AS \"createBy\" , xu.username AS \"username\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id LEFT JOIN xdap_users xu ON xu.id = af.create_by WHERE t.template_name LIKE CONCAT('%', #templateName, '%') AND t.status LIKE CONCAT('%', #status, '%') AND t.created_time LIKE CONCAT('%', #createdTime, '%') AND xu.username LIKE CONCAT('%', #username, '%') AND af.flow_type = 1 AND (af.id IN (#ids) OR af.create_by = #createBy) ORDER BY CASE af.flow_status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'REJECTED' THEN 4 ELSE 5 END ASC")
}) })
@Data @Data
public class TodoAndTemplateView { public class TodoAndTemplateView {

View File

@ -1,16 +1,24 @@
package com.xdap.self_development.service; package com.xdap.self_development.service;
import com.xdap.self_development.controller.form.ModelCommon; import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.controller.form.ModelCommonParameterInsertForm; import com.xdap.self_development.pojo.AnalysisCommonParameters;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
public interface CommonParameterService { public interface CommonParameterService {
List<ModelCommonItem> getSystemAndPara();
List<ModelCommon> getModelCommonParameter(@NotBlank String userId); List<ModelCommon> getModelCommonParameter(@NotBlank String userId);
void insertModelCommonParameter(@Valid ModelCommonParameterInsertForm form); void insertModelCommonParameter(@Valid ModelCommonParameterInsertForm form);
void updateModelCommonParameter(@Valid ModelCommonParameterInsertForm form); void updateModelCommonParameter(@Valid ModelCommonParameterUpdateForm form);
List<AnalysisCommonParameters> getAnalysisCommonParameter(@NotBlank String userId);
void insertAnalysisCommonParameter(@Valid AnalysisCommonParameterInsertForm form);
void updateAnalysisCommonParameter(AnalysisCommonParameterUpdateForm form);
} }

View File

@ -1,18 +1,21 @@
package com.xdap.self_development.service.impl; package com.xdap.self_development.service.impl;
import com.xdap.self_development.config.BusinessDatabase; import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.form.ModelCommon; import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.controller.form.ModelCommonItem;
import com.xdap.self_development.controller.form.ModelCommonParameterInsertForm;
import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.pojo.AnalysisCommonParameters;
import com.xdap.self_development.pojo.CommonParameter;
import com.xdap.self_development.pojo.ModelCommonParameters; import com.xdap.self_development.pojo.ModelCommonParameters;
import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.view.ParametersView; import com.xdap.self_development.pojo.view.ParametersView;
import com.xdap.self_development.service.CommonParameterService; import com.xdap.self_development.service.CommonParameterService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -23,44 +26,165 @@ public class CommonParameterServiceImpl implements CommonParameterService {
private BusinessDatabase bd; private BusinessDatabase bd;
@Override @Override
public List<ModelCommon> getModelCommonParameter(String userId) { public List<ModelCommonItem> getSystemAndPara() {
List<ModelCommonParameters> modelCommonParameters = bd.getBusinessDatabase() List<Parameter> parameters = bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("getCommonById") .view("getAllSubsystemAndPara")
.setVar("userId", userId) .doQuery(Parameter.class);
.doQuery(ModelCommonParameters.class);
return convertToModelCommonList(modelCommonParameters); return convertToModelCommonItemList(parameters);
}
@Override
public List<ModelCommon> getModelCommonParameter(String userId) {
List<CommonParameter> commonParameters = bd.getBusinessDatabase()
.eq("create_by", userId)
.eq("common_type", 1)
.doQuery(CommonParameter.class);
List<String> ids = commonParameters.stream().map(CommonParameter::getId).collect(Collectors.toList());
if (ids.isEmpty()) {
return Collections.emptyList();
}
// 数据处理
List<ModelCommonParameters> modelCommonParameters = bd.getBusinessDatabase()
.in("common_id", ids).doQuery(ModelCommonParameters.class);
return convertToModelCommonList(modelCommonParameters, commonParameters);
} }
@Override @Override
@Transactional(rollbackFor = CommonException.class) @Transactional(rollbackFor = CommonException.class)
public void insertModelCommonParameter(ModelCommonParameterInsertForm form) { public void insertModelCommonParameter(ModelCommonParameterInsertForm form) {
// 检查名字是否重复 // 检查名字是否重复
List<ModelCommonParameters> modelCommonParameters = convertToModelCommonParameters(form.getCommon(), form.getUserId()); List<CommonParameter> modelCommonParameters1 = bd.getBusinessDatabase()
.eq("common_name", form.getCommonName()).doQuery(CommonParameter.class);
if (!modelCommonParameters1.isEmpty()) {
throw new CommonException("常用名重复,请重新命名");
}
// 新增常用
CommonParameter commonParameter = new CommonParameter();
commonParameter.setCommonName(form.getCommonName());
commonParameter.setCommonType(1);
commonParameter.setCreateBy(form.getUserId());
bd.getBusinessDatabase().doInsert(commonParameter);
// 关联常用参数
List<ModelCommonParameters> modelCommonParameters =
convertToModelCommonParameters(form.getSubsystems(), commonParameter.getId());
bd.getBusinessDatabase().doBatchInsert(modelCommonParameters); bd.getBusinessDatabase().doBatchInsert(modelCommonParameters);
} }
@Override @Override
@Transactional(rollbackFor = CommonException.class) @Transactional(rollbackFor = CommonException.class)
public void updateModelCommonParameter(ModelCommonParameterInsertForm form) { public void updateModelCommonParameter(ModelCommonParameterUpdateForm form) {
bd.getBusinessDatabase().eq("common_name", form.getCommon().getCommonName()).doDelete(ModelCommonParameters.class); CommonParameter commonParameter = bd.getBusinessDatabase()
insertModelCommonParameter(form); .eq("id", form.getCommonId()).doQueryFirst(CommonParameter.class);
if (commonParameter == null) {
throw new CommonException("无该常用");
}
bd.getBusinessDatabase().eq("common_id", form.getCommonId())
.doDelete(ModelCommonParameters.class);
List<ModelCommonParameters> modelCommonParameters =
convertToModelCommonParameters(form.getSubsystems(), form.getCommonId());
bd.getBusinessDatabase().doBatchInsert(modelCommonParameters);
}
@Override
public List<AnalysisCommonParameters> getAnalysisCommonParameter(String userId) {
List<CommonParameter> commonParameters = bd.getBusinessDatabase()
.eq("create_by", userId)
.eq("common_type", 2)
.doQuery(CommonParameter.class);
List<String> ids = commonParameters.stream().map(CommonParameter::getId).collect(Collectors.toList());
if (ids.isEmpty()) {
return Collections.emptyList();
}
// 数据处理
List<AnalysisCommonParameters> modelCommonParameters = bd.getBusinessDatabase()
.in("common_id", ids).doQuery(AnalysisCommonParameters.class);
return modelCommonParameters;
}
@Override
@Transactional(rollbackFor = CommonException.class)
public void insertAnalysisCommonParameter(AnalysisCommonParameterInsertForm form) {
// 检查名字是否重复
List<CommonParameter> modelCommonParameters1 = bd.getBusinessDatabase()
.eq("common_name", form.getCommonName()).doQuery(CommonParameter.class);
if (!modelCommonParameters1.isEmpty()) {
throw new CommonException("常用名重复,请重新命名");
}
// 新增常用
CommonParameter commonParameter = new CommonParameter();
commonParameter.setCommonName(form.getCommonName());
commonParameter.setCommonType(2);
commonParameter.setCreateBy(form.getUserId());
bd.getBusinessDatabase().doInsert(commonParameter);
// 关联常用参数
AnalysisCommonParameters analysisCommonParameter = new AnalysisCommonParameters();
BeanUtils.copyProperties(form, analysisCommonParameter);
analysisCommonParameter.setCommonId(commonParameter.getId());
bd.getBusinessDatabase().doInsert(analysisCommonParameter);
}
@Override
@Transactional(rollbackFor = CommonException.class)
public void updateAnalysisCommonParameter(AnalysisCommonParameterUpdateForm form) {
CommonParameter commonParameter = bd.getBusinessDatabase()
.eq("id", form.getCommonId()).doQueryFirst(CommonParameter.class);
if (commonParameter == null) {
throw new CommonException("无该常用");
}
AnalysisCommonParameters commonParameters = bd.getBusinessDatabase()
.eq("common_id", form.getCommonId())
.doQueryFirst(AnalysisCommonParameters.class);
BeanUtils.copyProperties(form, commonParameters);
bd.getBusinessDatabase().rowid("id", commonParameter.getRowId()).doUpdate(commonParameter);
}
/**
* Parameter 列表转换为 ModelCommonItem 列表
*/
public static List<ModelCommonItem> convertToModelCommonItemList(List<Parameter> parameterList) {
if (parameterList == null || parameterList.isEmpty()) {
return new ArrayList<>();
}
Map<String, List<Parameter>> groupedBySubsystem = parameterList.stream()
.collect(Collectors.groupingBy(Parameter::getSubsystemName));
List<ModelCommonItem> result = new ArrayList<>();
for (Map.Entry<String, List<Parameter>> entry : groupedBySubsystem.entrySet()) {
ModelCommonItem item = new ModelCommonItem();
item.setSubsystem(entry.getKey());
List<ParametersView> parameters = entry.getValue().stream()
.map(param -> new ParametersView(param.getId(), param.getParameterName()))
.collect(Collectors.toList());
item.setParameters(parameters);
result.add(item);
}
return result;
} }
/** /**
* ModelCommonParameters 列表转换为 ModelCommon 列表 * ModelCommonParameters 列表转换为 ModelCommon 列表
*/ */
private List<ModelCommon> convertToModelCommonList(List<ModelCommonParameters> paramsList) { private List<ModelCommon> convertToModelCommonList(
List<ModelCommonParameters> paramsList, List<CommonParameter> commonParameters
) {
if (paramsList == null || paramsList.isEmpty()) { if (paramsList == null || paramsList.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
Map<String, List<ModelCommonParameters>> groupedByCommonName = paramsList.stream() Map<String, List<ModelCommonParameters>> groupedByCommonId = paramsList.stream()
.collect(Collectors.groupingBy(ModelCommonParameters::getCommonName)); .collect(Collectors.groupingBy(ModelCommonParameters::getCommonId));
List<ModelCommon> result = new ArrayList<>(); List<ModelCommon> result = new ArrayList<>();
for (Map.Entry<String, List<ModelCommonParameters>> commonNameEntry : groupedByCommonName.entrySet()) { for (CommonParameter commonParameter : commonParameters) {
ModelCommon modelCommon = new ModelCommon(); ModelCommon modelCommon = new ModelCommon();
modelCommon.setCommonName(commonNameEntry.getKey()); modelCommon.setCommonName(commonParameter.getCommonName());
Map<String, List<ModelCommonParameters>> groupedBySubsystem = commonNameEntry.getValue().stream() modelCommon.setCommonId(commonParameter.getId());
Map<String, List<ModelCommonParameters>> groupedBySubsystem =
groupedByCommonId.get(modelCommon.getCommonId()).stream()
.collect(Collectors.groupingBy(ModelCommonParameters::getSubsystem)); .collect(Collectors.groupingBy(ModelCommonParameters::getSubsystem));
List<ModelCommonItem> items = new ArrayList<>(); List<ModelCommonItem> items = new ArrayList<>();
for (Map.Entry<String, List<ModelCommonParameters>> subsystemEntry : groupedBySubsystem.entrySet()) { for (Map.Entry<String, List<ModelCommonParameters>> subsystemEntry : groupedBySubsystem.entrySet()) {
@ -82,23 +206,17 @@ public class CommonParameterServiceImpl implements CommonParameterService {
* 将ModelCommon 转换为 ModelCommonParameters 列表 * 将ModelCommon 转换为 ModelCommonParameters 列表
*/ */
private List<ModelCommonParameters> convertToModelCommonParameters( private List<ModelCommonParameters> convertToModelCommonParameters(
ModelCommon modelCommon, String userId) { List<ModelCommonItem> commonItems, String commonId) {
if (modelCommon == null) {
return new ArrayList<>();
}
List<ModelCommonParameters> result = new ArrayList<>(); List<ModelCommonParameters> result = new ArrayList<>();
String commonName = modelCommon.getCommonName(); if (commonItems != null) {
if (modelCommon.getSubsystems() != null) { for (ModelCommonItem item : commonItems) {
for (ModelCommonItem item : modelCommon.getSubsystems()) {
String subsystem = item.getSubsystem(); String subsystem = item.getSubsystem();
if (item.getParameters() != null) { if (item.getParameters() != null) {
for (ParametersView paramView : item.getParameters()) { for (ParametersView paramView : item.getParameters()) {
ModelCommonParameters param = new ModelCommonParameters(); ModelCommonParameters param = new ModelCommonParameters();
param.setSubsystem(subsystem); param.setSubsystem(subsystem);
param.setParameterId(paramView.getParameterId()); param.setParameterId(paramView.getParameterId());
param.setUserId(userId); param.setCommonId(commonId);
param.setCommonName(commonName);
param.setParameterName(paramView.getParameterName());
result.add(param); result.add(param);
} }
} }

View File

@ -3,7 +3,7 @@ package com.xdap.self_development.service.impl;
import com.xdap.self_development.config.BusinessDatabase; import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.request.ModelRolesRequest; import com.xdap.self_development.controller.request.ModelRolesRequest;
import com.xdap.self_development.pojo.ModelMenuPermissionPojo; import com.xdap.self_development.pojo.ModelMenuDictionaryPojo;
import com.xdap.self_development.pojo.ModelRolesPojo; import com.xdap.self_development.pojo.ModelRolesPojo;
import com.xdap.self_development.pojo.view.MenuListView; import com.xdap.self_development.pojo.view.MenuListView;
import com.xdap.self_development.service.ModelMenuPermissionService; import com.xdap.self_development.service.ModelMenuPermissionService;
@ -31,10 +31,10 @@ public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionServic
Map<String, MenuListView> nodeMap = new HashMap<>(); Map<String, MenuListView> nodeMap = new HashMap<>();
List<MenuListView> views = new ArrayList<>(); List<MenuListView> views = new ArrayList<>();
List<ModelMenuPermissionPojo> permissionPojos = businessDatabase.getBusinessDatabase() List<ModelMenuDictionaryPojo> permissionPojos = businessDatabase.getBusinessDatabase()
.doQuery(ModelMenuPermissionPojo.class); .doQuery(ModelMenuDictionaryPojo.class);
for (ModelMenuPermissionPojo pojo : permissionPojos) { for (ModelMenuDictionaryPojo pojo : permissionPojos) {
MenuListView node = new MenuListView(); MenuListView node = new MenuListView();
node.setId(pojo.getId()); node.setId(pojo.getId());
node.setMenu(pojo.getMenuName()); node.setMenu(pojo.getMenuName());
@ -42,7 +42,7 @@ public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionServic
nodeMap.put(pojo.getId(), node); nodeMap.put(pojo.getId(), node);
} }
for (ModelMenuPermissionPojo pojo : permissionPojos) { for (ModelMenuDictionaryPojo pojo : permissionPojos) {
String parentId = pojo.getParentId(); String parentId = pojo.getParentId();
MenuListView currentNode = nodeMap.get(pojo.getId()); MenuListView currentNode = nodeMap.get(pojo.getId());

View File

@ -71,8 +71,6 @@ public class ParameterServiceImpl implements ParameterService {
// 获取基准模板和最新模板 // 获取基准模板和最新模板
TemplateBenchmark benchmark = getTemplateBenchmark(form.getTemplateRowId()); TemplateBenchmark benchmark = getTemplateBenchmark(form.getTemplateRowId());
// todo 根据上传的部分参数更新模板
// todo 部分维护的参数同步到最新的草稿中
Template newVersionTemplate; Template newVersionTemplate;
// 如果当前修改的模板为最新版并且为草稿状态就不需要新建版本 // 如果当前修改的模板为最新版并且为草稿状态就不需要新建版本
if (Objects.equals(benchmark.getLastTemplate().getId(), benchmark.getBaseTemplate().getId()) if (Objects.equals(benchmark.getLastTemplate().getId(), benchmark.getBaseTemplate().getId())
@ -82,6 +80,16 @@ public class ParameterServiceImpl implements ParameterService {
} }
// 否则创建新版本 // 否则创建新版本
else { else {
switch (benchmark.getLastTemplate().getStatus()) {
// 如果最新版本为草稿状态沿用该版本
case "DRAFT":
newVersionTemplate = benchmark.getLastTemplate();
break;
// 如果最新版本为审核中则不允许新建版本
case "APPROVING":
throw new CommonException("最新模板审核中,暂时无法新建版本");
// 如果最新版本为已完成创建新版本
default:
newVersionTemplate = new Template( newVersionTemplate = new Template(
benchmark.getLastTemplate().getTemplateName(), calculateNextVersion(benchmark.getLastTemplate().getVersion()), benchmark.getLastTemplate().getTemplateName(), calculateNextVersion(benchmark.getLastTemplate().getVersion()),
"DRAFT", Timestamp.valueOf(LocalDateTime.now()), null, form.getCreateBy() "DRAFT", Timestamp.valueOf(LocalDateTime.now()), null, form.getCreateBy()
@ -89,6 +97,7 @@ public class ParameterServiceImpl implements ParameterService {
// 保存新模板 // 保存新模板
bd.getBusinessDatabase().doInsert(newVersionTemplate); bd.getBusinessDatabase().doInsert(newVersionTemplate);
} }
}
// 4. 处理参数变更 // 4. 处理参数变更
ParameterProcessingResult processingResult = processParameters( ParameterProcessingResult processingResult = processParameters(

View File

@ -269,7 +269,22 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
if (!Objects.equals(flow.getCreateBy(), request.getUserId())) { if (!Objects.equals(flow.getCreateBy(), request.getUserId())) {
throw new CommonException("不是申请人无法撤回"); throw new CommonException("不是申请人无法撤回");
} }
if (!Objects.equals(flow.getCurrentNode(), "PROOFREAD")) {
throw new CommonException("已进入流程无法撤回");
}
if (!Objects.equals(flow.getFlowStatus(), "APPROVING")) {
throw new CommonException("不在流程无法撤回");
}
if ("RETURN".equals(request.getResult())) { if ("RETURN".equals(request.getResult())) {
ApprovalRecord record = new ApprovalRecord();
record.setFlowId(flow.getId());
record.setNode(flow.getCurrentNode());
record.setUserId(request.getUserId());
record.setOpinion(request.getOpinion());
record.setResult(request.getResult());
record.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
bd.getBusinessDatabase().doInsert(record);
// 申请人撤回 // 申请人撤回
cancelProcess(flow, "RETURNED"); cancelProcess(flow, "RETURNED");
} { } {
@ -371,7 +386,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
flow.setFlowStatus(status); flow.setFlowStatus(status);
bd.getBusinessDatabase() bd.getBusinessDatabase()
.rowid("id", flow.getRowId()) .rowid("id", flow.getRowId())
.update("status", flow.getFlowStatus()) .update("flow_status", flow.getFlowStatus())
.doUpdate(ApprovalFlow.class); .doUpdate(ApprovalFlow.class);
// 更新模板状态(重新打回草稿状态) // 更新模板状态(重新打回草稿状态)
Template template = bd.getBusinessDatabase() Template template = bd.getBusinessDatabase()

View File

@ -54,17 +54,17 @@ public class TemplateServiceImpl implements TemplateService {
.eq("template_name", form.getTemplateName()) .eq("template_name", form.getTemplateName())
.doQueryFirst(Template.class); .doQueryFirst(Template.class);
// 如果有同名称模板
if (template != null) {
throw new CommonException("已有同名版本,不允许新建模板");
}
// 创建新模板 // 创建新模板
Template newTemplate = new Template( Template newTemplate = new Template(
form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()), form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
null, form.getCreateBy() null, form.getCreateBy()
); );
// 如果有同名称模板
if (template != null) {
throw new CommonException("已有同名版本,导入失败");
}
bd.getBusinessDatabase().doInsert(newTemplate); bd.getBusinessDatabase().doInsert(newTemplate);
} }
@ -248,11 +248,7 @@ public class TemplateServiceImpl implements TemplateService {
problems.setFlag(true); problems.setFlag(true);
problems.getErrors().add("模板‘"+templateName+"‘的最新版本正在审核中,无法导入"); problems.getErrors().add("模板‘"+templateName+"‘的最新版本正在审核中,无法导入");
return; return;
case "RETURNED": // 最新版本已发布增加版本号新增
problems.setFlag(true);
problems.getErrors().add("模板‘"+templateName+"’的最新版本已被退回,无法导入");
return;
// 最新版本已发布或已退回增加版本号新增
default: default:
lastTemplate = new Template( lastTemplate = new Template(
templateName, lastTemplate.getVersion()+1, "DRAFT", templateName, lastTemplate.getVersion()+1, "DRAFT",

View File

@ -1,14 +1,23 @@
DROP TABLE IF EXISTS yfsjglpt_common_parameter;
CREATE TABLE yfsjglpt_common_parameter (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
`common_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用名称',
`common_type` int COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用类型',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='常用参数表';
DROP TABLE IF EXISTS yfsjglpt_model_common_parameters;
-- 新增机型参数常用参数表 -- 新增机型参数常用参数表
CREATE TABLE yfsjglpt_model_common_parameters ( CREATE TABLE yfsjglpt_model_common_parameters (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID', `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
`subsystem` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '子系统', `subsystem` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '子系统',
`parameter_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数ID', `parameter_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数ID',
`user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户ID', `common_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用id',
`common_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用名称',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='机型参数常用参数表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='机型参数常用参数表';
DROP TABLE IF EXISTS yfsjglpt_analysis_common_parameters;
-- 新增分析常用参数表 -- 新增分析常用参数表
CREATE TABLE yfsjglpt_analysis_common_parameters ( CREATE TABLE yfsjglpt_analysis_common_parameters (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID', `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
@ -18,11 +27,11 @@ CREATE TABLE yfsjglpt_analysis_common_parameters (
`series` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '系列', `series` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '系列',
`project_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目名称', `project_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目名称',
`project_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目编号', `project_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目编号',
`emission` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放', `emission` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放',
`displacement_min` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放下限', `displacement_min` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放下限',
`displacement_max` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放上限', `displacement_max` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放上限',
`combustion_type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '燃烧类型', `combustion_type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '燃烧类型',
`user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户ID', `common_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用id',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='统计分析常用参数表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='统计分析常用参数表';