修改:对标报告逻辑问题
This commit is contained in:
parent
793764326f
commit
7eae9974f8
@ -1,6 +1,7 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||||
@ -77,7 +78,7 @@ public class BenchmarkingReportController {
|
|||||||
throw new CommonException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
List<TodoAndReportView> list = benchmarkingReportService
|
PageQueryResult<TodoAndReportView> list = benchmarkingReportService
|
||||||
.getBenchmarkingReportByCondition(form);
|
.getBenchmarkingReportByCondition(form);
|
||||||
return Response.ok().data(list);
|
return Response.ok().data(list);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,11 +4,13 @@ import com.definesys.mpaas.common.http.Response;
|
|||||||
import com.definesys.mpaas.query.MpaasQueryFactory;
|
import com.definesys.mpaas.query.MpaasQueryFactory;
|
||||||
import com.xdap.motor.entity.SnowflakeIdWorker;
|
import com.xdap.motor.entity.SnowflakeIdWorker;
|
||||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||||
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.common.UserPermissionGetter;
|
import com.xdap.self_development.common.UserPermissionGetter;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||||
import com.xdap.self_development.pojo.ClassificationAttribute;
|
import com.xdap.self_development.pojo.ClassificationAttribute;
|
||||||
import com.xdap.self_development.pojo.EnginePartsCollection;
|
import com.xdap.self_development.pojo.EnginePartsCollection;
|
||||||
|
import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -35,12 +37,20 @@ public class DeleteController {
|
|||||||
private RuntimeAppContextService runtimeAppContextService;
|
private RuntimeAppContextService runtimeAppContextService;
|
||||||
@Resource
|
@Resource
|
||||||
private SnowflakeIdWorker snowflakeIdWorker;
|
private SnowflakeIdWorker snowflakeIdWorker;
|
||||||
|
@Resource
|
||||||
|
private ParameterValueCalculationTimer timer;
|
||||||
|
|
||||||
@Value("${apaas.token.clientId}")
|
@Value("${apaas.token.clientId}")
|
||||||
private String clientId;
|
private String clientId;
|
||||||
@Value("${apaas.token.clientSecred}")
|
@Value("${apaas.token.clientSecred}")
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
|
|
||||||
|
@GetMapping("/timer")
|
||||||
|
public Response timer() {
|
||||||
|
MyResponse myResponse = timer.dailyCalculate();
|
||||||
|
return Response.ok().data(myResponse);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/getTC")
|
@GetMapping("/getTC")
|
||||||
public Response getTC(
|
public Response getTC(
|
||||||
@RequestParam String productNumber,
|
@RequestParam String productNumber,
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package com.xdap.self_development.controller.form;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApprovalListForm {
|
public class ApprovalListForm {
|
||||||
@ -10,5 +12,13 @@ public class ApprovalListForm {
|
|||||||
private String username;
|
private String username;
|
||||||
private String createDate;
|
private String createDate;
|
||||||
private String status;
|
private String status;
|
||||||
|
@NotBlank(message = "用户不能为空")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
@NotNull(message = "页码不能为空")
|
||||||
|
@Min(value = 1, message = "页码不能小于1")
|
||||||
|
private Integer pageNumber;
|
||||||
|
|
||||||
|
@NotNull(message = "每页条数不能为空")
|
||||||
|
@Min(value = 1, message = "每页条数不能小于1")
|
||||||
|
private Integer pageSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package com.xdap.self_development.controller.form;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BenchmarkingReportPageForm {
|
public class BenchmarkingReportPageForm {
|
||||||
@ -22,11 +24,11 @@ public class BenchmarkingReportPageForm {
|
|||||||
@NotBlank(message = "上传用户不能为空")
|
@NotBlank(message = "上传用户不能为空")
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
// @NotNull(message = "页码不能为空")
|
@NotNull(message = "页码不能为空")
|
||||||
// @Min(value = 1, message = "页码不能小于1")
|
@Min(value = 1, message = "页码不能小于1")
|
||||||
// private Integer pageNumber;
|
private Integer pageNumber;
|
||||||
//
|
|
||||||
// @NotNull(message = "每页条数不能为空")
|
@NotNull(message = "每页条数不能为空")
|
||||||
// @Min(value = 1, message = "每页条数不能小于1")
|
@Min(value = 1, message = "每页条数不能小于1")
|
||||||
// private Integer pageSize;
|
private Integer pageSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public class BenchmarkingReport extends MpaasBasePojo {
|
|||||||
private String projectName;
|
private String projectName;
|
||||||
private String projectNumber;
|
private String projectNumber;
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Timestamp uploadTime;
|
private Timestamp uploadTime;
|
||||||
|
|||||||
@ -6,8 +6,11 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SQLQuery(value = {
|
@SQLQuery(value = {
|
||||||
|
@SQL(view = "getAllReportApproval",
|
||||||
|
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.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 af.flow_type = 2 ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"),
|
||||||
@SQL(view = "getReportByUserIdAndIds",
|
@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 = "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(view = "getTodoAndReport",
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@SQLQuery(value = {
|
@SQLQuery(value = {
|
||||||
@SQL(view = "getAllApproval",
|
@SQL(view = "getAllApproval",
|
||||||
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 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"),
|
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 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"),
|
||||||
@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",
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package com.xdap.self_development.schedule;
|
package com.xdap.self_development.schedule;
|
||||||
|
|
||||||
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.exception.CommonException;
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.ClassificationAttribute;
|
import com.xdap.self_development.pojo.ClassificationAttribute;
|
||||||
import com.xdap.self_development.pojo.EnginePartsCollection;
|
import com.xdap.self_development.pojo.EnginePartsCollection;
|
||||||
import com.xdap.self_development.pojo.view.CalculationParameterView;
|
import com.xdap.self_development.pojo.view.CalculationParameterView;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -23,11 +25,16 @@ import java.util.stream.Collectors;
|
|||||||
public class ParameterValueCalculationTimer {
|
public class ParameterValueCalculationTimer {
|
||||||
@Resource
|
@Resource
|
||||||
private BusinessDatabase bd;
|
private BusinessDatabase bd;
|
||||||
// @Scheduled(cron = "0 0 0 * * ?")
|
|
||||||
|
// @Scheduled(cron = "0 0 0 * * ?")
|
||||||
// @Scheduled(cron = "0 */1 * * * *")
|
// @Scheduled(cron = "0 */1 * * * *")
|
||||||
public void dailyCalculate() {
|
public MyResponse dailyCalculate() {
|
||||||
|
MyResponse myResponse = new MyResponse();
|
||||||
|
myResponse.setErrors(new ArrayList<>());
|
||||||
|
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
log.info("开始执行{}参数计算任务", today);
|
log.info("开始执行{}参数计算任务", today);
|
||||||
|
myResponse.getErrors().add("开始执行"+today+"参数计算任务");
|
||||||
List<CalculationParameterView> toUpdate = new ArrayList<>();
|
List<CalculationParameterView> toUpdate = new ArrayList<>();
|
||||||
|
|
||||||
// 1.查询所有参数配置
|
// 1.查询所有参数配置
|
||||||
@ -37,26 +44,30 @@ public class ParameterValueCalculationTimer {
|
|||||||
.doQuery(CalculationParameterView.class);
|
.doQuery(CalculationParameterView.class);
|
||||||
if (parameterValues.isEmpty()) {
|
if (parameterValues.isEmpty()) {
|
||||||
log.info("无参数配置,跳过计算");
|
log.info("无参数配置,跳过计算");
|
||||||
return;
|
return myResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.从中台更新参数值
|
// 2.从中台更新参数值
|
||||||
for (CalculationParameterView parameter : parameterValues) {
|
for (CalculationParameterView parameter : parameterValues) {
|
||||||
if (Objects.equals(parameter.getParameterSource(), "TC分类表")) {
|
if (Objects.equals(parameter.getParameterSource(), "TC分类表")) {
|
||||||
EnginePartsCollection enginePartsCollection = bd.getBusinessDatabase()
|
try {
|
||||||
.eq("ztj", parameter.getProductNumber())
|
EnginePartsCollection enginePartsCollection = bd.getBusinessDatabase()
|
||||||
.eq("lbjmc", parameter.getPartsName())
|
.eq("ztj", parameter.getProductNumber())
|
||||||
.doQueryFirst(EnginePartsCollection.class);
|
.eq("lbjmc", parameter.getPartsName())
|
||||||
if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) {
|
.doQueryFirst(EnginePartsCollection.class);
|
||||||
continue;
|
if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) {
|
||||||
}
|
continue;
|
||||||
ClassificationAttribute classificationAttribute = bd.getBusinessDatabase()
|
}
|
||||||
.eq("pitemId", enginePartsCollection.getLbjth())
|
ClassificationAttribute classificationAttribute = bd.getBusinessDatabase()
|
||||||
.eq("idattrtbutehame", parameter.getParameterName())
|
.eq("pitemId", enginePartsCollection.getLbjth())
|
||||||
.doQueryFirst(ClassificationAttribute.class);
|
.eq("idattrtbutehame", parameter.getParameterName())
|
||||||
if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) {
|
.doQueryFirst(ClassificationAttribute.class);
|
||||||
parameter.setParameterValue(classificationAttribute.getFieldvalue());
|
if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) {
|
||||||
toUpdate.add(parameter);
|
parameter.setParameterValue(classificationAttribute.getFieldvalue());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("参数【{}】从中台更新值失败:{}", parameter.getParameterName(), e.getMessage(), e);
|
||||||
|
myResponse.getErrors().add("参数【"+parameter.getParameterName()+"】从中台更新值失败:"+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,30 +89,34 @@ public class ParameterValueCalculationTimer {
|
|||||||
String replacedFormula = replaceParametersInFormula(formula, parameterNames, originalValueMap, modelId);
|
String replacedFormula = replaceParametersInFormula(formula, parameterNames, originalValueMap, modelId);
|
||||||
Double result = calculateExpression(replacedFormula);
|
Double result = calculateExpression(replacedFormula);
|
||||||
String formattedResult = String.format("%.6f", result);
|
String formattedResult = String.format("%.6f", result);
|
||||||
log.info("计算结果:{}", formattedResult);
|
|
||||||
parameterValue.setParameterValue(formattedResult);
|
parameterValue.setParameterValue(formattedResult);
|
||||||
toUpdate.add(parameterValue);
|
toUpdate.add(parameterValue);
|
||||||
log.info("参数【{}】计算结果:{}", parameterValue.getParameterName(), formattedResult);
|
log.info("参数【{}】计算结果:{}", parameterValue.getParameterName(), formattedResult);
|
||||||
|
myResponse.getErrors().add("参数【"+parameterValue.getParameterName()+"】计算结果:"+formattedResult);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("参数【{}】计算失败:{},公式:{},模型ID:{}",
|
log.error("参数【{}】计算失败:{},公式:{},模型ID:{}",
|
||||||
parameterValue.getParameterName(), e.getMessage(), formula, modelId);
|
parameterValue.getParameterName(), e.getMessage(), formula, modelId, e);
|
||||||
throw new RuntimeException("参数【" + parameterValue.getParameterName() + "】计算失败:" + e.getMessage());
|
myResponse.getErrors().add("参数【"+parameterValue.getParameterName()+"】计算失败:"+e.getMessage()+",公式:"+formula+"模型ID:"+modelId);
|
||||||
|
parameterValue.setParameterValue(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量插入或更新计算结果
|
// 批量插入或更新计算结果
|
||||||
if (!toUpdate.isEmpty()) {
|
// if (!toUpdate.isEmpty()) {
|
||||||
toUpdate.forEach(parameterValue -> {
|
// toUpdate.forEach(parameterValue -> {
|
||||||
bd.getBusinessDatabase()
|
// if (parameterValue.getParameterValue() != null) {
|
||||||
.table("engine_param_detail")
|
// bd.getBusinessDatabase()
|
||||||
.eq("id", parameterValue.getId())
|
// .table("engine_param_detail")
|
||||||
.update("parameter_value", parameterValue.getParameterValue())
|
// .eq("id", parameterValue.getId())
|
||||||
.doUpdate();
|
// .update("parameter_value", parameterValue.getParameterValue())
|
||||||
});
|
// .doUpdate();
|
||||||
}
|
// }
|
||||||
log.info("{}参数计算完成,共处理{}个参数", today, toUpdate.size());
|
// });
|
||||||
|
// }
|
||||||
|
// log.info("{}参数计算完成,成功处理{}个参数,失败参数已跳过", today, toUpdate.stream()
|
||||||
|
// .filter(p -> p.getParameterValue() != null).count());
|
||||||
|
return myResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String replaceParametersInFormula(String formula, List<String> parameterNames,
|
private String replaceParametersInFormula(String formula, List<String> parameterNames,
|
||||||
@ -114,7 +129,6 @@ public class ParameterValueCalculationTimer {
|
|||||||
String value = getParameterValue(valueMap, paramName, modelId);
|
String value = getParameterValue(valueMap, paramName, modelId);
|
||||||
result = result.replaceAll(pattern, value);
|
result = result.replaceAll(pattern, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,12 +144,10 @@ public class ParameterValueCalculationTimer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Double calculateExpression(String expression) throws RuntimeException {
|
private Double calculateExpression(String expression) throws RuntimeException {
|
||||||
|
|
||||||
Double result = calculateWithScriptEngine(expression);
|
Double result = calculateWithScriptEngine(expression);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException("无法计算表达式: " + expression);
|
throw new RuntimeException("无法计算表达式: " + expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +164,7 @@ public class ParameterValueCalculationTimer {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("ScriptEngine计算失败: {}, 错误: {}", expression, e.getMessage());
|
log.warn("ScriptEngine计算失败: {}, 错误: {}", expression, e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +181,6 @@ public class ParameterValueCalculationTimer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +190,6 @@ public class ParameterValueCalculationTimer {
|
|||||||
if (list == null) {
|
if (list == null) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数名在所有子系统都唯一
|
// 参数名在所有子系统都唯一
|
||||||
// 转为以参数名为key,(机型代号为key,参数值为值)为值的形式
|
// 转为以参数名为key,(机型代号为key,参数值为值)为值的形式
|
||||||
return list.stream()
|
return list.stream()
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.xdap.self_development.service;
|
package com.xdap.self_development.service;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||||
@ -14,7 +15,7 @@ import javax.validation.constraints.NotBlank;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface BenchmarkingReportService {
|
public interface BenchmarkingReportService {
|
||||||
List<TodoAndReportView> getBenchmarkingReportByCondition(@Valid BenchmarkingReportPageForm form);
|
PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(@Valid BenchmarkingReportPageForm form);
|
||||||
|
|
||||||
void saveBenchmarkingReport(@Valid SaveBenchmarkingReportForm form);
|
void saveBenchmarkingReport(@Valid SaveBenchmarkingReportForm form);
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface TemplateApprovalService {
|
public interface TemplateApprovalService {
|
||||||
String startApproval(StartApprovalRequest request);
|
String startApproval(StartApprovalRequest request);
|
||||||
List<TodoAndTemplateView> getApprovalList(ApprovalListForm form);
|
PageQueryResult<TodoAndTemplateView> getApprovalList(ApprovalListForm form);
|
||||||
void handleApproval(HandleApprovalRequest request);
|
void handleApproval(HandleApprovalRequest request);
|
||||||
PageQueryResult<TemplateChangeView> getTemplateChanges(@Valid ApprovalAndParameterForm form);
|
PageQueryResult<TemplateChangeView> getTemplateChanges(@Valid ApprovalAndParameterForm form);
|
||||||
ApprovalFlowView getApprovalProcess(@Valid ApprovalFlowForm form);
|
ApprovalFlowView getApprovalProcess(@Valid ApprovalFlowForm form);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xdap.self_development.service.impl;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||||
import com.xdap.self_development.common.UserPermissionGetter;
|
import com.xdap.self_development.common.UserPermissionGetter;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
@ -75,6 +76,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||||
report.setStatus("APPROVING");
|
report.setStatus("APPROVING");
|
||||||
report.setCreateBy(form.getUserId());
|
report.setCreateBy(form.getUserId());
|
||||||
|
report.setIsDelete(0);
|
||||||
bd.getBusinessDatabase().doInsert(report);
|
bd.getBusinessDatabase().doInsert(report);
|
||||||
// 2. 创建审批流程
|
// 2. 创建审批流程
|
||||||
ApprovalFlow flow = new ApprovalFlow();
|
ApprovalFlow flow = new ApprovalFlow();
|
||||||
@ -129,17 +131,20 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restartReportApproval(UpdateBenchmarkingReportForm form) {
|
public void restartReportApproval(UpdateBenchmarkingReportForm form) {
|
||||||
BenchmarkingReport originalReport = bd.getBusinessDatabase()
|
bd.getBusinessDatabase()
|
||||||
.eq("id", form.getReportId()).doQueryFirst(BenchmarkingReport.class);
|
.eq("id", form.getReportId())
|
||||||
BeanUtils.copyProperties(form, originalReport);
|
.update("is_delete", 1)
|
||||||
originalReport.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
.doUpdate(BenchmarkingReport.class);
|
||||||
originalReport.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
BenchmarkingReport report = new BenchmarkingReport();
|
||||||
originalReport.setStatus("APPROVING");
|
BeanUtils.copyProperties(form, report);
|
||||||
originalReport.setCreateBy(form.getCreateBy());
|
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||||
bd.getBusinessDatabase().doUpdate(originalReport);
|
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||||
|
report.setStatus("APPROVING");
|
||||||
|
report.setCreateBy(form.getCreateBy());
|
||||||
|
bd.getBusinessDatabase().doInsert(report);
|
||||||
|
|
||||||
ApprovalFlow flow = new ApprovalFlow();
|
ApprovalFlow flow = new ApprovalFlow();
|
||||||
flow.setTemplateId(originalReport.getId());
|
flow.setTemplateId(report.getId());
|
||||||
flow.setCurrentNode("PROOFREAD");
|
flow.setCurrentNode("PROOFREAD");
|
||||||
flow.setFlowStatus("APPROVING");
|
flow.setFlowStatus("APPROVING");
|
||||||
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
||||||
@ -189,15 +194,13 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
|
public PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
|
||||||
List<TodoAndReportView> approvalList = new ArrayList<>();
|
// List<TodoAndReportView> approvalList = new ArrayList<>();
|
||||||
Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy())));
|
// Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getCreateBy())));
|
||||||
List<String> ids = new ArrayList<>(flowIds);
|
// List<String> ids = new ArrayList<>(flowIds);
|
||||||
List<TodoAndReportView> todoList =bd.getBusinessDatabase()
|
PageQueryResult<TodoAndReportView> result = bd.getBusinessDatabase()
|
||||||
.viewQueryMode(true)
|
.viewQueryMode(true)
|
||||||
.view("getTodoAndReport")
|
.view("getAllReportApproval")
|
||||||
.setVar("ids", ids)
|
|
||||||
.setVar("createBy", form.getCreateBy())
|
|
||||||
.setVar("title", form.getTitle())
|
.setVar("title", form.getTitle())
|
||||||
.setVar("manufacturerName", form.getManufacturerName())
|
.setVar("manufacturerName", form.getManufacturerName())
|
||||||
.setVar("modelName", form.getModelName())
|
.setVar("modelName", form.getModelName())
|
||||||
@ -210,19 +213,36 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
.setVar("projectName", form.getProjectName())
|
.setVar("projectName", form.getProjectName())
|
||||||
.setVar("projectNumber", form.getProjectNumber())
|
.setVar("projectNumber", form.getProjectNumber())
|
||||||
.setVar("status", form.getStatus())
|
.setVar("status", form.getStatus())
|
||||||
.doQuery(TodoAndReportView.class);
|
.doPageQuery(form.getPageNumber(), form.getPageSize(), TodoAndReportView.class);
|
||||||
setCurrentApprovers(approvalList, todoList);
|
// List<TodoAndReportView> todoList = bd.getBusinessDatabase()
|
||||||
return approvalList;
|
// .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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrentApprovers(List<TodoAndReportView> approvalList, List<TodoAndReportView> todoAndReportViews) {
|
private void setCurrentApprovers(PageQueryResult<TodoAndReportView> result) {
|
||||||
todoAndReportViews.forEach(item -> {
|
result.getResult().forEach(item -> {
|
||||||
ApprovalXdapUsers approvalXdapUser = bd.getBusinessDatabase()
|
ApprovalXdapUsers approvalXdapUser = bd.getBusinessDatabase()
|
||||||
.eq("id", item.getCreateBy())
|
.eq("id", item.getCreateBy())
|
||||||
.doQueryFirst(ApprovalXdapUsers.class);
|
.doQueryFirst(ApprovalXdapUsers.class);
|
||||||
item.setCreateBy(approvalXdapUser == null ? item.getCreateBy() : approvalXdapUser.getUsername());
|
item.setCreateBy(approvalXdapUser == null ? item.getCreateBy() : approvalXdapUser.getUsername());
|
||||||
});
|
});
|
||||||
approvalList.addAll(todoAndReportViews);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -212,7 +212,7 @@ public class CommonParameterServiceImpl implements CommonParameterService {
|
|||||||
.map(param -> new ParametersView(
|
.map(param -> new ParametersView(
|
||||||
param.getParameterId(),
|
param.getParameterId(),
|
||||||
param.getParameterName(),
|
param.getParameterName(),
|
||||||
param.getSubsystemName(),
|
param.getParameterType(),
|
||||||
param.getSubsystemName(),
|
param.getSubsystemName(),
|
||||||
param.getPartsName()
|
param.getPartsName()
|
||||||
))
|
))
|
||||||
|
|||||||
@ -141,31 +141,34 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<TodoAndTemplateView> getApprovalList(ApprovalListForm form) {
|
public PageQueryResult<TodoAndTemplateView> getApprovalList(ApprovalListForm form) {
|
||||||
// List<TodoAndTemplateView> todoAndTemplateViews = bd.getBusinessDatabase()
|
// List<TodoAndTemplateView> approvalList = new ArrayList<>();
|
||||||
// .viewQueryMode(true)
|
// Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getUserId())));
|
||||||
// .view("getAllApproval")
|
// List<String> ids = new ArrayList<>(flowIds);
|
||||||
// .doQuery(TodoAndTemplateView.class);
|
PageQueryResult<TodoAndTemplateView> result = bd.getBusinessDatabase()
|
||||||
List<TodoAndTemplateView> approvalList = new ArrayList<>();
|
|
||||||
Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getUserId())));
|
|
||||||
List<String> ids = new ArrayList<>(flowIds);
|
|
||||||
List<TodoAndTemplateView> todoList =bd.getBusinessDatabase()
|
|
||||||
.viewQueryMode(true)
|
.viewQueryMode(true)
|
||||||
.view("getTodoAndTemplate")
|
.view("getAllApproval")
|
||||||
.setVar("ids", ids)
|
|
||||||
.setVar("createBy", form.getUserId())
|
|
||||||
.setVar("templateName", form.getTemplateName())
|
.setVar("templateName", form.getTemplateName())
|
||||||
.setVar("status", form.getStatus())
|
.setVar("status", form.getStatus())
|
||||||
.setVar("createdTime", form.getCreateDate() == null ? "" : form.getCreateDate())
|
.setVar("createdTime", form.getCreateDate() == null ? "" : form.getCreateDate())
|
||||||
.setVar("username",form.getUsername())
|
.setVar("username", form.getUsername())
|
||||||
.doQuery(TodoAndTemplateView.class);
|
.doPageQuery(form.getPageNumber(), form.getPageSize(), TodoAndTemplateView.class);
|
||||||
setCurrentApprovers(approvalList, todoList);
|
// List<TodoAndTemplateView> todoList =bd.getBusinessDatabase()
|
||||||
return approvalList;
|
// .viewQueryMode(true)
|
||||||
// return todoAndTemplateViews;
|
// .view("getTodoAndTemplate")
|
||||||
|
// .setVar("ids", ids)
|
||||||
|
// .setVar("createBy", form.getUserId())
|
||||||
|
// .setVar("templateName", form.getTemplateName())
|
||||||
|
// .setVar("status", form.getStatus())
|
||||||
|
// .setVar("createdTime", form.getCreateDate() == null ? "" : form.getCreateDate())
|
||||||
|
// .setVar("username",form.getUsername())
|
||||||
|
// .doQuery(TodoAndTemplateView.class);
|
||||||
|
setCurrentApprovers(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrentApprovers(List<TodoAndTemplateView> approvalList, List<TodoAndTemplateView> todoAndTemplateViews) {
|
private void setCurrentApprovers(PageQueryResult<TodoAndTemplateView> result) {
|
||||||
todoAndTemplateViews.forEach(item -> {
|
result.getResult().forEach(item -> {
|
||||||
if (item.getCurrentUsers() == null || item.getCurrentUsers().isEmpty()) {
|
if (item.getCurrentUsers() == null || item.getCurrentUsers().isEmpty()) {
|
||||||
item.setCurrentApprovers(null);
|
item.setCurrentApprovers(null);
|
||||||
item.setCurrentUsers(null);
|
item.setCurrentUsers(null);
|
||||||
@ -178,7 +181,6 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
item.setCurrentUsers(null);
|
item.setCurrentUsers(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
approvalList.addAll(todoAndTemplateViews);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user