diff --git a/pom.xml b/pom.xml index b1e3f8f..7388830 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ + zjh 1.8 2.9.2-01 2.4.3-01 @@ -60,7 +61,7 @@ org.projectlombok lombok - 1.18.12 + 1.18.20 true diff --git a/src/main/java/com/xdap/self_development/MainApplication.java b/src/main/java/com/xdap/self_development/MainApplication.java index 0244593..f0f6e89 100644 --- a/src/main/java/com/xdap/self_development/MainApplication.java +++ b/src/main/java/com/xdap/self_development/MainApplication.java @@ -3,7 +3,6 @@ package com.xdap.self_development; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; -import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/src/main/java/com/xdap/self_development/controller/AnalysisCommonController.java b/src/main/java/com/xdap/self_development/controller/AnalysisCommonController.java index dd38804..4c6eff2 100644 --- a/src/main/java/com/xdap/self_development/controller/AnalysisCommonController.java +++ b/src/main/java/com/xdap/self_development/controller/AnalysisCommonController.java @@ -1,17 +1,14 @@ package com.xdap.self_development.controller; import com.definesys.mpaas.common.http.Response; -import com.xdap.self_development.controller.request.AnalysisRequest; import com.xdap.self_development.controller.request.ReportRequest; import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; -import com.xdap.self_development.domain.view.AnalysisModelParamterView; import com.xdap.self_development.domain.view.AnalysisModelParamterViewAndParam; import com.xdap.self_development.service.AnalysisCommonParametersService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.constraints.NotEmpty; -import java.util.ArrayList; import java.util.List; /** @@ -27,18 +24,6 @@ public class AnalysisCommonController { @Resource AnalysisCommonParametersService analysisCommonParametersService; - /** - * 机型常用返回机型数据(暂未使用) - * - * @param analysisRequest 分析请求对象 - * @return 机型参数视图列表 - */ - @PostMapping("/selectModelParamByCommon") - public Response selectModelParamByCommon(@RequestBody AnalysisRequest analysisRequest) { - ArrayList lists = analysisCommonParametersService.selectModelParamByCommon(analysisRequest); - return Response.ok().data(lists); - } - /** * 获取可用参数 * diff --git a/src/main/java/com/xdap/self_development/controller/DataEntryController.java b/src/main/java/com/xdap/self_development/controller/DataEntryController.java index 06954b1..e9df99c 100644 --- a/src/main/java/com/xdap/self_development/controller/DataEntryController.java +++ b/src/main/java/com/xdap/self_development/controller/DataEntryController.java @@ -5,15 +5,15 @@ import com.xdap.api.moudle.user.vo.LoginUserVo; import com.xdap.runtime.service.RuntimeAppContextService; import com.xdap.runtime.service.RuntimeUserService; import com.xdap.self_development.controller.form.OptionForm; -import com.xdap.self_development.controller.form.TemplateForm; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.TemplatePojo; import com.xdap.self_development.service.DataEntryService; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -80,44 +80,4 @@ public class DataEntryController { List parameters = dataEntryService.getParameterByCondition(form); return Response.ok().data(parameters); } - - /** - * 添加模板参数(form需指定模板名称) - * - * @param form 模板表单 - * @return 操作结果响应 - */ - @PostMapping("/insertParameter") - public Response insertParameter(@RequestBody TemplateForm form) { - dataEntryService.insertParameter(form); - return Response.ok().setMessage("添加成功"); - } - - /** - * 导入模板(导入全部模板参数) - * - * @param file 模板文件 - * @return 操作结果响应 - */ - @PostMapping("/import") - public Response importTemplate(@RequestParam("file") MultipartFile file) { - dataEntryService.readExcel(file); - return Response.ok().setMessage("导入成功"); - } - - /** - * 导出模板(导出全部模板参数) - * 可选择导出全部、导出指定名称模板、导出空参数模板、可以指定导出某些参数或者不导出某些参数 - * - * @param form 导出选项表单 - * @param response HTTP响应 - */ - @GetMapping("/export") - public void exportTemplate( - @RequestBody OptionForm form, - HttpServletResponse response - ) { - dataEntryService.writeExcel(form, response); - } - } diff --git a/src/main/java/com/xdap/self_development/controller/form/ApprovalFlowForm.java b/src/main/java/com/xdap/self_development/controller/form/ApprovalFlowForm.java index c33b2c8..7a5ac6b 100644 --- a/src/main/java/com/xdap/self_development/controller/form/ApprovalFlowForm.java +++ b/src/main/java/com/xdap/self_development/controller/form/ApprovalFlowForm.java @@ -12,10 +12,11 @@ import javax.validation.constraints.NotBlank; @Data public class ApprovalFlowForm { - @NotBlank(message = "流程不能为空") + /** * 流程ID */ + @NotBlank(message = "流程不能为空") private String flowId; /** * 模板ID diff --git a/src/main/java/com/xdap/self_development/controller/form/StartApprovalRequest.java b/src/main/java/com/xdap/self_development/controller/form/StartApprovalRequest.java index a451225..8973dd3 100644 --- a/src/main/java/com/xdap/self_development/controller/form/StartApprovalRequest.java +++ b/src/main/java/com/xdap/self_development/controller/form/StartApprovalRequest.java @@ -15,21 +15,21 @@ import java.util.List; @Data public class StartApprovalRequest { - @NotBlank(message = "用户不能为空") + /** * 用户ID */ + @NotBlank(message = "用户不能为空") private String userId; - - @NotBlank(message = "流程标题不能为空") /** * 流程标题 */ + @NotBlank(message = "流程标题不能为空") private String processTitle; - @NotBlank(message = "请选择审核内容") /** * 模板行ID */ + @NotBlank(message = "请选择审核内容") private String templateRowId; /** * 审批环节配置列表 diff --git a/src/main/java/com/xdap/self_development/controller/form/UpdateTemplateForm.java b/src/main/java/com/xdap/self_development/controller/form/UpdateTemplateForm.java index a75eac4..66da677 100644 --- a/src/main/java/com/xdap/self_development/controller/form/UpdateTemplateForm.java +++ b/src/main/java/com/xdap/self_development/controller/form/UpdateTemplateForm.java @@ -3,7 +3,6 @@ package com.xdap.self_development.controller.form; import lombok.Data; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; @Data public class UpdateTemplateForm { diff --git a/src/main/java/com/xdap/self_development/controller/request/DataEntryEngineModelExcel.java b/src/main/java/com/xdap/self_development/controller/request/DataEntryEngineModelExcel.java index 3e7ba17..5bfc53c 100644 --- a/src/main/java/com/xdap/self_development/controller/request/DataEntryEngineModelExcel.java +++ b/src/main/java/com/xdap/self_development/controller/request/DataEntryEngineModelExcel.java @@ -99,26 +99,8 @@ public class DataEntryEngineModelExcel { * 生产日期 */ @ExcelIgnore -// @ExcelProperty("生产日期") @DateTimeFormat("yyyy-MM-dd") private Date productionDate; -// -// /** -// * 填写部门 -// */ -// @ExcelProperty("填写部门") -// private String dept; -// -// /** -// * 责任人 -// */ -// @ExcelProperty("责任人") -// private String resPerson; -// /** -// * 责任人ID -// */ -// @ExcelIgnore -// private String resPersonId; /** * sheet名称 diff --git a/src/main/java/com/xdap/self_development/controller/request/EngineReviewListRequest.java b/src/main/java/com/xdap/self_development/controller/request/EngineReviewListRequest.java index a573834..89a937e 100644 --- a/src/main/java/com/xdap/self_development/controller/request/EngineReviewListRequest.java +++ b/src/main/java/com/xdap/self_development/controller/request/EngineReviewListRequest.java @@ -1,11 +1,7 @@ package com.xdap.self_development.controller.request; import com.alibaba.excel.annotation.ExcelProperty; -import com.definesys.mpaas.query.annotation.RowID; -import com.definesys.mpaas.query.annotation.RowIDType; -import com.definesys.mpaas.query.annotation.Table; import lombok.Data; -import lombok.EqualsAndHashCode; import java.io.Serializable; import java.util.Date; diff --git a/src/main/java/com/xdap/self_development/controller/request/ModelRolesRequest.java b/src/main/java/com/xdap/self_development/controller/request/ModelRolesRequest.java index 8f7f682..d526e88 100644 --- a/src/main/java/com/xdap/self_development/controller/request/ModelRolesRequest.java +++ b/src/main/java/com/xdap/self_development/controller/request/ModelRolesRequest.java @@ -1,12 +1,6 @@ package com.xdap.self_development.controller.request; -import com.definesys.mpaas.query.annotation.RowID; -import com.definesys.mpaas.query.annotation.RowIDType; -import com.definesys.mpaas.query.annotation.Table; import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.Date; @Data public class ModelRolesRequest { diff --git a/src/main/java/com/xdap/self_development/controller/request/RolePerJoinRequest.java b/src/main/java/com/xdap/self_development/controller/request/RolePerJoinRequest.java index 8a3688e..95510ba 100644 --- a/src/main/java/com/xdap/self_development/controller/request/RolePerJoinRequest.java +++ b/src/main/java/com/xdap/self_development/controller/request/RolePerJoinRequest.java @@ -6,11 +6,6 @@ import lombok.Data; public class RolePerJoinRequest { //角色ID private String roleId; - // private String menuName; -// private String parameterId; -// private String subsystem; -// //零部件名称 -// private String partsName; private String permissionPath; private Integer parameterPer; private String userId; diff --git a/src/main/java/com/xdap/self_development/domain/dto/ActivitiDataAndRecordDTO.java b/src/main/java/com/xdap/self_development/domain/dto/ActivitiDataAndRecordDTO.java index d3928a8..4c9700a 100644 --- a/src/main/java/com/xdap/self_development/domain/dto/ActivitiDataAndRecordDTO.java +++ b/src/main/java/com/xdap/self_development/domain/dto/ActivitiDataAndRecordDTO.java @@ -32,10 +32,10 @@ public class ActivitiDataAndRecordDTO { * 创建人 */ private String createBy; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") /** * 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; /** * 当前节点 diff --git a/src/main/java/com/xdap/self_development/domain/dto/AppTokenDTO.java b/src/main/java/com/xdap/self_development/domain/dto/AppTokenDTO.java index 0a4e47c..7951be6 100644 --- a/src/main/java/com/xdap/self_development/domain/dto/AppTokenDTO.java +++ b/src/main/java/com/xdap/self_development/domain/dto/AppTokenDTO.java @@ -13,15 +13,15 @@ public class AppTokenDTO { /** * 访问令牌 */ - private String access_token; + private String accessToken; /** * 令牌类型 */ - private String token_type; + private String tokenType; /** * 过期时间(秒) */ - private Integer expires_in; + private Integer expiresIn; /** * 权限范围 */ @@ -29,11 +29,11 @@ public class AppTokenDTO { /** * 租户ID */ - private String tenant_id; + private String tenantId; /** * 应用ID */ - private String app_id; + private String appId; /** * JWT标识符 */ diff --git a/src/main/java/com/xdap/self_development/domain/dto/UserTokenDT0.java b/src/main/java/com/xdap/self_development/domain/dto/UserTokenDT0.java index 4bff476..1f93dda 100644 --- a/src/main/java/com/xdap/self_development/domain/dto/UserTokenDT0.java +++ b/src/main/java/com/xdap/self_development/domain/dto/UserTokenDT0.java @@ -4,5 +4,5 @@ import lombok.Data; @Data public class UserTokenDT0 { - private String access_token; + private String accessToken; } diff --git a/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskCommonResultDTO.java b/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskCommonResultDTO.java index ea2cbc0..5698707 100644 --- a/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskCommonResultDTO.java +++ b/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskCommonResultDTO.java @@ -10,20 +10,20 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class YcTodoTaskCommonResultDTO { /* - * private String id string 非必须 流程唯一id -private String username string 非必须 员工编号 -private String title string 非必须 主题 -private String createDate string 非必须 经办时间 -private String activityName string 非必须 当前环节 -private String type string 非必须 类别,玉柴云/OA/CRM/SRM/TC/法务平台 -private String url string 非必须 PC端流程地址 -private String urlMobileOA string 非必须 移动OA流程地址,可以留空 -private String urlWx string 非必须 企业微信流程地址,可以留空 -private String mobileSuit string 非必须 "是否支持移动化,支持移动OA展示,传入1 -是否支持移动化,支持企业微信,传入2 -是否支持移动化,支持支持移动OA+企业微信,传入3 -可以留空" -*/ + * private String id string 非必须 流程唯一id + private String username string 非必须 员工编号 + private String title string 非必须 主题 + private String createDate string 非必须 经办时间 + private String activityName string 非必须 当前环节 + private String type string 非必须 类别,玉柴云/OA/CRM/SRM/TC/法务平台 + private String url string 非必须 PC端流程地址 + private String urlMobileOA string 非必须 移动OA流程地址,可以留空 + private String urlWx string 非必须 企业微信流程地址,可以留空 + private String mobileSuit string 非必须 "是否支持移动化,支持移动OA展示,传入1 + 是否支持移动化,支持企业微信,传入2 + 是否支持移动化,支持支持移动OA+企业微信,传入3 + 可以留空" + */ private String username; private String title; private String createDate; diff --git a/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskResultDTO.java b/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskResultDTO.java index cfbb83c..e72700c 100644 --- a/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskResultDTO.java +++ b/src/main/java/com/xdap/self_development/domain/dto/YcTodoTaskResultDTO.java @@ -7,21 +7,6 @@ import lombok.NoArgsConstructor; import java.util.Date; //待办 -//返回示例 -//{ -// "code": "ok", -// "total": 1, -// "table": [ -// { -// "title": "关于111/发动机YC6G205L-D20-111零部件发图/布点开发评审流程(免理化)", -// "url": "http://172.16.90.68:7777/ycloudShipElectricityApp/#/YcBpmShipProcess/YcShipElectricityDistributeProcess/submitted/900165654?instanceId=44573722", -// "updateDate": "2024-08-19 18:18", -// "activityLabel": "分管领导审核", -// "systemName": "BPM" -// } -// ], -// "requestid": "e078ecd04886494ab884630303f413e8" -// } @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/xdap/self_development/domain/pojo/AnalysisCommonParametersPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/AnalysisCommonParametersPojo.java index d1df3a3..4af62e5 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/AnalysisCommonParametersPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/AnalysisCommonParametersPojo.java @@ -5,24 +5,25 @@ import com.definesys.mpaas.query.model.MpaasBasePojo; import lombok.Data; import lombok.EqualsAndHashCode; -@SQLQuery(value = { - @SQL(view = "queryCommon", - sql = "select cp.*, c.common_name from yfsjglpt_common_parameter c left join yfsjglpt_analysis_common_parameters cp on c.id = cp.common_id where c.common_type = 2 and c.create_by = #userId") -}) + /** * 分析公共参数实体类,用于存储分析相关的公共参数信息 * * @version 1.0 * @since 2025 */ +@SQLQuery(value = { + @SQL(view = "queryCommon", + sql = "select cp.*, c.common_name from yfsjglpt_common_parameter c left join yfsjglpt_analysis_common_parameters cp on c.id = cp.common_id where c.common_type = 2 and c.create_by = #userId") +}) @EqualsAndHashCode(callSuper = true) @Data @Table("yfsjglpt_analysis_common_parameters") public class AnalysisCommonParametersPojo extends MpaasBasePojo { - @RowID(sequence = "analysis_common_parameters_s", type = RowIDType.UUID) /** * ID */ + @RowID(sequence = "analysis_common_parameters_s", type = RowIDType.UUID) private String id; /** @@ -71,9 +72,9 @@ public class AnalysisCommonParametersPojo extends MpaasBasePojo { */ private String commonId; - @Column(type = ColumnType.CALCULATE) /** * 公共名称 */ + @Column(type = ColumnType.CALCULATE) private String commonName; } diff --git a/src/main/java/com/xdap/self_development/domain/pojo/BenchmarkingReportPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/BenchmarkingReportPojo.java index aa34fc3..1e6d87a 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/BenchmarkingReportPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/BenchmarkingReportPojo.java @@ -9,25 +9,26 @@ import lombok.NoArgsConstructor; import java.sql.Timestamp; -@SQLQuery(value = { - @SQL(view = "getReportById", - sql = "SELECT ymbr.series, ymbr.id, ymbr.title, ymbr.manufacturer_name, ymbr.model_name, ymbr.module , ymbr.manufacturer_abbreviation, ymbr.model_abbreviation, ymbr.product_number, ymbr.plate, ymbr.platform , ymbr.market_segment, ymbr.project_name, ymbr.project_number, ymbr.upload_time, ymbr.file_path , ymbr.status, ymbr.file_name, xu.username AS create_by FROM yfsjglpt_model_benchmarking_report ymbr LEFT JOIN xdap_users xu ON xu.id = ymbr.create_by where ymbr.id = #reportId") -}) + /** * 对标报告实体类,用于存储对标报告的基本信息 * * @version 1.0 * @since 2025 */ +@SQLQuery(value = { + @SQL(view = "getReportById", + sql = "SELECT ymbr.series, ymbr.id, ymbr.title, ymbr.manufacturer_name, ymbr.model_name, ymbr.module , ymbr.manufacturer_abbreviation, ymbr.model_abbreviation, ymbr.product_number, ymbr.plate, ymbr.platform , ymbr.market_segment, ymbr.project_name, ymbr.project_number, ymbr.upload_time, ymbr.file_path , ymbr.status, ymbr.file_name, xu.username AS create_by FROM yfsjglpt_model_benchmarking_report ymbr LEFT JOIN xdap_users xu ON xu.id = ymbr.create_by where ymbr.id = #reportId") +}) @EqualsAndHashCode(callSuper = true) @Data @Table("yfsjglpt_model_benchmarking_report") @NoArgsConstructor public class BenchmarkingReportPojo extends MpaasBasePojo { - @RowID(sequence = "benchmarking_report_s", type = RowIDType.UUID) /** * ID */ + @RowID(sequence = "benchmarking_report_s", type = RowIDType.UUID) private String id; /** @@ -96,10 +97,10 @@ public class BenchmarkingReportPojo extends MpaasBasePojo { * 是否删除 */ 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; /** * 文件路径 diff --git a/src/main/java/com/xdap/self_development/domain/pojo/CompletedTaskPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/CompletedTaskPojo.java index e6364a9..d34324f 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/CompletedTaskPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/CompletedTaskPojo.java @@ -75,7 +75,7 @@ public class CompletedTaskPojo implements Serializable { /** * 所属人ID */ - private String OwnerId; + private String ownerId; /** * 所属人ID */ diff --git a/src/main/java/com/xdap/self_development/domain/pojo/ModelRolePermissionPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/ModelRolePermissionPojo.java index 81aedb4..354af79 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/ModelRolePermissionPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/ModelRolePermissionPojo.java @@ -14,7 +14,6 @@ import java.util.Date; public class ModelRolePermissionPojo { @RowID(sequence = "yfsjglpt_model_role_permission_s", type = RowIDType.UUID) - /* ID,; */ private String id ; /** 角色ID,; */ private String roleId ; diff --git a/src/main/java/com/xdap/self_development/domain/pojo/ParameterPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/ParameterPojo.java index d596a27..9ff9e50 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/ParameterPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/ParameterPojo.java @@ -37,80 +37,77 @@ import lombok.NoArgsConstructor; @Table("yfsjglpt_model_parameter") @NoArgsConstructor public class ParameterPojo extends MpaasBasePojo { - @RowID(sequence = "parameter_s", type = RowIDType.UUID) /** * 参数ID */ + @RowID(sequence = "parameter_s", type = RowIDType.UUID) private String id; - @ExcelProperty("序号") /** * 参数序号 */ + @ExcelProperty("序号") private Integer parameterNumber; - @ExcelProperty("子系统") /** * 子系统名称 */ + @ExcelProperty("子系统") private String subsystemName; - @ExcelProperty("类型") /** * 参数类型 */ + @ExcelProperty("类型") private String parameterType; - @ExcelProperty("零部件名称") /** * 零部件名称 */ + @ExcelProperty("零部件名称") private String partsName; - @ExcelProperty("参数名称") /** * 参数名称 */ + @ExcelProperty("参数名称") private String parameterName; - @ExcelProperty("单位") /** * 参数单位 */ + @ExcelProperty("单位") private String unit; - @ExcelProperty("参数计划来源") /** * 参数来源 */ + @ExcelProperty("参数计划来源") private String parameterSource; - @ExcelProperty("当前可适用的分类属性表编号(需要修订)或公式") /** * 分类属性表编号或公式 */ + @ExcelProperty("当前可适用的分类属性表编号(需要修订)或公式") private String numberOrFormula; - @ExcelProperty("填写部门") /** * 填写部门 */ + @ExcelProperty("填写部门") private String department; - @ExcelProperty("备注") /** * 备注信息 */ + @ExcelProperty("备注") private String remarks; - - @ExcelIgnore /** * 创建者 */ - private String createdBy; - @ExcelIgnore - @Column(type=ColumnType.CALCULATE) + private String createdBy; /** * 排序号 */ - private Integer orderNum; - @ExcelIgnore - @Column(value = "max_number",type=ColumnType.CALCULATE) + @Column(type=ColumnType.CALCULATE) + private Integer orderNum; /** * 最大序号 */ + @ExcelIgnore + @Column(value = "max_number",type=ColumnType.CALCULATE) private Integer maxNumber; public ParameterPojo(Integer parameterNumber, String subsystemName, String parameterType, diff --git a/src/main/java/com/xdap/self_development/domain/pojo/ResponsiblePersonPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/ResponsiblePersonPojo.java index 3271240..54fa675 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/ResponsiblePersonPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/ResponsiblePersonPojo.java @@ -24,7 +24,6 @@ public class ResponsiblePersonPojo extends MpaasBasePojo { private String department; @ExcelProperty("子系统") private String subsystem; - // private String partsName; private Integer personLevel; private Timestamp creationDate; diff --git a/src/main/java/com/xdap/self_development/domain/pojo/TemplatePojo.java b/src/main/java/com/xdap/self_development/domain/pojo/TemplatePojo.java index 5f18744..8f28060 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/TemplatePojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/TemplatePojo.java @@ -33,10 +33,10 @@ import java.sql.Timestamp; @Table("yfsjglpt_model_template") @NoArgsConstructor public class TemplatePojo extends MpaasBasePojo { - @RowID(sequence = "template_s", type = RowIDType.UUID) /** * 模板ID */ + @RowID(sequence = "template_s", type = RowIDType.UUID) private String id; /** * 模板名称 @@ -73,10 +73,10 @@ public class TemplatePojo extends MpaasBasePojo { */ private Integer returnNum; - @Column(type = ColumnType.CALCULATE) /** * 最大排序号 */ + @Column(type = ColumnType.CALCULATE) private Integer maxOrder; public TemplatePojo(String templateName, Integer version, String status, diff --git a/src/main/java/com/xdap/self_development/domain/pojo/TodoTaskPojo.java b/src/main/java/com/xdap/self_development/domain/pojo/TodoTaskPojo.java index 68a5f38..821b89f 100644 --- a/src/main/java/com/xdap/self_development/domain/pojo/TodoTaskPojo.java +++ b/src/main/java/com/xdap/self_development/domain/pojo/TodoTaskPojo.java @@ -75,7 +75,7 @@ public class TodoTaskPojo implements Serializable { /** * 所属人ID */ - private String OwnerId; + private String ownerId; /** * 所属人ID */ diff --git a/src/main/java/com/xdap/self_development/domain/view/ApprovalFlowNodeView.java b/src/main/java/com/xdap/self_development/domain/view/ApprovalFlowNodeView.java index 2783a82..d7569d6 100644 --- a/src/main/java/com/xdap/self_development/domain/view/ApprovalFlowNodeView.java +++ b/src/main/java/com/xdap/self_development/domain/view/ApprovalFlowNodeView.java @@ -12,7 +12,7 @@ public class ApprovalFlowNodeView { private String flowStatus; private String progressTitle; - private String ContentName; + private String contentName; private Integer templateVersion; private String createBy; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") diff --git a/src/main/java/com/xdap/self_development/domain/view/MenuListView.java b/src/main/java/com/xdap/self_development/domain/view/MenuListView.java index 2933d30..6e1a5f4 100644 --- a/src/main/java/com/xdap/self_development/domain/view/MenuListView.java +++ b/src/main/java/com/xdap/self_development/domain/view/MenuListView.java @@ -8,7 +8,7 @@ import java.util.ArrayList; @Data public class MenuListView { private String id; - private String parent_id; + private String parentId; private String menu; private String menuDesc; ArrayList listViews; diff --git a/src/main/java/com/xdap/self_development/domain/view/MenuParamView.java b/src/main/java/com/xdap/self_development/domain/view/MenuParamView.java index 724ef63..fb3f5a9 100644 --- a/src/main/java/com/xdap/self_development/domain/view/MenuParamView.java +++ b/src/main/java/com/xdap/self_development/domain/view/MenuParamView.java @@ -10,11 +10,8 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class MenuParamView { private String id; - // private String menuPath; private String subsystem; private String partsName; - // private String parameterName; -// private String parameterId; private String permissionPath; private String parameterPer; private Integer isAdmin; diff --git a/src/main/java/com/xdap/self_development/exception/ExcelImportException.java b/src/main/java/com/xdap/self_development/exception/ExcelImportException.java index 45869d8..efc00d2 100644 --- a/src/main/java/com/xdap/self_development/exception/ExcelImportException.java +++ b/src/main/java/com/xdap/self_development/exception/ExcelImportException.java @@ -1,7 +1,9 @@ package com.xdap.self_development.exception; import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) @Data public class ExcelImportException extends RuntimeException{ private String sheetName; diff --git a/src/main/java/com/xdap/self_development/feign/ApaasMyTokenFeign.java b/src/main/java/com/xdap/self_development/feign/ApaasMyTokenFeign.java index 62e1cd7..2818827 100644 --- a/src/main/java/com/xdap/self_development/feign/ApaasMyTokenFeign.java +++ b/src/main/java/com/xdap/self_development/feign/ApaasMyTokenFeign.java @@ -18,9 +18,9 @@ public interface ApaasMyTokenFeign { // 获取应用凭证 @PostMapping("/xdap-open/token") AppTokenDTO getAppToken( - @RequestParam("grant_type") String grant_type, - @RequestParam("client_id") String client_id, - @RequestParam("client_secret")String client_secret + @RequestParam("grant_type") String grantType, + @RequestParam("client_id") String clientId, + @RequestParam("client_secret") String clientSecret ); // 获取用户凭证 @@ -34,7 +34,7 @@ public interface ApaasMyTokenFeign { @PostMapping(value = "/xdap-open/open/attachments/v1/simpleUploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) FileUploadDTO uploadFile( - @RequestHeader(value = "Authorization") String access_token, + @RequestHeader(value = "Authorization") String accessToken, @RequestHeader("Content-Type") String type, @RequestPart("file") MultipartFile file, diff --git a/src/main/java/com/xdap/self_development/listener/EngineModelListener.java b/src/main/java/com/xdap/self_development/listener/EngineModelListener.java index c39b52e..c30a818 100644 --- a/src/main/java/com/xdap/self_development/listener/EngineModelListener.java +++ b/src/main/java/com/xdap/self_development/listener/EngineModelListener.java @@ -9,8 +9,11 @@ import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.self_development.controller.request.DataEntryEngineModelExcel; import com.xdap.self_development.domain.enums.DistributeStatusEnum; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; +import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; +import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; +import com.xdap.self_development.domain.pojo.ParameterPojo; +import com.xdap.self_development.domain.pojo.TodoTaskPojo; import com.xdap.self_development.exception.ExcelImportException; -import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.service.EngineParamDetailService; import com.xdap.self_development.service.ResponsiblePerService; import lombok.extern.slf4j.Slf4j; @@ -21,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.UUID; @@ -35,9 +37,8 @@ public class EngineModelListener implements ReadListener cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); @@ -54,30 +55,19 @@ public class EngineModelListener implements ReadListener personPojos = responsiblePersonService.selectByDepName(engineModelPojo.getDept()); -// if (ObjectUtils.isEmpty(personPojos)) { -// throw new ExcelImportException( -// String.format("请检查该部门是否有责任人,%s页第%d行", analysisContext.readSheetHolder().getSheetName(), analysisContext.readRowHolder().getRowIndex() + 1) -// ); -// } else { -// engineModelPojo.setResPersonId(personPojos.get(0).getId()); -// } - cachedDataList.add(engineModelPojo); } /** * 校验逻辑 * - * @param cachedDataList */ private void dataStrictly(List cachedDataList) { if (ObjectUtils.isEmpty(cachedDataList)) { log.error("机型数据为空"); throw new ExcelImportException( - String.format("Excel无数据") + "Excel无数据" ); } @@ -95,15 +85,7 @@ public class EngineModelListener implements ReadListener modelPojos, List parameters) { - /** - * 遍历机型 - * 查找参数 将每个机型都把参数,和参数所属的填写部门关联上 - * 参数值暂时放空 - */ List engineParamDetailPojos = new ArrayList<>(); for (DataEntryEngineModelPojo modelPojo : modelPojos) { for (ParameterPojo parameter : parameters) { @@ -176,60 +153,10 @@ public class EngineModelListener implements ReadListener personPojos = responsiblePerService.selectByDepName(parameter.getDepartment()); - if (ObjectUtils.isNotEmpty(personPojos)) { - // 不再默认生成责任人 engineParamDetailPojo.setResponsiblePersonId(personPojos.get(0).getId()); - } } } batchInsertParamDetail(engineParamDetailPojos); -// -// //生成分解任务给责任人 参数根据机型+责任人分组 生成数据 -// List paramDetailPojos = engineParamDetailPojos.stream() -// // 以engineModelId和responsiblePersonId组合作为key,元素本身作为value -// .collect(Collectors.toMap(pojo -> pojo.getEngineModelId() + "_" + pojo.getResponsiblePersonId(), -// pojo -> pojo, -// (existing, replacement) -> existing -// )) -// // 提取去重后的value集合 -// .values() -// .stream() -// .collect(Collectors.toList()); -// ArrayList todoTaskPojos = new ArrayList<>(); -// for (EngineParamDetailPojo paramDetailPojo : paramDetailPojos) { -// //查找参数对应的机型 -// DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo(); -// if (ObjectUtils.isNotEmpty(paramDetailPojo.getEngineModelId())) { -// List modelPojos2 = sw.buildFromDatasource("xdap_app_223770822127386625") -// .eq("id", paramDetailPojo.getEngineModelId()).doQuery(DataEntryEngineModelPojo.class); -// if (ObjectUtils.isNotEmpty(modelPojos2)) { -// modelPojo = modelPojos2.get(0); -// } -// } -// //组装待办 -// TodoTaskPojo todoTaskPojo = new TodoTaskPojo(); -// todoTaskPojo.setCreatedById(usersPojo.getId()); -// todoTaskPojo.setDocumentNo(UUID.randomUUID().toString()); -// todoTaskPojo.setProcessTitle("新增发动机型号流程"); -// todoTaskPojo.setCurrentNode(CurrentNodeEnum.JOBSPLIT.getDesc()); -// todoTaskPojo.setStatusCode(String.valueOf(ParamValueVersionEnum.DRAFT.getCode())); -// todoTaskPojo.setModelName(modelPojo.getModelName()); -// todoTaskPojo.setModelId(paramDetailPojo.getEngineModelId()); -// todoTaskPojo.setCreationDate(createdDate); -// todoTaskPojo.setDataType("玉柴"); -// todoTaskPojo.setVersionNumber(versionNumber); -// todoTaskPojo.setIsDelete(0); -// if (ObjectUtils.isNotEmpty(paramDetailPojo.getResponsiblePersonId())) { -// ResponsiblePersonPojo responsiblePersonPojo = responsiblePerService.selectById(paramDetailPojo.getResponsiblePersonId()); -// todoTaskPojo.setOwnerId(ObjectUtils.isNotEmpty(responsiblePersonPojo) ? responsiblePersonPojo.getUserId() : null); -// } -// todoTaskPojo.setCreatedBy(usersPojo.getUsername()); -// todoTaskPojos.add(todoTaskPojo); -// } - - // 又不在这生成待办了 改为管理员进去选择责任人后待办 batchInsertTodoTask(todoTaskPojos); } @@ -243,13 +170,7 @@ public class EngineModelListener implements ReadListener modelPojos) { sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(modelPojos); -// 分批插入(如每1000条一批,但整体在一个事务中) -// int batchSize = 1000; -// for (int i = 0; i < modelPojos.size(); i += batchSize) { -// int end = Math.min(i + batchSize, modelPojos.size()); -// List batch = modelPojos.subList(i, end); -// sw.buildFromDatasource("test_demo").doBatchInsert(modelPojos); -// } + } } diff --git a/src/main/java/com/xdap/self_development/listener/EngineParamDetailListener.java b/src/main/java/com/xdap/self_development/listener/EngineParamDetailListener.java index 4eb3b8c..2078a25 100644 --- a/src/main/java/com/xdap/self_development/listener/EngineParamDetailListener.java +++ b/src/main/java/com/xdap/self_development/listener/EngineParamDetailListener.java @@ -8,13 +8,13 @@ import com.definesys.mpaas.query.MpaasQueryFactory; import com.xdap.self_development.controller.request.EngineParamDetailExcel; import com.xdap.self_development.domain.enums.ParamOperationEnum; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; -import com.xdap.self_development.domain.pojo.*; +import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; +import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; import com.xdap.self_development.service.DataEntryEngineModelService; import com.xdap.self_development.service.DataEntryService; import com.xdap.self_development.service.ResponsiblePerService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; @@ -23,8 +23,6 @@ import java.util.Map; @Slf4j -//@Component 暂时不交给spring管理 -//@Scope("prototype") public class EngineParamDetailListener implements ReadListener { private final MpaasQueryFactory sw; private final DataEntryEngineModelPojo modelPojo; @@ -34,10 +32,7 @@ public class EngineParamDetailListener implements ReadListener stringParameterMap; - private RuntimeException importException = null; - private ArrayList successSheetName = null; private String userId; private List cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); @@ -61,38 +56,10 @@ public class EngineParamDetailListener implements ReadListener cachedDataList) { -// if (ObjectUtils.isEmpty(cachedDataList)) { -// log.error("数据为空"); -// throw new ExcelImportException( -// String.format("请检查是否有空数据sheet页或联系管理员") -//// String.format("检查无数据sheet页,导入成功的sheet页有%s",successSheetName) -// ); -// } -// for (EngineParamDetailExcel data : cachedDataList) { -// String sheetName = data.getSheetName(); -// Integer rowIndex = data.getRowIndex(); -// //空值校验 -// if (ObjectUtils.isBlank(data.getParameterValue())) { -// throw new ExcelImportException( -// String.format("请检查必要字段(参数值)是否漏填,%s页第%d行", sheetName, rowIndex) -//// String.format("请检查必要字段(参数值)是否漏填,%s页第%d行,导入成功的sheet页有%s", sheetName, rowIndex,successSheetName) -// ); -// } -// -// } - } @Override public void doAfterAllAnalysed(AnalysisContext analysisContext) { - - dataStrictly(cachedDataList); // 存储到数据库 saveData(); cachedDataList = new ArrayList<>(); @@ -104,16 +71,12 @@ public class EngineParamDetailListener implements ReadListener engineParamDetailPojos = new ArrayList<>(); for (EngineParamDetailExcel paramDetailExcel : cachedDataList) { if (ObjectUtils.isEmpty(paramDetailExcel.getParameterValue())) { //如果参数值为空直接返回 - log.warn("%s页第%d行参数值为空",paramDetailExcel.getSheetName(),paramDetailExcel.getRowIndex()); continue; } - EngineParamDetailPojo engineParamDetailPojo = new EngineParamDetailPojo(); - List detailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") .eq("id",paramDetailExcel.getId()) @@ -129,48 +92,7 @@ public class EngineParamDetailListener implements ReadListener personPojos = responsiblePersonService.selectByDepName(paramDetailExcel.getDepartment()); -// if (ObjectUtils.isNotEmpty(personPojos)) { -// engineParamDetailPojo.setResponsiblePersonId(personPojos.get(0).getId()); -// } -// //todo通过部门+姓名存入填写人 最好根据工号 -// engineParamDetailPojo.setFilledBy(); -// engineParamDetailPojo.setVersionStatus(ParamValueVersionEnum.DRAFT.getCode()); -// engineParamDetailPojo.setOperation(String.valueOf(ParamOperationEnum.INSERT)); -// engineParamDetailPojo.setCreatedBy(createdBy); -// engineParamDetailPojo.setCreatedDate(createdDate); -// engineParamDetailPojo.setLastUpdatedBy(lastModifiedBy); -// engineParamDetailPojo.setLastUpdatedDate(lastModifiedDate); -// engineParamDetailPojos.add(engineParamDetailPojo); - } - } -// batchInsert(engineParamDetailPojos); } - - @Transactional // 发生任何异常都回滚 - public void batchInsert(List engineParamDetailPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(engineParamDetailPojos); - } - } diff --git a/src/main/java/com/xdap/self_development/listener/PersonReadListener.java b/src/main/java/com/xdap/self_development/listener/PersonReadListener.java index 7053133..7478bf3 100644 --- a/src/main/java/com/xdap/self_development/listener/PersonReadListener.java +++ b/src/main/java/com/xdap/self_development/listener/PersonReadListener.java @@ -15,7 +15,7 @@ import java.util.List; public class PersonReadListener implements ReadListener { MyResponse problems; private final ResponsiblePersonService responsiblePersonService; - private List cachedDataList; + private final List cachedDataList; public PersonReadListener(ResponsiblePersonService responsiblePersonService, MyResponse problems) { this.problems = problems; diff --git a/src/main/java/com/xdap/self_development/listener/SheetDataListener.java b/src/main/java/com/xdap/self_development/listener/SheetDataListener.java index 3e36749..41c0ea5 100644 --- a/src/main/java/com/xdap/self_development/listener/SheetDataListener.java +++ b/src/main/java/com/xdap/self_development/listener/SheetDataListener.java @@ -8,8 +8,9 @@ import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.service.TemplateService; import lombok.extern.slf4j.Slf4j; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; @Slf4j public class SheetDataListener implements ReadListener { @@ -18,18 +19,10 @@ public class SheetDataListener implements ReadListener { private final TemplateService templateService; private final String templateRowId; private final String createBy; - private List cachedDataList; + private final List cachedDataList; private String currentSheetName; MyResponse problems; - // 用于存储表头 - private Set actualHeaders = new HashSet<>(); - // 是否已检查过表头 - private boolean headerChecked = false; - // 必须包含的字段集合 - private final Set requiredHeaders; - // 标记当前sheet是否有效 - private boolean validSheet = false; public SheetDataListener(TemplateService templateService, String templateRowId, String createBy, MyResponse problems) { @@ -38,32 +31,18 @@ public class SheetDataListener implements ReadListener { this.createBy = createBy; this.cachedDataList = new ArrayList<>(BATCH_SIZE); this.problems = problems; - this.requiredHeaders = getIncludeColumnFieldNames(); } @Override public void invokeHead(Map> headMap, AnalysisContext context) { - // 获取表头 - actualHeaders = headMap.values().stream() - .map(ReadCellData::getStringValue) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); -// 第一次读取数据时检查表头 -// if (!headerChecked) { -// checkHeaderAndSkipIfNeeded(context); -// headerChecked = true; -// } currentSheetName = context.readSheetHolder().getSheetName(); log.info("开始解析Sheet: {}", currentSheetName); } @Override public void invoke(ParameterPojo data, AnalysisContext context) { - // 如果sheet无效,直接返回,不处理数据 -// if (!validSheet) { -// return; -// } - if (currentSheetName == null) { + + if (currentSheetName == null) { currentSheetName = context.readSheetHolder().getSheetName(); } cachedDataList.add(data); @@ -79,7 +58,6 @@ public class SheetDataListener implements ReadListener { if (!cachedDataList.isEmpty()) { processBatch(); } - resetForNextSheet(); } private void processBatch() { @@ -92,59 +70,4 @@ public class SheetDataListener implements ReadListener { ); cachedDataList.clear(); } - - /** - * 检查表头并决定是否跳过当前sheet - */ - private void checkHeaderAndSkipIfNeeded(AnalysisContext context) { - if (actualHeaders.isEmpty()) { - problems.setFlag(true); - problems.getErrors().add("未读取到表头,跳过sheet"); - log.info("未读取到表头,跳过sheet"); - validSheet = false; - return; - } - // 检查实际表头是否包含所有必需字段 - boolean containsAll = actualHeaders.containsAll(requiredHeaders); - if (!containsAll) { - StringBuilder sb = new StringBuilder(); - requiredHeaders.stream() - .filter(required -> !actualHeaders.contains(required)) - .collect(Collectors.toSet()).forEach(required -> { - sb.append(required).append(" "); - }); - // 不包含必需字段,跳过当前sheet - problems.setFlag(true); - problems.getErrors().add(currentSheetName + "缺少字段:"+ sb); - validSheet = false; - } else { - validSheet = true; - System.out.println("Sheet表头验证通过,开始处理数据"); - } - } - - /** - * 重置状态,准备读取下一个sheet - */ - private void resetForNextSheet() { - headerChecked = false; - validSheet = false; - actualHeaders.clear(); - } - - private static Set getIncludeColumnFieldNames() { - Set includeColumnFieldNames; - includeColumnFieldNames = new HashSet<>(); - includeColumnFieldNames.add("序号"); - includeColumnFieldNames.add("子系统"); - includeColumnFieldNames.add("类型"); - includeColumnFieldNames.add("零部件名称"); - includeColumnFieldNames.add("参数名称"); - includeColumnFieldNames.add("单位"); - includeColumnFieldNames.add("参数计划来源"); - includeColumnFieldNames.add("当前可适用的分类属性表编号(需要修订)或公式"); - includeColumnFieldNames.add("填写部门"); - includeColumnFieldNames.add("备注"); - return includeColumnFieldNames; - } } diff --git a/src/main/java/com/xdap/self_development/schedule/ParameterValueCalculationTimer.java b/src/main/java/com/xdap/self_development/schedule/ParameterValueCalculationTimer.java index 2f56b2a..3b0cc1e 100644 --- a/src/main/java/com/xdap/self_development/schedule/ParameterValueCalculationTimer.java +++ b/src/main/java/com/xdap/self_development/schedule/ParameterValueCalculationTimer.java @@ -1,12 +1,13 @@ package com.xdap.self_development.schedule; -import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.domain.pojo.ClassificationAttributePojo; import com.xdap.self_development.domain.pojo.EnginePartsCollectionPojo; import com.xdap.self_development.domain.view.CalculationParameterView; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.utils.FormulaValidatorUtils; import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,29 +25,26 @@ import java.util.stream.Collectors; public class ParameterValueCalculationTimer { @Resource private BusinessDatabase bd; - - private ScriptEngineManager scriptEngineManager; + private ScriptEngine scriptEngine; @PostConstruct public void init() { + ScriptEngineManager scriptEngineManager; scriptEngineManager = new ScriptEngineManager(); scriptEngine = scriptEngineManager.getEngineByName("JavaScript"); } // 每天凌晨执行一次 -// @Scheduled(cron = "0 0 0 * * ?") + @Scheduled(cron = "0 0 0 * * ?") @Transactional - public MyResponse dailyCalculate() { - MyResponse myResponse = new MyResponse(); - myResponse.setErrors(new ArrayList<>()); + public void dailyCalculate() { LocalDate today = LocalDate.now(); log.info("开始执行{}参数计算任务", today); - myResponse.getErrors().add("开始执行"+today+"参数计算任务"); - + // 统计信息 - int totalParameters = 0; + int totalParameters; int tcParameters = 0; int calculatedParameters = 0; int updatedFromTC = 0; @@ -62,12 +60,9 @@ public class ParameterValueCalculationTimer { totalParameters = parameterValues.size(); log.info("共查询到{}个参数配置", totalParameters); - myResponse.getErrors().add("共查询到"+totalParameters+"个参数配置"); - + if (parameterValues.isEmpty()) { log.info("无参数配置,跳过计算"); - myResponse.getErrors().add("无参数配置,跳过计算"); - return myResponse; } // 2.从中台更新参数值 @@ -82,7 +77,6 @@ public class ParameterValueCalculationTimer { if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) { log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应零部件,零部件名:{}", parameter.getProductNumber(), parameter.getParameterName(), parameter.getPartsName()); - myResponse.getErrors().add("机型【"+parameter.getProductNumber()+"】的参数【"+parameter.getParameterName()+"】在TC分类表中未找到对应零部件"); failedToUpdateFromTC++; continue; } @@ -94,23 +88,19 @@ public class ParameterValueCalculationTimer { String originalValue = parameter.getParameterValue(); parameter.setParameterValue(classificationAttribute.getFieldvalue()); log.debug("机型【{}】的参数【{}】从中台更新值:{} -> {}",parameter.getProductNumber(), parameter.getParameterName(), originalValue, classificationAttribute.getFieldvalue()); - myResponse.getErrors().add("机型【"+parameter.getProductNumber()+"】的参数【"+parameter.getParameterName()+"】从中台更新值:"+ originalValue + " -> " + classificationAttribute.getFieldvalue()); updatedFromTC++; } else { log.warn("机型【{}】的参数【{}】在TC分类表中未找到对应值",parameter.getProductNumber(), parameter.getParameterName()); - myResponse.getErrors().add("机型【"+parameter.getProductNumber()+"】的参数【"+parameter.getParameterName()+"】在TC分类表中未找到对应值"); failedToUpdateFromTC++; } } catch (Exception e) { log.error("机型【{}】的参数【{}】从中台更新值失败:{}",parameter.getProductNumber(), parameter.getParameterName(), e.getMessage(), e); - myResponse.getErrors().add("机型【"+parameter.getProductNumber()+"】的参数【"+parameter.getParameterName()+"】从中台更新值失败:"+e.getMessage()); failedToUpdateFromTC++; } } } log.info("从中台更新参数完成,共处理{}个TC参数,成功{}个,失败{}个", tcParameters, updatedFromTC, failedToUpdateFromTC); - myResponse.getErrors().add("从中台更新参数完成,共处理"+tcParameters+"个TC参数,成功"+updatedFromTC+"个,失败"+failedToUpdateFromTC+"个"); // 3.维护所有参数的原始值 Map> originalValueMap = convertMap(parameterValues); @@ -136,12 +126,10 @@ public class ParameterValueCalculationTimer { parameterValue.setParameterValue(formattedResult); toUpdate.add(parameterValue); log.info("机型【{}】的参数【{}】计算结果:{}",parameterValue.getProductNumber(), parameterValue.getParameterName(), formattedResult); - myResponse.getErrors().add("机型【"+parameterValue.getProductNumber()+"】的参数【"+parameterValue.getParameterName()+"】计算结果:"+formattedResult); successCount++; } catch (Exception e) { log.error("机型【{}】的参数【{}】计算失败:{},公式:{},模型ID:{}",parameterValue.getProductNumber(), parameterValue.getParameterName(), e.getMessage(), formula, modelId, e); - myResponse.getErrors().add("机型【"+parameterValue.getProductNumber()+"】的参数【"+parameterValue.getParameterName()+"】计算失败:"+e.getMessage()+",公式:"+formula+"模型ID:"+modelId); parameterValue.setParameterValue(null); toUpdate.add(parameterValue); // 仍然添加到更新列表,用于更新null值 failureCount++; @@ -150,7 +138,6 @@ public class ParameterValueCalculationTimer { } log.info("公式计算参数完成,共处理{}个计算参数,成功{}个,失败{}个", calculatedParameters, successCount, failureCount); - myResponse.getErrors().add("公式计算参数完成,共处理"+calculatedParameters+"个计算参数,成功"+successCount+"个,失败"+failureCount+"个"); // 批量插入或更新计算结果 int updatedCount = 0; @@ -175,26 +162,19 @@ public class ParameterValueCalculationTimer { updatedCount++; } catch (Exception e) { log.error("参数【{}】更新数据库失败:{}", parameterValue.getParameterName(), e.getMessage(), e); - myResponse.getErrors().add("参数【"+parameterValue.getParameterName()+"】更新数据库失败:"+e.getMessage()); dbUpdateFailures++; } } log.info("{}参数计算完成,成功处理{}个参数,失败{}个参数,更新{}个参数,数据库更新失败{}个", today, successCount, failureCount, updatedCount, dbUpdateFailures); - myResponse.getErrors().add("数据库更新完成,成功更新"+updatedCount+"个参数,更新失败"+dbUpdateFailures+"个"); } else { log.info("{}参数计算完成,无需更新任何参数", today); - myResponse.getErrors().add("无需更新任何参数"); } // 添加汇总信息 - myResponse.getErrors().add("任务汇总:共处理"+totalParameters+"个参数,其中TC参数"+tcParameters+"个(成功"+updatedFromTC+"个,失败"+failedToUpdateFromTC+"个),计算参数"+calculatedParameters+"个(成功"+successCount+"个,失败"+failureCount+"个)"); - log.info("{}参数计算任务结束,总参数数{},TC参数{}(成功{},失败{}),计算参数{}(成功{},失败{}),数据库更新{}(失败{})", today, totalParameters, tcParameters, updatedFromTC, failedToUpdateFromTC, calculatedParameters, successCount, failureCount, updatedCount, dbUpdateFailures); - - return myResponse; } private String replaceParametersInFormula(String formula, List parameterNames, @@ -204,8 +184,7 @@ public class ParameterValueCalculationTimer { result = result.replace("π", "PI").replace("PI", "Math.PI"); result = result.replace("e", "Math.E"); for (String paramName : formulaParams) { - if (!parameterNames.contains(paramName)) continue; - if (Objects.equals(paramName, currentParameterName)) continue; + if (!parameterNames.contains(paramName) || Objects.equals(paramName, currentParameterName)) continue; String pattern = "\\b" + Pattern.quote(paramName) + "\\b"; String value = getParameterValue(valueMap, paramName, modelId); result = result.replaceAll(pattern, value); @@ -224,12 +203,12 @@ public class ParameterValueCalculationTimer { return paramName; } - private Double calculateExpression(String expression) throws RuntimeException { + private Double calculateExpression(String expression) throws CommonException { Double result = calculateWithScriptEngine(expression); if (result != null) { return result; } - throw new RuntimeException("无法计算表达式: " + expression); + throw new CommonException("无法计算表达式: " + expression); } private Double calculateWithScriptEngine(String expression) { @@ -251,6 +230,7 @@ public class ParameterValueCalculationTimer { private boolean isSafeExpression(String expression) { // 允许的字符:数字、基本运算符、括号、数学常量和函数 String safePattern = "^[0-9+\\-*/().\\sMathPIEsincostanlogsqrtabs]+$"; + if (!expression.matches(safePattern)) { return false; } diff --git a/src/main/java/com/xdap/self_development/service/ActivitiProcessService.java b/src/main/java/com/xdap/self_development/service/ActivitiProcessService.java index 4fd339a..0df0fb9 100644 --- a/src/main/java/com/xdap/self_development/service/ActivitiProcessService.java +++ b/src/main/java/com/xdap/self_development/service/ActivitiProcessService.java @@ -4,11 +4,13 @@ package com.xdap.self_development.service; import com.xdap.self_development.controller.form.HandleApprovalRequest; import com.xdap.self_development.controller.form.HandleReturnNodeForm; import com.xdap.self_development.controller.form.UpdateNodeForm; -import com.xdap.self_development.controller.request.ApprovalByPlatformRequest; import com.xdap.self_development.controller.request.ApprovalNodeRequest; -import com.xdap.self_development.domain.enums.ParamValueVersionEnum; -import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.domain.dto.*; +import com.xdap.self_development.domain.enums.ParamValueVersionEnum; +import com.xdap.self_development.domain.pojo.ApprovalConfigPojo; +import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; +import com.xdap.self_development.domain.pojo.EngineReviewListPojo; +import com.xdap.self_development.domain.pojo.ParamApprovalRecordPojo; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -24,8 +26,6 @@ public interface ActivitiProcessService { //操作 String handleApproval(HandleApprovalDTO handleApprovalDTO); - void startActivitiByPlatform(ApprovalByPlatformRequest request); - boolean getIsDirect(String flowId); ApprovalNodesDTO getApprovalUsers(@NotBlank String flowId); diff --git a/src/main/java/com/xdap/self_development/service/AnalysisCommonParametersService.java b/src/main/java/com/xdap/self_development/service/AnalysisCommonParametersService.java index 3fef333..ee5be48 100644 --- a/src/main/java/com/xdap/self_development/service/AnalysisCommonParametersService.java +++ b/src/main/java/com/xdap/self_development/service/AnalysisCommonParametersService.java @@ -1,22 +1,15 @@ package com.xdap.self_development.service; -import com.xdap.self_development.controller.request.AnalysisRequest; - import com.xdap.self_development.controller.request.ReportRequest; import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; -import com.xdap.self_development.domain.view.AnalysisModelParamterView; import com.xdap.self_development.domain.view.AnalysisModelParamterViewAndParam; -import java.util.ArrayList; import java.util.List; public interface AnalysisCommonParametersService { - //查询常用参数返回机型数据 - ArrayList selectModelParamByCommon(AnalysisRequest analysisRequest); AnalysisModelParamterViewAndParam showReport(List models); - AnalysisModelParamterViewAndParam showReportParamList(ReportRequest analysisRequest); List selectModelByLike(ReportRequest request); diff --git a/src/main/java/com/xdap/self_development/service/DataEntryEngineModelService.java b/src/main/java/com/xdap/self_development/service/DataEntryEngineModelService.java index c8c3405..d233dab 100644 --- a/src/main/java/com/xdap/self_development/service/DataEntryEngineModelService.java +++ b/src/main/java/com/xdap/self_development/service/DataEntryEngineModelService.java @@ -1,9 +1,9 @@ package com.xdap.self_development.service; import com.xdap.self_development.controller.request.DataEntryEngineModelPageRequest; -import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; import com.xdap.self_development.domain.dto.DataEntryEngineModelDto; import com.xdap.self_development.domain.dto.PageResultDTO; +import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -36,8 +36,6 @@ public interface DataEntryEngineModelService { */ int insert(DataEntryEngineModelPageRequest request, String userId); - void updateModelForNewVersion(); - void excelExport(HttpServletResponse response); DataEntryEngineModelPojo selectBymodelId(String modelID); diff --git a/src/main/java/com/xdap/self_development/service/DataEntryService.java b/src/main/java/com/xdap/self_development/service/DataEntryService.java index 1d213d1..bb6574e 100644 --- a/src/main/java/com/xdap/self_development/service/DataEntryService.java +++ b/src/main/java/com/xdap/self_development/service/DataEntryService.java @@ -1,20 +1,13 @@ package com.xdap.self_development.service; import com.xdap.self_development.controller.form.OptionForm; -import com.xdap.self_development.controller.form.TemplateForm; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.TemplatePojo; -import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; import java.util.List; public interface DataEntryService { - void readExcel(MultipartFile file); - void writeExcel(OptionForm form, HttpServletResponse response); - - void insertParameter(TemplateForm form); List getParameterByCondition(OptionForm form); diff --git a/src/main/java/com/xdap/self_development/service/EngineParamDetailService.java b/src/main/java/com/xdap/self_development/service/EngineParamDetailService.java index cc8ddb2..4eff711 100644 --- a/src/main/java/com/xdap/self_development/service/EngineParamDetailService.java +++ b/src/main/java/com/xdap/self_development/service/EngineParamDetailService.java @@ -2,9 +2,9 @@ package com.xdap.self_development.service; import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.self_development.controller.request.EngineParamDetailRequest; +import com.xdap.self_development.domain.dto.EngineParamDetailDTO; import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; import com.xdap.self_development.domain.pojo.ParameterPojo; -import com.xdap.self_development.domain.dto.EngineParamDetailDTO; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -39,20 +39,12 @@ public interface EngineParamDetailService { List selectAllByNewVersion(); List selectAllAndTcByNewVersion(); -/** - * 根据型号查询最新的引擎参数详情列表 - * - * @param model 型号名称 - * @return 返回指定型号的最新版本引擎参数详情列表 - */ + List selectByModelNewVersion(String model); //根据责任人查询最新发版的参数详情 List selectByResId(String resId); //根据填写人查询最新发版的参数详情 - List selectByfiledId(String filledId); - //根据流程ID查数据 - List selectByapprovalId(String approvalId); //根据ID查询数据 EngineParamDetailPojo selectById(String id); diff --git a/src/main/java/com/xdap/self_development/service/ModelMenuPermissionService.java b/src/main/java/com/xdap/self_development/service/ModelMenuPermissionService.java index 526fd5c..3f4ed2a 100644 --- a/src/main/java/com/xdap/self_development/service/ModelMenuPermissionService.java +++ b/src/main/java/com/xdap/self_development/service/ModelMenuPermissionService.java @@ -1,7 +1,6 @@ package com.xdap.self_development.service; -import com.xdap.self_development.domain.pojo.ModelMenuDictionaryPojo; import com.xdap.self_development.domain.view.MenuListView; import java.util.List; @@ -10,6 +9,4 @@ public interface ModelMenuPermissionService { //菜单查询 List selectMenus(); - //根据ID查询路径 - ModelMenuDictionaryPojo selectMenuById(String menuName); } diff --git a/src/main/java/com/xdap/self_development/service/ModelRoleService.java b/src/main/java/com/xdap/self_development/service/ModelRoleService.java index 743c3c3..785bf0c 100644 --- a/src/main/java/com/xdap/self_development/service/ModelRoleService.java +++ b/src/main/java/com/xdap/self_development/service/ModelRoleService.java @@ -5,7 +5,6 @@ import com.xdap.self_development.controller.request.ModelRolesRequest; import com.xdap.self_development.controller.request.RolePerJoinRequest; import com.xdap.self_development.controller.request.UserRoleBindingRequest; import com.xdap.self_development.domain.pojo.ModelRolesPojo; -import com.xdap.self_development.domain.dto.PageResultDTO; import com.xdap.self_development.domain.view.MenuParamView; import javax.validation.constraints.NotBlank; @@ -16,10 +15,8 @@ public interface ModelRoleService { void addRoles(ModelRolesRequest request); - PageResultDTO selectRolesByPage(String userID); List selectRoles(); - void updatePerForRole(List request); void updateRole(ModelRolesPojo modelRolesPojo, String userID); diff --git a/src/main/java/com/xdap/self_development/service/ResponsiblePerService.java b/src/main/java/com/xdap/self_development/service/ResponsiblePerService.java index eb643b6..2cc9f5a 100644 --- a/src/main/java/com/xdap/self_development/service/ResponsiblePerService.java +++ b/src/main/java/com/xdap/self_development/service/ResponsiblePerService.java @@ -16,15 +16,12 @@ import java.util.List; public interface ResponsiblePerService { ResponsiblePersonPojo selectByDepAndPer(String department, String resPerson); - ResponsiblePersonPojo selectByDep(String departmentId); + List selectByUserId(List userIds); + List selectByDepName(String departmentName); Object insert(ResponsiblePersonPojo responsiblePerson); - List seelctAll(); - - ResponsiblePersonPojo selectById(String responsiblePersonId); - List selectBysubSystemDept(String subSystem, String dept); } diff --git a/src/main/java/com/xdap/self_development/service/TcDataQueryService.java b/src/main/java/com/xdap/self_development/service/TcDataQueryService.java index 1923468..b92dcbb 100644 --- a/src/main/java/com/xdap/self_development/service/TcDataQueryService.java +++ b/src/main/java/com/xdap/self_development/service/TcDataQueryService.java @@ -3,23 +3,17 @@ package com.xdap.self_development.service; import com.xdap.self_development.controller.request.AnalysisRequest; import com.xdap.self_development.controller.request.AnalysisVerRequest; import com.xdap.self_development.controller.request.ModelComparisonExportRequest; -import com.xdap.self_development.domain.pojo.ClassificationAttributePojo; import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; public interface TcDataQueryService { - //查询TC数据返回格式Map> - HashMap> tcDataSelectByC(String productNumber, String partsName, String parameterName); - - ArrayList tcDataSelectAllByproductNumber(DataEntryEngineModelPojo engineModelPojo); Map> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest); + Map> tcDataSelectAllByPartsNameBack(AnalysisRequest analysisRequest); void excelExportA(HttpServletResponse response); diff --git a/src/main/java/com/xdap/self_development/service/TodoTaskService.java b/src/main/java/com/xdap/self_development/service/TodoTaskService.java index a8a16a8..c09b9a4 100644 --- a/src/main/java/com/xdap/self_development/service/TodoTaskService.java +++ b/src/main/java/com/xdap/self_development/service/TodoTaskService.java @@ -3,10 +3,13 @@ package com.xdap.self_development.service; import com.xdap.self_development.controller.request.TodoReturnRequest; import com.xdap.self_development.controller.request.TodoTaskRequest; import com.xdap.self_development.controller.request.YcGetTodoTaskRequest; +import com.xdap.self_development.domain.dto.EngineParamDetailDTO; +import com.xdap.self_development.domain.dto.PageResultDTO; +import com.xdap.self_development.domain.dto.YcTodoTaskCommonResultDTO; +import com.xdap.self_development.domain.dto.YcTodoTaskResultDTO; import com.xdap.self_development.domain.pojo.CompletedTaskPojo; import com.xdap.self_development.domain.pojo.InitiatedTaskPojo; import com.xdap.self_development.domain.pojo.TodoTaskPojo; -import com.xdap.self_development.domain.dto.*; import java.util.List; @@ -19,7 +22,6 @@ import java.util.List; * @since 2025-11-18 */ public interface TodoTaskService { - void batchInsert(List taskPojo); //根据人员ID查询发起事项 PageResultDTO selectByPage(TodoTaskRequest todoTaskRequest); @@ -32,10 +34,6 @@ public interface TodoTaskService { void todoReturn(TodoReturnRequest todoReturnRequest); - void batchInsertTodoTask(List todoTaskPojos); - - void batchInsertInitiatedTask(List taskPojos); - //---------------------------------玉柴调用接口-------------------------------- List returnTodoTask(YcGetTodoTaskRequest ycGetTodoTaskRequest); diff --git a/src/main/java/com/xdap/self_development/service/impl/ActivitiProcessServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ActivitiProcessServiceImpl.java index 367b361..cfa8752 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ActivitiProcessServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ActivitiProcessServiceImpl.java @@ -7,16 +7,15 @@ import com.xdap.self_development.controller.form.ApprovalUserNodeDTO; import com.xdap.self_development.controller.form.HandleApprovalRequest; import com.xdap.self_development.controller.form.HandleReturnNodeForm; import com.xdap.self_development.controller.form.UpdateNodeForm; -import com.xdap.self_development.controller.request.ApprovalByPlatformRequest; import com.xdap.self_development.controller.request.ApprovalNodeRequest; +import com.xdap.self_development.domain.dto.*; import com.xdap.self_development.domain.enums.ApprovalOrderEnum; import com.xdap.self_development.domain.enums.CurrentNodeEnum; import com.xdap.self_development.domain.enums.ParamOperationEnum; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; -import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.*; import com.xdap.self_development.domain.view.FlowNode; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.*; import com.xdap.self_development.utils.RedisLockUtils; import groovy.util.logging.Slf4j; @@ -62,6 +61,15 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { private static final int FLOW_LOCK_EXPIRE_SECONDS = 5; + private static List getStrings(EngineReviewListPojo reviewListPojo) { + if (reviewListPojo == null || Objects.equals(reviewListPojo.getStatusCode(), ParamValueVersionEnum.REFUSE.getCode()) + || Objects.equals(reviewListPojo.getStatusCode(), ParamValueVersionEnum.PASSED.getCode())) { + throw new CommonException("无效的审批记录请检查是否已经审批完成或被拒绝"); + } + String currentAssignees = reviewListPojo.getApproverPersons(); + return Arrays.asList(currentAssignees.split(",")); + } + /** * 发起审批流程 - 初始化审批数据 * 根据机型ID和用户ID查找待审批的参数数据,生成变更说明并返回给前端显示 @@ -81,10 +89,10 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { && userID.equals(x.getLastUpdatedBy() == null ? "" : x.getLastUpdatedBy())) .collect(Collectors.toList()); if (ObjectUtils.isEmpty(engineParamDetailPojos)) { - throw new RuntimeException(); + throw new CommonException(""); } } catch (Exception e) { - throw new RuntimeException("找不到机型ID对应的参数或机型参数里最新版本没有UPDATE的数据"); + throw new CommonException("找不到机型ID对应的参数或机型参数里最新版本没有UPDATE的数据"); } ArrayList activitiDataDTOS = new ArrayList<>(); ArrayList das = new ArrayList<>(); @@ -94,7 +102,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { .eq("id", parameterId) .doQuery(ParameterPojo.class); if (ObjectUtils.isEmpty(parameters)) { - throw new RuntimeException("未找到对应参数模板中的参数"); + throw new CommonException("未找到对应参数模板中的参数"); } ParameterPojo parameter = parameters.get(0); String com = ""; @@ -116,7 +124,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { } DataEntryEngineModelPojo modelPojo = dataEntryEngineModelService.selectBymodelId(engineParamDetailPojo.getEngineModelId()); if (ObjectUtils.isEmpty(modelPojo)) { - throw new RuntimeException("该发动机型号不存在"); + throw new CommonException("该发动机型号不存在"); } ActivitiDataDTO activitiDataDTO = new ActivitiDataDTO(); BeanUtils.copyProperties(engineParamDetailPojo, activitiDataDTO); @@ -169,17 +177,17 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { .filter(x -> ParamOperationEnum.UPDATE.toString() .equals(x.getOperation()) && userId.equals(x.getLastUpdatedBy() == null ? "" : x.getLastUpdatedBy())).collect(Collectors.toList()); if (ObjectUtils.isEmpty(paramList)) { - throw new RuntimeException(); + throw new CommonException(""); } } catch (Exception e) { - throw new RuntimeException("找不到机型ID对应的参数或机型参数里最新版本没有UPDATE的数据"); + throw new CommonException("找不到机型ID对应的参数或机型参数里最新版本没有UPDATE的数据"); } String engineModelId = approvalNodeRequest.getModelId(); // 查询旧的发动机型号信息 DataEntryEngineModelPojo modelPojoOld = dataEntryEngineModelService.selectBymodelId(engineModelId); //获取提交人 - XdapUsers XdapUsers = xdapDeptUsersService.selectUserByID(userId); - String createBy = ObjectUtils.isNotEmpty(XdapUsers) ? XdapUsers.getUsername() : null; + XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId); + String createBy = ObjectUtils.isNotEmpty(xdapUsers) ? xdapUsers.getUsername() : null; String approvalId = UUID.randomUUID().toString(); if (approvalNodeRequest.getFlowId() != null && !approvalNodeRequest.getFlowId().isEmpty()) { @@ -296,7 +304,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { ); } - /** * 处理审批操作 * 根据用户的审批操作(通过/拒绝)来推进审批流程,并更新相关数据状态 @@ -317,7 +324,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { .doQueryFirst(EngineReviewListPojo.class); List assigneeList = getStrings(reviewListPojo); if (!assigneeList.contains(approver)) { - throw new RuntimeException("当前用户无权限处理此审批环节"); + throw new CommonException("当前用户无权限处理此审批环节"); } ParamApprovalRecordPojo lastedRecord = bd.getBusinessDatabase() @@ -358,20 +365,11 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { // 如果有待插入的参数明细数据,则执行批量插入 if (ObjectUtils.isNotEmpty(list)) { - batchInsertParamDetail(list); + bd.getBusinessDatabase().doBatchInsert(list); } return "已审批"; } - private static List getStrings(EngineReviewListPojo reviewListPojo) { - if (reviewListPojo == null || Objects.equals(reviewListPojo.getStatusCode(), ParamValueVersionEnum.REFUSE.getCode()) - || Objects.equals(reviewListPojo.getStatusCode(), ParamValueVersionEnum.PASSED.getCode())) { - throw new RuntimeException("无效的审批记录请检查是否已经审批完成或被拒绝"); - } - String currentAssignees = reviewListPojo.getApproverPersons(); - return Arrays.asList(currentAssignees.split(",")); - } - @Override public void processApproval( EngineReviewListPojo flow, @@ -673,7 +671,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { * * @param flowId 流程ID * @param title 新的流程标题 - * @return void */ @Override @Transactional @@ -716,7 +713,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { * * @param flowId 流程ID * @param userId 用户ID - * @return void */ @Override public void continueApproval(String flowId, String userId) { @@ -800,7 +796,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { * 更新审批流程中的节点配置信息 * * @param form 更新节点表单对象 - * @return void */ @Override public void updateNode(UpdateNodeForm form) { @@ -825,35 +820,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { } } - /** - * 平台发起审批流程 - * 从外部平台发起审批时,在本地系统创建相应的审批流程记录 - * - * @param request 审批请求对象,包含审批的基本信息 - * @return void - */ - @Override - public void startActivitiByPlatform(ApprovalByPlatformRequest request) { - - DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(request.getModelID()); - EngineReviewListPojo engineReviewListPojo = new EngineReviewListPojo(); - engineReviewListPojo.setId(request.getDocumentID()); - engineReviewListPojo.setModelId(request.getModelID()); - engineReviewListPojo.setModelName(dataEntryEngineModelPojo.getModelName()); - engineReviewListPojo.setYcOrOth(dataEntryEngineModelPojo.getYcOrOth()); - String processTopic = "参数审批"; - engineReviewListPojo.setProcessTopic(processTopic); - engineReviewListPojo.setStatusCode(ParamValueVersionEnum.UNDER.getCode()); - engineReviewListPojo.setApplicant(request.getApplicant()); - engineReviewListPojo.setStatusDescription(ParamValueVersionEnum.UNDER.getDesc()); - engineReviewListPojo.setNodeName(request.getNodeName()); - engineReviewListPojo.setApproverPersons(String.join(",", request.getApproverPersons())); - engineReviewListPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now())); - engineReviewListPojo.setCreatedBy(request.getApplicant()); - bd.getBusinessDatabase().doInsert(engineReviewListPojo); - - } - /** * 判断是否为直送流程 * 检查指定流程是否为直送流程 @@ -1002,18 +968,19 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { .doUpdate(TodoTaskPojo.class); // 创建直送记录 - ParamApprovalRecordPojo record = new ParamApprovalRecordPojo( - flow.getId(), - "直送至" + preNode.getNodeName(), - xdapDeptUsersService.selectUserByID(userId).getUsername(), - "MSG", - Timestamp.valueOf(LocalDateTime.now()), - "直送", - currentNode.getNodeOrder(), - Timestamp.valueOf(LocalDateTime.now()), - level + bd.getBusinessDatabase().doInsert( + new ParamApprovalRecordPojo( + flow.getId(), + "直送至" + preNode.getNodeName(), + xdapDeptUsersService.selectUserByID(userId).getUsername(), + "MSG", + Timestamp.valueOf(LocalDateTime.now()), + "直送", + currentNode.getNodeOrder(), + Timestamp.valueOf(LocalDateTime.now()), + level + ) ); - bd.getBusinessDatabase().doInsert(record); } /** @@ -1047,7 +1014,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { * 将审批流程退回至指定节点 * * @param form 退回节点表单 - * @return void */ @Override public void handleReturnToNode(HandleReturnNodeForm form) { @@ -1190,16 +1156,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { } } - /** - * 批量插入参数明细数据 - * 在审批通过后,批量插入新版本的参数数据 - * - * @param engineParamDetailPojos 参数明细POJO列表 - */ - @Transactional // 发生任何异常都回滚 - public void batchInsertParamDetail(List engineParamDetailPojos) { - bd.getBusinessDatabase().doBatchInsert(engineParamDetailPojos); - } /** * 查看审批详情 @@ -1212,7 +1168,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { public ActivitiDataAndRecordDTO showActivitiData(ShowActivitiDTO showActivitiDTO) { String approvalId = showActivitiDTO.getApprovalId(); if (approvalId == null) { - throw new RuntimeException("无效的审批记录"); + throw new CommonException("无效的审批记录"); } ActivitiDataAndRecordDTO activitiDataAndRecordDTO = new ActivitiDataAndRecordDTO(); //查找审批数据 @@ -1224,7 +1180,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { .doQuery(EngineParamDetailPojo.class); List ids = detailPojos.stream().map(EngineParamDetailPojo::getId).collect(Collectors.toList()); if (ObjectUtils.isEmpty(ids)) { - throw new RuntimeException("该审批流没有绑定的参数,请维护好参数后重新发起审批"); + throw new CommonException("该审批流没有绑定的参数,请维护好参数后重新发起审批"); } // 查询数据变更评论 List dataChangeCommentPojos = bd.getBusinessDatabase() @@ -1239,7 +1195,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService { activitiDataDTOS.add(activitiDataDTO); } activitiDataAndRecordDTO.setActivitiDataDTOS(activitiDataDTOS); - // TODO生成审批记录节点 List flowNodes = new ArrayList<>(); EngineReviewListPojo flow = bd.getBusinessDatabase() .eq("id", approvalId) diff --git a/src/main/java/com/xdap/self_development/service/impl/AnalysisCommonParametersServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/AnalysisCommonParametersServiceImpl.java index 40b7faf..81dbb2f 100644 --- a/src/main/java/com/xdap/self_development/service/impl/AnalysisCommonParametersServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/AnalysisCommonParametersServiceImpl.java @@ -1,23 +1,24 @@ package com.xdap.self_development.service.impl; -import java.util.regex.Pattern; - import com.xdap.self_development.common.BusinessDatabase; -import com.xdap.self_development.controller.request.*; -import com.xdap.self_development.exception.CommonException; -import com.xdap.self_development.domain.pojo.*; +import com.xdap.self_development.controller.request.ReportRequest; +import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo; +import com.xdap.self_development.domain.pojo.EngineParamDetailPojo; +import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.view.AnalysisModelParamterView; import com.xdap.self_development.domain.view.AnalysisModelParamterViewAndParam; -import com.xdap.self_development.service.*; +import com.xdap.self_development.exception.CommonException; +import com.xdap.self_development.service.AnalysisCommonParametersService; +import com.xdap.self_development.service.TcDataQueryService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.*; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -32,65 +33,15 @@ import java.util.stream.Stream; @Service public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParametersService { - // 机型处理批次大小 - @Value("${tc.query.model.batch.size:20}") - private Integer modelBatchSize; - - @Autowired + @Resource BusinessDatabase businessDatabase; - @Autowired - EngineParamDetailService engineParamDetailService; - @Autowired + + @Resource TcDataQueryService tcDataQueryService; - @Autowired - DataEntryEngineModelService dataEntryEngineModelService; + private static final Pattern ALL_NUMBER_PATTERN = Pattern.compile("^[-+]?\\d+(\\.\\d+)?([Ee][-+]?\\d+)?$"); - /** - * 根据常用参数选择模型参数 - * 根据分析请求对象筛选符合条件的模型参数 - * - * @param analysisRequest 分析请求对象 - * @return 模型参数视图列表 - */ - @Override - public ArrayList selectModelParamByCommon(AnalysisRequest analysisRequest) { -// if (ObjectUtils.isEmpty(analysisRequest.getModelIds()) || ObjectUtils.isEmpty(analysisRequest) || ObjectUtils.isEmpty(analysisRequest.getCommonId())) { -// log.warn("analysisRequest is empty"); -// return null; -// } -// List commons = businessDatabase.getBusinessDatabase() -// .eq("common_id", analysisRequest.getCommonId()) -// .doQuery(ModelCommonParametersPojo.class); -// List paramIds = commons.stream().map(x -> x.getParameterId()).collect(Collectors.toList()); -// if (ObjectUtils.isEmpty(paramIds)) { -// return null; -// } -// -// ArrayList analysisModelParamterViews = new ArrayList<>(); -// //查找每个机型的参数并且根据常用筛选 -// for (String modelId : analysisRequest.getModelIds()) { -// List pojoListAll = new ArrayList<>(); -// List pojoList = engineParamDetailService.selectByModelNewVersion(modelId); -// List pojos = pojoList.stream() -// .filter(x -> paramIds.contains(x.getParameterId())).collect(Collectors.toList()); -// if (ObjectUtils.isNotEmpty(pojos)) { -// pojoListAll.addAll(pojos); -// } -// AnalysisModelParamterView analysisModelParamterView = new AnalysisModelParamterView(); -// DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(modelId); -// analysisModelParamterView.setModelID(modelId); -// analysisModelParamterView.setModelName(ObjectUtils.isEmpty(dataEntryEngineModelPojo.getModelName()) ? "" : dataEntryEngineModelPojo.getModelName()); -// analysisModelParamterView.setPojos(pojoListAll); -// analysisModelParamterViews.add(analysisModelParamterView); -// -// } -// -// return analysisModelParamterViews; - return null; - } - /** * 显示报表 * 根据模型列表生成分析报表 @@ -105,21 +56,6 @@ public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParame } - - /** - * 显示报表参数列表 - * 根据报表请求返回参数列表 - * - * @param request 报表请求对象 - * @return 分析模型参数视图和参数对象 - */ - @Override - public AnalysisModelParamterViewAndParam showReportParamList(ReportRequest request) { - -// return showReport1(request); - return null; - } - /** * 模糊查询模型 * 根据报表请求条件模糊匹配符合条件的模型 @@ -164,67 +100,7 @@ public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParame .doQuery(ParameterPojo.class); return modelParams.stream().filter(x -> x.getUnit() != null && !x.getUnit().equals("/")).map(ParameterPojo::getParameterName).distinct().collect(Collectors.toList()); } -/* - public AnalysisModelParamterViewAndParam showReport1(List modelIds) { - long startTime = System.currentTimeMillis(); - List queryResult = businessDatabase.getBusinessDatabase() -// .eq("yc_or_oth", request.getYcOrOth()) - .like("model_name", request.getModelName()) -// .like("product_number", request.getProductNumber()) - .like("plate", request.getPlate()) - .like("platform", request.getPlatform()) - .like("series", request.getSeries()) -// .like("market_segment", request.getMarketSegment()) - .like("project_name", request.getProjectName()) - .like("project_number", request.getProjectNumber()) - .like("emission", request.getEmission()) - .like("burn_type", request.getBurnType()) - .doQuery(DataEntryEngineModelPojo.class); - Double engineCapacityMin = request.getEngineCapacityMin(); - Double engineCapacityMax = request.getEngineCapacityMax(); - List engineModelPojos = queryResult; - if (ObjectUtils.isNotEmpty(engineCapacityMin) && ObjectUtils.isNotEmpty(engineCapacityMax)) { - engineModelPojos = queryResult.stream().filter(dataEntryEngineModelPojo -> { - String engineCapacity = dataEntryEngineModelPojo.getEngineCapacity(); - Double ec = extractDisplacement(engineCapacity); - if (ec == null) { - return false; - } - return (Double.compare(ec, engineCapacityMin) >= 0 && Double.compare(ec, engineCapacityMax) < 0); - }).collect(Collectors.toList()); - } - - AnalysisModelParamterViewAndParam andParam = new AnalysisModelParamterViewAndParam(); - ArrayList analysisModelParamterViews = new ArrayList<>(); - - for (DataEntryEngineModelPojo engineModelPojo : engineModelPojos) { - AnalysisModelParamterView analysisModelParamterView = new AnalysisModelParamterView(); - List pojoList = engineParamDetailService.selectByModelNewVersion(engineModelPojo.getId()); - // - ArrayList engineParamDetailPojos = tcDataQueryService.tcDataSelectAllByproductNumber(engineModelPojo); - if (ObjectUtils.isNotEmpty(engineParamDetailPojos)) { - pojoList.addAll(engineParamDetailPojos); - } - pojoList = pojoList.stream().filter(x -> ObjectUtils.isNotEmpty(x.getParameterValue()) && isNumber(x.getParameterValue())).collect(Collectors.toList()); - analysisModelParamterView.setModelID(engineModelPojo.getId()); - analysisModelParamterView.setModelName(engineModelPojo.getModelName()); - BeanUtils.copyProperties(engineModelPojo, analysisModelParamterView); - analysisModelParamterView.setPojos(pojoList); - analysisModelParamterViews.add(analysisModelParamterView); - } - List list = new ArrayList<>(); - for (AnalysisModelParamterView analysisModelParamterView : analysisModelParamterViews) { - analysisModelParamterView.getPojos().stream().forEach(x -> list.add(x.getParameterName())); - } - List strings = list.stream().distinct().collect(Collectors.toList()); - andParam.setParamList(strings); - andParam.setPojos(analysisModelParamterViews); - long endTime = System.currentTimeMillis(); -// throw new RuntimeException(String.valueOf(endTime-startTime)); - return andParam; - } -*/ /** * 显示报表2 * 根据模型列表生成分析报表(第二个实现) @@ -308,31 +184,4 @@ public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParame return ALL_NUMBER_PATTERN.matcher(str.trim()).matches(); } - /** - * 分批处理机型 - * 将模型列表按照指定批次大小分割 - * - * @param source 源模型列表 - * @param batchSize 批次大小 - * @return 分割后的批次列表 - */ - private List> splitModelBatch( - List source, - int batchSize - ) { - List> batches = new ArrayList<>(); - List currentBatch = new ArrayList<>(batchSize); - for (DataEntryEngineModelPojo pojo : source) { - currentBatch.add(pojo); - if (currentBatch.size() >= batchSize) { - batches.add(new ArrayList<>(currentBatch)); - currentBatch.clear(); - } - } - if (!currentBatch.isEmpty()) { - batches.add(currentBatch); - } - return batches; - } - } diff --git a/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java index af49f6a..74deecf 100644 --- a/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java @@ -8,15 +8,14 @@ import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.runtime.service.RuntimeAppContextService; import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.form.*; +import com.xdap.self_development.domain.dto.*; +import com.xdap.self_development.domain.pojo.*; +import com.xdap.self_development.domain.view.ApprovalFlowNodeView; +import com.xdap.self_development.domain.view.FlowNode; +import com.xdap.self_development.domain.view.TodoAndReportListView; +import com.xdap.self_development.domain.view.TodoAndReportView; import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.feign.ApaasMyTokenFeign; -import com.xdap.self_development.domain.dto.AppTokenDTO; -import com.xdap.self_development.domain.dto.FileUploadDTO; -import com.xdap.self_development.domain.dto.UserTokenDT0; -import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.ApprovalNodeDTO; -import com.xdap.self_development.domain.dto.ApprovalNodesDTO; -import com.xdap.self_development.domain.view.*; import com.xdap.self_development.service.BenchmarkingReportService; import com.xdap.self_development.service.XdapDeptUsersService; import com.xdap.self_development.utils.RedisLockUtils; @@ -194,13 +193,13 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService ); UserTokenDT0 userToken = apaasMyTokenFeign.getUserToken( - token.getAccess_token(), + token.getAccessToken(), userId ); String uploadId = new ObjectId().toHexString(); FileUploadDTO fileUploadDTO = apaasMyTokenFeign.uploadFile( - "Bearer " + userToken.getAccess_token(), + "Bearer " + userToken.getAccessToken(), "application/x-www-form-urlencoded", file, uploadId, diff --git a/src/main/java/com/xdap/self_development/service/impl/CommonParameterServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/CommonParameterServiceImpl.java index c37489f..ca8a8e0 100644 --- a/src/main/java/com/xdap/self_development/service/impl/CommonParameterServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/CommonParameterServiceImpl.java @@ -2,10 +2,10 @@ package com.xdap.self_development.service.impl; import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.form.*; -import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.domain.view.ParameterItem; import com.xdap.self_development.domain.view.ParametersView; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.CommonParameterService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/xdap/self_development/service/impl/DataEntryEngineModelServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/DataEntryEngineModelServiceImpl.java index 2be775a..bbf60e0 100644 --- a/src/main/java/com/xdap/self_development/service/impl/DataEntryEngineModelServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/DataEntryEngineModelServiceImpl.java @@ -11,16 +11,17 @@ import com.definesys.mpaas.query.MpaasQueryFactory; import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.runtime.service.RuntimeDatasourceService; +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.request.DataEntryEngineModelExcel; import com.xdap.self_development.controller.request.DataEntryEngineModelPageRequest; +import com.xdap.self_development.domain.dto.DataEntryEngineModelDto; +import com.xdap.self_development.domain.dto.PageResultDTO; import com.xdap.self_development.domain.enums.DistributeStatusEnum; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; +import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.ExcelImportException; import com.xdap.self_development.listener.EngineModelListener; -import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.DataEntryEngineModelDto; -import com.xdap.self_development.domain.dto.PageResultDTO; import com.xdap.self_development.service.DataEntryEngineModelService; import com.xdap.self_development.service.EngineParamDetailService; import com.xdap.self_development.service.ResponsiblePerService; @@ -29,7 +30,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.poi.ss.usermodel.IndexedColors; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -55,16 +55,18 @@ import java.util.stream.Collectors; public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelService { - @Autowired - private MpaasQueryFactory sw; - @Autowired + @Resource + private BusinessDatabase bd; + @Resource private ResponsiblePerService responsiblePerService; @Resource private RuntimeDatasourceService runtimeDatasourceService; - @Autowired + @Resource private XdapDeptUsersService xdapDeptUsersService; - @Autowired + @Resource private EngineParamDetailService engineParamDetailService; + @Resource + private MpaasQueryFactory sw; private int page = 1; private int size = 10; @@ -81,10 +83,9 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ */ @Override public List selectAll() { - List modelPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + return bd.getBusinessDatabase() .eq("is_delete", 0) .doQuery(DataEntryEngineModelPojo.class); - return modelPojos; } @@ -113,7 +114,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ if (!ObjectUtils.isEmpty(responsiblePersonPojo)) { resPerIds.add(responsiblePersonPojo.getId()); } else { - throw new RuntimeException("没有找到该责任人"); + throw new CommonException("没有找到该责任人"); } //部门筛选 } else if (ObjectUtils.isNotEmpty(department) && ObjectUtils.isEmpty(resPerson)) { @@ -122,7 +123,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ if (ObjectUtils.isNotEmpty(strings)) { resPerIds.addAll(strings); } else { - throw new RuntimeException("没有找到该部门下责任人"); + throw new CommonException("没有找到该部门下责任人"); } //人员筛选 } else if (ObjectUtils.isEmpty(department) && ObjectUtils.isNotEmpty(resPerson)) { @@ -131,7 +132,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ if (ObjectUtils.isNotEmpty(strings)) { resPerIds.addAll(strings); } else { - throw new RuntimeException("没有找到该责任人"); + throw new CommonException("没有找到该责任人"); } } @@ -144,8 +145,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc(request.getDistributeStatus()); Integer status = byDesc != null ? byDesc.getCode() : null; - PageQueryResult pageQueryResult = sw - .buildFromDatasource("xdap_app_223770822127386625") + PageQueryResult pageQueryResult = bd.getBusinessDatabase() .eq("yc_or_oth", request.getYcOrOth()) .like("model_name", request.getModelName()) .like("product_number", request.getProductNumber()) @@ -165,16 +165,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ DataEntryEngineModelDto dataEntryEngineModelDto = new DataEntryEngineModelDto(); BeanUtils.copyProperties(modelPojo, dataEntryEngineModelDto); dataEntryEngineModelDto.setId(modelPojo.getId()); - //部门,责任人,状态 -// 去掉责任人和部门 ResponsiblePersonPojo responsiblePersonPojo1 = responsiblePersonService.selectById(modelPojo.getResponsiblePersonId()); -// XdapDepartmentsPojo deptByID = xdapDeptUsersService.selectDeptByID(responsiblePersonPojo1.getXdapDepartmentId()); -// XdapUsersPojo xdapUsersPojo = xdapDeptUsersService.selectUserByID(responsiblePersonPojo1.getXdapUserId()); -// if (ObjectUtils.isNotEmpty(deptByID)) { -// dataEntryEngineModelDto.setDept(deptByID.getName()); -// } -// if (ObjectUtils.isNotEmpty(xdapUsersPojo)) { -// dataEntryEngineModelDto.setResPerson(xdapUsersPojo.getUsername()); -// } + DistributeStatusEnum byDesc1 = DistributeStatusEnum.getByCode(modelPojo.getDistributeStatus()); dataEntryEngineModelDto.setDistributeStatus(byDesc1 != null ? byDesc1.getDesc() : null); dataEntryEngineModelDtos.add(dataEntryEngineModelDto); @@ -214,7 +205,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ .doRead(); } catch (IOException e) { log.error("读取文件异常"); - throw new RuntimeException(e); + throw new CommonException("读取文件异常"); } catch (RuntimeException e) { throw new ExcelImportException(e.getMessage()); } @@ -230,75 +221,19 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ */ @Override @Transactional - public int insert(DataEntryEngineModelPageRequest request, String userId) {/* - DateTime date = DateUtil.date(); - String createdBy = "添加机型"; - Date createdDate = date; - String lastModifiedBy = ""; - Date lastModifiedDate = date; - - DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo(); - BeanUtils.copyProperties(request, modelPojo, "status", "lastModifiedDate", "lastModifiedBy", "createdBy", "createdDate"); - modelPojo.setCreatedBy(createdBy); - modelPojo.setCreatedDate(createdDate); - modelPojo.setLastUpdatedBy(lastModifiedBy); - modelPojo.setLastUpdatedDate(lastModifiedDate); - log.info(request.toString()); - String depId; - request.getDepartment(), request.getResPerson() - List users = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") - .eq("id", userId) - .doQuery(XdapUsersPojo.class); - ResponsiblePersonPojo personPojo = responsiblePersonService.selectByDep(depId); - if (ObjectUtils.isNotNull(personPojo)) { - modelPojo.setResponsiblePersonId(personPojo.getId()); - } else { - personPojo = new ResponsiblePersonPojo(); - personPojo.setCreatedBy(createdBy); - personPojo.setLastUpdatedBy(lastModifiedBy); - personPojo.setLastUpdatedDate(lastModifiedDate); - personPojo.setCreatedDate(createdDate); - personPojo.setResponsiblePerson(request.getResPerson()); - personPojo.setDepartment(request.getDepartment()); - log.info(personPojo.getRowId()); - Object id = responsiblePersonService.insert(personPojo); - modelPojo.setResponsiblePersonId((String) id); - } - DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc(StrUtil.isEmpty(request.getStatus()) ? "" : request.getStatus()); - modelPojo.setStatus(byDesc != null ? byDesc.getCode() : null); - modelPojo.setVersionNumber(versionNumber); - modelPojo.setIsDelete(0); - Object testDemo = null; - try { - testDemo = sw.buildFromDatasource("test_demo") - .doInsert(modelPojo); - log.info("发动机型号数据写入成功,{}", testDemo.toString()); - } catch (Exception e) { - log.error("发动机型号数据写入失败"); - throw new RuntimeException(e); - } - - return 0;*/ + public int insert(DataEntryEngineModelPageRequest request, String userId) { List parameters = engineParamDetailService.selectAllByNewVersion(); DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo(); BeanUtils.copyProperties(request, modelPojo, "status"); - List personPojos = responsiblePerService.selectByDepName(request.getDepartment()); - List modelPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List modelPojos = bd.getBusinessDatabase() .eq("product_number", request.getProductNumber()) -// .eq("brand", data.getBrand()) .doQuery(DataEntryEngineModelPojo.class); if (ObjectUtils.isNotEmpty(modelPojos)) { throw new ExcelImportException( "请检查该型号是否已经存在" ); } -// 去掉责任人 if (ObjectUtils.isEmpty(personPojos)) { -// throw new ExcelImportException( -// String.format("请检查该部门是否有责任人,部门:%s", request.getDepartment()) -// ); -// } else { -// modelPojo.setResponsiblePersonId(personPojos.get(0).getId()); -// } + List users = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") .eq("id", userId) .doQuery(XdapUsers.class); @@ -319,43 +254,12 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ modelPojo.setLastUpdateDate(Timestamp.valueOf(LocalDateTime.now())); modelPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now())); modelPojo.setId(UUID.randomUUID().toString()); - sw.buildFromDatasource("xdap_app_223770822127386625").doInsert(modelPojo); + bd.getBusinessDatabase().doInsert(modelPojo); saveDataParamDetail(modelPojo, parameters, versionNumber, xdapUsersPojo); return 0; } - //模板管理审批完成触发更新 参数版本 - //遍历所有机型 把所有机型的版本加一 状态为未分发 绑定新版参数新版参数版本加一 所有新参数值为空 重新走分发 - /** - * 更新模型到新版本 - * 将所有机型更新到新版本并绑定新参数 - * - * @return void - */ - @Override - @Transactional - public void updateModelForNewVersion() { - List parameters = engineParamDetailService.selectAllByNewVersion(); - DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("未分发"); - Integer distribute_status = byDesc != null ? byDesc.getCode() : null; - List entryEngineModelPojos = selectAll(); - - for (DataEntryEngineModelPojo entryEngineModelPojo : entryEngineModelPojos) { - Integer oldVersionNum = entryEngineModelPojo.getVersionNumber(); - Integer newVersionNum = oldVersionNum + 1; - sw.buildFromDatasource("xdap_app_223770822127386625") - .update("distribute_status", distribute_status) - .update("version_number", newVersionNum) - .update("last_updated_by", "模板审核完成触发") - .update("last_update_date", new Date()) - .rowid("id", entryEngineModelPojo.getId()) - .doUpdate(DataEntryEngineModelPojo.class); - //绑定参数准备重新走分发 - saveDataParamDetail(entryEngineModelPojo, parameters, newVersionNum, null); - } - } - /** * 为每个机型绑定参数 * 将参数与发动机型号进行绑定 @@ -393,63 +297,13 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ //为每个参数生成默认责任人 List personPojos = responsiblePerService.selectByDepName(parameter.getDepartment()); if (ObjectUtils.isNotEmpty(personPojos)) { -// 不再默认生成责任人 engineParamDetailPojo.setResponsiblePersonId(personPojos.get(0).getId()); } engineParamDetailPojos.add(engineParamDetailPojo); } - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(engineParamDetailPojos); - -// -// //生成分解任务给责任人 参数根据机型+责任人分组 生成数据 -// List paramDetailPojos = engineParamDetailPojos.stream() -// // 以engineModelId和responsiblePersonId组合作为key,元素本身作为value -// .collect(Collectors.toMap(pojo -> pojo.getEngineModelId() + "_" + pojo.getResponsiblePersonId(), -// pojo -> pojo, -// (existing, replacement) -> existing -// )) -// // 提取去重后的value集合 -// .values() -// .stream() -// .collect(Collectors.toList()); -// ArrayList todoTaskPojos = new ArrayList<>(); -// for (EngineParamDetailPojo paramDetailPojo : paramDetailPojos) { -// //组装待办 -// TodoTaskPojo todoTaskPojo = new TodoTaskPojo(); -// todoTaskPojo.setCreatedById(xdapUsersPojo.getId()); -// todoTaskPojo.setDocumentNo(UUID.randomUUID().toString()); -// todoTaskPojo.setProcessTitle("新增发动机型号流程"); -// todoTaskPojo.setCurrentNode(CurrentNodeEnum.JOBSPLIT.getDesc()); -// todoTaskPojo.setStatusCode(String.valueOf(ParamValueVersionEnum.DRAFT.getCode())); -// todoTaskPojo.setModelName(modelPojo.getModelName()); -// todoTaskPojo.setModelId(modelPojo.getId()); -// todoTaskPojo.setCreationDate(new Date()); -// todoTaskPojo.setDataType("玉柴"); -// todoTaskPojo.setVersionNumber(versionNumber); -// todoTaskPojo.setIsDelete(0); -// if (ObjectUtils.isNotEmpty(paramDetailPojo.getResponsiblePersonId())) { -// ResponsiblePersonPojo responsiblePersonPojo = responsiblePerService.selectById(paramDetailPojo.getResponsiblePersonId()); -// todoTaskPojo.setOwnerId(ObjectUtils.isNotEmpty(responsiblePersonPojo) ? responsiblePersonPojo.getUserId() : null); -// } -// todoTaskPojo.setCreatedBy(xdapUsersPojo.getUsername()); -// todoTaskPojos.add(todoTaskPojo); -// } - -// 又不在这生成待办了 改为管理员进去选择责任人后待办 batchInsertTodoTask(todoTaskPojos); + bd.getBusinessDatabase().doBatchInsert(engineParamDetailPojos); } - /** - * 批量插入待办任务 - * 批量添加待办任务到数据库 - * - * @param todoTaskPojos 待办任务POJO列表 - * @return void - */ - public void batchInsertTodoTask(List todoTaskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(todoTaskPojos); - } - - /** * Excel导出发动机型号数据 * 导出发动机型号数据到Excel文件 @@ -459,12 +313,9 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ */ @Override public void excelExport(HttpServletResponse response) { - try { - setupResponse(response, "机型导入模板" + (formatter.format(LocalDateTime.now()))); - } catch (IOException e) { - } // 定义Sheet名称集合 try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) { + setupResponse(response, "机型导入模板" + (formatter.format(LocalDateTime.now()))); List dataEntryEngineModelExcel = new ArrayList<>(); WriteCellStyle headWriteCellStyle = new WriteCellStyle(); // 设置背景色为灰色 @@ -485,7 +336,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ .build(); excelWriter.write(dataEntryEngineModelExcel, sheet); // 写入数据,只生成表头 } catch (Exception e) { - e.printStackTrace(); + throw new CommonException("导出Excel文件异常"); } } @@ -499,7 +350,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ @Override public DataEntryEngineModelPojo selectBymodelId(String modelId) { if (ObjectUtils.isNotEmpty(modelId)) { - List modelPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List modelPojos = bd.getBusinessDatabase() .eq("id", modelId).doQuery(DataEntryEngineModelPojo.class); if (ObjectUtils.isNotEmpty(modelPojos)) { return modelPojos.get(0); @@ -517,7 +368,7 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ */ @Override public PageResultDTO selectVersionByConditionPage() { - List list = sw.buildFromDatasource("xdap_app_223770822127386625") + List list = bd.getBusinessDatabase() .viewQueryMode(true) .view("selectVersionByConditionPage") .doQuery(DataEntryEngineModelDto.class); @@ -536,21 +387,21 @@ public class DataEntryEngineModelServiceImpl implements DataEntryEngineModelServ */ @Override public void delete(String modelId) { - EngineReviewListPojo model = sw.buildFromDatasource("xdap_app_223770822127386625") + EngineReviewListPojo model = bd.getBusinessDatabase() .eq("model_id", modelId) .doQueryFirst(EngineReviewListPojo.class); if (!ObjectUtils.isEmpty(model)) { throw new CommonException("参数值在审批值,机型无法删除"); } - List initiatedTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List initiatedTaskPojos = bd.getBusinessDatabase() .eq("model_id", modelId) .doQuery(InitiatedTaskPojo.class); if (!ObjectUtils.isEmpty(initiatedTaskPojos)) { throw new CommonException("机型已分发,无法删除"); } - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("id", modelId) .doDelete(DataEntryEngineModelPojo.class); } diff --git a/src/main/java/com/xdap/self_development/service/impl/DataEntryServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/DataEntryServiceImpl.java index 8ab2d73..e7125f4 100644 --- a/src/main/java/com/xdap/self_development/service/impl/DataEntryServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/DataEntryServiceImpl.java @@ -1,18 +1,15 @@ package com.xdap.self_development.service.impl; -import com.definesys.mpaas.query.MpaasQueryFactory; +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.form.OptionForm; -import com.xdap.self_development.controller.form.TemplateForm; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.TemplatePojo; import com.xdap.self_development.service.DataEntryService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import java.util.Collections; import java.util.List; @@ -26,44 +23,9 @@ import java.util.List; @Slf4j @Service public class DataEntryServiceImpl implements DataEntryService { - @Resource - private MpaasQueryFactory sw; - /** - * 读取Excel文件 - * 从上传的Excel文件中读取数据 - * - * @param file Excel文件 - * @return void - */ - @Override - public void readExcel(MultipartFile file) { + @Resource + private BusinessDatabase bd; - } - - /** - * 写入Excel文件 - * 将数据写入Excel文件并输出到响应 - * - * @param form 选项表单 - * @param response HTTP响应对象 - * @return void - */ - @Override - public void writeExcel(OptionForm form, HttpServletResponse response) { - - } - - /** - * 插入参数 - * 根据模板表单插入新的参数数据 - * - * @param form 模板表单 - * @return void - */ - @Override - public void insertParameter(TemplateForm form) { - - } /** * 根据条件获取参数 @@ -74,8 +36,7 @@ public class DataEntryServiceImpl implements DataEntryService { */ @Override public List getParameterByCondition(OptionForm form) { - List parameters = sw.buildFromDatasource("xdap_app_223770822127386625").doQuery(ParameterPojo.class); - return parameters; + return bd.getBusinessDatabase().doQuery(ParameterPojo.class); } /** @@ -89,170 +50,4 @@ public class DataEntryServiceImpl implements DataEntryService { public List getTemplateByCondition(String templateName) { return Collections.emptyList(); } - - // -// @Override -// public void readExcel(MultipartFile file) { -// try (InputStream inputStream = file.getInputStream()){ -// EasyExcel.read(inputStream, ParameterPojo.class, new SheetDataListener(sw)).doReadAll(); -// } catch (IOException e) { -// throw new RuntimeException("读取文件失败", e); -// } -// } -// -// @Override -// public void writeExcel(OptionForm form, HttpServletResponse response) { -// String fileName = form.getTemplateName() + -// (form.getTemplateEmpty() ? "空模板_" : "参数模板_") + -// LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")); -// -// try { -// setupResponse(response, fileName); -// -// if (form.getTemplateName() == null || form.getTemplateName().trim().isEmpty()) { -// throw new RuntimeException("未指定模板名称"); -// } -// -// String templateName = form.getTemplateName().trim(); -// List templates = sw.buildFromDatasource("template_db2") -// .eq("template_name", templateName) -// .doQuery(TemplatePojo.class); -// if (templates.size() != 1) { -// throw new RuntimeException("查找模板异常"); -// } -// TemplatePojo template = templates.get(0); -// -// Set fieldList = getIncludeColumnFieldNames(form); -// List list; -// if (form.getTemplateEmpty()) { -// list = new ArrayList<>(); -// list.add(new ParameterPojo()); -// } else { -// list = sw.buildFromDatasource("template_db2") -// .viewQueryMode(true) -// .view("selectParametersByTemplateId") -// .setVar("templateId", template.getId()) -// .like("parts_name", form.getPartsName()) -// .like("parameter_type", form.getParameterType()) -// .like("parameter_name", form.getParameterName()) -// .doQuery(ParameterPojo.class); -// } -// EasyExcel.write(response.getOutputStream(), ParameterPojo.class) -// .includeColumnFieldNames(fieldList) -// .sheet(form.getTemplateName()) -// .doWrite(list); -// -// } catch (Exception e) { -// throw new RuntimeException("导出Excel失败: " + e.getMessage(), e); -// } -// } -// -// -// private static Set getIncludeColumnFieldNames(OptionForm form) { -// Set includeColumnFieldNames; -// if ("公式运算需求汇总".equals(form.getTemplateName())) { -// includeColumnFieldNames = new HashSet<>(); -// includeColumnFieldNames.add("number"); -// includeColumnFieldNames.add("parameterTemplateName"); -// includeColumnFieldNames.add("subsystemName"); -// includeColumnFieldNames.add("parameterType"); -// includeColumnFieldNames.add("parameterName"); -// includeColumnFieldNames.add("unit"); -// includeColumnFieldNames.add("dataSource"); -// includeColumnFieldNames.add("calculationFormula"); -// includeColumnFieldNames.add("classificationNumber"); -// includeColumnFieldNames.add("isAnnouncementParameters"); -// includeColumnFieldNames.add("remarks"); -// } else { -// includeColumnFieldNames = new HashSet<>(); -// includeColumnFieldNames.add("number"); -// includeColumnFieldNames.add("subsystemName"); -// includeColumnFieldNames.add("type"); -// includeColumnFieldNames.add("partsName"); -// includeColumnFieldNames.add("parameterName"); -// includeColumnFieldNames.add("unit"); -// includeColumnFieldNames.add("parameterSource"); -// includeColumnFieldNames.add("numberOrFormula"); -// includeColumnFieldNames.add("department"); -// includeColumnFieldNames.add("remarks"); -// } -// return includeColumnFieldNames; -// } -// -// @Transactional -// @Override -// public void insertParameter(TemplateForm form) { -// List templates = sw.buildFromDatasource("template_db2") -// .eq("template_name", form.getTemplateName()) -// .doQuery(TemplatePojo.class); -// if (templates.size() != 1) { -// throw new RuntimeException("查找模板错误"); -// } -// TemplatePojo template = templates.get(0); -// ParameterPojo parameter = new ParameterPojo(); -// parameter.setSubsystemName(form.getSubsystemName() == null ? null:form.getSubsystemName()); -// parameter.setType(form.getType() == null ? null:form.getType()); -// parameter.setPartsName(form.getPartsName() == null ? null:form.getPartsName()); -// parameter.setParameterName(form.getParameterName() == null ? null:form.getParameterName()); -// parameter.setUnit(form.getUnit() == null ? null:form.getUnit()); -// parameter.setParameterSource(form.getParameterSource() == null ? null:form.getParameterSource()); -// parameter.setNumberOrFormula(form.getNumberOrFormula() == null ? null:form.getNumberOrFormula()); -// parameter.setDepartment(form.getDepartment() == null ? null:form.getDepartment()); -// parameter.setRemarks(form.getRemarks() == null ? null:form.getRemarks()); -// parameter.setParameterTemplateName(form.getParameterTemplateName() == null ? null:form.getParameterTemplateName()); -// parameter.setParameterType(form.getParameterType() == null ? null:form.getParameterType()); -// parameter.setDataSource(form.getDataSource() == null ? null:form.getDataSource()); -// parameter.setCalculationFormula(form.getCalculationFormula() == null ? null:form.getCalculationFormula()); -// parameter.setClassificationNumber(form.getClassificationNumber() == null ? null:form.getClassificationNumber()); -// parameter.setIsAnnouncementParameters(form.getIsAnnouncementParameters() == null ? null:form.getIsAnnouncementParameters()); -// sw.buildFromDatasource("template_db2") -// .doInsert(parameter); -// TemplateAndParameterPojo templateAndParameter = new TemplateAndParameterPojo(); -// templateAndParameter.setParameterId(parameter.getId()); -// templateAndParameter.setTemplateId(template.getId()); -// sw.buildFromDatasource("template_db2") -// .doInsert(templateAndParameter); -// } -// -// @Override -// public List getParameterByCondition(OptionForm form) { -// List templates = sw.buildFromDatasource("template_db2") -// .eq("template_name", form.getTemplateName()) -// .doQuery(TemplatePojo.class); -// if (templates.size() != 1) { -// throw new RuntimeException("查找模板错误"); -// } -// TemplatePojo template = templates.get(0); -// -// return sw.buildFromDatasource("template_db2") -// .viewQueryMode(true) -// .view("selectParametersByTemplateId") -// .setVar("templateId", template.getId()) -// .like("parts_name", form.getPartsName()) -// .like("parameter_type", form.getParameterType()) -// .like("parameter_name", form.getParameterName()) -// .doQuery(ParameterPojo.class); -// } -// -// @Override -// public List getTemplateByCondition(String templateName) { -// return sw.buildFromDatasource("template_db2") -// .like("template_name", templateName) -// .doQuery(TemplatePojo.class); -// } -// -// private void setupResponse(HttpServletResponse response, String fileName) throws IOException { -// String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); -// -// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); -// response.setCharacterEncoding("UTF-8"); -// response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + encodedFileName + ".xlsx"); -// -// // 禁用缓存 -// response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); -// response.setHeader("Pragma", "no-cache"); -// response.setDateHeader("Expires", 0); -// } - - } diff --git a/src/main/java/com/xdap/self_development/service/impl/EngineParamDetailServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/EngineParamDetailServiceImpl.java index a039d85..a29c30b 100644 --- a/src/main/java/com/xdap/self_development/service/impl/EngineParamDetailServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/EngineParamDetailServiceImpl.java @@ -10,26 +10,26 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.fastjson.JSON; import com.definesys.mpaas.query.MpaasQueryFactory; import com.xdap.api.moudle.user.pojo.XdapUsers; +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.request.EngineParamDetailExcel; import com.xdap.self_development.controller.request.EngineParamDetailRequest; +import com.xdap.self_development.domain.dto.EngineParamDetailDTO; import com.xdap.self_development.domain.enums.CurrentNodeEnum; import com.xdap.self_development.domain.enums.ParamOperationEnum; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; +import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.exception.ExcelImportException; import com.xdap.self_development.listener.EngineParamDetailListener; -import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.EngineParamDetailDTO; import com.xdap.self_development.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.poi.ss.usermodel.IndexedColors; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; @@ -52,19 +52,19 @@ import java.util.stream.Stream; @Service public class EngineParamDetailServiceImpl implements EngineParamDetailService { - @Autowired + @Resource + private BusinessDatabase bd; + @Resource private MpaasQueryFactory sw; - @Autowired + @Resource private DataEntryEngineModelService dataEntryEngineModelService; - @Autowired + @Resource private DataEntryService dataEntryService; - @Autowired + @Resource private XdapDeptUsersService xdapDeptUsersService; - @Autowired + @Resource private ResponsiblePerService responsiblePerService; - private Integer versionNumber = 0; - private String createdBy = "Excel导入"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @@ -85,12 +85,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { parameters = selectAllByNewVersion(); } - List templates = - sw.buildFromDatasource("xdap_app_223770822127386625") + List templates = bd.getBusinessDatabase() .eq("status", "COMPLETE") .doQuery(TemplatePojo.class); if (ObjectUtils.isEmpty(templates)) { - throw new RuntimeException("未找到未找到已发布的参数模板"); + throw new CommonException("未找到未找到已发布的参数模板"); } //查找每个模板最新版本 // 每组内按版本号降序,取第一个(最新版本) @@ -239,12 +238,10 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { String userId ) { // 定义Sheet名称集合 -// List parameterByCondition = dataEntryService.getParameterByCondition(new OptionForm()); - List engineParams = sw.buildFromDatasource("xdap_app_223770822127386625") + List engineParams = bd.getBusinessDatabase() .eq("engine_model_id", modelId) .eq("filled_by", userId) .doQuery(EngineParamDetailPojo.class); -// List parameterByCondition = selectAllByNewVersion(); if (ObjectUtils.isEmpty(engineParams)) { log.error("模板参数为空"); throw new ExcelImportException( @@ -268,7 +265,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .map(EngineParamDetailPojo::getSubsystemName) .distinct().collect(Collectors.toList()); -// List parameters = selectAllByNewVersion(); try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) { setupResponse(response, "参数值导入模板" + (formatter.format(LocalDateTime.now()))); // 循环创建Sheet @@ -291,7 +287,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { excelWriter.write(engineParamDetailExcels, sheet); // 写入数据,只生成表头 } } catch (Exception e) { - e.printStackTrace(); + throw new CommonException("导出Excel文件异常"); } } @@ -308,9 +304,9 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { String subsystemName = engineParamDetailRequest.getSubsystemName(); String parameterType = engineParamDetailRequest.getParameterType(); if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemName) || ObjectUtils.isEmpty(parameterType)) { - throw new RuntimeException("传入参数为空,请检查"); + throw new CommonException("传入参数为空,请检查"); } - List detailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List detailPojos = bd.getBusinessDatabase() .eq("engine_model_id", engineModelID) .eq("subsystem_name", subsystemName) .eq("parameter_type", parameterType) @@ -338,7 +334,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { List subsystemTypes = engineParamDetailRequest.getSubsystemParts(); if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes)) { - throw new RuntimeException("传入参数为空,请检查"); + throw new CommonException("传入参数为空,请检查"); } List detailPojos = new ArrayList<>(); ArrayList engineParamDetailDTOS = new ArrayList<>(); @@ -354,13 +350,13 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { } for (String subsystemType : subsystemTypes) { if (subsystemType.split("-").length != 2) { - throw new RuntimeException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/”"); + throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/”"); } String subsystem = subsystemType.split("-")[0]; String type = subsystemType.split("-")[1]; //若传入填写人则查询填写人需要填写的参数 if (ObjectUtils.isNotEmpty(filledById)) { - detailPojos.addAll(sw.buildFromDatasource("xdap_app_223770822127386625") + detailPojos.addAll(bd.getBusinessDatabase() .eq("filled_by", filledById) .eq("engine_model_id", engineModelID) .eq("version_status", code) @@ -370,7 +366,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .doQuery(EngineParamDetailPojo.class)); } else if (ObjectUtils.isNotEmpty(resId)) { //若传入责任人则查询责任人需要分发的参数 - detailPojos.addAll(sw.buildFromDatasource("xdap_app_223770822127386625") + detailPojos.addAll(bd.getBusinessDatabase() .eq("engine_model_id", engineModelID) .eq("responsible_person_id", resId) .eq("version_status", code) @@ -379,33 +375,18 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .eq("parameter_source", "数据平台手工录入") .doQuery(EngineParamDetailPojo.class)); } else { - detailPojos.addAll(sw.buildFromDatasource("xdap_app_223770822127386625") + detailPojos.addAll(bd.getBusinessDatabase() .eq("engine_model_id", engineModelID) .eq("version_status", code) .eq("subsystem_name", subsystem) .eq("parts_name", type) .eq("parameter_source", "数据平台手工录入") .doQuery(EngineParamDetailPojo.class)); -// 加权限先注释 List pojoList = sw.buildFromDatasource("xdap_app_223770822127386625") -// .eq("engine_model_id", engineModelID) -// .eq("version_status", code) -// .eq("subsystem_name", subsystem) -// .eq("parameter_type", type) -// .doQuery(EngineParamDetailPojo.class); -// //判断当前用户是否有参数权限 -// List parameterIds = userPermissionGetter.getParamPermissions(); -// for (String parameterId : parameterIds) { -// List pojos = pojoList.stream().filter(x -> x.getParameterId().equals(parameterId)) -// .collect(Collectors.toList()); -// if (ObjectUtils.isNotEmpty(pojos)) { -// detailPojos.addAll(pojos); -// } -// } } } if (ObjectUtils.isEmpty(detailPojos)) { - throw new RuntimeException("没有可查看参数,可能是因为您没有权限"); + throw new CommonException("没有可查看参数,可能是因为您没有权限"); } if (ObjectUtils.isNotEmpty(engineParamDetailRequest.getMajorVersion()) && engineParamDetailRequest.getMajorVersion() != 0) { detailPojos = detailPojos.stream() @@ -432,7 +413,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { BeanUtils.copyProperties(detailPojo, engineParamDetailDTO); String unit = ""; if (ObjectUtils.isNotEmpty(detailPojo.getParameterId())) { - List parameters = sw.buildFromDatasource("xdap_app_223770822127386625") + List parameters = bd.getBusinessDatabase() .eq("id", detailPojo.getParameterId()) .doQuery(ParameterPojo.class); unit = parameters.get(0).getUnit(); @@ -445,14 +426,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { engineParamDetailDTO.setApprovalId(detailPojo.getApprovalId()); engineParamDetailDTOS.add(engineParamDetailDTO); } -// Map> valueBySubSysName = -// engineParamDetailDTOS.stream() -// .sorted(Comparator.comparing(EngineParamDetailDTO::getParameterName)) -// .collect(Collectors.groupingBy( -// EngineParamDetailDTO::getSubsystemName, -// LinkedHashMap::new, -// Collectors.toList() -// )); + return engineParamDetailDTOS.stream() .collect(Collectors.groupingBy( @@ -477,22 +451,22 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { */ @Override public void updateParamValue(List engineParamDetailPojos, String currentUserId) { -// String currentUserId = runtimeAppContextService.getCurrentUserId(); + if (ObjectUtils.isEmpty(engineParamDetailPojos)) { - throw new RuntimeException("集合为空,请检查"); + throw new CommonException("集合为空,请检查"); } for (EngineParamDetailPojo engineParamDetailPojo : engineParamDetailPojos) { EngineParamDetailPojo engineParamDetailPojo1 = selectById(engineParamDetailPojo.getId()); //查找参数是否已经在审批中 if (ObjectUtils.isNotEmpty(engineParamDetailPojo1) && Objects.equals(ParamValueVersionEnum.UNDER.getCode(), engineParamDetailPojo1.getVersionStatus())) { - throw new RuntimeException("您修改参数中有正在审批中的,请查看审批流审批后再修改,零部件+参数名称:" + engineParamDetailPojo.getPartsName() + "-" + engineParamDetailPojo.getParameterName()); + throw new CommonException("您修改参数中有正在审批中的,请查看审批流审批后再修改,零部件+参数名称:" + engineParamDetailPojo.getPartsName() + "-" + engineParamDetailPojo.getParameterName()); } //通过操作状态对应不同操作新增和更新都新增数据为小版本且为草稿状态 if (engineParamDetailPojo.getOperation().equals(String.valueOf(ParamOperationEnum.UPDATE))) { String id = engineParamDetailPojo.getId(); EngineParamDetailPojo engineParamDetailPojoById = selectById(id); - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("minor_version", engineParamDetailPojo.getParameterValue()) .update("version_status", ParamValueVersionEnum.DRAFT.getCode()) .update("operation", String.valueOf(ParamOperationEnum.UPDATE)) @@ -502,7 +476,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .doUpdate(EngineParamDetailPojo.class); } else if (engineParamDetailPojo.getOperation().equals(String.valueOf(ParamOperationEnum.DELETE))) { String id = engineParamDetailPojo.getId(); - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("is_delete", "1") .update("version_status", ParamValueVersionEnum.DRAFT.getCode()) .update("operation", String.valueOf(ParamOperationEnum.DELETE)) @@ -511,8 +485,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .rowid("id", id) .doUpdate(EngineParamDetailPojo.class); - } else if (engineParamDetailPojo.getOperation().equals(String.valueOf(ParamOperationEnum.INSERT))) { - } } EngineParamDetailPojo engineParamDetailPojo = engineParamDetailPojos.get(0); @@ -521,26 +493,23 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { if (ObjectUtils.isEmpty(x.getFilledBy())) { return false; } - if (x.getFilledBy().equals(currentUserId) && ObjectUtils.isEmpty(x.getMinorVersion())) { - return true; - } - return false; + return x.getFilledBy().equals(currentUserId) && ObjectUtils.isEmpty(x.getMinorVersion()); }); //填写后检查是否完全填写完成用来消除待办 if (ObjectUtils.isNotEmpty(paramDetailPojoStream)) { - TodoTaskPojo todoTaskPojo = sw.buildFromDatasource("xdap_app_223770822127386625") + TodoTaskPojo todoTaskPojo = bd.getBusinessDatabase() .eq("owner_id", currentUserId) .eq("model_id", engineParamDetailPojo.getEngineModelId()) .eq("data_type", "数据维护") .doQueryFirst(TodoTaskPojo.class); //修改待办和发起的任务状态 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("is_delete", 1) .update("current_node", "已维护") .update("last_update_date", new Date()) .eq("document_no", todoTaskPojo.getDocumentNo()) .doUpdate(TodoTaskPojo.class); - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("current_node", "已维护") .update("last_update_date", new Date()) .eq("document_no", todoTaskPojo.getDocumentNo()) @@ -553,57 +522,8 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { completedTaskPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now())); completedTaskPojo.setIsDelete(0); completedTaskPojo.setCurrentNode("已维护"); - sw.buildFromDatasource("xdap_app_223770822127386625").doInsert(completedTaskPojo); + bd.getBusinessDatabase().doInsert(completedTaskPojo); } - //应该不会有新增参数 要不然还要给参数绑定部门,责任人,填写人 -// EngineParamDetailPojo ei = new EngineParamDetailPojo(); -// -// BeanUtils.copyProperties(engineParamDetailPojo, ei,"id","majorVersion"); -// ei.setMinorVersion(engineParamDetailPojo.getParameterValue()); -// ei.setOperation(String.valueOf(ParamOperationEnum.INSERT)); -// ei.setApprovalId(stringUuid); -// ei.setCreatedDate(createdDate); -// -// insertDetails.add(ei); - - -// -// -//// ----------------------------------------------------- -// List detailPojos = -// sw.buildFromDatasource("test_demo") -// .eq("parameter_id", engineParamDetailPojo.getParameterId()) -// .eq("engine_model_id", engineParamDetailPojo.getEngineModelId()) -// .doQuery(EngineParamDetailPojo.class); -// if (ObjectUtils.isEmpty(detailPojos)) { -// log.error("查不到数据ID为:{}", engineParamDetailPojo.getId()); -// continue; -// } -// //找到最大版本 -// EngineParamDetailPojo engineParamDetailPojoMaxVersion = detailPojos.stream() -// .sorted(Comparator.comparing(EngineParamDetailPojo::getMajorVersion) -// .reversed()).collect(Collectors.toList()).get(0); -// -// //草稿或最新数据 todo先修改小版本参数审批后大版本加一 -// if (ObjectUtils.isEmpty(engineParamDetailPojo.getId())) { -// throw new RuntimeException("数据ID为空,联系管理员检查是否传入ID,"); -// } -// if (engineParamDetailPojo.getVersionStatus().equals(ParamValueVersionEnum.DRAFT.getCode())) { -// sw.buildFromDatasource("test_demo") -//// .update("parameter_value", engineParamDetailPojo.getParameterValue()) -// .update("minor_version", engineParamDetailPojo.getParameterValue()) -// .rowid("id", engineParamDetailPojo.getId()) -// .doUpdate(EngineParamDetailPojo.class); -// } else if (engineParamDetailPojoMaxVersion.getMajorVersion().equals(engineParamDetailPojo.getMajorVersion())) { -// sw.buildFromDatasource("test_demo") -//// .update("parameter_value", engineParamDetailPojo.getParameterValue()) -// .update("minor_version", engineParamDetailPojo.getParameterValue()) -// .rowid("id", engineParamDetailPojo.getId()) -// .doUpdate(EngineParamDetailPojo.class); -// } else { -// throw new RuntimeException("有数据并非草稿或最新版本或超出最新版本,请检查后更新"); -// } - } /** @@ -622,7 +542,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { return; } String engineModelId = engineParamDetailPojos.get(0).getEngineModelId(); - TodoTaskPojo todoTaskPojo = sw.buildFromDatasource("xdap_app_223770822127386625") + TodoTaskPojo todoTaskPojo = bd.getBusinessDatabase() .eq("owner_id", userID) .eq("model_id", engineModelId) .eq("data_type", "任务分解") @@ -635,20 +555,20 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { DataEntryEngineModelPojo modelPojo = dataEntryEngineModelService.selectBymodelId(engineModelId); - XdapUsers XdapUsers = xdapDeptUsersService.selectUserByID(userID); + XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userID); ArrayList todoTaskPojos = new ArrayList<>(); ArrayList taskPojos = new ArrayList<>(); //分解任务更新填写人 for (EngineParamDetailPojo engineParamDetailPojo : engineParamDetailPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("filled_by", engineParamDetailPojo.getFilledBy()) .rowid("id", engineParamDetailPojo.getId()) .doUpdate(engineParamDetailPojo); } // 清除待办 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("model_id", modelPojo.getId()) .eq("data_type", CurrentNodeEnum.REPAIR.getDesc()) .update("is_delete", 1) @@ -671,15 +591,16 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { todoTask.setOwnerId(filledBy); todoTask.setCurrentProcessor(JSON.toJSONString(Collections.singletonList(filledBy))); todoTask.setIsDelete(0); - todoTask.setCreatedBy(ObjectUtils.isNotEmpty(XdapUsers) ? XdapUsers.getUsername() : ""); + todoTask.setCreatedBy(ObjectUtils.isNotEmpty(xdapUsers) ? xdapUsers.getUsername() : ""); todoTaskPojos.add(todoTask); InitiatedTaskPojo initiatedTaskPojo = new InitiatedTaskPojo(); BeanUtils.copyProperties(todoTask, initiatedTaskPojo); initiatedTaskPojo.setLastUpdatedBy(filledBy); taskPojos.add(initiatedTaskPojo); } - batchInsertTodoTask(todoTaskPojos); - batchInsertInitiatedTask(taskPojos); + bd.getBusinessDatabase().doBatchInsert(todoTaskPojos); + bd.getBusinessDatabase().doBatchInsert(taskPojos); + //每次分发填写人时进行检测 //这个责任人相关的填写人是否都已经填写完成如果没有则待办不动 如果填写完了待办完成 List detailPojos = selectByResId(userID); @@ -689,20 +610,20 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { .collect(Collectors.toList()); if (ObjectUtils.isEmpty(paramDetailPojos)) { //软删除这个代办人的任务 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("model_id", modelPojo.getId()) .eq("data_type", CurrentNodeEnum.JOBSPLIT.getDesc()) .eq("owner_id", userID) .update("is_delete", 1) .doUpdate(TodoTaskPojo.class); //更新待办和发起的任务状态 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("is_delete", 1) .update("current_node", "已分解") .update("last_update_date", new Date()) .eq("document_no", todoTaskPojo.getId()) .doUpdate(TodoTaskPojo.class); - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("current_node", "已分解") .update("last_update_date", new Date()) .eq("document_no", todoTaskPojo.getId()) @@ -715,41 +636,10 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { completedTaskPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now())); completedTaskPojo.setIsDelete(0); completedTaskPojo.setCurrentNode("已分解"); - sw.buildFromDatasource("xdap_app_223770822127386625").doInsert(completedTaskPojo); -// //机型的分发状态改为已分发 -// DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("已分发"); -// Integer status = byDesc != null ? byDesc.getCode() : null; -// sw.buildFromDatasource("xdap_app_223770822127386625") -// .eq("id", engineModelId) -// .update("status", status) -// .doUpdate(DataEntryEngineModelPojo.class); + bd.getBusinessDatabase().doInsert(completedTaskPojo); } } - /** - * 批量插入待办任务 - * 批量插入待办任务到数据库 - * - * @param todoTaskPojos 待办任务POJO列表 - * @return void - */ - @Transactional // 发生任何异常都回滚 - public void batchInsertTodoTask(List todoTaskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(todoTaskPojos); - } - - /** - * 批量插入发起任务 - * 批量插入发起任务到数据库 - * - * @param taskPojos 发起任务POJO列表 - * @return void - */ - @Transactional // 发生任何异常都回滚 - public void batchInsertInitiatedTask(List taskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(taskPojos); - } - /** * 查询所有新版本参数 * 查询所有最新版本的参数信息 @@ -760,11 +650,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { public List selectAllByNewVersion() { //读取已通过审核的版本 DRAFT(草稿)、APPROVING(审批中)、COMPLETE(已完成)、RETURNED(已撤回)、REJECTED(已拒绝) List templates = - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("status", "COMPLETE") .doQuery(TemplatePojo.class); if (ObjectUtils.isEmpty(templates)) { - throw new RuntimeException("未找到未找到已发布的参数模板"); + throw new CommonException("未找到未找到已发布的参数模板"); } //查找每个模板最新版本 Map latestTemplateMap = templates.stream() @@ -781,12 +671,12 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { List strings = templatesMax.stream().map(TemplatePojo::getId).collect(Collectors.toList()); //查找最新模板关联的参数 List templateAndParameters = - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .in("template_id", strings) .doQuery(TemplateAndParameterPojo.class); List pIds = templateAndParameters.stream().map(TemplateAndParameterPojo::getParameterId).collect(Collectors.toList()); - List parameterList = sw.buildFromDatasource("xdap_app_223770822127386625") + List parameterList = bd.getBusinessDatabase() .in("id", pIds) .doQuery(ParameterPojo.class); //不需要TC数据来源的参数 @@ -814,11 +704,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { public List selectAllAndTcByNewVersion() { //读取已通过审核的版本 DRAFT(草稿)、APPROVING(审批中)、COMPLETE(已完成)、RETURNED(已撤回)、REJECTED(已拒绝) List templates = - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("status", "COMPLETE") .doQuery(TemplatePojo.class); if (ObjectUtils.isEmpty(templates)) { - throw new RuntimeException("未找到未找到已发布的参数模板"); + throw new CommonException("未找到未找到已发布的参数模板"); } //查找每个模板最新版本 // 每组内按版本号降序,取第一个(最新版本) @@ -829,12 +719,12 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { List strings = templatesMax.stream().map(TemplatePojo::getId).collect(Collectors.toList()); //查找最新模板关联的参数 List templateAndParameters = - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .in("template_id", strings) .doQuery(TemplateAndParameterPojo.class); List pIds = templateAndParameters.stream().map(TemplateAndParameterPojo::getParameterId).collect(Collectors.toList()); - return sw.buildFromDatasource("xdap_app_223770822127386625") + return bd.getBusinessDatabase() .in("id", pIds) .doQuery(ParameterPojo.class); } @@ -852,7 +742,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { if (ObjectUtils.isEmpty(modelId)) { return Collections.emptyList(); } - List engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List engineParamDetailPojos = bd.getBusinessDatabase() .eq("engine_model_id", modelId) .doQuery(EngineParamDetailPojo.class); @@ -860,11 +750,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(modelId); if (ObjectUtils.isEmpty(dataEntryEngineModelPojo)) { - throw new RuntimeException("机型不存在"); + throw new CommonException("机型不存在"); } return engineParamDetailPojos.stream().filter( - x -> x.getMajorVersion() == dataEntryEngineModelPojo.getVersionNumber() + x -> Objects.equals(x.getMajorVersion(), dataEntryEngineModelPojo.getVersionNumber()) ).collect(Collectors.toList()); } @@ -880,7 +770,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { if (ObjectUtils.isEmpty(resId)) { return Collections.emptyList(); } - List engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List engineParamDetailPojos = bd.getBusinessDatabase() .eq("responsible_person_id", resId) .doQuery(EngineParamDetailPojo.class); if (ObjectUtils.isEmpty(engineParamDetailPojos)) { @@ -896,48 +786,6 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { ).collect(Collectors.toList()); } - /** - * 根据填写人ID查询参数详情 - * 根据填写人ID查询相关的参数详情 - * - * @param filledId 填写人ID - * @return 参数详情POJO列表 - */ - @Override - public List selectByfiledId(String filledId) { - if (ObjectUtils.isEmpty(filledId)) { - return Collections.emptyList(); - } - List engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") - .eq("filled_by", filledId) - .doQuery(EngineParamDetailPojo.class); - - EngineParamDetailPojo engineParamDetailPojoMaxVersion = engineParamDetailPojos.stream() - .sorted(Comparator.comparing(EngineParamDetailPojo::getMajorVersion) - .reversed()).collect(Collectors.toList()).get(0); - - return engineParamDetailPojos.stream().filter( - x -> Objects.equals(x.getMajorVersion(), engineParamDetailPojoMaxVersion.getMajorVersion()) - ).collect(Collectors.toList()); - } - - /** - * 根据审批ID查询参数详情 - * 根据审批ID查询相关的参数详情 - * - * @param approvalId 审批ID - * @return 参数详情POJO列表 - */ - @Override - public List selectByapprovalId(String approvalId) { - if (ObjectUtils.isNotEmpty(approvalId)) { - return sw.buildFromDatasource("xdap_app_223770822127386625") - .eq("approval_id", approvalId) - .doQuery(EngineParamDetailPojo.class); - } - return Collections.emptyList(); - } - /** * 根据ID查询参数详情 * 根据ID查询单个参数详情 @@ -947,7 +795,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { */ @Override public EngineParamDetailPojo selectById(String id) { - List engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List engineParamDetailPojos = bd.getBusinessDatabase() .eq("id", id) .doQuery(EngineParamDetailPojo.class); if (ObjectUtils.isNotEmpty(engineParamDetailPojos)) { @@ -966,12 +814,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { @Override public List selectVersionList(String modelId) { if (ObjectUtils.isNotEmpty(modelId)) { - List detailPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List detailPojos = bd.getBusinessDatabase() .eq("engine_model_id", modelId) .doQuery(EngineParamDetailPojo.class); - List versionNumList = detailPojos.stream().map(x -> x.getMajorVersion()) + return detailPojos.stream().map(EngineParamDetailPojo::getMajorVersion) .distinct().collect(Collectors.toList()); - return versionNumList; } return Collections.emptyList(); } @@ -990,7 +837,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { List xdapUsersPojos = new ArrayList<>(); List personPojos = responsiblePerService.selectBysubSystemDept(subSystem, dept); if (ObjectUtils.isEmpty(personPojos)) { - throw new RuntimeException("该子系统和部门没有查找到相关人子系统:" + subSystem + ",部门:" + dept); + throw new CommonException("该子系统和部门没有查找到相关人子系统:" + subSystem + ",部门:" + dept); } try { List collected = personPojos.stream().filter(x -> Objects.equals(x.getPersonLevel(), type)).collect(Collectors.toList()); @@ -999,7 +846,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService { xdapUsersPojos.add(xdapDeptUsersService.selectUserByID(id)); } } catch (Exception e) { - throw new RuntimeException("根据TYPE查询异常"); + throw new CommonException("根据TYPE查询异常"); } return xdapUsersPojos; diff --git a/src/main/java/com/xdap/self_development/service/impl/EngineReviewListServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/EngineReviewListServiceImpl.java index 8c6e154..1d3c29f 100644 --- a/src/main/java/com/xdap/self_development/service/impl/EngineReviewListServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/EngineReviewListServiceImpl.java @@ -1,23 +1,24 @@ package com.xdap.self_development.service.impl; -import com.definesys.mpaas.query.MpaasQueryFactory; import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.api.moudle.user.pojo.XdapUsers; +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.request.EngineReviewListRequest; +import com.xdap.self_development.domain.dto.PageResultDTO; import com.xdap.self_development.domain.enums.ParamValueVersionEnum; import com.xdap.self_development.domain.pojo.EngineReviewListPojo; import com.xdap.self_development.domain.pojo.ParamApprovalRecordPojo; import com.xdap.self_development.domain.pojo.TodoTaskPojo; -import com.xdap.self_development.domain.dto.PageResultDTO; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.EngineReviewListService; import com.xdap.self_development.service.XdapDeptUsersService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -33,9 +34,9 @@ import java.util.stream.Collectors; @Service @Slf4j public class EngineReviewListServiceImpl implements EngineReviewListService { - @Autowired - private MpaasQueryFactory sw; - @Autowired + @Resource + private BusinessDatabase bd; + @Resource private XdapDeptUsersService xdapDeptUsersService; /** @@ -50,18 +51,9 @@ public class EngineReviewListServiceImpl implements EngineReviewListService { Integer page = engineReviewListRequest.getPage(); Integer size = engineReviewListRequest.getSize(); - PageQueryResult engineReviewListPojoPageQueryResult = sw.buildFromDatasource("xdap_app_223770822127386625") -// .like("model_name", engineReviewListRequest.getModelName()) -// .like("process_topic", engineReviewListRequest.getProcessTopic()) -// .like("subsystem_name", engineReviewListRequest.getSubsystemName()) -// .like("status_description", engineReviewListRequest.getStatusDescription()) -// .eq("yc_or_oth", engineReviewListRequest.getYcOrOth()) -// .eq("applicant", engineReviewListRequest.getUserID()) -// .conjuctionOr() -// .like("approver_persons",engineReviewListRequest.getUserID() ) + PageQueryResult engineReviewListPojoPageQueryResult = bd.getBusinessDatabase() .like("model_name", engineReviewListRequest.getModelName()) .like("process_topic", engineReviewListRequest.getProcessTopic()) -// .like("subsystem_name", engineReviewListRequest.getSubsystemName()) .eq("status_description", engineReviewListRequest.getStatusDescription()) .eq("applicant", engineReviewListRequest.getApplicant()) .eq("yc_or_oth", engineReviewListRequest.getYcOrOth()) @@ -94,7 +86,7 @@ public class EngineReviewListServiceImpl implements EngineReviewListService { engineReviewListPojos1.add(engineReviewListPojo1); } - PageResultDTO pageResultDTO = new PageResultDTO(); + PageResultDTO pageResultDTO = new PageResultDTO<>(); pageResultDTO.setList(engineReviewListPojos1); pageResultDTO.setTotalCount(engineReviewListPojoPageQueryResult.getCount()); return pageResultDTO; @@ -111,18 +103,18 @@ public class EngineReviewListServiceImpl implements EngineReviewListService { @Override public String returnApproval(String approvalId) { if (StringUtils.isEmpty(approvalId)) { - throw new RuntimeException("未传入审批流ID"); + throw new CommonException("未传入审批流ID"); } //如果这个审批流没有被审批过 boolean b = true; - List engineReviewListPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List engineReviewListPojos = bd.getBusinessDatabase() .eq("id", approvalId) .doQuery(EngineReviewListPojo.class); if (ObjectUtils.isEmpty(engineReviewListPojos)) { - throw new RuntimeException("审批流未找到"); + throw new CommonException("审批流未找到"); } // 获取环节 - List paramApprovalRecordPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List paramApprovalRecordPojos = bd.getBusinessDatabase() .eq("approval_id", approvalId) .doQuery(ParamApprovalRecordPojo.class); if (paramApprovalRecordPojos.stream().anyMatch(x -> x.getOperator().equals("同意"))) { @@ -130,14 +122,14 @@ public class EngineReviewListServiceImpl implements EngineReviewListService { } if (b) { // 更新审批流状态为已撤回 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("status_code", ParamValueVersionEnum.WITHDRAWN.getCode()) .update("status_description", ParamValueVersionEnum.WITHDRAWN.getDesc()) .update("approver_persons", "") .update("last_update_date", new Date()) .eq("id", approvalId).doUpdate(EngineReviewListPojo.class); //删除审批人的待办 - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("is_delete", 1) .update("last_update_date", new Date()) .eq("document_no", approvalId).doUpdate(TodoTaskPojo.class); diff --git a/src/main/java/com/xdap/self_development/service/impl/ModelMenuPermissionServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ModelMenuPermissionServiceImpl.java index fc22024..5550ec7 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ModelMenuPermissionServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ModelMenuPermissionServiceImpl.java @@ -7,10 +7,13 @@ import com.xdap.self_development.domain.view.MenuListView; import com.xdap.self_development.service.ModelMenuPermissionService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** @@ -23,8 +26,8 @@ import java.util.*; @Service public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionService { - @Autowired - BusinessDatabase businessDatabase; + @Resource + private BusinessDatabase businessDatabase; /** @@ -69,28 +72,4 @@ public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionServic return views; } - - /** - * 根据菜单名称查询菜单 - * 根据菜单名称查询菜单信息 - * - * @param menuName 菜单名称 - * @return 菜单字典POJO - */ - @Override - public ModelMenuDictionaryPojo selectMenuById(String menuName) { - if (ObjectUtils.isEmpty(menuName)) { - throw new RuntimeException("根据ID查询菜单时ID未传入"); - } - ModelMenuDictionaryPojo modelMenuDictionaryPojo = null; - try { - modelMenuDictionaryPojo = businessDatabase.getBusinessDatabase() - .eq("menu_name", menuName) - .doQueryFirst(ModelMenuDictionaryPojo.class); - } catch (Exception e) { - throw new RuntimeException("查询权限菜单时发生异常", e); - } - return modelMenuDictionaryPojo; - } - } diff --git a/src/main/java/com/xdap/self_development/service/impl/ModelRoleServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ModelRoleServiceImpl.java index 6a9402c..05486cc 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ModelRoleServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ModelRoleServiceImpl.java @@ -8,19 +8,21 @@ import com.xdap.self_development.controller.request.ModelRolesRequest; import com.xdap.self_development.controller.request.RolePerJoinRequest; import com.xdap.self_development.controller.request.UserRoleBindingRequest; import com.xdap.self_development.domain.enums.ParamPermissionEnum; -import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.PageResultDTO; +import com.xdap.self_development.domain.pojo.ModelDepUserRolePojo; +import com.xdap.self_development.domain.pojo.ModelMenuParameterPojo; +import com.xdap.self_development.domain.pojo.ModelRolePermissionPojo; +import com.xdap.self_development.domain.pojo.ModelRolesPojo; import com.xdap.self_development.domain.view.MenuParamView; -import com.xdap.self_development.service.ModelMenuPermissionService; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.ModelRoleService; import com.xdap.self_development.service.XdapDeptUsersService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -35,12 +37,11 @@ import java.util.stream.Collectors; @Service public class ModelRoleServiceImpl implements ModelRoleService { - @Autowired - BusinessDatabase businessDatabase; - @Autowired - ModelMenuPermissionService modelMenuPermissionService; - @Autowired - XdapDeptUsersService xdapDeptUsersService; + @Resource + private BusinessDatabase businessDatabase; + + @Resource + private XdapDeptUsersService xdapDeptUsersService; /** * 添加角色 @@ -56,7 +57,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { .eq("role_code", request.getRoleCode()) .doQuery(ModelRolesPojo.class); if (ObjectUtils.isNotEmpty(modelRolesPojos)) { - throw new RuntimeException("角色已存在"); + throw new CommonException("角色已存在"); } ModelRolesPojo modelRolesPojo = new ModelRolesPojo(); BeanUtils.copyProperties(request, modelRolesPojo); @@ -67,18 +68,6 @@ public class ModelRoleServiceImpl implements ModelRoleService { .doInsert(modelRolesPojo); } - /** - * 分页查询角色 - * 根据用户ID分页查询角色信息 - * - * @param userID 用户ID - * @return 角色POJO分页结果 - */ - @Override - public PageResultDTO selectRolesByPage(String userID) { - return null; - } - /** * 查询所有角色 * 查询系统中的所有角色信息 @@ -87,10 +76,9 @@ public class ModelRoleServiceImpl implements ModelRoleService { */ @Override public List selectRoles() { - List modelRolesPojos = businessDatabase.getBusinessDatabase() + return businessDatabase.getBusinessDatabase() .eq("is_enabled", 1) .doQuery(ModelRolesPojo.class); - return modelRolesPojos; } /** @@ -118,15 +106,14 @@ public class ModelRoleServiceImpl implements ModelRoleService { for (RolePerJoinRequest request : requests) { String roleId = request.getRoleId(); String permissionPath = request.getPermissionPath(); -// String menuName = request.getMenuName(); -// String parameterId = request.getParameterId(); + Integer parameterPer = request.getParameterPer(); if (ObjectUtils.isEmpty(permissionPath) || ObjectUtils.isEmpty(parameterPer) || ObjectUtils.isEmpty(roleId)) { log.warn("参数不完整无法写入"); continue; } List modelMenuParameterPojos = businessDatabase.getBusinessDatabase() -// .eq("menu_id", menuName) + .eq("permission_path", permissionPath) .eq("parameter_per", parameterPer) .doQuery(ModelMenuParameterPojo.class); @@ -135,14 +122,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { String id = String.valueOf(UUID.randomUUID()); if (ObjectUtils.isEmpty(modelMenuParameterPojos)) { //查找参数 组装权限 -// ParameterPojo parameter = businessDatabase.getBusinessDatabase() -// .eq("id", parameterId) -// .doQuery(ParameterPojo.class).get(0); ModelMenuParameterPojo modelMenuParameterPojo = new ModelMenuParameterPojo(); -// modelMenuParameterPojo.setMenuId(menuName); -// modelMenuParameterPojo.setSubsystem(subsystem); -// modelMenuParameterPojo.setPartsName(partsName); -// modelMenuParameterPojo.setParameterId(parameterId); modelMenuParameterPojo.setPermissionPath(permissionPath); modelMenuParameterPojo.setParameterPer(parameterPer); modelMenuParameterPojo.setId(id); @@ -198,7 +178,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { @Override public List selectPersByUser(String userOrDepID) { if (ObjectUtils.isEmpty(userOrDepID)) { - throw new RuntimeException("用户或部门ID为空"); + throw new CommonException("用户或部门ID为空"); } List userOrDeps = businessDatabase.getBusinessDatabase() .eq("user_or_dep", userOrDepID) @@ -224,14 +204,14 @@ public class ModelRoleServiceImpl implements ModelRoleService { @Override public List selectPersByRole(String roleID) { if (ObjectUtils.isEmpty(roleID)) { - throw new RuntimeException("角色为空"); + throw new CommonException("角色为空"); } ModelRolesPojo modelRolesPojos = businessDatabase.getBusinessDatabase() .eq("is_enabled", 1) .eq("id", roleID) .doQueryFirst(ModelRolesPojo.class); if (ObjectUtils.isNotEmpty(modelRolesPojos) && (modelRolesPojos.getRoleCode().equals("super_admin"))) { - return Arrays.asList(new MenuParamView(roleID, "","", "", "", 1)); + return Collections.singletonList(new MenuParamView(roleID, "", "", "", "", 1)); } ArrayList menuParamViews = new ArrayList<>(); List role = businessDatabase.getBusinessDatabase() @@ -240,45 +220,30 @@ public class ModelRoleServiceImpl implements ModelRoleService { .doQuery(ModelRolePermissionPojo.class); if (ObjectUtils.isEmpty(role)) { log.warn("该角色没有权限"); - return null; + return Collections.emptyList(); } try { - List perids = role.stream().map(x -> x.getPerId()).distinct().collect(Collectors.toList()); + List perids = role.stream().map(ModelRolePermissionPojo::getPerId).distinct().collect(Collectors.toList()); List menuParameters = businessDatabase.getBusinessDatabase() .in("id", perids) .doQuery(ModelMenuParameterPojo.class); //获取权限 for (ModelMenuParameterPojo menuParameter : menuParameters) { - /* 权限变更不再管理菜单且不再存参数 改为子系统+零部件 - ModelMenuDictionaryPojo modelMenuDictionaryPojo = modelMenuPermissionService.selectMenuById(menuParameter.getMenuId()); - String parameterId = menuParameter.getParameterId(); - //查找参数 组装权限 - List parameters = businessDatabase.getBusinessDatabase() - .eq("id", parameterId) - .doQuery(ParameterPojo.class); - - if (ObjectUtils.isEmpty(parameters)) { - log.warn("未找到ID为{}的参数", parameterId); - continue; // 或者抛出更具体的异常 - } - - ParameterPojo parameter = parameters.get(0);*/ ParamPermissionEnum byCode = ParamPermissionEnum.getByCode(menuParameter.getParameterPer()); if (byCode == null) { - throw new RuntimeException("权限异常"); + throw new CommonException("权限异常"); } MenuParamView menuParamView = new MenuParamView(); menuParamView.setId(menuParameter.getId()); -// menuParamView.setMenuPath(modelMenuDictionaryPojo.getMenuDesc()); -// menuParamView.setPartsName(menuParameter.getPartsName()); + menuParamView.setPermissionPath(menuParameter.getPermissionPath()); menuParamView.setParameterPer(byCode.getDesc()); menuParamViews.add(menuParamView); } } catch (Exception e) { - return null; + return Collections.emptyList(); } return menuParamViews; @@ -290,13 +255,12 @@ public class ModelRoleServiceImpl implements ModelRoleService { * * @param roleID 角色ID * @param userID 用户ID - * @return void */ @Override @Transactional public void removeRoles(String roleID, String userID) { if (ObjectUtils.isEmpty(roleID)) { - throw new RuntimeException("删除的角色为空"); + throw new CommonException("删除的角色为空"); } businessDatabase.getBusinessDatabase() .update("is_enabled", 0) @@ -318,7 +282,6 @@ public class ModelRoleServiceImpl implements ModelRoleService { * 将用户或部门与角色进行绑定 * * @param userRoleBindingRequest 用户角色绑定请求 - * @return void */ @Override @Transactional @@ -339,7 +302,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { modelDepUserRolePojo.setUserOrDep(userOrDeptId); modelDepUserRolePojo.setIsEnable(1); if (isDept != 0 && isDept != 1) { - throw new RuntimeException("用户定位异常,非用户或部门"); + throw new CommonException("用户定位异常,非用户或部门"); } modelDepUserRolePojo.setIsDep(isDept); modelDepUserRolePojo.setCreationDate(new Date()); @@ -359,7 +322,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { @Override public HashMap> selectUserOrDeptByRole(String roleID) { if (ObjectUtils.isEmpty(roleID)) { - return null; + return new HashMap<>(); } List modelDepUserRolePojos = businessDatabase.getBusinessDatabase() .eq("role_id", roleID) @@ -393,7 +356,7 @@ public class ModelRoleServiceImpl implements ModelRoleService { map.put("人员", stringsUser); return map; } - return null; + return new HashMap<>(); } } diff --git a/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java index 46e95e3..e1c272a 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java @@ -1,20 +1,20 @@ package com.xdap.self_development.service.impl; import com.definesys.mpaas.query.db.PageQueryResult; -import com.xdap.self_development.common.MyPageResult; import com.xdap.self_development.common.BusinessDatabase; +import com.xdap.self_development.common.MyPageResult; import com.xdap.self_development.controller.form.ParameterForm; import com.xdap.self_development.controller.form.ParameterPageForm; import com.xdap.self_development.controller.form.UpdateParameterForm; -import com.xdap.self_development.exception.CommonException; +import com.xdap.self_development.domain.enums.ParameterOperationEnum; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.RevisionRecordPojo; import com.xdap.self_development.domain.pojo.TemplateAndParameterPojo; import com.xdap.self_development.domain.pojo.TemplatePojo; import com.xdap.self_development.domain.view.TemplateInfoView; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.ParameterService; import com.xdap.self_development.utils.FormulaValidatorUtils; -import com.xdap.self_development.domain.enums.ParameterOperationEnum; import lombok.AllArgsConstructor; import lombok.Data; import org.springframework.beans.BeanUtils; @@ -86,7 +86,7 @@ public class ParameterServiceImpl implements ParameterService { if (Objects.equals(parameter.getParameterSource(), "公式计算")) { Map validationResult = FormulaValidatorUtils.validateFormulaDetailed( parameter.getNumberOrFormula()); - if (!(Boolean) validationResult.get("isValid")) { + if (!(boolean) validationResult.get("isValid")) { String errorMsg = String.format("参数 '%s' 公式格式错误: %s", parameter.getParameterName(), validationResult.get("errorMessage")); @@ -216,9 +216,7 @@ public class ParameterServiceImpl implements ParameterService { return new TemplateBenchmark(baseTemplate, lastTemplate, parameters); } - /** - * 模板基准信息封装类 - */ + /** * 模板基准信息封装类 */ @@ -230,9 +228,7 @@ public class ParameterServiceImpl implements ParameterService { private final List parameters; } - /** - * 参数处理结果封装类 - */ + /** * 参数处理结果封装类 */ diff --git a/src/main/java/com/xdap/self_development/service/impl/ResponsiblePerServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ResponsiblePerServiceImpl.java index 2a2b42c..70153c0 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ResponsiblePerServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ResponsiblePerServiceImpl.java @@ -2,18 +2,19 @@ package com.xdap.self_development.service.impl; import com.definesys.mpaas.common.exception.MpaasRuntimeException; -import com.definesys.mpaas.query.MpaasQueryFactory; import com.xdap.api.moudle.department.pojo.entity.XdapDepartments; import com.xdap.api.moudle.user.pojo.XdapUsers; +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.domain.pojo.ResponsiblePersonPojo; import com.xdap.self_development.service.ResponsiblePerService; import com.xdap.self_development.service.XdapDeptUsersService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -26,9 +27,9 @@ import java.util.List; @Service public class ResponsiblePerServiceImpl implements ResponsiblePerService { - @Autowired - private MpaasQueryFactory sw; - @Autowired + @Resource + private BusinessDatabase bd; + @Resource private XdapDeptUsersService xdapDeptUsersService; /** * 根据部门和人员查询责任人 @@ -45,41 +46,19 @@ public class ResponsiblePerServiceImpl implements ResponsiblePerService { } XdapDepartments deptByName = xdapDeptUsersService.selectDeptByName(department); List userByName = xdapDeptUsersService.selectUserByPersonName(resPerson); - XdapUsers XdapUsers = xdapDeptUsersService.selectUserByUserListAndDeptName(userByName, deptByName); - ResponsiblePersonPojo ResponsiblePerson = null; - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + XdapUsers xdapUsers = xdapDeptUsersService.selectUserByUserListAndDeptName(userByName, deptByName); + ResponsiblePersonPojo responsiblePerson = null; + List personPojos = bd.getBusinessDatabase() .eq("department_id", deptByName.getId()) - .eq("user_id", XdapUsers.getId()) + .eq("user_id", xdapUsers.getId()) .doQuery(ResponsiblePersonPojo.class); if (personPojos != null && !personPojos.isEmpty()) { - ResponsiblePerson = personPojos.get(0); + responsiblePerson = personPojos.get(0); } - return ResponsiblePerson; + return responsiblePerson; } - /** - * 根据部门查询责任人 - * 根据部门ID查询责任人信息 - * - * @param departmentId 部门ID - * @return 责任人POJO - */ - @Override - public ResponsiblePersonPojo selectByDep(String departmentId) { - if (ObjectUtils.isEmpty(departmentId) && ObjectUtils.isEmpty(departmentId)) { - return null; - } - ResponsiblePersonPojo ResponsiblePerson = null; - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") - .eq("department_id", departmentId) - .doQuery(ResponsiblePersonPojo.class); - - if (personPojos != null && !personPojos.isEmpty()) { - ResponsiblePerson = personPojos.get(0); - } - return ResponsiblePerson; - } /** * 根据用户ID查询责任人 @@ -91,16 +70,15 @@ public class ResponsiblePerServiceImpl implements ResponsiblePerService { @Override public List selectByUserId(List userIds) { if (ObjectUtils.isEmpty(userIds)) { - return null; + return Collections.emptyList(); } List idlist = new ArrayList<>(); for (XdapUsers userId : userIds) { idlist.add(userId.getId()); } - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + return bd.getBusinessDatabase() .in("user_id", idlist) .doQuery(ResponsiblePersonPojo.class); - return personPojos; } /** @@ -112,29 +90,28 @@ public class ResponsiblePerServiceImpl implements ResponsiblePerService { */ @Override public List selectByDepName(String departmentName) { - XdapDepartments XdapDepartments = xdapDeptUsersService.selectDeptByName(departmentName); - if (ObjectUtils.isEmpty(XdapDepartments)) { - return null; + XdapDepartments xdapDepartments = xdapDeptUsersService.selectDeptByName(departmentName); + if (ObjectUtils.isEmpty(xdapDepartments)) { + return Collections.emptyList(); } - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") - .eq("department_id", XdapDepartments.getId()) + return bd.getBusinessDatabase() + .eq("department_id", xdapDepartments.getId()) .doQuery(ResponsiblePersonPojo.class); - return personPojos; } /** * 插入责任人 * 插入责任人信息到数据库 * - * @param ResponsiblePerson 责任人POJO + * @param responsiblePerson 责任人POJO * @return 插入结果 */ @Override - public Object insert(ResponsiblePersonPojo ResponsiblePerson) { + public Object insert(ResponsiblePersonPojo responsiblePerson) { Object testDemo = null; try { - testDemo = sw.buildFromDatasource("xdap_app_223770822127386625") - .doInsert(ResponsiblePerson); + testDemo = bd.getBusinessDatabase() + .doInsert(responsiblePerson); log.info("责任人数据写入成功={}", testDemo); } catch (MpaasRuntimeException e) { log.warn("唯一索引冲突,跳过插入"); @@ -142,41 +119,6 @@ public class ResponsiblePerServiceImpl implements ResponsiblePerService { return testDemo; } - /** - * 查询所有责任人 - * 查询数据库中所有的责任人信息 - * - * @return 责任人POJO列表 - */ - @Override - public List seelctAll() { - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") - .doQuery(ResponsiblePersonPojo.class); - return personPojos; - } - - /** - * 根据ID查询责任人 - * 根据责任人ID查询责任人信息 - * - * @param responsiblePersonId 责任人ID - * @return 责任人POJO - */ - @Override - public ResponsiblePersonPojo selectById(String responsiblePersonId) { - if (ObjectUtils.isEmpty(responsiblePersonId)) { - return null; - } - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") - .in("id", responsiblePersonId) - .doQuery(ResponsiblePersonPojo.class); - if (ObjectUtils.isNotEmpty(personPojos)) { - return personPojos.get(0); - }else { - return null; - } - } - /** * 根据子系统和部门查询责任人 * 根据子系统名称和部门名称查询责任人信息 @@ -187,10 +129,9 @@ public class ResponsiblePerServiceImpl implements ResponsiblePerService { */ @Override public List selectBysubSystemDept(String subSystem, String dept) { - List personPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + return bd.getBusinessDatabase() .like("subsystem", subSystem) .eq("department", dept) .doQuery(ResponsiblePersonPojo.class); - return personPojos; } } diff --git a/src/main/java/com/xdap/self_development/service/impl/ResponsiblePersonServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ResponsiblePersonServiceImpl.java index c0c379f..85a2820 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ResponsiblePersonServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ResponsiblePersonServiceImpl.java @@ -5,15 +5,14 @@ import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.api.moudle.department.pojo.entity.XdapDepartments; import com.xdap.api.moudle.user.pojo.XdapUsers; -import com.xdap.runtime.service.RuntimeDatasourceService; -import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.common.BusinessDatabase; +import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.controller.form.*; -import com.xdap.self_development.exception.CommonException; -import com.xdap.self_development.listener.PersonReadListener; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.ResponsiblePersonPojo; import com.xdap.self_development.domain.view.XdapUserView; +import com.xdap.self_development.exception.CommonException; +import com.xdap.self_development.listener.PersonReadListener; import com.xdap.self_development.service.ResponsiblePersonService; import com.xdap.self_development.service.XdapDeptUsersService; import org.apache.commons.lang3.ObjectUtils; @@ -44,8 +43,7 @@ import java.util.stream.Collectors; public class ResponsiblePersonServiceImpl implements ResponsiblePersonService { @Resource private BusinessDatabase bd; - @Resource - private RuntimeDatasourceService runtimeDatasourceService; + @Resource private XdapDeptUsersService xdapDeptUsersService; @@ -218,13 +216,13 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService { if (ObjectUtils.isEmpty(dept)) { return null; } - ArrayList xdapUsers1 = new ArrayList(); + ArrayList xdapUsers1 = new ArrayList<>(); List responsiblePeople = bd.getBusinessDatabase() .eq("department", dept) .eq("subsystem", subsystem) .doQuery(ResponsiblePersonPojo.class); if (!responsiblePeople.isEmpty()) { - List userIds = responsiblePeople.stream().map(x -> x.getUserId()).collect(Collectors.toList()); + List userIds = responsiblePeople.stream().map(ResponsiblePersonPojo::getUserId).collect(Collectors.toList()); for (String userId : userIds) { XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId); if (xdapUsers != null) { diff --git a/src/main/java/com/xdap/self_development/service/impl/TcDataQueryServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/TcDataQueryServiceImpl.java index 7192e77..2e0a928 100644 --- a/src/main/java/com/xdap/self_development/service/impl/TcDataQueryServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/TcDataQueryServiceImpl.java @@ -3,7 +3,6 @@ package com.xdap.self_development.service.impl; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; -import com.definesys.mpaas.query.MpaasQueryFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.xdap.motor.utils.StringUtils; import com.xdap.self_development.common.BusinessDatabase; @@ -12,13 +11,13 @@ import com.xdap.self_development.controller.request.AnalysisVerRequest; import com.xdap.self_development.controller.request.ModelComparisonExportRequest; import com.xdap.self_development.controller.request.ModelItem; import com.xdap.self_development.domain.pojo.*; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.DataEntryEngineModelService; import com.xdap.self_development.service.EngineParamDetailService; import com.xdap.self_development.service.TcDataQueryService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @@ -41,19 +40,13 @@ import java.util.stream.Collectors; @Service @Slf4j public class TcDataQueryServiceImpl implements TcDataQueryService { - // TC参数in查询的批次大小 - @Value("${tc.query.lbjth.batch.size:1000}") - private Integer lbjthBatchSize; - @Resource private BusinessDatabase bd; - @Autowired + @Resource private EngineParamDetailService engineParamDetailService; - @Autowired + @Resource private DataEntryEngineModelService engineModelService; @Autowired - private MpaasQueryFactory sw; - @Autowired private StringRedisTemplate redisTemplate; private ObjectMapper objectMapper = new ObjectMapper(); @@ -61,105 +54,13 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - //产品编号(状态代号) = 状态机 - @Override - /** - * 根据产品编号查询TC数据 - * - * @param productNumber 产品编号 - * @param partsName 部件名称 - * @param parameterName 参数名称 - * @return 分类属性映射 - */ - public HashMap> tcDataSelectByC(String productNumber, String partsName, String parameterName) { - - EnginePartsCollectionPojo enginePartsCollection = bd.getTCDatabase() - .eq("ztj", productNumber) - .eq("lbjmc", partsName) - .doQueryFirst(EnginePartsCollectionPojo.class); - if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) { - return null; - } - List list = bd.getTCDatabase() - .eq("pitemId", enginePartsCollection.getLbjth()) - .doQuery(ClassificationAttributePojo.class); - HashMap> stringListHashMap = new HashMap<>(); - stringListHashMap.put(productNumber, list); - return stringListHashMap; - } - - - //通过状态代号(产品编号) - @Override - /** - * 根据产品编号查询所有TC数据 - * - * @param engineModelPojo 引擎模型对象 - * @return 引擎参数详情列表 - */ - public ArrayList tcDataSelectAllByproductNumber(DataEntryEngineModelPojo engineModelPojo) { - String productNumber = engineModelPojo.getProductNumber(); - HashMap> stringListHashMap = new HashMap<>(); - if (ObjectUtils.isEmpty(productNumber)) { - return null; - } - ArrayList engineParamDetailPojos = new ArrayList<>(); - //查找参数模板TC参数数据 - List parameters = engineParamDetailService.selectAllAndTcByNewVersion(); - List collect = parameters.stream().filter(x -> "TC分类表".equals(x.getParameterSource())).collect(Collectors.toList()); - if (ObjectUtils.isEmpty(collect)) { - return null; - } - //通过零部件集合+状态机 查找图号 - String id = engineModelPojo.getId(); - - Map> stringListMap = collect.stream().collect(Collectors.groupingBy(ParameterPojo::getPartsName)); - Set partsNames = stringListMap.keySet(); - for (String partsName : partsNames) { - //获取系统内零部件下的参数 - List parametersOnPartsName = stringListMap.get(partsName).stream().map(x -> x.getParameterName()).collect(Collectors.toList()); - - List partsCollections = bd.getTCDatabase() - .eq("ztj", productNumber) - .eq("lbjmc", partsName) - .doQuery(EnginePartsCollectionPojo.class); - //查找图号 - List allLbjths = partsCollections.stream() - .map(EnginePartsCollectionPojo::getLbjth) - .filter(ObjectUtils::isNotEmpty) - .distinct() - .collect(Collectors.toList()); - //查找参数 - if (!allLbjths.isEmpty()) { - List allClassifications = bd.getTCDatabase() - .in("pitemId", allLbjths) - .doQuery(ClassificationAttributePojo.class) - .stream() - .filter(attr -> parametersOnPartsName.contains(attr.getIdattrtbutehame())) - .collect(Collectors.toList()); - - for (ClassificationAttributePojo classificationAttribute : allClassifications) { - EngineParamDetailPojo engineParamDetailPojo = new EngineParamDetailPojo(); - engineParamDetailPojo.setEngineModelId(engineModelPojo.getId()); - engineParamDetailPojo.setPartsName(partsName); - engineParamDetailPojo.setParameterName(classificationAttribute.getIdattrtbutehame()); - engineParamDetailPojo.setParameterValue(classificationAttribute.getFieldvalue()); - engineParamDetailPojos.add(engineParamDetailPojo); - } - } - } - - - return engineParamDetailPojos; - } - - @Override /** * 根据部件名称查询所有TC数据 * * @param analysisRequest 分析请求对象 * @return 引擎参数详情映射 */ + @Override public Map> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest) { return tcDataSelectAllByPartsNameFunctionOptimized(analysisRequest); @@ -178,30 +79,28 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { } public Map> tcDataSelectAllByPartsNameFunction(AnalysisRequest analysisRequest) { - // long a = System.currentTimeMillis(); String engineModelID = analysisRequest.getEngineModelID(); List subsystemTypes = analysisRequest.getSubsystemParts(); if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes)) { - throw new RuntimeException("传入参数为空,请检查"); + throw new CommonException("传入参数为空,请检查"); } List allPojos = new ArrayList<>(); -// List SysAllPojos = new ArrayList<>(); List parameters = engineParamDetailService.selectAllAndTcByNewVersion(); DataEntryEngineModelPojo dataEntryEngineModelPojo = engineModelService.selectBymodelId(engineModelID); //查到所有TC表的参数 返回零部件,参数列表 for (String subsystemType : subsystemTypes) { HashMap> stringListHashMap = new HashMap<>(); if (subsystemType.split("-").length != 2) { - throw new RuntimeException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/”"); + throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/”"); } String subsystem = subsystemType.split("-")[0]; - String parts_name = subsystemType.split("-")[1]; + String partsName = subsystemType.split("-")[1]; //开始查找系统数据 - List pojoList = sw.buildFromDatasource("xdap_app_223770822127386625") + List pojoList = bd.getBusinessDatabase() .eq("engine_model_id", engineModelID) .eq("subsystem_name", subsystem) - .eq("parts_name", parts_name) + .eq("parts_name", partsName) .doQuery(EngineParamDetailPojo.class); pojoList = pojoList.stream() @@ -215,7 +114,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { //开始查找TC数据 List lbjmcs = bd.getTCDatabase() .eq("ztj", dataEntryEngineModelPojo.getProductNumber()) - .eq("lbjmc", parts_name) + .eq("lbjmc", partsName) .doQuery(EnginePartsCollectionPojo.class); if (ObjectUtils.isEmpty(lbjmcs)) { log.error("根据零部件未找到状态机图号列表"); @@ -231,7 +130,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { .eq("pitemId", lbjth) .doQuery(ClassificationAttributePojo.class)); } - stringListHashMap.put(parts_name, listl); + stringListHashMap.put(partsName, listl); for (Map.Entry> stringListEntry : stringListHashMap.entrySet()) { String key = stringListEntry.getKey();//零部件 List list = stringListEntry.getValue();//零部件里的值 @@ -256,11 +155,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { } } - Map> valueBySubSysName = - allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); - long b = System.currentTimeMillis(); -// throw new RuntimeException(String.valueOf(b - a)); - return valueBySubSysName; + return allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); } @@ -270,7 +165,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { String userID = analysisRequest.getUserID(); if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes) || ObjectUtils.isEmpty(userID)) { - throw new RuntimeException("传入参数部分为空,请检查"); + throw new CommonException("传入参数部分为空,请检查"); } @@ -286,18 +181,18 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { List> subsystemPartsPairs = subsystemTypes.stream() .map(subsystemType -> { if (subsystemType.split("-").length != 2) { - throw new RuntimeException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); + throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); } String subsystem = subsystemType.split("-")[0]; - String parts_name = subsystemType.split("-")[1]; - return new AbstractMap.SimpleEntry<>(subsystem, parts_name); + String partsName = subsystemType.split("-")[1]; + return new AbstractMap.SimpleEntry<>(subsystem, partsName); }) .collect(Collectors.toList()); //批量查询所有系统数据 List systemDataList = new ArrayList<>(); for (Map.Entry subsystemPartsPair : subsystemPartsPairs) { - List pojoList = sw.buildFromDatasource("xdap_app_223770822127386625") + List pojoList = bd.getBusinessDatabase() .eq("engine_model_id", engineModelID) .eq("subsystem_name", subsystemPartsPair.getKey()) .eq("parts_name", subsystemPartsPair.getValue()) @@ -349,7 +244,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { // 处理每个子系统-零部件对 for (Map.Entry pair : subsystemPartsPairs) { - String subsystem = pair.getKey(); + String partsName = pair.getValue(); // 获取该零部件的所有图号 @@ -390,14 +285,11 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { log.info("成功将数据存储到Redis,KEY: {}", redisKey); } catch (Exception e) { log.error("存储数据到Redis失败: {}", e.getMessage()); - throw new RuntimeException("存储数据到Redis失败:"+e.getMessage()); + throw new CommonException("存储数据到Redis失败:" + e.getMessage()); } - Map> valueBySubSysName = - allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); - - return valueBySubSysName; + return allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); } @Override @@ -429,7 +321,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { .build(); excelWriter.write(enginePartsCollections, sheet); // 写入数据,只生成表头 } catch (Exception e) { - e.printStackTrace(); + throw new CommonException("导出Excel文件异常"); } } @@ -456,7 +348,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { .build(); excelWriter.write(enginePartsCollections, sheet); // 写入数据,只生成表头 } catch (Exception e) { - e.printStackTrace(); + throw new CommonException("导出Excel文件异常"); } } @@ -472,22 +364,22 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { String userID = request.getUserID(); List subsystemParts = request.getSubsystemParts(); -// 1. 前置空指针检查,提前拦截异常并给出明确信息 + // 1. 前置空指针检查,提前拦截异常并给出明确信息 if (models == null) { log.error("导出失败:机型列表为null"); - throw new RuntimeException("导出失败:机型列表不能为空"); + throw new CommonException("导出失败:机型列表不能为空"); } if (StringUtils.isEmpty(userID)) { log.error("导出失败:用户ID为空"); - throw new RuntimeException("导出失败:用户ID不能为空"); + throw new CommonException("导出失败:用户ID不能为空"); } if (subsystemParts.isEmpty()) { log.error("导出失败:子系统部件列表为null"); - throw new RuntimeException("导出失败:子系统部件列表不能为空"); + throw new CommonException("导出失败:子系统部件列表不能为空"); } if (response == null) { log.error("导出失败:响应对象为null"); - throw new RuntimeException("导出失败:响应对象异常"); + throw new CommonException("导出失败:响应对象异常"); } try { @@ -531,14 +423,14 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { String redisKey = userID + ":" + modelId + ":" + paramVersion + ":" + "ComparisonExport"; // 防护redisTemplate为null if (redisTemplate == null) { - throw new RuntimeException("Redis模板对象未初始化"); + throw new CommonException("Redis模板对象未初始化"); } String cachedData = redisTemplate.opsForValue().get(redisKey); if (ObjectUtils.isNotEmpty(cachedData)) { // 防护objectMapper为null if (objectMapper == null) { - throw new RuntimeException("ObjectMapper对象未初始化"); + throw new CommonException("ObjectMapper对象未初始化"); } // 反序列化数据 List allPojos = objectMapper.readValue(cachedData, @@ -595,7 +487,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { errorMsg = String.format("从Redis读取机型%s数据失败: %s", model.getModelId(), e.toString()); } log.error(errorMsg, e); // 记录完整异常栈 - throw new RuntimeException(errorMsg, e); // 传递异常根因 + throw new CommonException(errorMsg, e); // 传递异常根因 } } @@ -659,7 +551,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { // 关键修复:使用e.toString()而非e.getMessage(),并记录完整异常栈 String errorMsg = "导出失败: " + e.toString(); log.error(errorMsg, e); // 记录完整异常栈,便于定位问题 - throw new RuntimeException(errorMsg, e); // 传递根异常,保留调用栈 + throw new CommonException(errorMsg, e); // 传递根异常,保留调用栈 } } @@ -671,30 +563,25 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { * @return 引擎参数详情映射 */ public Map> tcDataSelectByVersion(AnalysisVerRequest analysisRequest) { -// List allPojos = new ArrayList<>(); List parameters = engineParamDetailService.selectAllAndTcByNewVersion(); DataEntryEngineModelPojo dataEntryEngineModelPojo = engineModelService.selectBymodelId(analysisRequest.getEngineModelID()); - // 预加载所有参数信息 -// Map> parameterMap = parameters.stream() -// .collect(Collectors.groupingBy(p -> p.getPartsName() + "&&" + p.getParameterName())); - //解析所有子系统-零部件对 List> subsystemPartsPairs = analysisRequest.getSubsystemParts().stream() .map(subsystemType -> { if (subsystemType.split("-").length != 2) { - throw new RuntimeException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); + throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); } String subsystem = subsystemType.split("-")[0]; - String parts_name = subsystemType.split("-")[1]; - return new AbstractMap.SimpleEntry<>(subsystem, parts_name); + String partsName = subsystemType.split("-")[1]; + return new AbstractMap.SimpleEntry<>(subsystem, partsName); }) .collect(Collectors.toList()); //批量查询所有系统数据 List systemDataList = new ArrayList<>(); for (Map.Entry subsystemPartsPair : subsystemPartsPairs) { - List pojoList = sw.buildFromDatasource("xdap_app_223770822127386625") + List pojoList = bd.getBusinessDatabase() .eq("engine_model_id", analysisRequest.getEngineModelID()) .eq("major_version", analysisRequest.getParameterVersion()) .eq("subsystem_name", subsystemPartsPair.getKey()) @@ -706,13 +593,6 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { } } - // 过滤版本号 -// List filteredSystemData = systemDataList.stream() -// .filter(x -> x.getMajorVersion().equals(dataEntryEngineModelPojo.getVersionNumber())) -// .collect(Collectors.toList()); - -// allPojos.addAll(filteredSystemData); - //批量查询所有TC数据 Map> parameterMapTc = parameters.stream() .filter(x-> Objects.equals(x.getParameterSource(), "TC分类表")) @@ -720,11 +600,11 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { List> subsystemPartsPairsTc = analysisRequest.getSubsystemParts().stream() .map(subsystemType -> { if (subsystemType.split("-").length != 2) { - throw new RuntimeException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); + throw new CommonException("查询条件异常,需子系统-零部件名称,若零部件为空则传入“/ ”"); } String subsystem = subsystemType.split("-")[0]; - String parts_name = subsystemType.split("-")[1]; - return new AbstractMap.SimpleEntry<>(subsystem, parts_name); + String partsName = subsystemType.split("-")[1]; + return new AbstractMap.SimpleEntry<>(subsystem, partsName); }) .collect(Collectors.toList()); List uniquePartsNames = subsystemPartsPairsTc.stream() @@ -761,7 +641,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { // 处理每个子系统-零部件对 for (Map.Entry pair : subsystemPartsPairsTc) { - String subsystem = pair.getKey(); + String partsName = pair.getValue(); // 获取该零部件的所有图号 @@ -804,11 +684,8 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { log.error("存储数据到Redis失败: {}", e.getMessage()); } - Map> valueBySubSysName = - systemDataList.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); - - return valueBySubSysName; + return systemDataList.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); } @Override @@ -962,23 +839,6 @@ public class TcDataQueryServiceImpl implements TcDataQueryService { return result; } - // 拆分in参数批次 - private List> splitBatch(Set source, int batchSize) { - List> batches = new ArrayList<>(); - List currentBatch = new ArrayList<>(batchSize); - for (String s : source) { - currentBatch.add(s); - if (currentBatch.size() >= batchSize) { - batches.add(new ArrayList<>(currentBatch)); - currentBatch.clear(); - } - } - if (!currentBatch.isEmpty()) { - batches.add(currentBatch); - } - return batches; - } - private void setupResponse(HttpServletResponse response, String fileName) throws IOException { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); diff --git a/src/main/java/com/xdap/self_development/service/impl/TemplateApprovalServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/TemplateApprovalServiceImpl.java index f8d5143..d66da38 100644 --- a/src/main/java/com/xdap/self_development/service/impl/TemplateApprovalServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/TemplateApprovalServiceImpl.java @@ -5,14 +5,14 @@ import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.form.*; -import com.xdap.self_development.exception.CommonException; -import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.domain.dto.ApprovalNodeDTO; import com.xdap.self_development.domain.dto.ApprovalNodesDTO; +import com.xdap.self_development.domain.pojo.*; import com.xdap.self_development.domain.view.ApprovalFlowNodeView; import com.xdap.self_development.domain.view.FlowNode; import com.xdap.self_development.domain.view.TemplateChangeView; import com.xdap.self_development.domain.view.TodoAndTemplateView; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.TemplateApprovalService; import com.xdap.self_development.service.XdapDeptUsersService; import com.xdap.self_development.utils.RedisLockUtils; @@ -375,16 +375,17 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { .doUpdate(TodoTaskPojo.class); // 创建直送记录 - ApprovalRecordPojo record = new ApprovalRecordPojo( - flow.getId(), - "直送至" + preNode.getNodeName(), - xdapDeptUsersService.selectUserByID(userId).getUsername(), - "直送", - "MSG", - Timestamp.valueOf(LocalDateTime.now()), - level + bd.getBusinessDatabase().doInsert( + new ApprovalRecordPojo( + flow.getId(), + "直送至" + preNode.getNodeName(), + xdapDeptUsersService.selectUserByID(userId).getUsername(), + "直送", + "MSG", + Timestamp.valueOf(LocalDateTime.now()), + level + ) ); - bd.getBusinessDatabase().doInsert(record); } // 查询所有流程 @@ -499,16 +500,17 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { ) { // 新增当前审批结果 - ApprovalRecordPojo record = new ApprovalRecordPojo( - flow.getId(), - currentNode.getNodeName(), - request.getUserId(), - request.getOpinion(), - request.getResult(), - Timestamp.valueOf(LocalDateTime.now()), - lastedRecord == null ? 1 : lastedRecord.getApprovalLevel() + bd.getBusinessDatabase().doInsert( + new ApprovalRecordPojo( + flow.getId(), + currentNode.getNodeName(), + request.getUserId(), + request.getOpinion(), + request.getResult(), + Timestamp.valueOf(LocalDateTime.now()), + lastedRecord == null ? 1 : lastedRecord.getApprovalLevel() + ) ); - bd.getBusinessDatabase().doInsert(record); // 软删除当前节点当前处理人的待办 if (!Objects.equals(currentNode.getNodeName(), "会签")) { @@ -650,8 +652,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { .doUpdate(TemplatePojo.class); // 待办环节修改 myself.updateTasks(flow, "已完成", 0, null); - // 更新机型版本 -// dataEntryEngineModelService.updateModelForNewVersion(); + } else { flow.setCurrentNode(nextNode.getNodeOrder()); myself.addNodeTodo(flow, nextNode, template, userId, 0); @@ -1163,17 +1164,17 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { (first, second) -> first )) .values()); - uniqueRecords.forEach(record -> { - ApprovalConfigPojo approvalConfigPojo = nodesMap.get(record.getNode()); + uniqueRecords.forEach(approvalecord -> { + ApprovalConfigPojo approvalConfigPojo = nodesMap.get(approvalecord.getNode()); if (approvalConfigPojo != null) { flowNodes.add(getFlowNodeView(approvalConfigPojo, form.getFlowId(), level)); nodeList.add(approvalConfigPojo.getNodeOrder()); } else { FlowNode flowNode = new FlowNode(); - flowNode.setNode(record.getNode()); - flowNode.setTodoUserName(record.getUserId()); - flowNode.setResult(record.getResult()); - flowNode.setApprovalTime(record.getApprovalTime()); + flowNode.setNode(approvalecord.getNode()); + flowNode.setTodoUserName(approvalecord.getUserId()); + flowNode.setResult(approvalecord.getResult()); + flowNode.setApprovalTime(approvalecord.getApprovalTime()); flowNodes.add(flowNode); } }); @@ -1236,19 +1237,19 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { nodeView.setUndoUserName(getUserNames(JSON.parseArray(node.getAssignees()).toJavaList(String.class))); } } else { - ApprovalRecordPojo record = bd.getBusinessDatabase() + ApprovalRecordPojo flowRecord = bd.getBusinessDatabase() .eq("flow_id", flowId) .eq("node", node.getNodeName()) .eq("approval_level", level) .doQueryFirst(ApprovalRecordPojo.class); nodeView.setNodeOrder(node.getNodeOrder()); nodeView.setNode(node.getNodeName()); - if (record != null) { + if (flowRecord != null) { // 节点已完成 - nodeView.setResult(record.getResult()); - nodeView.setOpinions(Collections.singletonList(getUserNames(Collections.singletonList(record.getUserId())) + ":" + record.getOpinion())); - nodeView.setApprovalTime(record.getApprovalTime()); - nodeView.setTodoUserName(getUserNames(Collections.singletonList(record.getUserId()))); + nodeView.setResult(flowRecord.getResult()); + nodeView.setOpinions(Collections.singletonList(getUserNames(Collections.singletonList(flowRecord.getUserId())) + ":" + flowRecord.getOpinion())); + nodeView.setApprovalTime(flowRecord.getApprovalTime()); + nodeView.setTodoUserName(getUserNames(Collections.singletonList(flowRecord.getUserId()))); } else { // 节点未完成 nodeView.setResult("待审批"); @@ -1393,7 +1394,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { .eq("flow_id", flow.getId()) .orderBy("approval_time", "desc") .doQueryFirst(ApprovalRecordPojo.class); - ApprovalRecordPojo record = new ApprovalRecordPojo( + ApprovalRecordPojo flowRecord = new ApprovalRecordPojo( flow.getId(), currentNode.getNodeName(), form.getProcessUserId(), @@ -1402,7 +1403,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService { Timestamp.valueOf(LocalDateTime.now()), lastedRecord.getApprovalLevel() ); - bd.getBusinessDatabase().doInsert(record); + bd.getBusinessDatabase().doInsert(flowRecord); ApprovalRecordPojo approvalRecord = new ApprovalRecordPojo( flow.getId(), "退回至" + toNode.getNodeName(), diff --git a/src/main/java/com/xdap/self_development/service/impl/TemplateServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/TemplateServiceImpl.java index 816e166..1928ade 100644 --- a/src/main/java/com/xdap/self_development/service/impl/TemplateServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/TemplateServiceImpl.java @@ -5,18 +5,17 @@ import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.definesys.mpaas.query.db.PageQueryResult; -import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.common.BusinessDatabase; +import com.xdap.self_development.common.MyResponse; import com.xdap.self_development.controller.form.*; -import com.xdap.self_development.exception.CommonException; -import com.xdap.self_development.listener.SheetDataListener; import com.xdap.self_development.domain.pojo.ParameterPojo; import com.xdap.self_development.domain.pojo.RevisionRecordPojo; import com.xdap.self_development.domain.pojo.TemplateAndParameterPojo; import com.xdap.self_development.domain.pojo.TemplatePojo; +import com.xdap.self_development.exception.CommonException; +import com.xdap.self_development.listener.SheetDataListener; import com.xdap.self_development.service.TemplateService; import com.xdap.self_development.utils.FormulaValidatorUtils; -import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,13 +44,13 @@ public class TemplateServiceImpl implements TemplateService { @Resource private BusinessDatabase bd; - @Override /** * 根据条件获取模板 * * @param form 模板页面表单 * @return 模板分页查询结果 */ + @Override public PageQueryResult getTemplateByCondition(TemplatePageForm form) { return bd.getBusinessDatabase() .viewQueryMode(true) @@ -60,12 +59,12 @@ public class TemplateServiceImpl implements TemplateService { .doPageQuery(form.getPageNumber(), form.getPageSize(), TemplatePojo.class); } - @Override /** * 插入模板 * * @param form 插入模板表单 */ + @Override public void insertTemplate(InsertTemplateForm form) { TemplatePojo template = bd.getBusinessDatabase() .viewQueryMode(true) @@ -87,13 +86,13 @@ public class TemplateServiceImpl implements TemplateService { bd.getBusinessDatabase().doInsert(newTemplate); } - @Override - @Transactional /** * 更新模板 * * @param form 更新模板表单 */ + @Override + @Transactional public void updateTemplate(UpdateTemplateForm form) { TemplatePojo template = bd.getBusinessDatabase() .viewQueryMode(true) @@ -154,8 +153,6 @@ public class TemplateServiceImpl implements TemplateService { .doUpdate(TemplatePojo.class); } - @Override - @Transactional /** * 导入模板 * @@ -164,6 +161,8 @@ public class TemplateServiceImpl implements TemplateService { * @param userId 用户ID * @return 操作响应结果 */ + @Override + @Transactional public MyResponse importTemplate(MultipartFile file, String templateRowId, String userId) { // 验证文件是否为工作表 if (file == null || file.isEmpty()) { @@ -193,13 +192,13 @@ public class TemplateServiceImpl implements TemplateService { return problems; } - @Override /** * 导出模板 * * @param form 导出模板表单 * @param response HTTP响应对象 */ + @Override public void exportTemplate(ExportTemplateForm form, HttpServletResponse response) { TemplatePojo templateDB = bd.getBusinessDatabase() .rowid("id", form.getTemplateRowId()) @@ -241,13 +240,13 @@ public class TemplateServiceImpl implements TemplateService { } } - @Override /** * 获取模板版本 * * @param form 模板行ID表单 * @return 模板版本列表 */ + @Override public List getTemplateVersion(TemplateRowIdForm form) { TemplatePojo template = bd.getBusinessDatabase() .rowid("id", form.getTemplateRowId()) @@ -258,25 +257,26 @@ public class TemplateServiceImpl implements TemplateService { .doQuery(TemplatePojo.class); } - @Override /** * 根据ID获取模板 * * @param templateId 模板ID * @return 模板POJO对象 */ + @Override public TemplatePojo getTemplateById(String templateId) { return bd.getBusinessDatabase() .eq("id", templateId) .doQueryFirst(TemplatePojo.class); } - @Override + /** * 删除模板 * * @param templateId 模板ID */ + @Override public void deleteTemplate(String templateId) { TemplatePojo template = bd.getBusinessDatabase() .eq("id", templateId) @@ -291,8 +291,6 @@ public class TemplateServiceImpl implements TemplateService { bd.getBusinessDatabase().eq("id", templateId).doDelete(TemplatePojo.class); } - @Override - @Transactional /** * 处理表格数据 * @@ -302,6 +300,8 @@ public class TemplateServiceImpl implements TemplateService { * @param createBy 创建者 * @param problems 问题收集对象 */ + @Override + @Transactional public void processSheetData(List dataList, String sheetName, String templateRowId, String createBy, MyResponse problems) { if (dataList.isEmpty()) { @@ -324,7 +324,7 @@ public class TemplateServiceImpl implements TemplateService { if (Objects.equals(data.getParameterSource(), "公式计算")) { Map validationResult = FormulaValidatorUtils.validateFormulaDetailed( data.getNumberOrFormula()); - if (!(Boolean) validationResult.get("isValid")) { + if (!(boolean) validationResult.get("isValid")) { String errorMsg = String.format("模板导入失败:"+"模板'%s'的参数'%s'公式格式错误, %s", sheetName, data.getParameterName(), validationResult.get("errorMessage")); diff --git a/src/main/java/com/xdap/self_development/service/impl/TodoTaskServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/TodoTaskServiceImpl.java index 3d0190d..2a00db3 100644 --- a/src/main/java/com/xdap/self_development/service/impl/TodoTaskServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/TodoTaskServiceImpl.java @@ -1,17 +1,20 @@ package com.xdap.self_development.service.impl; import com.alibaba.fastjson2.JSON; -import com.definesys.mpaas.query.MpaasQueryFactory; import com.definesys.mpaas.query.db.PageQueryResult; import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.controller.request.TodoReturnRequest; import com.xdap.self_development.controller.request.TodoTaskRequest; import com.xdap.self_development.controller.request.YcGetTodoTaskRequest; +import com.xdap.self_development.domain.dto.EngineParamDetailDTO; +import com.xdap.self_development.domain.dto.PageResultDTO; +import com.xdap.self_development.domain.dto.YcTodoTaskCommonResultDTO; +import com.xdap.self_development.domain.dto.YcTodoTaskResultDTO; import com.xdap.self_development.domain.enums.CurrentNodeEnum; import com.xdap.self_development.domain.enums.DistributeStatusEnum; import com.xdap.self_development.domain.pojo.*; -import com.xdap.self_development.domain.dto.*; +import com.xdap.self_development.exception.CommonException; import com.xdap.self_development.service.DataEntryEngineModelService; import com.xdap.self_development.service.EngineParamDetailService; import com.xdap.self_development.service.TodoTaskService; @@ -40,8 +43,6 @@ import java.util.stream.Collectors; @Service public class TodoTaskServiceImpl implements TodoTaskService { - @Resource - private MpaasQueryFactory sw; @Resource private EngineParamDetailService engineParamDetailService; @Resource @@ -50,8 +51,7 @@ public class TodoTaskServiceImpl implements TodoTaskService { private DataEntryEngineModelService dataEntryEngineModelService; @Resource private BusinessDatabase bd; - @Resource - private TodoTaskService myself; + private final String SYSTEM = "研发数据管理平台"; @@ -66,31 +66,21 @@ public class TodoTaskServiceImpl implements TodoTaskService { private static final String dateFormat = "yyyy-MM-dd HH:mm:ss"; - @Override - /** - * 批量插入待办任务 - * - * @param taskPojos 待办任务POJO列表 - */ - public void batchInsert(List taskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625") - .doBatchInsert(taskPojos); - } - @Override /** * 分页查询发起任务 * * @param taskRequest 待办任务请求对象 * @return 发起任务分页结果DTO */ + @Override public PageResultDTO selectByPage(TodoTaskRequest taskRequest) { if (ObjectUtils.isEmpty(taskRequest.getCreatedById())) { - throw new RuntimeException("请传入发起人"); + throw new CommonException("请传入发起人"); } List tods = new ArrayList<>(); PageResultDTO taskPojoPageResultDTO = new PageResultDTO<>(); - PageQueryResult queryResult = sw.buildFromDatasource("xdap_app_223770822127386625") + PageQueryResult queryResult = bd.getBusinessDatabase() .eq("created_by_id", taskRequest.getCreatedById()) .eq("is_delete", 0) .orderBy("creation_date", "desc") @@ -125,17 +115,17 @@ public class TodoTaskServiceImpl implements TodoTaskService { return taskPojoPageResultDTO; } - @Override /** * 分页查询责任人待办任务 * * @param todoTaskRequest 待办任务请求对象 * @return 待办任务分页结果DTO */ + @Override public PageResultDTO selectByresPersonTodoPage(TodoTaskRequest todoTaskRequest) { PageResultDTO pageResultDTO = new PageResultDTO<>(); - PageQueryResult queryResult = sw.buildFromDatasource("xdap_app_223770822127386625") + PageQueryResult queryResult = bd.getBusinessDatabase() .eq("owner_id", todoTaskRequest.getPersonId()) .eq("is_delete", 0) .orderBy("creation_date", "desc") @@ -171,17 +161,17 @@ public class TodoTaskServiceImpl implements TodoTaskService { return pageResultDTO; } - @Override /** * 分页查询责任人已办任务 * * @param taskRequest 待办任务请求对象 * @return 已办任务分页结果DTO */ + @Override public PageResultDTO selectByresPersonCompletedPage(TodoTaskRequest taskRequest) { PageResultDTO pageResultDTO = new PageResultDTO<>(); - List completedTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List completedTaskPojos = bd.getBusinessDatabase() .eq("owner_id", taskRequest.getPersonId()) .eq("is_delete", 0) .orderBy("creation_date", "desc") @@ -231,22 +221,22 @@ public class TodoTaskServiceImpl implements TodoTaskService { } - @Override /** * 创建责任人任务 * * @param paramDetailPojosAll 引擎参数详情DTO列表 * @param userID 用户ID */ + @Override public void createResPerson(List paramDetailPojosAll, String userID) { if (ObjectUtils.isEmpty(paramDetailPojosAll)) { - throw new RuntimeException("未传入要变更的数据数据"); + throw new CommonException("未传入要变更的数据数据"); } String modelId = paramDetailPojosAll.get(0).getEngineModelId(); //为参数更新责任人 for (EngineParamDetailDTO engineParamDetailDTO : paramDetailPojosAll) { - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("responsible_person_id", engineParamDetailDTO.getResPersonId()) .rowid("id", engineParamDetailDTO.getId()) .doUpdate(EngineParamDetailPojo.class); @@ -295,8 +285,8 @@ public class TodoTaskServiceImpl implements TodoTaskService { initiatedTaskPojo.setLastUpdatedBy(engineParamDetailDTO.getResPersonId()); taskPojos.add(initiatedTaskPojo); } - myself.batchInsertTodoTask(todoTaskPojos); - myself.batchInsertInitiatedTask(taskPojos); + bd.getBusinessDatabase().doBatchInsert(todoTaskPojos); + bd.getBusinessDatabase().doBatchInsert(taskPojos); List detailPojos = engineParamDetailService.selectByModelNewVersion(modelId); List paramDetailPojos = detailPojos.stream() .filter(x -> ObjectUtils.isEmpty(x.getResponsiblePersonId()) @@ -306,44 +296,44 @@ public class TodoTaskServiceImpl implements TodoTaskService { if (ObjectUtils.isEmpty(paramDetailPojos)) { DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("已分发"); Integer status = byDesc != null ? byDesc.getCode() : null; - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("id", modelId) .update("distribute_status", status) .doUpdate(DataEntryEngineModelPojo.class); } else { DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("部分分发"); Integer status = byDesc != null ? byDesc.getCode() : null; - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .eq("id", modelId) .update("distribute_status", status) .doUpdate(DataEntryEngineModelPojo.class); } } - @Override - @Transactional /** * 待办任务退回 * * @param todoReturnRequest 待办退回请求对象 */ + @Override + @Transactional public void todoReturn(TodoReturnRequest todoReturnRequest) { String todoTaskId = todoReturnRequest.getTodoTaskId(); if (ObjectUtils.isEmpty(todoTaskId)) { - throw new RuntimeException("未传入单据"); + throw new CommonException("未传入单据"); } - List todoTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List todoTaskPojos = bd.getBusinessDatabase() .eq("id", todoTaskId) .doQuery(TodoTaskPojo.class); if (ObjectUtils.isEmpty(todoTaskPojos)) { - throw new RuntimeException("传入的单据查不到"); + throw new CommonException("传入的单据查不到"); } TodoTaskPojo todoTaskPojo1 = todoTaskPojos.get(0); String modelID = todoReturnRequest.getModelID(); //如果是填写人退回 把填写人的待办删除 则为该条责任人添加待办 并且待办创建人改为退回人 if ("填写人退回".equals(todoReturnRequest.getSteps())) { - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("is_delete", 1) .update("last_update_date", new Date()) .eq("id", todoTaskId).doUpdate(TodoTaskPojo.class); @@ -366,49 +356,40 @@ public class TodoTaskServiceImpl implements TodoTaskService { todoTaskPojo.setCurrentProcessor(JSON.toJSONString(Collections.singletonList(todoTaskPojo1.getCreatedById()))); todoTaskPojo.setOwnerId(todoTaskPojo1.getCreatedById()); todoTaskPojo.setCreatedBy(ObjectUtils.isNotEmpty(xdapUsersPojo) ? xdapUsersPojo.getUsername() : ""); - sw.buildFromDatasource("xdap_app_223770822127386625").doInsert(todoTaskPojo); + bd.getBusinessDatabase().doInsert(todoTaskPojo); //把相关参数中的填写人退回 List pojoList = engineParamDetailService.selectByModelNewVersion(modelID); List pojos = pojoList.stream().filter(x -> x.getFilledBy().equals(todoReturnRequest.getUserID())) .collect(Collectors.toList()); for (EngineParamDetailPojo pojo : pojos) { - sw.buildFromDatasource("xdap_app_223770822127386625") + bd.getBusinessDatabase() .update("filled_by", null) .eq("id",pojo.getId()) .doUpdate(pojo); } - } else if ("责任人退回".equals(todoReturnRequest.getSteps())) { - //如果是责任人退回 则该条数据还是属于未分发状态 - //暂时先不这么做处理,责任人退回无法记录退回人,容易重复提交分发 -// DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("未分发"); -// int distribute_status = byDesc != null ? byDesc.getCode() : null; -// sw.buildFromDatasource("xdap_app_223770822127386625") -// .update("distribute_status", distribute_status) -// .eq("id", todoTaskPojo1.getModelId()) -// .doUpdate(DataEntryEngineModelPojo.class); } } - @Override /** * 返回云柴待办任务 * * @param ycGetTodoTaskRequest 云柴获取待办任务请求对象 * @return 云柴待办任务结果DTO列表 */ + @Override public List returnTodoTask(YcGetTodoTaskRequest ycGetTodoTaskRequest) { String username = ycGetTodoTaskRequest.getUsername(); if (ObjectUtils.isEmpty(username)) { - return null; + return Collections.emptyList(); } ArrayList dtos = new ArrayList<>(); XdapUsers xdapUsers = xdapDeptUsersService.selectUserByCode(username); if (ObjectUtils.isNotEmpty(xdapUsers)) { String id = xdapUsers.getId(); - List todoTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + List todoTaskPojos = bd.getBusinessDatabase() .eq("owner_id", id) .eq("is_delete", 0) .doQuery(TodoTaskPojo.class); @@ -424,27 +405,27 @@ public class TodoTaskServiceImpl implements TodoTaskService { return dtos; } - return null; + return Collections.emptyList(); } - @Override /** * 返回已办任务 * * @param ycGetTodoTaskRequest 云柴获取待办任务请求对象 * @return 云柴已办任务通用结果DTO分页结果 */ + @Override public PageResultDTO returnCompleted(YcGetTodoTaskRequest ycGetTodoTaskRequest) { return commonTodoTask(ycGetTodoTaskRequest, "已办"); } - @Override /** * 返回发起任务 * * @param ycGetTodoTaskRequest 云柴获取待办任务请求对象 * @return 云柴发起任务通用结果DTO分页结果 */ + @Override public PageResultDTO returnInitiator(YcGetTodoTaskRequest ycGetTodoTaskRequest) { return commonTodoTask(ycGetTodoTaskRequest, "发起"); } @@ -452,7 +433,7 @@ public class TodoTaskServiceImpl implements TodoTaskService { private PageResultDTO commonTodoTask(YcGetTodoTaskRequest ycGetTodoTaskRequest, String o) { if (ObjectUtils.isEmpty(ycGetTodoTaskRequest.getCreateDateStart())) { - throw new RuntimeException("开始时间为必填项"); + throw new CommonException("开始时间为必填项"); } String userCode = ObjectUtils.isEmpty(ycGetTodoTaskRequest.getUsername()) ? "" : ycGetTodoTaskRequest.getUsername(); String userid = ObjectUtils.isEmpty(xdapDeptUsersService.selectUserByCode(userCode)) ? "" : xdapDeptUsersService.selectUserByCode(userCode).getId(); @@ -475,9 +456,9 @@ public class TodoTaskServiceImpl implements TodoTaskService { } } catch (ParseException e) { - throw new RuntimeException("检查日期格式是否正确为“yyyy-MM-dd HH:mm:ss”"); + throw new CommonException("检查日期格式是否正确为“yyyy-MM-dd HH:mm:ss”"); } - todoTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625") + todoTaskPojos = bd.getBusinessDatabase() .eq(str, userid) .gt("creation_date", parseStart) .lt("creation_date", parseEnd) @@ -498,11 +479,11 @@ public class TodoTaskServiceImpl implements TodoTaskService { pageint = Integer.parseInt(page); pageSizeint = Integer.parseInt(pageSize); } catch (NumberFormatException e) { - throw new RuntimeException("您的页码或页数非数字"); + throw new CommonException("您的页码或页数非数字"); } PageQueryResult queryResult; if (!o.equals("发起")) { - queryResult = sw.buildFromDatasource("xdap_app_223770822127386625") + queryResult = bd.getBusinessDatabase() .eq(str, userid) .eq("is_delete", 1) .gt("creation_date", parseStart) @@ -510,7 +491,7 @@ public class TodoTaskServiceImpl implements TodoTaskService { .eq("process_title", ycGetTodoTaskRequest.getTitle()) .doPageQuery(pageint, pageSizeint, TodoTaskPojo.class); } else { - queryResult = sw.buildFromDatasource("xdap_app_223770822127386625") + queryResult = bd.getBusinessDatabase() .eq(str, userid) .gt("creation_date", parseStart) .lt("creation_date", parseEnd) @@ -523,7 +504,7 @@ public class TodoTaskServiceImpl implements TodoTaskService { for (TodoTaskPojo todoTaskPojo : todoTaskPojos) { XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(todoTaskPojo.getOwnerId()); -// SimpleDateFormat format = new SimpleDateFormat(dateFormat); + YcTodoTaskCommonResultDTO ycCompletedResultDTO = new YcTodoTaskCommonResultDTO(); if (!o.equals("发起")) { ycCompletedResultDTO.setUrl(COMPLETEDURL); @@ -539,26 +520,4 @@ public class TodoTaskServiceImpl implements TodoTaskService { ycCompletedResultDTOPageResultDTO.setList(ycCompletedResultDTOS); return ycCompletedResultDTOPageResultDTO; } - - @Override - @Transactional // 发生任何异常都回滚 - /** - * 批量插入待办任务 - * - * @param todoTaskPojos 待办任务POJO列表 - */ - public void batchInsertTodoTask(List todoTaskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(todoTaskPojos); - } - @Override - @Transactional // 发生任何异常都回滚 - /** - * 批量插入发起任务 - * - * @param taskPojos 发起任务POJO列表 - */ - public void batchInsertInitiatedTask(List taskPojos) { - sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(taskPojos); - } - } diff --git a/src/main/java/com/xdap/self_development/service/impl/XdapDeptUsersServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/XdapDeptUsersServiceImpl.java index 83a63c2..4e4f585 100644 --- a/src/main/java/com/xdap/self_development/service/impl/XdapDeptUsersServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/XdapDeptUsersServiceImpl.java @@ -1,19 +1,17 @@ package com.xdap.self_development.service.impl; -import com.definesys.mpaas.query.MpaasQueryFactory; import com.xdap.api.moudle.department.pojo.entity.XdapDepartments; import com.xdap.api.moudle.department.pojo.entity.XdapDeptUsers; import com.xdap.api.moudle.user.pojo.XdapUsers; -import com.xdap.runtime.service.RuntimeDatasourceService; - +import com.xdap.self_development.common.BusinessDatabase; import com.xdap.self_development.service.XdapDeptUsersService; import groovy.util.logging.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -30,23 +28,22 @@ import java.util.stream.Collectors; public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { private static final Logger log = Logger.getLogger(XdapDeptUsersServiceImpl.class); - @Autowired - private MpaasQueryFactory sw; - @Autowired - private RuntimeDatasourceService runtimeDatasourceService; - @Override + @Resource + private BusinessDatabase bd; + /** * 根据ID查询部门 * * @param deptId 部门ID * @return 部门对象 */ + @Override public XdapDepartments selectDeptByID(String deptId) { if (ObjectUtils.isEmpty(deptId)) { return null; } - List departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List departmentsPojos = bd.getBusinessDatabase() .eq("id", deptId) .doQuery(XdapDepartments.class); if (ObjectUtils.isNotEmpty(departmentsPojos)) { @@ -55,18 +52,18 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { return null; } - @Override /** * 根据名称查询部门 * * @param deptName 部门名称 * @return 部门对象 */ + @Override public XdapDepartments selectDeptByName(String deptName) { if (ObjectUtils.isEmpty(deptName)) { return null; } - List departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List departmentsPojos = bd.getBusinessDatabase() .eq("name", deptName) .doQuery(XdapDepartments.class); if (ObjectUtils.isNotEmpty(departmentsPojos)) { @@ -75,23 +72,23 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { return null; } - @Override /** * 根据部门名称查询用户 * * @param deptName 部门名称 * @return 用户列表 */ + @Override public List selectUserByName(String deptName) { XdapDepartments xdapDepartmentsPojo = selectDeptByName(deptName); List xdapUsersPojos = new ArrayList<>(); if (ObjectUtils.isNotEmpty(xdapDepartmentsPojo)) { - List xdapDeptUsersPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List xdapDeptUsersPojos = bd.getBusinessDatabase() .eq("department_id", xdapDepartmentsPojo.getId()) .doQuery(XdapDeptUsers.class); if (ObjectUtils.isNotEmpty(xdapDeptUsersPojos)) { for (XdapDeptUsers xdapDeptUsersPojo : xdapDeptUsersPojos) { - List usersPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List usersPojos = bd.getBusinessDatabase() .eq("id", xdapDeptUsersPojo.getUserId()) .doQuery(XdapUsers.class); if (ObjectUtils.isNotEmpty(usersPojos)) { @@ -106,23 +103,22 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { return xdapUsersPojos; } - @Override /** * 根据人员姓名查询用户 * * @param personName 人员姓名 * @return 用户列表 */ + @Override public List selectUserByPersonName(String personName) { if (ObjectUtils.isEmpty(personName)) { return Collections.emptyList(); } - return runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + return bd.getBusinessDatabase() .eq("username", personName) .doQuery(XdapUsers.class); } - @Override /** * 根据用户列表和部门名称查询用户 * @@ -130,13 +126,14 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { * @param dpName 部门对象 * @return 匹配的用户对象 */ + @Override public XdapUsers selectUserByUserListAndDeptName(List xdapUsersPojos, XdapDepartments dpName) { if (ObjectUtils.isNotEmpty(xdapUsersPojos) && ObjectUtils.isNotEmpty(dpName)) { //提取用户ID集合 List idList = xdapUsersPojos.stream().map(x -> x.getId()).collect(Collectors.toList()); //根据用户ID查找对应关系表 - List departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List departmentsPojos = bd.getBusinessDatabase() .in("user_id", idList) .doQuery(XdapDeptUsers.class); //关系表筛选部门 @@ -144,7 +141,7 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { //筛选完成后查到对应的人员 if (ObjectUtils.isNotEmpty(collect)) { String userId = collect.get(0).getUserId(); - List usersPojo = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List usersPojo = bd.getBusinessDatabase() .eq("id", userId) .doQuery(XdapUsers.class); if (ObjectUtils.isNotEmpty(usersPojo)) { @@ -156,19 +153,20 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { return null; } - @Override + /** * 根据ID查询用户 * * @param userId 用户ID * @return 用户对象 */ + @Override public XdapUsers selectUserByID(String userId) { if (ObjectUtils.isEmpty(userId)) { return null; } - List userPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List userPojos = bd.getBusinessDatabase() .eq("id", userId) .doQuery(XdapUsers.class); if (ObjectUtils.isNotEmpty(userPojos)) { @@ -177,19 +175,19 @@ public class XdapDeptUsersServiceImpl implements XdapDeptUsersService { return null; } - @Override /** * 根据用户编码查询用户 * * @param userCode 用户编码 * @return 用户对象 */ + @Override public XdapUsers selectUserByCode(String userCode) { if (ObjectUtils.isEmpty(userCode)) { return null; } - List userPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625") + List userPojos = bd.getBusinessDatabase() .eq("user_number", userCode) .doQuery(XdapUsers.class); if (ObjectUtils.isNotEmpty(userPojos)) {