规范化代码格式-规范化修改4.0

This commit is contained in:
zjh 2026-01-22 16:24:18 +08:00
parent 86b2b12889
commit 9d189ba232
62 changed files with 519 additions and 1938 deletions

View File

@ -23,6 +23,7 @@
</repositories>
<properties>
<sonar.organization>zjh</sonar.organization>
<java.version>1.8</java.version>
<groovy.eclipse.compiler.version>2.9.2-01</groovy.eclipse.compiler.version>
<groovy.eclipse.batch.version>2.4.3-01</groovy.eclipse.batch.version>
@ -60,7 +61,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.20</version>
<optional>true</optional>
</dependency>

View File

@ -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;

View File

@ -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<AnalysisModelParamterView> lists = analysisCommonParametersService.selectModelParamByCommon(analysisRequest);
return Response.ok().data(lists);
}
/**
* 获取可用参数
*

View File

@ -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<ParameterPojo> 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);
}
}

View File

@ -12,10 +12,11 @@ import javax.validation.constraints.NotBlank;
@Data
public class ApprovalFlowForm {
@NotBlank(message = "流程不能为空")
/**
* 流程ID
*/
@NotBlank(message = "流程不能为空")
private String flowId;
/**
* 模板ID

View File

@ -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;
/**
* 审批环节配置列表

View File

@ -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 {

View File

@ -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名称

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;
/**
* 当前节点

View File

@ -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标识符
*/

View File

@ -4,5 +4,5 @@ import lombok.Data;
@Data
public class UserTokenDT0 {
private String access_token;
private String accessToken;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;
/**
* 文件路径

View File

@ -75,7 +75,7 @@ public class CompletedTaskPojo implements Serializable {
/**
* 所属人ID
*/
private String OwnerId;
private String ownerId;
/**
* 所属人ID
*/

View File

@ -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 ;

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -75,7 +75,7 @@ public class TodoTaskPojo implements Serializable {
/**
* 所属人ID
*/
private String OwnerId;
private String ownerId;
/**
* 所属人ID
*/

View File

@ -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")

View File

@ -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<MenuListView> listViews;

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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<DataEntryEngineModelExc
private final EngineParamDetailService engineParamDetailService;
private static final int BATCH_COUNT = 1000;
private final String ycOrOt;
private Integer versionNumber = 1;
private Date date = new Date();
private XdapUsers usersPojo;
private final Integer versionNumber = 1;
private final XdapUsers usersPojo;
private List<DataEntryEngineModelExcel> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@ -54,30 +55,19 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
public void invoke(DataEntryEngineModelExcel engineModelPojo, AnalysisContext analysisContext) throws ExcelAnalysisException {
engineModelPojo.setSheetName(analysisContext.readSheetHolder().getSheetName());
engineModelPojo.setRowIndex(analysisContext.readRowHolder().getRowIndex() + 1);
//
// 去掉责任人 List<ResponsiblePersonPojo> 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<DataEntryEngineModelExcel> cachedDataList) {
if (ObjectUtils.isEmpty(cachedDataList)) {
log.error("机型数据为空");
throw new ExcelImportException(
String.format("Excel无数据")
"Excel无数据"
);
}
@ -95,15 +85,7 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
String.format("请检查该型号是否已经存在,%s页第%d行", sheetName, rowIndex)
);
}
//空值校验
// 去掉责任人 if (StrUtil.isBlank(data.getModelName()) || StrUtil.isBlank(data.getDept())) {
// throw new ExcelImportException(
// String.format("请检查必要字段(发动机型号,部门)是否漏填,%s页第%d行", sheetName, rowIndex)
// );
// }
}
}
@Override
@ -126,7 +108,7 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
for (DataEntryEngineModelExcel modelExcel : cachedDataList) {
DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo();
BeanUtils.copyProperties(modelExcel, modelPojo, "status");
// 去掉责任人 modelPojo.setResponsiblePersonId(modelExcel.getResPersonId());
//获取状态码
DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("未分发");
modelPojo.setDistributeStatus(byDesc != null ? byDesc.getCode() : null);
@ -141,7 +123,7 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
modelPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
modelPojo.setId(UUID.randomUUID().toString());
modelPojos.add(modelPojo);
// sw.buildFromDatasource("test_demo").doInsert(modelPojo);
}
batchInsert(modelPojos);
@ -151,11 +133,6 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
//为每个机型绑定参数
private void saveDataParamDetail(ArrayList<DataEntryEngineModelPojo> modelPojos, List<ParameterPojo> parameters) {
/**
* 遍历机型
* 查找参数 将每个机型都把参数和参数所属的填写部门关联上
* 参数值暂时放空
*/
List<EngineParamDetailPojo> engineParamDetailPojos = new ArrayList<>();
for (DataEntryEngineModelPojo modelPojo : modelPojos) {
for (ParameterPojo parameter : parameters) {
@ -176,60 +153,10 @@ public class EngineModelListener implements ReadListener<DataEntryEngineModelExc
engineParamDetailPojo.setLastUpdateDate(Timestamp.valueOf(LocalDateTime.now()));
engineParamDetailPojo.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
engineParamDetailPojos.add(engineParamDetailPojo);
//为每个参数生成默认责任人
List<ResponsiblePersonPojo> personPojos = responsiblePerService.selectByDepName(parameter.getDepartment());
if (ObjectUtils.isNotEmpty(personPojos)) {
// 不再默认生成责任人 engineParamDetailPojo.setResponsiblePersonId(personPojos.get(0).getId());
}
}
}
batchInsertParamDetail(engineParamDetailPojos);
//
// //生成分解任务给责任人 参数根据机型+责任人分组 生成数据
// List<EngineParamDetailPojo> 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<TodoTaskPojo> todoTaskPojos = new ArrayList<>();
// for (EngineParamDetailPojo paramDetailPojo : paramDetailPojos) {
// //查找参数对应的机型
// DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo();
// if (ObjectUtils.isNotEmpty(paramDetailPojo.getEngineModelId())) {
// List<DataEntryEngineModelPojo> 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<DataEntryEngineModelExc
public void batchInsert(List<DataEntryEngineModelPojo> 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<DataEntryEngineModelPojo> batch = modelPojos.subList(i, end);
// sw.buildFromDatasource("test_demo").doBatchInsert(modelPojos);
// }
}
}

