存档版本
This commit is contained in:
parent
9d189ba232
commit
dec6fdb710
@ -7,9 +7,9 @@ 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.controller.form.*;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.domain.pojo.ResponsiblePersonPojo;
|
||||
import com.xdap.self_development.domain.view.DepartmentUserView;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.service.ResponsiblePersonService;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -38,6 +38,15 @@ public class ResponsiblePersonController {
|
||||
@Resource
|
||||
private ResponsiblePersonService responsiblePersonService;
|
||||
|
||||
/*
|
||||
* 获取责任部门
|
||||
*
|
||||
* */
|
||||
@GetMapping("/getResponsibleDepartment")
|
||||
public Response getResponsibleDepartment() {
|
||||
return Response.ok().data(responsiblePersonService.getResponsibleDepartment());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入责任人
|
||||
*
|
||||
|
||||
@ -21,7 +21,7 @@ public class ParameterForm {
|
||||
/**
|
||||
* 参数序号
|
||||
*/
|
||||
private Integer parameterNumber;
|
||||
private String parameterNumber;
|
||||
|
||||
/**
|
||||
* 子系统名称
|
||||
|
||||
@ -26,6 +26,7 @@ public class UpdateBenchmarkingReportForm {
|
||||
private String subsystem;
|
||||
private String partsName;
|
||||
private String fileUrl;
|
||||
private String fileName;
|
||||
|
||||
@NotBlank(message = "发起人不能为空")
|
||||
private String userId;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
package com.xdap.self_development.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xdap.self_development.domain.pojo.DataEntryEngineModelPojo;
|
||||
import com.xdap.self_development.domain.view.FlowNode;
|
||||
import lombok.Data;
|
||||
|
||||
@ -54,4 +55,9 @@ public class ActivitiDataAndRecordDTO {
|
||||
*/
|
||||
private List<FlowNode> flowNodes;
|
||||
|
||||
/**
|
||||
* 机型数据
|
||||
*/
|
||||
private DataEntryEngineModelPojo model;
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package com.xdap.self_development.domain.pojo;
|
||||
|
||||
import com.definesys.mpaas.query.annotation.RowID;
|
||||
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||
import com.definesys.mpaas.query.annotation.Table;
|
||||
import com.definesys.mpaas.query.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -17,6 +15,10 @@ import java.util.Date;
|
||||
* @author Lys111
|
||||
* @since 2025-11-26
|
||||
*/
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "selectLastedComment"
|
||||
, sql = "SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY param_detail_id ORDER BY creation_date DESC) AS rn FROM data_change_comment WHERE param_detail_id IN (#paramIds) ) ranked WHERE rn = 1 ORDER BY param_detail_id")
|
||||
})
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table("data_change_comment")
|
||||
|
||||
@ -8,6 +8,7 @@ package com.xdap.self_development.domain.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.definesys.mpaas.query.annotation.*;
|
||||
import com.definesys.mpaas.query.model.MpaasBasePojo;
|
||||
import lombok.Data;
|
||||
@ -46,51 +47,61 @@ public class ParameterPojo extends MpaasBasePojo {
|
||||
* 参数序号
|
||||
*/
|
||||
@ExcelProperty("序号")
|
||||
private Integer parameterNumber;
|
||||
@ColumnWidth(15)
|
||||
private String parameterNumber;
|
||||
/**
|
||||
* 子系统名称
|
||||
*/
|
||||
@ExcelProperty("子系统")
|
||||
@ColumnWidth(20)
|
||||
private String subsystemName;
|
||||
/**
|
||||
* 参数类型
|
||||
*/
|
||||
@ExcelProperty("类型")
|
||||
@ColumnWidth(20)
|
||||
private String parameterType;
|
||||
/**
|
||||
* 零部件名称
|
||||
*/
|
||||
@ExcelProperty("零部件名称")
|
||||
@ColumnWidth(20)
|
||||
private String partsName;
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
@ExcelProperty("参数名称")
|
||||
@ColumnWidth(20)
|
||||
private String parameterName;
|
||||
/**
|
||||
* 参数单位
|
||||
*/
|
||||
@ExcelProperty("单位")
|
||||
@ColumnWidth(15)
|
||||
private String unit;
|
||||
/**
|
||||
* 参数来源
|
||||
*/
|
||||
@ExcelProperty("参数计划来源")
|
||||
@ColumnWidth(20)
|
||||
private String parameterSource;
|
||||
/**
|
||||
* 分类属性表编号或公式
|
||||
*/
|
||||
@ExcelProperty("当前可适用的分类属性表编号(需要修订)或公式")
|
||||
@ColumnWidth(30)
|
||||
private String numberOrFormula;
|
||||
/**
|
||||
* 填写部门
|
||||
*/
|
||||
@ExcelProperty("填写部门")
|
||||
@ColumnWidth(20)
|
||||
private String department;
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
@ExcelProperty("备注")
|
||||
@ColumnWidth(30)
|
||||
private String remarks;
|
||||
/**
|
||||
* 创建者
|
||||
@ -110,7 +121,7 @@ public class ParameterPojo extends MpaasBasePojo {
|
||||
@Column(value = "max_number",type=ColumnType.CALCULATE)
|
||||
private Integer maxNumber;
|
||||
|
||||
public ParameterPojo(Integer parameterNumber, String subsystemName, String parameterType,
|
||||
public ParameterPojo(String parameterNumber, String subsystemName, String parameterType,
|
||||
String partsName, String parameterName, String unit, String parameterSource,
|
||||
String numberOrFormula, String department, String remarks) {
|
||||
this.parameterNumber = parameterNumber;
|
||||
@ -124,4 +135,18 @@ public class ParameterPojo extends MpaasBasePojo {
|
||||
this.department = department;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public static String[] getFieldDescriptions() {
|
||||
return new String[]{
|
||||
"非必填",
|
||||
"必填",
|
||||
"必填",
|
||||
"非必填",
|
||||
"必填",
|
||||
"非必填",
|
||||
"必填,并且为下列之一:数据平台手工录入、TC分类表、公式计算",
|
||||
"非必填,如果参数来源为'公式计算'则必填;公式示例:Π*(直径(内径)/2)*(直径(内径)/2)",
|
||||
"非必填,如果参数来源为'数据平台手工录入'则必填;部门必须为研发总院的子部门,如‘研发部’",
|
||||
"非必填"};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xdap.self_development.domain.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.definesys.mpaas.query.annotation.*;
|
||||
import com.definesys.mpaas.query.model.MpaasBasePojo;
|
||||
import lombok.Data;
|
||||
@ -21,18 +22,30 @@ public class ResponsiblePersonPojo extends MpaasBasePojo {
|
||||
private String departmentId;
|
||||
private String userId;
|
||||
@ExcelProperty("责任部门")
|
||||
@ColumnWidth(20)
|
||||
private String department;
|
||||
@ExcelProperty("子系统")
|
||||
@ColumnWidth(20)
|
||||
private String subsystem;
|
||||
private Integer personLevel;
|
||||
|
||||
private Timestamp creationDate;
|
||||
|
||||
@ExcelProperty("责任人")
|
||||
@ColumnWidth(20)
|
||||
@Column(type = ColumnType.CALCULATE)
|
||||
private String username;
|
||||
|
||||
@ExcelProperty("工号")
|
||||
@Column(type = ColumnType.JAVA)
|
||||
@ExcelProperty("工号")
|
||||
@ColumnWidth(20)
|
||||
private String userAccount;
|
||||
|
||||
public static String[] getFieldDescriptions() {
|
||||
return new String[]{
|
||||
"必填,并且必须为研发总院的子部门,如‘研发部’",
|
||||
"必填",
|
||||
"必填,填写名字即可",
|
||||
"非必填,如果名字有重复,则加上工号"};
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,7 @@ public class RevisionRecordPojo extends MpaasBasePojo {
|
||||
private String id;
|
||||
private String templateName;
|
||||
private Integer version;
|
||||
private Integer parameterNumber;
|
||||
private String parameterNumber;
|
||||
private String modifyDetails;
|
||||
private String templateId;
|
||||
private String preTemplateId;
|
||||
@ -31,7 +31,7 @@ public class RevisionRecordPojo extends MpaasBasePojo {
|
||||
private Integer returnNum;
|
||||
|
||||
public RevisionRecordPojo(String templateName, Integer version,
|
||||
Integer parameterNumber, String modifyDetails,
|
||||
String parameterNumber, String modifyDetails,
|
||||
String templateId, String preTemplateId,
|
||||
Timestamp createTime, String parameterId,
|
||||
Integer returnNum) {
|
||||
|
||||
@ -25,10 +25,10 @@ public class PersonReadListener implements ReadListener<ResponsiblePersonPojo> {
|
||||
|
||||
@Override
|
||||
public void invoke(ResponsiblePersonPojo responsiblePerson, AnalysisContext analysisContext) {
|
||||
if (analysisContext.readRowHolder().getRowIndex() == 1) return;
|
||||
if (
|
||||
responsiblePerson.getDepartment() == null ||
|
||||
responsiblePerson.getUsername() == null ||
|
||||
responsiblePerson.getUserAccount() == null ||
|
||||
responsiblePerson.getSubsystem() == null
|
||||
) {
|
||||
problems.setFlag(true);
|
||||
@ -37,9 +37,9 @@ public class PersonReadListener implements ReadListener<ResponsiblePersonPojo> {
|
||||
}
|
||||
XdapUserView user = responsiblePersonService
|
||||
.getUserByDeptAndName(responsiblePerson.getDepartment(), responsiblePerson.getUserAccount(), responsiblePerson.getUsername());
|
||||
if (user == null || user.getUserId() == null) {
|
||||
if (user.getUserId() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("责任人导入失败:用户" + responsiblePerson.getUsername() + "无法找到");
|
||||
problems.getErrors().add("责任人导入失败:用户" + responsiblePerson.getUsername() + "无法找到或有多个重名用户");
|
||||
} else if (user.getDepartmentId() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("责任人导入失败:部门" + responsiblePerson.getUsername() + "无法找到");
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xdap.self_development.listener;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xdap.self_development.common.MyResponse;
|
||||
import com.xdap.self_development.domain.pojo.ParameterPojo;
|
||||
import com.xdap.self_development.service.TemplateService;
|
||||
@ -20,31 +21,79 @@ public class SheetDataListener implements ReadListener<ParameterPojo> {
|
||||
private final String templateRowId;
|
||||
private final String createBy;
|
||||
private final List<ParameterPojo> cachedDataList;
|
||||
private final List<String> subDepartments;
|
||||
private String currentSheetName;
|
||||
MyResponse problems;
|
||||
|
||||
|
||||
public SheetDataListener(TemplateService templateService,
|
||||
String templateRowId, String createBy, MyResponse problems) {
|
||||
String templateRowId, String createBy,
|
||||
MyResponse problems, List<String> subDepartments) {
|
||||
this.templateService = templateService;
|
||||
this.templateRowId = templateRowId;
|
||||
this.createBy = createBy;
|
||||
this.cachedDataList = new ArrayList<>(BATCH_SIZE);
|
||||
this.problems = problems;
|
||||
this.subDepartments = subDepartments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
|
||||
currentSheetName = context.readSheetHolder().getSheetName();
|
||||
log.info("开始解析Sheet: {}", currentSheetName);
|
||||
log.info("开始解析表头行: {}", context.readRowHolder().getRowIndex());
|
||||
log.info("解析到一条头数据:{}", JSON.toJSONString(headMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(ParameterPojo data, AnalysisContext context) {
|
||||
log.info("开始解析数据行: {}", context.readRowHolder().getRowIndex());
|
||||
log.info("解析到一条数据: {}", data);
|
||||
if (context.readRowHolder().getRowIndex() == 1) return;
|
||||
// 参数校验
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSheetName == null) {
|
||||
currentSheetName = context.readSheetHolder().getSheetName();
|
||||
}
|
||||
|
||||
if (!"数据平台手工录入".equals(data.getParameterSource())
|
||||
&& !"TC分类表".equals(data.getParameterSource())
|
||||
&& !"公式计算".equals(data.getParameterSource())
|
||||
) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add(String.format("模板导入失败:" + "模板'%s'的参数'%s'来源错误, %s",
|
||||
currentSheetName, data.getParameterName(),
|
||||
data.getParameterSource()));
|
||||
return;
|
||||
}
|
||||
|
||||
if ("公式计算".equals(data.getParameterSource()) && data.getNumberOrFormula() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add(String.format("模板导入失败:" + "模板'%s'的参数'%s'公式不能为空",
|
||||
currentSheetName, data.getParameterName()));
|
||||
return;
|
||||
}
|
||||
|
||||
if ("数据平台手工录入".equals(data.getParameterSource())) {
|
||||
if (data.getDepartment() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add(String.format("模板导入失败:" + "模板'%s'的参数'%s'部门不能为空",
|
||||
currentSheetName, data.getParameterName()));
|
||||
return;
|
||||
}
|
||||
// if (!subDepartments.isEmpty() && !subDepartments.contains(data.getDepartment())) {
|
||||
// String errorMsg = String.format("模板导入失败:"+"模板'%s'的参数'%s'部门找不到, %s",
|
||||
// currentSheetName, data.getParameterName(),
|
||||
// data.getDepartment());
|
||||
// problems.setFlag(true);
|
||||
// problems.getErrors().add(errorMsg);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
cachedDataList.add(data);
|
||||
|
||||
// 达到批处理大小时提前处理
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xdap.self_development.service;
|
||||
|
||||
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.self_development.common.MyResponse;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
@ -41,8 +42,9 @@ public interface ResponsiblePersonService {
|
||||
|
||||
MyResponse importPerson(MultipartFile file, String userId);
|
||||
|
||||
|
||||
void importAllPerson(List<ResponsiblePersonPojo> cachedDataList, MyResponse problems);
|
||||
|
||||
XdapUserView getUserByDeptAndName(String department, String userAccount, String username);
|
||||
|
||||
List<XdapDepartments> getResponsibleDepartment();
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
bd.getBusinessDatabase().doInsert(todoTask);
|
||||
}
|
||||
// 更新发起和已办
|
||||
myself.updateTasks(flow, status.getDesc(), 0, node);
|
||||
myself.updateTasks(flow, "编制", 0, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -751,7 +751,8 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
.update("status_code", ParamValueVersionEnum.UNDER.getCode())
|
||||
.update("status_description", ParamValueVersionEnum.UNDER.getDesc())
|
||||
.update("last_update_date", new Date())
|
||||
.eq("id", reviewListPojo.getId()).doUpdate(EngineReviewListPojo.class);
|
||||
.eq("id", reviewListPojo.getId())
|
||||
.doUpdate(EngineReviewListPojo.class);
|
||||
}
|
||||
|
||||
// 添加新待办
|
||||
@ -762,17 +763,19 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
1
|
||||
);
|
||||
|
||||
ApprovalRecordPojo lastedRecord = bd.getBusinessDatabase()
|
||||
.eq("flow_id", reviewListPojo.getId())
|
||||
.orderBy("approval_time", "desc")
|
||||
.doQueryFirst(ApprovalRecordPojo.class);
|
||||
ParamApprovalRecordPojo lastedRecord = bd.getBusinessDatabase()
|
||||
.eq("approval_id", reviewListPojo.getId())
|
||||
.orderBy("operate_time", "desc")
|
||||
.doQueryFirst(ParamApprovalRecordPojo.class);
|
||||
bd.getBusinessDatabase().doInsert(
|
||||
new ApprovalRecordPojo(
|
||||
new ParamApprovalRecordPojo(
|
||||
reviewListPojo.getId(),
|
||||
"重新发起",
|
||||
xdapDeptUsersService.selectUserByID(userId).getUsername(),
|
||||
"重新发起",
|
||||
Timestamp.valueOf(LocalDateTime.now()),
|
||||
"MSG",
|
||||
firstNode.getNodeOrder(),
|
||||
Timestamp.valueOf(LocalDateTime.now()),
|
||||
lastedRecord.getApprovalLevel() + 1
|
||||
)
|
||||
@ -892,7 +895,6 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
*
|
||||
* @param flowId 流程ID
|
||||
* @param userId 用户ID
|
||||
* @return void
|
||||
*/
|
||||
@Override
|
||||
public void directSendingApproval(String flowId, String userId) {
|
||||
@ -1166,11 +1168,19 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
*/
|
||||
@Override
|
||||
public ActivitiDataAndRecordDTO showActivitiData(ShowActivitiDTO showActivitiDTO) {
|
||||
String approvalId = showActivitiDTO.getApprovalId();
|
||||
if (approvalId == null) {
|
||||
EngineReviewListPojo engineFlow = bd.getBusinessDatabase()
|
||||
.eq("id", showActivitiDTO.getApprovalId() == null ? "" : showActivitiDTO.getApprovalId())
|
||||
.doQueryFirst(EngineReviewListPojo.class);
|
||||
if (engineFlow == null || showActivitiDTO.getApprovalId() == null) {
|
||||
throw new CommonException("无效的审批记录");
|
||||
}
|
||||
String approvalId = engineFlow.getId();
|
||||
ActivitiDataAndRecordDTO activitiDataAndRecordDTO = new ActivitiDataAndRecordDTO();
|
||||
// 获取机型
|
||||
DataEntryEngineModelPojo model = bd.getBusinessDatabase()
|
||||
.eq("id", engineFlow.getModelId())
|
||||
.doQueryFirst(DataEntryEngineModelPojo.class);
|
||||
activitiDataAndRecordDTO.setModel(model);
|
||||
//查找审批数据
|
||||
ArrayList<ActivitiDataDTO> activitiDataDTOS = new ArrayList<>();
|
||||
|
||||
@ -1184,7 +1194,9 @@ public class ActivitiProcessServiceImpl implements ActivitiProcessService {
|
||||
}
|
||||
// 查询数据变更评论
|
||||
List<DataChangeCommentPojo> dataChangeCommentPojos = bd.getBusinessDatabase()
|
||||
.in("param_detail_id", ids)
|
||||
.viewQueryMode(true)
|
||||
.view("selectLastedComment")
|
||||
.setVar("paramIds", ids)
|
||||
.doQuery(DataChangeCommentPojo.class);
|
||||
for (DataChangeCommentPojo dataChangeCommentPojo : dataChangeCommentPojos) {
|
||||
ActivitiDataDTO activitiDataDTO = new ActivitiDataDTO();
|
||||
|
||||
@ -1170,7 +1170,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
todoTask.setCurrentProcessor(JSON.toJSONString(Collections.singletonList(flow.getCreateBy())));
|
||||
bd.getBusinessDatabase().doInsert(todoTask);
|
||||
}
|
||||
myself.updateTasks(flow, Objects.equals(report.getStatus(), "RETURNED") ? "已撤回" : "已拒绝", 0, node);
|
||||
myself.updateTasks(flow, "编制", 0, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -606,7 +606,8 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
|
||||
List<EngineParamDetailPojo> detailPojos = selectByResId(userID);
|
||||
List<EngineParamDetailPojo> paramDetailPojos = detailPojos.stream()
|
||||
.filter(x -> x.getEngineModelId().equals(engineModelId)
|
||||
&& ObjectUtils.isEmpty(x.getFilledBy()) && Objects.equals(x.getParameterSource(), "数据平台手工录入"))
|
||||
&& ObjectUtils.isEmpty(x.getFilledBy())
|
||||
&& Objects.equals(x.getParameterSource(), "数据平台手工录入"))
|
||||
.collect(Collectors.toList());
|
||||
if (ObjectUtils.isEmpty(paramDetailPojos)) {
|
||||
//软删除这个代办人的任务
|
||||
|
||||
@ -336,7 +336,8 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
BeanUtils.copyProperties(form, newParameter);
|
||||
newParameter.setCreatedBy(userId);
|
||||
newParameter.setId(null);
|
||||
|
||||
newParameter.setParameterNumber(String.valueOf(new Random().nextInt(100000)));
|
||||
/*
|
||||
ParameterPojo parameter = bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("selectMaxNumber")
|
||||
@ -357,6 +358,7 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
int i = Math.max(maxNum + 1, parameter.getMaxNumber() + 1);
|
||||
newParameter.setParameterNumber(i);
|
||||
}
|
||||
*/
|
||||
newParameter.setId(null);
|
||||
bd.getBusinessDatabase().doInsert(newParameter);
|
||||
newParameters.add(newParameter);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.xdap.self_development.service.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
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;
|
||||
@ -15,6 +14,7 @@ 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 com.xdap.self_development.utils.DescriptionWriteUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -28,9 +28,7 @@ import java.net.URLEncoder;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -258,7 +256,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
.doQuery(ResponsiblePersonPojo.class);
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), ResponsiblePersonPojo.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new DescriptionWriteUtils(ResponsiblePersonPojo.getFieldDescriptions()))
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.sheet("责任人")
|
||||
.doWrite(list);
|
||||
@ -289,7 +287,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
list.add(new ResponsiblePersonPojo());
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), ResponsiblePersonPojo.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new DescriptionWriteUtils(ResponsiblePersonPojo.getFieldDescriptions()))
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.sheet("责任人")
|
||||
.doWrite(list);
|
||||
@ -346,20 +344,52 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
*/
|
||||
public XdapUserView getUserByDeptAndName(String department, String userAccount, String username) {
|
||||
XdapUserView xdapUserView = new XdapUserView();
|
||||
xdapUserView.setDepartmentId(
|
||||
bd.getBusinessDatabase()
|
||||
.eq("structure_name", department)
|
||||
.doQueryFirst(XdapDepartments.class).getId()
|
||||
);
|
||||
xdapUserView.setUserId(
|
||||
bd.getBusinessDatabase()
|
||||
.eq("user_number", userAccount)
|
||||
.eq("username", username)
|
||||
.doQueryFirst(XdapUsers.class).getId()
|
||||
);
|
||||
XdapDepartments xdapDepartments = bd.getBusinessDatabase()
|
||||
.eq("name", "研发总院")
|
||||
.doQueryFirst(XdapDepartments.class);
|
||||
XdapDepartments currentDept = bd.getBusinessDatabase()
|
||||
.eq("name", department)
|
||||
.eq("parent_id", xdapDepartments.getId())
|
||||
.doQueryFirst(XdapDepartments.class);
|
||||
|
||||
if (currentDept != null)
|
||||
xdapUserView.setDepartmentId(currentDept.getId());
|
||||
if (userAccount != null) {
|
||||
XdapUsers currentUser = bd.getBusinessDatabase()
|
||||
.eq("user_number", userAccount)
|
||||
.eq("username", username)
|
||||
.eq("exit_status", "ENABLE")
|
||||
.doQueryFirst(XdapUsers.class);
|
||||
if (currentUser != null)
|
||||
xdapUserView.setUserId(currentUser.getId());
|
||||
} else {
|
||||
List<XdapUsers> xdapUsers = bd.getBusinessDatabase()
|
||||
.eq("username", username)
|
||||
.eq("exit_status", "ENABLE")
|
||||
.doQuery(XdapUsers.class);
|
||||
if (xdapUsers.size() == 1) {
|
||||
xdapUserView.setUserId(xdapUsers.get(0).getId());
|
||||
}
|
||||
}
|
||||
return xdapUserView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有责任部门
|
||||
*
|
||||
* @return 责任部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<XdapDepartments> getResponsibleDepartment() {
|
||||
XdapDepartments currentDept = bd.getBusinessDatabase()
|
||||
.eq("name", "研发总院")
|
||||
.doQueryFirst(XdapDepartments.class);
|
||||
if (currentDept == null) return Collections.emptyList();
|
||||
return bd.getBusinessDatabase()
|
||||
.eq("parent_id", currentDept.getId())
|
||||
.doQuery(XdapDepartments.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
/**
|
||||
@ -369,20 +399,29 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
* @param problems 问题收集对象
|
||||
*/
|
||||
public void importAllPerson(List<ResponsiblePersonPojo> cachedDataList, MyResponse problems) {
|
||||
List<ResponsiblePersonPojo> list = new ArrayList<>();
|
||||
Map<String, List<ResponsiblePersonPojo>> departmentMap = new HashMap<>();
|
||||
cachedDataList.forEach(item -> {
|
||||
List<ResponsiblePersonPojo> responsiblePeople = bd.getBusinessDatabase()
|
||||
.eq("department_id", item.getDepartmentId())
|
||||
.eq("subsystem", item.getSubsystem())
|
||||
.eq("personLevel", 1)
|
||||
.eq("person_level", 1)
|
||||
.doQuery(ResponsiblePersonPojo.class);
|
||||
|
||||
if (!responsiblePeople.isEmpty()) {
|
||||
if (!responsiblePeople.isEmpty() || departmentMap.containsKey(item.getDepartment() + "-" + item.getSubsystem())) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("部门:" + item.getDepartment() + "子系统:" + item.getSubsystem() + "已存在责任人");
|
||||
} else {
|
||||
bd.getBusinessDatabase().doInsert(item);
|
||||
departmentMap.put(item.getDepartment() + "-" + item.getSubsystem(), responsiblePeople);
|
||||
list.add(item);
|
||||
}
|
||||
});
|
||||
if (list.isEmpty()) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("没有合适的责任人导入");
|
||||
return;
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(template.getVersion());
|
||||
todoTask.setOwnerId(person);
|
||||
todoTask.setCurrentProcessor(JSON.toJSONString(firstNode.getAssignees()));
|
||||
todoTask.setCurrentProcessor(firstNode.getAssignees());
|
||||
list.add(todoTask);
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
@ -609,7 +609,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
bd.getBusinessDatabase().doInsert(todoTask);
|
||||
}
|
||||
// 更新发起和已办
|
||||
myself.updateTasks(flow, Objects.equals(status, "REJECTED") ? "已拒绝" : "已撤回", 0, node);
|
||||
myself.updateTasks(flow, "编制", 0, node);
|
||||
}
|
||||
|
||||
// 处理下一节点流转
|
||||
|
||||
@ -15,6 +15,7 @@ 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.DescriptionWriteUtils;
|
||||
import com.xdap.self_development.utils.FormulaValidatorUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -178,12 +179,25 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
MyResponse problems =
|
||||
new MyResponse(false, new ArrayList<>(), new StringBuilder("已完成导入:无"));
|
||||
|
||||
// String targetDepartmentIds = bd.getBusinessDatabase()
|
||||
// .eq("name", "研发总院")
|
||||
// .doQueryFirst(XdapDepartments.class).getId();
|
||||
//
|
||||
// List<String> subDepartments = bd.getBusinessDatabase()
|
||||
// .in("parent_id", targetDepartmentIds)
|
||||
// .doQuery(XdapDepartments.class).stream().map(XdapDepartments::getName)
|
||||
// .collect(Collectors.toList());
|
||||
List<String> subDepartments = new ArrayList<>();
|
||||
|
||||
try (InputStream inputStream = file.getInputStream()){
|
||||
EasyExcel.read(
|
||||
inputStream,
|
||||
ParameterPojo.class,
|
||||
new SheetDataListener(this, templateRowId, userId, problems)
|
||||
).doReadAll();
|
||||
new SheetDataListener(this, templateRowId, userId, problems, subDepartments)
|
||||
)
|
||||
.ignoreEmptyRow(true)
|
||||
.autoTrim(true)
|
||||
.doReadAll();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new CommonException("读取文件失败");
|
||||
@ -231,6 +245,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
}
|
||||
EasyExcel.write(response.getOutputStream(), ParameterPojo.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new DescriptionWriteUtils(ParameterPojo.getFieldDescriptions()))
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.sheet(templateDB.getTemplateName())
|
||||
.doWrite(list);
|
||||
@ -315,7 +330,17 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
if (data.getSubsystemName() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板导入失败:" + sheetName + "模板的参数" + data.getParameterName() + "的子系统字段为空");
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (data.getParameterType() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板导入失败:" + sheetName + "模板的参数" + data.getParameterName() + "的参数类型字段为空");
|
||||
continue;
|
||||
}
|
||||
if (data.getParameterName() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板导入失败:" + sheetName + "模板的参数" + data.getParameterName() + "的参数名称字段为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.getPartsName() == null || data.getPartsName().isEmpty()) {
|
||||
@ -347,7 +372,6 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
if (!Objects.equals(templateName, sheetName)) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板导入失败:+Excel页名与模板名不一致");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,6 +384,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
problems.getErrors().add("模板导入失败:模板'" + templateName + "'正在审批中");
|
||||
}
|
||||
|
||||
// 检查不通过,直接返回
|
||||
if (problems.isFlag()) {
|
||||
return;
|
||||
}
|
||||
@ -590,6 +615,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), ParameterPojo.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new DescriptionWriteUtils(ParameterPojo.getFieldDescriptions()))
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.sheet("xxx")
|
||||
.doWrite(list);
|
||||
@ -599,6 +625,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
} else {
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), ParameterPojo.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new DescriptionWriteUtils(ParameterPojo.getFieldDescriptions()))
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.build()) {
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.xdap.self_development.utils;
|
||||
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||
import jdk.nashorn.internal.runtime.logging.Logger;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
||||
@Slf4j
|
||||
@Logger
|
||||
public class DescriptionWriteUtils implements SheetWriteHandler {
|
||||
// 字段说明数组
|
||||
private final String[] descriptions;
|
||||
|
||||
public DescriptionWriteUtils(String[] descriptions) {
|
||||
this.descriptions = descriptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
Sheet sheet = writeSheetHolder.getSheet();
|
||||
Workbook workbook = writeWorkbookHolder.getWorkbook();
|
||||
|
||||
// 创建单元格样式
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
Font font = workbook.createFont();
|
||||
font.setColor(IndexedColors.GREY_50_PERCENT.getIndex()); // 灰色字体
|
||||
style.setFont(font);
|
||||
style.setWrapText(true);
|
||||
|
||||
log.info("Creating description row for sheet: {}", writeSheetHolder.getSheetName());
|
||||
// 获取表头行的下一行
|
||||
Row descRow = sheet.createRow(1);
|
||||
// 填充每个字段的说明
|
||||
for (int i = 0; i < descriptions.length; i++) {
|
||||
Cell cell = descRow.createCell(i);
|
||||
cell.setCellValue(descriptions[i]);
|
||||
cell.setCellStyle(style);
|
||||
log.info("Set cell value to: {}", descriptions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user