View File

@ -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<EngineParamDetailExcel> {
private final MpaasQueryFactory sw;
private final DataEntryEngineModelPojo modelPojo;
@ -34,10 +32,7 @@ public class EngineParamDetailListener implements ReadListener<EngineParamDetail
private static final int BATCH_COUNT = 1000;
private Integer versionNumber = 1;
private Date date = new Date();
private String createdBy = "Excel导入";
Map<String, String> stringParameterMap;
private RuntimeException importException = null;
private ArrayList<String> successSheetName = null;
private String userId;
private List<EngineParamDetailExcel> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@ -61,38 +56,10 @@ public class EngineParamDetailListener implements ReadListener<EngineParamDetail
}
/**
* 校验逻辑
*
* @param cachedDataList
*/
private void dataStrictly(List<EngineParamDetailExcel> 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<EngineParamDetail
log.info("开始处理 处理数据条数{}", cachedDataList.size());
ArrayList<EngineParamDetailPojo> 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<EngineParamDetailPojo> detailPojos =
sw.buildFromDatasource("xdap_app_223770822127386625")
.eq("id",paramDetailExcel.getId())
@ -129,48 +92,7 @@ public class EngineParamDetailListener implements ReadListener<EngineParamDetail
.update("operation",String.valueOf(ParamOperationEnum.UPDATE))
.rowid("id", detailPojos.get(0).getId())
.doUpdate(EngineParamDetailPojo.class);
} else if(ObjectUtils.isEmpty(detailPojos)&&ObjectUtils.isNotEmpty(paramDetailExcel.getId())){
//如果ID匹配不上说明ID被动了 并且ID不为空 说明不是新增的参数 直接返回
log.warn("%s页第%d行ID匹配不上",paramDetailExcel.getSheetName(),paramDetailExcel.getRowIndex());
continue;
}
if(ObjectUtils.isEmpty(paramDetailExcel.getId())){
log.warn("%s页第%d行非最新模板参数或者该参数未维护",paramDetailExcel.getSheetName(),paramDetailExcel.getRowIndex());
// //todo查找新增参数的对应的参数模板ID
// String parameterName = paramDetailExcel.getParameterName();
// String subsystemName = paramDetailExcel.getSubsystemName();
// String parameterType = paramDetailExcel.getParameterType();
// //组装参数
// engineParamDetailPojo.setMajorVersion(0);
// engineParamDetailPojo.setEngineModelId(modelPojo.getId());
// engineParamDetailPojo.setParameterName(parameterName);
// engineParamDetailPojo.setSubsystemName(subsystemName);
// engineParamDetailPojo.setParameterType(parameterType);
// engineParamDetailPojo.setMinorVersion(paramDetailExcel.getParameterValue());
//// 刚上传的参数值存放在小版本值里 engineParamDetailPojo.setParameterValue(paramDetailExcel.getParameterValue());
// engineParamDetailPojo.setDepartment(paramDetailExcel.getDepartment());
// List<ResponsiblePersonPojo> 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<EngineParamDetailPojo> engineParamDetailPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(engineParamDetailPojos);
}
}

View File

@ -15,7 +15,7 @@ import java.util.List;
public class PersonReadListener implements ReadListener<ResponsiblePersonPojo> {
MyResponse problems;
private final ResponsiblePersonService responsiblePersonService;
private List<ResponsiblePersonPojo> cachedDataList;
private final List<ResponsiblePersonPojo> cachedDataList;
public PersonReadListener(ResponsiblePersonService responsiblePersonService, MyResponse problems) {
this.problems = problems;

View File

@ -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<ParameterPojo> {
@ -18,18 +19,10 @@ public class SheetDataListener implements ReadListener<ParameterPojo> {
private final TemplateService templateService;
private final String templateRowId;
private final String createBy;
private List<ParameterPojo> cachedDataList;
private final List<ParameterPojo> cachedDataList;
private String currentSheetName;
MyResponse problems;
// 用于存储表头
private Set<String> actualHeaders = new HashSet<>();
// 是否已检查过表头
private boolean headerChecked = false;
// 必须包含的字段集合
private final Set<String> requiredHeaders;
// 标记当前sheet是否有效
private boolean validSheet = false;
public SheetDataListener(TemplateService templateService,
String templateRowId, String createBy, MyResponse problems) {
@ -38,31 +31,17 @@ public class SheetDataListener implements ReadListener<ParameterPojo> {
this.createBy = createBy;
this.cachedDataList = new ArrayList<>(BATCH_SIZE);
this.problems = problems;
this.requiredHeaders = getIncludeColumnFieldNames();
}
@Override
public void invokeHead(Map<Integer, ReadCellData<?>> 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) {
currentSheetName = context.readSheetHolder().getSheetName();
}
@ -79,7 +58,6 @@ public class SheetDataListener implements ReadListener<ParameterPojo> {
if (!cachedDataList.isEmpty()) {
processBatch();
}
resetForNextSheet();
}
private void processBatch() {
@ -92,59 +70,4 @@ public class SheetDataListener implements ReadListener<ParameterPojo> {
);
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<String> getIncludeColumnFieldNames() {
Set<String> 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;
}
}

View File

@ -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;
@ -25,28 +26,25 @@ 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<String, Map<String, String>> 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<String> 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;
}

View File

@ -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);

View File

@ -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<AnalysisModelParamterView> selectModelParamByCommon(AnalysisRequest analysisRequest);
AnalysisModelParamterViewAndParam showReport(List<String> models);
AnalysisModelParamterViewAndParam showReportParamList(ReportRequest analysisRequest);
List<DataEntryEngineModelPojo> selectModelByLike(ReportRequest request);

View File

@ -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);

View File

@ -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<ParameterPojo> getParameterByCondition(OptionForm form);

View File

@ -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<ParameterPojo> selectAllByNewVersion();
List<ParameterPojo> selectAllAndTcByNewVersion();
/**
* 根据型号查询最新的引擎参数详情列表
*
* @param model 型号名称
* @return 返回指定型号的最新版本引擎参数详情列表
*/
List<EngineParamDetailPojo> selectByModelNewVersion(String model);
//根据责任人查询最新发版的参数详情
List<EngineParamDetailPojo> selectByResId(String resId);
//根据填写人查询最新发版的参数详情
List<EngineParamDetailPojo> selectByfiledId(String filledId);
//根据流程ID查数据
List<EngineParamDetailPojo> selectByapprovalId(String approvalId);
//根据ID查询数据
EngineParamDetailPojo selectById(String id);

View File

@ -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<MenuListView> selectMenus();
//根据ID查询路径
ModelMenuDictionaryPojo selectMenuById(String menuName);
}

View File

@ -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<ModelRolesPojo> selectRolesByPage(String userID);
List<ModelRolesPojo> selectRoles();
void updatePerForRole(List<RolePerJoinRequest> request);
void updateRole(ModelRolesPojo modelRolesPojo, String userID);

View File

@ -16,15 +16,12 @@ import java.util.List;
public interface ResponsiblePerService {
ResponsiblePersonPojo selectByDepAndPer(String department, String resPerson);
ResponsiblePersonPojo selectByDep(String departmentId);
List<ResponsiblePersonPojo> selectByUserId(List<XdapUsers> userIds);
List<ResponsiblePersonPojo> selectByDepName(String departmentName);
Object insert(ResponsiblePersonPojo responsiblePerson);
List<ResponsiblePersonPojo> seelctAll();
ResponsiblePersonPojo selectById(String responsiblePersonId);
List<ResponsiblePersonPojo> selectBysubSystemDept(String subSystem, String dept);
}

View File

@ -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<model,List<parameter>>
HashMap<String, List<ClassificationAttributePojo>> tcDataSelectByC(String productNumber, String partsName, String parameterName);
ArrayList<EngineParamDetailPojo> tcDataSelectAllByproductNumber(DataEntryEngineModelPojo engineModelPojo);
Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest);
Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsNameBack(AnalysisRequest analysisRequest);
void excelExportA(HttpServletResponse response);

View File

@ -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<TodoTaskPojo> taskPojo);
//根据人员ID查询发起事项
PageResultDTO<InitiatedTaskPojo> selectByPage(TodoTaskRequest todoTaskRequest);
@ -32,10 +34,6 @@ public interface TodoTaskService {
void todoReturn(TodoReturnRequest todoReturnRequest);
void batchInsertTodoTask(List<TodoTaskPojo> todoTaskPojos);
void batchInsertInitiatedTask(List<InitiatedTaskPojo> taskPojos);
//---------------------------------玉柴调用接口--------------------------------
List<YcTodoTaskResultDTO> returnTodoTask(YcGetTodoTaskRequest ycGetTodoTaskRequest);

View File

@ -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<String> 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<ActivitiDataDTO> activitiDataDTOS = new ArrayList<>();
ArrayList<DataChangeCommentPojo> 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<String> 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<String> 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,7 +968,8 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
.doUpdate(TodoTaskPojo.class);
// 创建直送记录
ParamApprovalRecordPojo record = new ParamApprovalRecordPojo(
bd.getBusinessDatabase().doInsert(
new ParamApprovalRecordPojo(
flow.getId(),
"直送至" + preNode.getNodeName(),
xdapDeptUsersService.selectUserByID(userId).getUsername(),
@ -1012,8 +979,8 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
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<EngineParamDetailPojo> 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<String> ids = detailPojos.stream().map(EngineParamDetailPojo::getId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(ids)) {
throw new RuntimeException("该审批流没有绑定的参数,请维护好参数后重新发起审批");
throw new CommonException("该审批流没有绑定的参数,请维护好参数后重新发起审批");
}
// 查询数据变更评论
List<DataChangeCommentPojo> dataChangeCommentPojos = bd.getBusinessDatabase()
@ -1239,7 +1195,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
activitiDataDTOS.add(activitiDataDTO);
}
activitiDataAndRecordDTO.setActivitiDataDTOS(activitiDataDTOS);
// TODO生成审批记录节点
List<FlowNode> flowNodes = new ArrayList<>();
EngineReviewListPojo flow = bd.getBusinessDatabase()
.eq("id", approvalId)

View File

@ -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<AnalysisModelParamterView> selectModelParamByCommon(AnalysisRequest analysisRequest) {
// if (ObjectUtils.isEmpty(analysisRequest.getModelIds()) || ObjectUtils.isEmpty(analysisRequest) || ObjectUtils.isEmpty(analysisRequest.getCommonId())) {
// log.warn("analysisRequest is empty");
// return null;
// }
// List<ModelCommonParametersPojo> commons = businessDatabase.getBusinessDatabase()
// .eq("common_id", analysisRequest.getCommonId())
// .doQuery(ModelCommonParametersPojo.class);
// List<String> paramIds = commons.stream().map(x -> x.getParameterId()).collect(Collectors.toList());
// if (ObjectUtils.isEmpty(paramIds)) {
// return null;
// }
//
// ArrayList<AnalysisModelParamterView> analysisModelParamterViews = new ArrayList<>();
// //查找每个机型的参数并且根据常用筛选
// for (String modelId : analysisRequest.getModelIds()) {
// List<EngineParamDetailPojo> pojoListAll = new ArrayList<>();
// List<EngineParamDetailPojo> pojoList = engineParamDetailService.selectByModelNewVersion(modelId);
// List<EngineParamDetailPojo> 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<String> modelIds) {
long startTime = System.currentTimeMillis();
List<DataEntryEngineModelPojo> 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<DataEntryEngineModelPojo> 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<AnalysisModelParamterView> analysisModelParamterViews = new ArrayList<>();
for (DataEntryEngineModelPojo engineModelPojo : engineModelPojos) {
AnalysisModelParamterView analysisModelParamterView = new AnalysisModelParamterView();
List<EngineParamDetailPojo> pojoList = engineParamDetailService.selectByModelNewVersion(engineModelPojo.getId());
//
ArrayList<EngineParamDetailPojo> 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<String> list = new ArrayList<>();
for (AnalysisModelParamterView analysisModelParamterView : analysisModelParamterViews) {
analysisModelParamterView.getPojos().stream().forEach(x -> list.add(x.getParameterName()));
}
List<String> 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<List<DataEntryEngineModelPojo>> splitModelBatch(
List<DataEntryEngineModelPojo> source,
int batchSize
) {
List<List<DataEntryEngineModelPojo>> batches = new ArrayList<>();
List<DataEntryEngineModelPojo> 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;
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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<DataEntryEngineModelPojo> selectAll() {
List<DataEntryEngineModelPojo> 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<DataEntryEngineModelPojo> pageQueryResult = sw
.buildFromDatasource("xdap_app_223770822127386625")
PageQueryResult<DataEntryEngineModelPojo> 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<XdapUsersPojo> 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<ParameterPojo> parameters = engineParamDetailService.selectAllByNewVersion();
DataEntryEngineModelPojo modelPojo = new DataEntryEngineModelPojo();
BeanUtils.copyProperties(request, modelPojo, "status");
List<ResponsiblePersonPojo> personPojos = responsiblePerService.selectByDepName(request.getDepartment());
List<DataEntryEngineModelPojo> modelPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<DataEntryEngineModelPojo> 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<XdapUsers> 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<ParameterPojo> parameters = engineParamDetailService.selectAllByNewVersion();
DistributeStatusEnum byDesc = DistributeStatusEnum.getByDesc("未分发");
Integer distribute_status = byDesc != null ? byDesc.getCode() : null;
List<DataEntryEngineModelPojo> 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<ResponsiblePersonPojo> 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<EngineParamDetailPojo> 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<TodoTaskPojo> 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<TodoTaskPojo> 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> 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<DataEntryEngineModelPojo> modelPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<DataEntryEngineModelPojo> 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<DataEntryEngineModelDto> selectVersionByConditionPage() {
List<DataEntryEngineModelDto> list = sw.buildFromDatasource("xdap_app_223770822127386625")
List<DataEntryEngineModelDto> 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<InitiatedTaskPojo> initiatedTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<InitiatedTaskPojo> 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);
}

View File

@ -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;
@ -27,43 +24,8 @@ import java.util.List;
@Service
public class DataEntryServiceImpl implements DataEntryService {
@Resource
private MpaasQueryFactory sw;
/**
* 读取Excel文件
* 从上传的Excel文件中读取数据
*
* @param file Excel文件
* @return void
*/
@Override
public void readExcel(MultipartFile file) {
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<ParameterPojo> getParameterByCondition(OptionForm form) {
List<ParameterPojo> 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<TemplatePojo> 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<TemplatePojo> 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<String> fieldList = getIncludeColumnFieldNames(form);
// List<ParameterPojo> 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<String> getIncludeColumnFieldNames(OptionForm form) {
// Set<String> 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<TemplatePojo> 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<ParameterPojo> getParameterByCondition(OptionForm form) {
// List<TemplatePojo> 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<TemplatePojo> 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);
// }
}

View File

@ -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<TemplatePojo> templates =
sw.buildFromDatasource("xdap_app_223770822127386625")
List<TemplatePojo> 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<ParameterPojo> parameterByCondition = dataEntryService.getParameterByCondition(new OptionForm());
List<EngineParamDetailPojo> engineParams = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> engineParams = bd.getBusinessDatabase()
.eq("engine_model_id", modelId)
.eq("filled_by", userId)
.doQuery(EngineParamDetailPojo.class);
// List<ParameterPojo> 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<ParameterPojo> 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<EngineParamDetailPojo> detailPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<String> subsystemTypes = engineParamDetailRequest.getSubsystemParts();
if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes)) {
throw new RuntimeException("传入参数为空,请检查");
throw new CommonException("传入参数为空,请检查");
}
List<EngineParamDetailPojo> detailPojos = new ArrayList<>();
ArrayList<EngineParamDetailDTO> 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<EngineParamDetailPojo> 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<String> parameterIds = userPermissionGetter.getParamPermissions();
// for (String parameterId : parameterIds) {
// List<EngineParamDetailPojo> 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<ParameterPojo> parameters = sw.buildFromDatasource("xdap_app_223770822127386625")
List<ParameterPojo> 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<String, List<EngineParamDetailDTO>> 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<EngineParamDetailPojo> 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<EngineParamDetailPojo> 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<TodoTaskPojo> todoTaskPojos = new ArrayList<>();
ArrayList<InitiatedTaskPojo> 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<EngineParamDetailPojo> 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<TodoTaskPojo> todoTaskPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(todoTaskPojos);
}
/**
* 批量插入发起任务
* 批量插入发起任务到数据库
*
* @param taskPojos 发起任务POJO列表
* @return void
*/
@Transactional // 发生任何异常都回滚
public void batchInsertInitiatedTask(List<InitiatedTaskPojo> taskPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(taskPojos);
}
/**
* 查询所有新版本参数
* 查询所有最新版本的参数信息
@ -760,11 +650,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
public List<ParameterPojo> selectAllByNewVersion() {
//读取已通过审核的版本 DRAFT(草稿)APPROVING审批中COMPLETE(已完成)RETURNED(已撤回)REJECTED(已拒绝)
List<TemplatePojo> 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<String, TemplatePojo> latestTemplateMap = templates.stream()
@ -781,12 +671,12 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
List<String> strings = templatesMax.stream().map(TemplatePojo::getId).collect(Collectors.toList());
//查找最新模板关联的参数
List<TemplateAndParameterPojo> templateAndParameters =
sw.buildFromDatasource("xdap_app_223770822127386625")
bd.getBusinessDatabase()
.in("template_id", strings)
.doQuery(TemplateAndParameterPojo.class);
List<String> pIds = templateAndParameters.stream().map(TemplateAndParameterPojo::getParameterId).collect(Collectors.toList());
List<ParameterPojo> parameterList = sw.buildFromDatasource("xdap_app_223770822127386625")
List<ParameterPojo> parameterList = bd.getBusinessDatabase()
.in("id", pIds)
.doQuery(ParameterPojo.class);
//不需要TC数据来源的参数
@ -814,11 +704,11 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
public List<ParameterPojo> selectAllAndTcByNewVersion() {
//读取已通过审核的版本 DRAFT(草稿)APPROVING审批中COMPLETE(已完成)RETURNED(已撤回)REJECTED(已拒绝)
List<TemplatePojo> 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<String> strings = templatesMax.stream().map(TemplatePojo::getId).collect(Collectors.toList());
//查找最新模板关联的参数
List<TemplateAndParameterPojo> templateAndParameters =
sw.buildFromDatasource("xdap_app_223770822127386625")
bd.getBusinessDatabase()
.in("template_id", strings)
.doQuery(TemplateAndParameterPojo.class);
List<String> 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<EngineParamDetailPojo> engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<EngineParamDetailPojo> engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<EngineParamDetailPojo> selectByfiledId(String filledId) {
if (ObjectUtils.isEmpty(filledId)) {
return Collections.emptyList();
}
List<EngineParamDetailPojo> 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<EngineParamDetailPojo> 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<EngineParamDetailPojo> engineParamDetailPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<Integer> selectVersionList(String modelId) {
if (ObjectUtils.isNotEmpty(modelId)) {
List<EngineParamDetailPojo> detailPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> detailPojos = bd.getBusinessDatabase()
.eq("engine_model_id", modelId)
.doQuery(EngineParamDetailPojo.class);
List<Integer> 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<XdapUsers> xdapUsersPojos = new ArrayList<>();
List<ResponsiblePersonPojo> personPojos = responsiblePerService.selectBysubSystemDept(subSystem, dept);
if (ObjectUtils.isEmpty(personPojos)) {
throw new RuntimeException("该子系统和部门没有查找到相关人子系统:" + subSystem + ",部门:" + dept);
throw new CommonException("该子系统和部门没有查找到相关人子系统:" + subSystem + ",部门:" + dept);
}
try {
List<ResponsiblePersonPojo> 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;

View File

@ -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<EngineReviewListPojo> 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<EngineReviewListPojo> 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<EngineReviewListPojo> pageResultDTO = new PageResultDTO();
PageResultDTO<EngineReviewListPojo> 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<EngineReviewListPojo> engineReviewListPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineReviewListPojo> engineReviewListPojos = bd.getBusinessDatabase()
.eq("id", approvalId)
.doQuery(EngineReviewListPojo.class);
if (ObjectUtils.isEmpty(engineReviewListPojos)) {
throw new RuntimeException("审批流未找到");
throw new CommonException("审批流未找到");
}
// 获取环节
List<ParamApprovalRecordPojo> paramApprovalRecordPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<ParamApprovalRecordPojo> 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);

View File

@ -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;
}
}

View File

@ -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<ModelRolesPojo> selectRolesByPage(String userID) {
return null;
}
/**
* 查询所有角色
* 查询系统中的所有角色信息
@ -87,10 +76,9 @@ public class ModelRoleServiceImpl implements ModelRoleService {
*/
@Override
public List<ModelRolesPojo> selectRoles() {
List<ModelRolesPojo> 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<ModelMenuParameterPojo> 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<MenuParamView> selectPersByUser(String userOrDepID) {
if (ObjectUtils.isEmpty(userOrDepID)) {
throw new RuntimeException("用户或部门ID为空");
throw new CommonException("用户或部门ID为空");
}
List<ModelDepUserRolePojo> userOrDeps = businessDatabase.getBusinessDatabase()
.eq("user_or_dep", userOrDepID)
@ -224,14 +204,14 @@ public class ModelRoleServiceImpl implements ModelRoleService {
@Override
public List<MenuParamView> 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<MenuParamView> menuParamViews = new ArrayList<>();
List<ModelRolePermissionPojo> 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<String> perids = role.stream().map(x -> x.getPerId()).distinct().collect(Collectors.toList());
List<String> perids = role.stream().map(ModelRolePermissionPojo::getPerId).distinct().collect(Collectors.toList());
List<ModelMenuParameterPojo> menuParameters = businessDatabase.getBusinessDatabase()
.in("id", perids)
.doQuery(ModelMenuParameterPojo.class);
//获取权限
for (ModelMenuParameterPojo menuParameter : menuParameters) {
/* 权限变更不再管理菜单且不再存参数 改为子系统+零部件
ModelMenuDictionaryPojo modelMenuDictionaryPojo = modelMenuPermissionService.selectMenuById(menuParameter.getMenuId());
String parameterId = menuParameter.getParameterId();
//查找参数 组装权限
List<ParameterPojo> 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<String, List<String>> selectUserOrDeptByRole(String roleID) {
if (ObjectUtils.isEmpty(roleID)) {
return null;
return new HashMap<>();
}
List<ModelDepUserRolePojo> 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<>();
}
}

View File

@ -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<String, Object> 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<ParameterPojo> parameters;
}
/**
* 参数处理结果封装类
*/
/**
* 参数处理结果封装类
*/

View File

@ -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<XdapUsers> userByName = xdapDeptUsersService.selectUserByPersonName(resPerson);
XdapUsers XdapUsers = xdapDeptUsersService.selectUserByUserListAndDeptName(userByName, deptByName);
ResponsiblePersonPojo ResponsiblePerson = null;
List<ResponsiblePersonPojo> personPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
XdapUsers xdapUsers = xdapDeptUsersService.selectUserByUserListAndDeptName(userByName, deptByName);
ResponsiblePersonPojo responsiblePerson = null;
List<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> selectByUserId(List<XdapUsers> userIds) {
if (ObjectUtils.isEmpty(userIds)) {
return null;
return Collections.emptyList();
}
List<String> idlist = new ArrayList<>();
for (XdapUsers userId : userIds) {
idlist.add(userId.getId());
}
List<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> seelctAll() {
List<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> 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<ResponsiblePersonPojo> selectBysubSystemDept(String subSystem, String dept) {
List<ResponsiblePersonPojo> personPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
return bd.getBusinessDatabase()
.like("subsystem", subSystem)
.eq("department", dept)
.doQuery(ResponsiblePersonPojo.class);
return personPojos;
}
}

View File

@ -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<XdapUsers> xdapUsers1 = new ArrayList<XdapUsers>();
ArrayList<XdapUsers> xdapUsers1 = new ArrayList<>();
List<ResponsiblePersonPojo> responsiblePeople = bd.getBusinessDatabase()
.eq("department", dept)
.eq("subsystem", subsystem)
.doQuery(ResponsiblePersonPojo.class);
if (!responsiblePeople.isEmpty()) {
List<String> userIds = responsiblePeople.stream().map(x -> x.getUserId()).collect(Collectors.toList());
List<String> userIds = responsiblePeople.stream().map(ResponsiblePersonPojo::getUserId).collect(Collectors.toList());
for (String userId : userIds) {
XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId);
if (xdapUsers != null) {

View File

@ -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<String, List<ClassificationAttributePojo>> 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<ClassificationAttributePojo> list = bd.getTCDatabase()
.eq("pitemId", enginePartsCollection.getLbjth())
.doQuery(ClassificationAttributePojo.class);
HashMap<String, List<ClassificationAttributePojo>> stringListHashMap = new HashMap<>();
stringListHashMap.put(productNumber, list);
return stringListHashMap;
}
//通过状态代号产品编号
@Override
/**
* 根据产品编号查询所有TC数据
*
* @param engineModelPojo 引擎模型对象
* @return 引擎参数详情列表
*/
public ArrayList<EngineParamDetailPojo> tcDataSelectAllByproductNumber(DataEntryEngineModelPojo engineModelPojo) {
String productNumber = engineModelPojo.getProductNumber();
HashMap<String, List<ClassificationAttributePojo>> stringListHashMap = new HashMap<>();
if (ObjectUtils.isEmpty(productNumber)) {
return null;
}
ArrayList<EngineParamDetailPojo> engineParamDetailPojos = new ArrayList<>();
//查找参数模板TC参数数据
List<ParameterPojo> parameters = engineParamDetailService.selectAllAndTcByNewVersion();
List<ParameterPojo> collect = parameters.stream().filter(x -> "TC分类表".equals(x.getParameterSource())).collect(Collectors.toList());
if (ObjectUtils.isEmpty(collect)) {
return null;
}
//通过零部件集合+状态机 查找图号
String id = engineModelPojo.getId();
Map<String, List<ParameterPojo>> stringListMap = collect.stream().collect(Collectors.groupingBy(ParameterPojo::getPartsName));
Set<String> partsNames = stringListMap.keySet();
for (String partsName : partsNames) {
//获取系统内零部件下的参数
List<String> parametersOnPartsName = stringListMap.get(partsName).stream().map(x -> x.getParameterName()).collect(Collectors.toList());
List<EnginePartsCollectionPojo> partsCollections = bd.getTCDatabase()
.eq("ztj", productNumber)
.eq("lbjmc", partsName)
.doQuery(EnginePartsCollectionPojo.class);
//查找图号
List<String> allLbjths = partsCollections.stream()
.map(EnginePartsCollectionPojo::getLbjth)
.filter(ObjectUtils::isNotEmpty)
.distinct()
.collect(Collectors.toList());
//查找参数
if (!allLbjths.isEmpty()) {
List<ClassificationAttributePojo> 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<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest) {
return tcDataSelectAllByPartsNameFunctionOptimized(analysisRequest);
@ -178,30 +79,28 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
}
public Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsNameFunction(AnalysisRequest analysisRequest) {
// long a = System.currentTimeMillis();
String engineModelID = analysisRequest.getEngineModelID();
List<String> subsystemTypes = analysisRequest.getSubsystemParts();
if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes)) {
throw new RuntimeException("传入参数为空,请检查");
throw new CommonException("传入参数为空,请检查");
}
List<EngineParamDetailPojo> allPojos = new ArrayList<>();
// List<EngineParamDetailPojo> SysAllPojos = new ArrayList<>();
List<ParameterPojo> parameters = engineParamDetailService.selectAllAndTcByNewVersion();
DataEntryEngineModelPojo dataEntryEngineModelPojo = engineModelService.selectBymodelId(engineModelID);
//查到所有TC表的参数 返回零部件参数列表
for (String subsystemType : subsystemTypes) {
HashMap<String, List<ClassificationAttributePojo>> 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<EngineParamDetailPojo> pojoList = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<EnginePartsCollectionPojo> 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<String, List<ClassificationAttributePojo>> stringListEntry : stringListHashMap.entrySet()) {
String key = stringListEntry.getKey();//零部件
List<ClassificationAttributePojo> list = stringListEntry.getValue();//零部件里的值
@ -256,11 +155,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
}
}
Map<String, List<EngineParamDetailPojo>> 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<Map.Entry<String, String>> 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<EngineParamDetailPojo> systemDataList = new ArrayList<>();
for (Map.Entry<String, String> subsystemPartsPair : subsystemPartsPairs) {
List<EngineParamDetailPojo> pojoList = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<String, String> pair : subsystemPartsPairs) {
String subsystem = pair.getKey();
String partsName = pair.getValue();
// 获取该零部件的所有图号
@ -390,14 +285,11 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
log.info("成功将数据存储到RedisKEY: {}", redisKey);
} catch (Exception e) {
log.error("存储数据到Redis失败: {}", e.getMessage());
throw new RuntimeException("存储数据到Redis失败"+e.getMessage());
throw new CommonException("存储数据到Redis失败" + e.getMessage());
}
Map<String, List<EngineParamDetailPojo>> 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文件异常");
}
}
@ -475,19 +367,19 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
// 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<EngineParamDetailPojo> 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<String, List<EngineParamDetailPojo>> tcDataSelectByVersion(AnalysisVerRequest analysisRequest) {
// List<EngineParamDetailPojo> allPojos = new ArrayList<>();
List<ParameterPojo> parameters = engineParamDetailService.selectAllAndTcByNewVersion();
DataEntryEngineModelPojo dataEntryEngineModelPojo = engineModelService.selectBymodelId(analysisRequest.getEngineModelID());
// 预加载所有参数信息
// Map<String, List<ParameterPojo>> parameterMap = parameters.stream()
// .collect(Collectors.groupingBy(p -> p.getPartsName() + "&&" + p.getParameterName()));
//解析所有子系统-零部件对
List<Map.Entry<String, String>> 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<EngineParamDetailPojo> systemDataList = new ArrayList<>();
for (Map.Entry<String, String> subsystemPartsPair : subsystemPartsPairs) {
List<EngineParamDetailPojo> pojoList = sw.buildFromDatasource("xdap_app_223770822127386625")
List<EngineParamDetailPojo> 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<EngineParamDetailPojo> filteredSystemData = systemDataList.stream()
// .filter(x -> x.getMajorVersion().equals(dataEntryEngineModelPojo.getVersionNumber()))
// .collect(Collectors.toList());
// allPojos.addAll(filteredSystemData);
//批量查询所有TC数据
Map<String, List<ParameterPojo>> parameterMapTc = parameters.stream()
.filter(x-> Objects.equals(x.getParameterSource(), "TC分类表"))
@ -720,11 +600,11 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
List<Map.Entry<String, String>> 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<String> uniquePartsNames = subsystemPartsPairsTc.stream()
@ -761,7 +641,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
// 处理每个子系统-零部件对
for (Map.Entry<String, String> 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<String, List<EngineParamDetailPojo>> 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<List<String>> splitBatch(Set<String> source, int batchSize) {
List<List<String>> batches = new ArrayList<>();
List<String> 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");

View File

@ -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,7 +375,8 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
.doUpdate(TodoTaskPojo.class);
// 创建直送记录
ApprovalRecordPojo record = new ApprovalRecordPojo(
bd.getBusinessDatabase().doInsert(
new ApprovalRecordPojo(
flow.getId(),
"直送至" + preNode.getNodeName(),
xdapDeptUsersService.selectUserByID(userId).getUsername(),
@ -383,8 +384,8 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
"MSG",
Timestamp.valueOf(LocalDateTime.now()),
level
)
);
bd.getBusinessDatabase().doInsert(record);
}
// 查询所有流程
@ -499,7 +500,8 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
) {
// 新增当前审批结果
ApprovalRecordPojo record = new ApprovalRecordPojo(
bd.getBusinessDatabase().doInsert(
new ApprovalRecordPojo(
flow.getId(),
currentNode.getNodeName(),
request.getUserId(),
@ -507,8 +509,8 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
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(),

View File

@ -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<TemplatePojo> 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<TemplatePojo> 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<ParameterPojo> 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<String, Object> 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"));

View File

@ -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<TodoTaskPojo> taskPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625")
.doBatchInsert(taskPojos);
}
@Override
/**
* 分页查询发起任务
*
* @param taskRequest 待办任务请求对象
* @return 发起任务分页结果DTO
*/
@Override
public PageResultDTO<InitiatedTaskPojo> selectByPage(TodoTaskRequest taskRequest) {
if (ObjectUtils.isEmpty(taskRequest.getCreatedById())) {
throw new RuntimeException("请传入发起人");
throw new CommonException("请传入发起人");
}
List<InitiatedTaskPojo> tods = new ArrayList<>();
PageResultDTO<InitiatedTaskPojo> taskPojoPageResultDTO = new PageResultDTO<>();
PageQueryResult<InitiatedTaskPojo> queryResult = sw.buildFromDatasource("xdap_app_223770822127386625")
PageQueryResult<InitiatedTaskPojo> 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<TodoTaskPojo> selectByresPersonTodoPage(TodoTaskRequest todoTaskRequest) {
PageResultDTO<TodoTaskPojo> pageResultDTO = new PageResultDTO<>();
PageQueryResult<TodoTaskPojo> queryResult = sw.buildFromDatasource("xdap_app_223770822127386625")
PageQueryResult<TodoTaskPojo> 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<CompletedTaskPojo> selectByresPersonCompletedPage(TodoTaskRequest taskRequest) {
PageResultDTO<CompletedTaskPojo> pageResultDTO = new PageResultDTO<>();
List<CompletedTaskPojo> completedTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<CompletedTaskPojo> 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<EngineParamDetailDTO> 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<EngineParamDetailPojo> detailPojos = engineParamDetailService.selectByModelNewVersion(modelId);
List<EngineParamDetailPojo> 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<TodoTaskPojo> todoTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<TodoTaskPojo> 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<EngineParamDetailPojo> pojoList = engineParamDetailService.selectByModelNewVersion(modelID);
List<EngineParamDetailPojo> 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<YcTodoTaskResultDTO> returnTodoTask(YcGetTodoTaskRequest ycGetTodoTaskRequest) {
String username = ycGetTodoTaskRequest.getUsername();
if (ObjectUtils.isEmpty(username)) {
return null;
return Collections.emptyList();
}
ArrayList<YcTodoTaskResultDTO> dtos = new ArrayList<>();
XdapUsers xdapUsers = xdapDeptUsersService.selectUserByCode(username);
if (ObjectUtils.isNotEmpty(xdapUsers)) {
String id = xdapUsers.getId();
List<TodoTaskPojo> todoTaskPojos = sw.buildFromDatasource("xdap_app_223770822127386625")
List<TodoTaskPojo> 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<YcTodoTaskCommonResultDTO> returnCompleted(YcGetTodoTaskRequest ycGetTodoTaskRequest) {
return commonTodoTask(ycGetTodoTaskRequest, "已办");
}
@Override
/**
* 返回发起任务
*
* @param ycGetTodoTaskRequest 云柴获取待办任务请求对象
* @return 云柴发起任务通用结果DTO分页结果
*/
@Override
public PageResultDTO<YcTodoTaskCommonResultDTO> returnInitiator(YcGetTodoTaskRequest ycGetTodoTaskRequest) {
return commonTodoTask(ycGetTodoTaskRequest, "发起");
}
@ -452,7 +433,7 @@ public class TodoTaskServiceImpl implements TodoTaskService {
private PageResultDTO<YcTodoTaskCommonResultDTO> 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<TodoTaskPojo> 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<TodoTaskPojo> todoTaskPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(todoTaskPojos);
}
@Override
@Transactional // 发生任何异常都回滚
/**
* 批量插入发起任务
*
* @param taskPojos 发起任务POJO列表
*/
public void batchInsertInitiatedTask(List<InitiatedTaskPojo> taskPojos) {
sw.buildFromDatasource("xdap_app_223770822127386625").doBatchInsert(taskPojos);
}
}

View File

@ -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<XdapDepartments> departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapDepartments> 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<XdapDepartments> departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapDepartments> 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<XdapUsers> selectUserByName(String deptName) {
XdapDepartments xdapDepartmentsPojo = selectDeptByName(deptName);
List<XdapUsers> xdapUsersPojos = new ArrayList<>();
if (ObjectUtils.isNotEmpty(xdapDepartmentsPojo)) {
List<XdapDeptUsers> xdapDeptUsersPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapDeptUsers> xdapDeptUsersPojos = bd.getBusinessDatabase()
.eq("department_id", xdapDepartmentsPojo.getId())
.doQuery(XdapDeptUsers.class);
if (ObjectUtils.isNotEmpty(xdapDeptUsersPojos)) {
for (XdapDeptUsers xdapDeptUsersPojo : xdapDeptUsersPojos) {
List<XdapUsers> usersPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapUsers> 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<XdapUsers> 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<XdapUsers> xdapUsersPojos, XdapDepartments dpName) {
if (ObjectUtils.isNotEmpty(xdapUsersPojos) && ObjectUtils.isNotEmpty(dpName)) {
//提取用户ID集合
List<String> idList = xdapUsersPojos.stream().map(x -> x.getId()).collect(Collectors.toList());
//根据用户ID查找对应关系表
List<XdapDeptUsers> departmentsPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapDeptUsers> 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<XdapUsers> usersPojo = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapUsers> 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<XdapUsers> userPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapUsers> 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<XdapUsers> userPojos = runtimeDatasourceService.buildTenantMpaasQuery("xdap_app_223770822127386625")
List<XdapUsers> userPojos = bd.getBusinessDatabase()
.eq("user_number", userCode)
.doQuery(XdapUsers.class);
if (ObjectUtils.isNotEmpty(userPojos)) {