feat(标准解读流程): 导出、导入

This commit is contained in:
yjz
2024-07-08 18:35:28 +08:00
parent a5abdea61a
commit c74944d0f8
7 changed files with 670 additions and 13 deletions
@@ -10,6 +10,7 @@ import com.jero.common.util.MessageUtils;
import com.jero.common.util.SnowflakeUtils;
import com.jero.modules.activiti.process.standardinterpret.dto.StandardInterpretFlowDTO;
import com.jero.modules.activiti.process.standardinterpret.entity.ProcessStandardInterpretClause;
import com.jero.modules.activiti.process.standardinterpret.entity.ProcessStandardInterpretClauseSublist;
import com.jero.modules.activiti.process.standardinterpret.service.StandardInterpretFlowService;
import com.jero.modules.activiti.process.standardinterpret.vo.StandardInterpretFlowVO;
import io.swagger.annotations.Api;
@@ -20,7 +21,10 @@ import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.task.Task;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -56,7 +60,7 @@ public class StandardInterpretFlowController {
*
* @return
*/
@AutoLog(value = "标准解读流程-通过标准id查询分解单列表")
@AutoLog(value = "标准解读流程-通过标准id查询分解单列表", operateType = CommonConstant.OPERATE_TYPE_1)
@ApiOperation(value="标准解读流程-通过标准id查询分解单列表", notes="标准解读流程-通过标准id查询分解单列表")
@GetMapping(value = "/getFileByStandardId")
public Result<List<DictModel>> queryFileByStandardId(String standardId) {
@@ -92,7 +96,7 @@ public class StandardInterpretFlowController {
* @param standardInterpretFlowDTO 标准解读流程对象
* @return 结果对象
*/
@AutoLog(value = "标准解读流程-流程保存")
@AutoLog(value = "标准解读流程-流程保存", operateType = CommonConstant.OPERATE_TYPE_3)
@ApiOperation(value="标准解读流程-流程保存", notes="标准解读流程-流程保存")
@PostMapping(value = "/flowSave")
public Result<T> flowSave(@RequestBody StandardInterpretFlowDTO standardInterpretFlowDTO) {
@@ -132,7 +136,7 @@ public class StandardInterpretFlowController {
* @param standardInterpretFlowDTO 标准解读流程对象
* @return 结果对象
*/
@AutoLog(value = "标准解读流程-驳回")
@AutoLog(value = "标准解读流程-驳回", operateType = CommonConstant.OPERATE_TYPE_3)
@ApiOperation(value="标准解读流程-驳回", notes="标准解读流程-驳回")
@PostMapping(value = "/flowReject")
public Result<T> flowReject(@RequestBody StandardInterpretFlowDTO standardInterpretFlowDTO) {
@@ -144,7 +148,7 @@ public class StandardInterpretFlowController {
* 标准解读流程-流程转办
* @return 结果对象
*/
@AutoLog(value = "标准解读流程-流程转办")
@AutoLog(value = "标准解读流程-流程转办", operateType = CommonConstant.OPERATE_TYPE_3)
@ApiOperation(value="标准解读流程-流程转办", notes="标准解读流程-流程转办")
@GetMapping(value = "/flowTransfer")
public Result<T> flowTransfer(@ApiParam("任务id") String taskId, @ApiParam("用户id") String userId) {
@@ -152,6 +156,32 @@ public class StandardInterpretFlowController {
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
/**
* 标准解读流程-导出(标准主解读人分发)
*/
@AutoLog(value = "标准解读流程-导出(标准主解读人分发)", operateType = CommonConstant.OPERATE_TYPE_6)
@ApiOperation(value="标准解读流程-导出(标准主解读人分发)", notes="标准解读流程-导出(标准主解读人分发)")
@GetMapping(value = "/exportExcelByDistribute")
public ModelAndView exportExcelByDistribute(HttpServletRequest request) {
return standardInterpretFlowService.exportExcelByDistribute(request);
}
/**
* 标准解读流程-导入(标准主解读人不分发)
*
* @param request
* @param response
* @return
*/
@AutoLog(value = "标准解读流程-标准解读流程-导入(标准主解读人不分发)")
@ApiOperation(value="标准解读流程-标准解读流程-导入(标准主解读人不分发)", notes="标准解读流程-标准解读流程-导入(标准主解读人不分发)")
@PostMapping(value = "/importExcelByUnDistribute")
@Translation
public Result<List<ProcessStandardInterpretClauseSublist>> importExcelByUnDistribute(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return standardInterpretFlowService.importExcelByUnDistribute(request, response);
}
/**
* 标准解读流程-生成项目id
* @return 项目id
@@ -21,6 +21,7 @@ import org.springframework.format.annotation.DateTimeFormat;
public class ProcessStandardInterpret extends BaseEntity {
/**主解读人*/
@ApiModelProperty(value = "主解读人")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String masterInterpretId;
/**父id*/
@ApiModelProperty(value = "父id")
@@ -62,15 +63,19 @@ public class ProcessStandardInterpret extends BaseEntity {
private String decompositionSource;
/**是否下发(字典:1:是,2:否)*/
@ApiModelProperty(value = "是否下发(字典:1:是,2:否)")
@Dict(dicCode = "is_distribute")
private String isDistribute;
/**会签人员*/
@ApiModelProperty(value = "会签人员")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String countersignPersonIds;
/**审核人员*/
@ApiModelProperty(value = "审核人员")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String uploader;
/**批准人员*/
@ApiModelProperty(value = "批准人员")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String approvePersonId;
}
@@ -7,6 +7,7 @@ import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* 标准解读流程_条款中间表(ProcessStandardInterpretClause)表实体类
@@ -26,17 +27,21 @@ public class ProcessStandardInterpretClause extends BaseEntity {
/**条款号/标准编号*/
@ApiModelProperty(value = "条款号/标准编号")
@TableField(exist = false)
@Excel(name = "标准编号/条款号", width = 15)
private String itemNum;
/**条款标题/标准名称*/
@ApiModelProperty(value = "条款标题/标准名称")
@TableField(exist = false)
@Excel(name = "标准名称/条款标题", width = 15)
private String itemTitle;
/**条款内容*/
@ApiModelProperty(value = "条款内容")
@TableField(exist = false)
@Excel(name = "条款内容", width = 15)
private String itemContent;
/**各涉及部门解读人*/
@ApiModelProperty(value = "各涉及部门解读人")
@Excel(name = "各涉及部门解读人", width = 15)
private String interpretPersonIds;
/**分解单来源(字典)*/
@ApiModelProperty(value = "分解单来源(字典)")
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.jero.modules.laws.documenttool.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* 标准解读流程_条款中间表_子表(ProcessStandardInterpretClauseSublist)表实体类
@@ -26,10 +27,12 @@ public class ProcessStandardInterpretClauseSublist extends BaseEntity {
/**条款号/标准编号*/
@ApiModelProperty(value = "条款号/标准编号")
@TableField(exist = false)
@Excel(name = "标准编号/条款号", width = 15)
private String itemNum;
/**条款标题/标准名称*/
@ApiModelProperty(value = "条款标题/标准名称")
@TableField(exist = false)
@Excel(name = "标准名称/条款标题", width = 15)
private String itemTitle;
/**条款内容*/
@ApiModelProperty(value = "条款内容")
@@ -40,93 +43,119 @@ public class ProcessStandardInterpretClauseSublist extends BaseEntity {
private String interpretPersonId;
/**译文*/
@ApiModelProperty(value = "译文")
@Excel(name = "译文", width = 15)
private String translation;
/**是否与上一版相同(字典:1:是,0:否)*/
@ApiModelProperty(value = "是否与上一版相同(字典:1:是,0:否)")
@Excel(name = "是否与上一版相同", width = 15)
private String isSameAsPrevVersion;
/**变化点说明*/
@ApiModelProperty(value = "变化点说明")
@ApiModelProperty(value = "相对上一版变化点说明")
@Excel(name = "相对上一版变化点说明", width = 15)
private String changeDescription;
/**法规注释*/
@ApiModelProperty(value = "法规注释")
@Excel(name = "法规注释", width = 15)
private String regulatoryNotes;
/**涉及系统/部件)*/
@ApiModelProperty(value = "涉及系统/部件)")
@Excel(name = "涉及系统/部件", width = 15)
private String keywords;
/**涉及系统/部件)*/
@ApiModelProperty(value = "关键控制器)")
@Excel(name = "关键控制器", width = 15)
private String keyController;
/**适用零部件*/
@ApiModelProperty(value = "适用零部件")
private String applicableComponents;
/**责任部门*/
@ApiModelProperty(value = "责任部门")
@Excel(name = "责任部门", width = 15)
private String responsibleDepartment;
/**责任部门专业模块*/
@ApiModelProperty(value = "责任部门专业模块")
private String responsibleModule;
/**关联部门*/
@ApiModelProperty(value = "关联部门")
@Excel(name = "关联部门", width = 15)
private String relatedDepartment;
/**关联部门专业模块*/
@ApiModelProperty(value = "关联部门专业模块")
private String relatedModule;
/**适用车型*/
@ApiModelProperty(value = "适用车型")
@Excel(name = "适用车型", width = 15)
private String applications;
/**动力类型*/
@ApiModelProperty(value = "动力类型")
@Excel(name = "动力类型", width = 15)
private String powerType;
/**专业领域*/
@ApiModelProperty(value = "专业领域")
@Excel(name = "专业领域", width = 15)
private String domainArea;
/**配置需求*/
@ApiModelProperty(value = "配置需求")
private String configurationRequirements;
/**新认证实施日期*/
@ApiModelProperty(value = "新认证实施日期")
@Excel(name = "新认证实施日期", width = 15)
private String newCerImplementDate;
/**新生产车实施日期*/
@ApiModelProperty(value = "新生产车实施日期")
private String newProductionImplementation;
/**注册日期*/
@ApiModelProperty(value = "注册日期")
@Excel(name = "注册日期", width = 15)
private String registrationDate;
/**企业标准*/
@ApiModelProperty(value = "企业标准")
@Excel(name = "企业标准", width = 15)
private String enterpriseStandard;
/**技术规范/设计指南*/
@ApiModelProperty(value = "技术规范/设计指南")
@Excel(name = "技术规范/设计指南", width = 15)
private String technicalSpecificationDesignGuide;
/**图纸模板*/
@ApiModelProperty(value = "图纸模板")
@Excel(name = "图纸模板", width = 15)
private String drawingTemplate;
/**技术协议模板*/
@ApiModelProperty(value = "技术协议模板")
@Excel(name = "技术协议模板", width = 15)
private String technicalAgreementTemplate;
/**校验报告模块/checklist*/
@ApiModelProperty(value = "校验报告模块/checklist")
@Excel(name = "校验报告模块/checklist", width = 15)
private String verificationReportTemplateChecklist;
/**DVP模板*/
@ApiModelProperty(value = "DVP模板")
@Excel(name = "DVP模板", width = 15)
private String dvpTemplate;
/**DFEMA*/
@ApiModelProperty(value = "DFEMA")
@Excel(name = "DFEMA", width = 15)
private String dfema;
/**关键技术分解表*/
@ApiModelProperty(value = "关键技术分解表")
@Excel(name = "关键技术分解表", width = 15)
private String keyTechnologyDecompositionTable;
/**其他文件或模板*/
@ApiModelProperty(value = "其他文件或模板")
@Excel(name = "其他文件或模板", width = 15)
private String otherDocumentsTemplates;
/**排查阶段*/
@ApiModelProperty(value = "排查阶段")
@Excel(name = "排查阶段", width = 15)
private java.lang.String investigationStage;
/**p3*/
@ApiModelProperty(value = "p3")
@Excel(name = "P3证明符合性的交付物名称", width = 15)
private String p3;
/**p5*/
@ApiModelProperty(value = "p5")
@Excel(name = "P5证明符合性的交付物名称", width = 15)
private String p5;
/**备注*/
@ApiModelProperty(value = "备注")
@Excel(name = "备注", width = 15)
private String remarks;
/**标准解读流程id 搜索用*/
@@ -1,12 +1,20 @@
package com.jero.modules.activiti.process.standardinterpret.service;
import com.jero.common.api.vo.Result;
import com.jero.common.system.vo.DictModel;
import com.jero.modules.activiti.entity.ProcessAll;
import com.jero.modules.activiti.entity.ProcessApprovalRecord;
import com.jero.modules.activiti.process.standardinterpret.dto.StandardInterpretDTO;
import com.jero.modules.activiti.process.standardinterpret.dto.StandardInterpretFlowDTO;
import com.jero.modules.activiti.process.standardinterpret.entity.ProcessStandardInterpretClause;
import com.jero.modules.activiti.process.standardinterpret.entity.ProcessStandardInterpretClauseSublist;
import com.jero.modules.activiti.process.standardinterpret.vo.StandardInterpretFlowVO;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.task.Task;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -70,6 +78,8 @@ public interface StandardInterpretFlowService {
*/
StandardInterpretFlowVO queryDetail(String projectId, String taskId);
StandardInterpretDTO queryBusinessData(ProcessAll processAll, ProcessApprovalRecord processApprovalRecord);
void demo(Map<String, Object> map);
List<Task> getTaskId(String processInstanceId);
@@ -88,4 +98,19 @@ public interface StandardInterpretFlowService {
* @return
*/
List<DictModel> queryFileByStandardId(String standardId);
/**
* 导出(标准主解读人分发)
* @param request
* @return
*/
ModelAndView exportExcelByDistribute(HttpServletRequest request);
/**
* 导入(标准主解读人不分发)
* @param request
* @param response
* @return
*/
Result<List<ProcessStandardInterpretClauseSublist>> importExcelByUnDistribute(HttpServletRequest request, HttpServletResponse response) throws Exception;
}
@@ -5,11 +5,14 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.enums.YesOrNoEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.base.controller.JeroController;
import com.jero.common.system.vo.DictModel;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.SnowflakeUtils;
import com.jero.common.util.*;
import com.jero.modules.activiti.common.ActivitiCommon;
import com.jero.modules.activiti.entity.ProcessAll;
import com.jero.modules.activiti.entity.ProcessApprovalRecord;
@@ -30,6 +33,7 @@ import com.jero.modules.activiti.process.standardinterpret.service.ProcessStanda
import com.jero.modules.activiti.process.standardinterpret.service.ProcessStandardInterpretService;
import com.jero.modules.activiti.process.standardinterpret.service.StandardInterpretFlowService;
import com.jero.modules.activiti.process.standardinterpret.vo.FlowApproveInfo;
import com.jero.modules.activiti.process.standardinterpret.vo.FlowImportExcel;
import com.jero.modules.activiti.process.standardinterpret.vo.StandardInterpretFlowVO;
import com.jero.modules.activiti.service.ProcessAllService;
import com.jero.modules.activiti.service.ProcessApprovalRecordService;
@@ -37,9 +41,16 @@ import com.jero.modules.activiti.service.ProcessNodeLinkService;
import com.jero.modules.laws.documenttool.entity.LawsDocumentSplit;
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.entity.PartName;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.laws.standard.service.ILawsPartNameService;
import com.jero.modules.split.entity.SarFileSplitInfoEO;
import com.jero.modules.split.service.ISarFileSplitInfoService;
import com.jero.modules.system.entity.SysDepart;
import com.jero.modules.system.service.ISysCategoryService;
import com.jero.modules.system.service.ISysDepartService;
import com.jero.modules.system.service.ISysDictService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -49,11 +60,26 @@ import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -85,6 +111,12 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
private final ISarFileSplitInfoService sarFileSplitInfoService;
private final DocumentSplitMapper documentSplitMapper;
private final ISysDictService sysDictService;
private final ISysCategoryService sysCategoryService;
private final ISysDepartService sysDepartService;
private final ILawsPartNameService lawsPartNameService;
private final ILawsEnterpriseStandardService lawsEnterpriseStandardService;
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@Override
public void flowStart(StandardInterpretFlowDTO standardInterpretFlowDTO) {
@@ -104,6 +136,9 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
+ lawsDomesticStandard.getStandardName() + "-解读";
processAll.setPrcName(prcName);
// 设置主流程实例id
map.put(ActivitiCommon.MAIN_INSTANCE_ID, SnowflakeUtils.snowflake());
// 根据流程key启动流程,设置流程变量,更新流程总表信息,更新流程审批信息,返回任务信息
Task task = startProcessInstanceByKey(StandardInterpretCommon.KEY_1, map,
processAll, processApprovalRecord, data);
@@ -281,8 +316,6 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
+ "," + standardInterpretClauseSublist.getKeywords());
first.setKeyController(first.getKeyController()
+ "," + standardInterpretClauseSublist.getKeyController());
first.setApplicableComponents(first.getApplicableComponents()
+ "," + standardInterpretClauseSublist.getApplicableComponents());
first.setRelatedDepartment(first.getRelatedDepartment()
+ "," + standardInterpretClauseSublist.getRelatedDepartment());
first.setResponsibleModule(first.getResponsibleModule()
@@ -388,7 +421,8 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
return standardInterpretFlowVO;
}
private StandardInterpretDTO queryBusinessData(ProcessAll processAll, ProcessApprovalRecord processApprovalRecord) {
@Override
public StandardInterpretDTO queryBusinessData(ProcessAll processAll, ProcessApprovalRecord processApprovalRecord) {
StandardInterpretDTO standardInterpretDTO = new StandardInterpretDTO();
// 标准解读流程
ProcessStandardInterpret processStandardInterpret = new ProcessStandardInterpret();
@@ -491,6 +525,347 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
return dictItems;
}
@Override
public ModelAndView exportExcelByDistribute(HttpServletRequest request) {
// Step.1 组装查询条件
ProcessAll processAll = new ProcessAll();
processAll.setProjectId(request.getParameter("projectId"));
ProcessApprovalRecord processApprovalRecord = new ProcessApprovalRecord();
processApprovalRecord.setNodeId(request.getParameter("nodeId"));
StandardInterpretDTO standardInterpretDTO = queryBusinessData(processAll, processApprovalRecord);
// Step.2 获取导出数据
List<ProcessStandardInterpretClause> exportList = standardInterpretDTO.getProcessStandardInterpretClauseList();
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = exportList.stream()
.filter(item -> selectionList.contains(item.getId()))
.collect(Collectors.toList());
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
try {
mv.addObject(JeroController.FILE_NAME, URLEncoder.encode("标准主解读人分发", "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
mv.addObject(JeroController.CLASS, ProcessStandardInterpretClause.class);
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(null, "标准主解读人分发");
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
mv.addObject(JeroController.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
@Override
public Result<List<ProcessStandardInterpretClauseSublist>> importExcelByUnDistribute(HttpServletRequest request, HttpServletResponse response) throws Exception {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
// 解密excel
MultipartFile file = IntekeyUtils.autoDecryptFile(entity.getValue());
ImportParams params = new ImportParams();
params.setNeedSave(true);
params.setHeadRows(1);
// excel表格头部校验
excelHeadVerify(file, FlowImportExcel.class, 0, 0);
List<FlowImportExcel> lists = ExcelImportUtil.importExcel(file.getInputStream(),
FlowImportExcel.class, params);
if (CollectionUtils.isEmpty(lists) || lists.size() <= 2) {
return Result.error(ResultCommon.IMPORT_DATA_CANNOT_BE_EMPTY);
}
lists.remove(0);
List<ProcessStandardInterpretClauseSublist> list = BeanCopyUtils.copyBeanList(lists,
ProcessStandardInterpretClauseSublist.class);
StringBuilder errorMSG = new StringBuilder();
// 字段校验
for (int i = 0; i < list.size(); i++) {
String head = "" + (i + 2) + "行:";
List<String> firstVerify = firstVerify(list.get(i));
List<String> secondVerify = secondVerify(list.get(i));
List<String> thirdVerify = thirdVerify(list.get(i));
List<String> fifthVerify = fifthVerify(list.get(i));
List<String> sixthVerify = sixthVerify(list.get(i));
firstVerify.addAll(secondVerify);
firstVerify.addAll(thirdVerify);
firstVerify.addAll(fifthVerify);
firstVerify.addAll(sixthVerify);
if (!firstVerify.isEmpty()){
errorMSG.append(head).append(String.join("", firstVerify)).append("<br/>");
}
}
//update-begin-author:taoyan date:20190528 for:批量插入数据
//update-end-author:taoyan date:20190528 for:批量插入数据
if (errorMSG.length() > 0){
throw new JeroBootException("文件导入失败:<br/>" + errorMSG);
}else {
// fillProperty(list);
return Result.OK("文件导入成功!数据行数:" + list.size(), list);
}
}
return Result.error("文件导入失败!");
}
private List<String> sixthVerify(ProcessStandardInterpretClauseSublist data) {
List<String> errorList = new ArrayList<>();
String enterpriseStandard = data.getEnterpriseStandard();
if (StringUtils.isNotBlank(enterpriseStandard)){
LawsEnterpriseStandard lawsEnterpriseStandard =
lawsEnterpriseStandardService.queryByStandardNumber(enterpriseStandard);
if (Objects.isNull(lawsEnterpriseStandard)){
errorList.add("企标标准不存在!");
}
}
String investigationStage = data.getInvestigationStage();
if (StringUtils.isNotBlank(investigationStage)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<DictModel> dictItems = sysDictService.getDictItems("investigation_stage");
for (String str : investigationStage.split(",")) {
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(str)).findFirst();
if (!optionalDictModel.isPresent()){
errorList.add("排查阶段不存在!");
flag = false;
break;
}
list.add(optionalDictModel.get().getValue());
}
if (flag){
data.setInvestigationStage(String.join(",", list));
}
}
return errorList;
}
private List<String> fifthVerify(ProcessStandardInterpretClauseSublist data) {
List<String> errorList = new ArrayList<>();
String applications = data.getApplications();
if (StringUtils.isNotBlank(applications)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<DictModel> dictItems = sysDictService.getDictItems("applicable_vehicle_type");
for (String str : applications.split(",")) {
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(str)).findFirst();
if (!optionalDictModel.isPresent()){
errorList.add("适用车型不存在!");
flag = false;
break;
}
list.add(optionalDictModel.get().getValue());
}
if (flag){
data.setApplications(String.join(",", list));
}
}
String powerType = data.getPowerType();
if (StringUtils.isNotBlank(powerType)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<DictModel> dictItems = sysDictService.getDictItems("dynamic_type");
for (String str : powerType.split(",")) {
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(str)).findFirst();
if (!optionalDictModel.isPresent()){
errorList.add("动力类型不存在!");
flag = false;
break;
}
list.add(optionalDictModel.get().getValue());
}
if (flag){
data.setPowerType(String.join(",", list));
}
}
return errorList;
}
private List<String> thirdVerify(ProcessStandardInterpretClauseSublist data) {
List<String> errorList = new ArrayList<>();
String responsibleDepartment = data.getResponsibleDepartment();
if (StringUtils.isNotBlank(responsibleDepartment)){
boolean flag = true;
List<String> list = new ArrayList<>();
for (String str : responsibleDepartment.split(",")) {
SysDepart one = sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>()
.eq(SysDepart::getDepartName, str), false);
if (Objects.isNull(one)){
errorList.add("责任部门不存在!");
flag = false;
break;
}else {
list.add(str);
}
}
if (flag){
data.setResponsibleDepartment(String.join(",", list));
}
}
String relatedDepartment = data.getRelatedDepartment();
if (StringUtils.isNotBlank(relatedDepartment)){
boolean flag = true;
List<String> list = new ArrayList<>();
for (String str : relatedDepartment.split(",")) {
SysDepart one = sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>()
.eq(SysDepart::getDepartName, str), false);
if (Objects.isNull(one)){
errorList.add("关联部门不存在!");
flag = false;
break;
}else {
list.add(str);
}
}
if (flag){
data.setRelatedDepartment(String.join(",", list));
}
}
return errorList;
}
private List<String> secondVerify(ProcessStandardInterpretClauseSublist data) {
List<String> errorList = new ArrayList<>();
String keywords = data.getKeywords();
if (StringUtils.isNotBlank(keywords)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<PartName> partNames = lawsPartNameService.list(new LambdaQueryWrapper<PartName>()
.ne(PartName::getCode, "Part"));
List<PartName> partNameList = partNameGetLevelPath(partNames);
for (String str : keywords.split(",")) {
List<PartName> path =
partNameList.stream().filter(o -> str.equals(o.getLevelPath()))
.collect(Collectors.toList());
if (path.size() > 1){
errorList.add("涉及系统/部件 中 " + str + "存在多个!");
flag = false;
break;
}else if (path.size() == 1){
list.add(path.get(0).getId());
}else {
errorList.add("涉及系统/部件不存在!");
flag = false;
break;
}
}
if (flag){
data.setKeywords(String.join(",", list));
}
}
String keyController = data.getKeyController();
if (StringUtils.isNotBlank(keyController)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<DictModel> dictItems = sysDictService.getDictItems("key_controller");
for (String str : keyController.split(",")) {
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(str)).findFirst();
if (!optionalDictModel.isPresent()){
errorList.add("关键控制器不存在!");
flag = false;
break;
}
list.add(optionalDictModel.get().getValue());
}
if (flag){
data.setKeyController(String.join(",", list));
}
}
return errorList;
}
private List<String> firstVerify(ProcessStandardInterpretClauseSublist data) {
List<String> errorList = new ArrayList<>();
String isSameAsPrevVersion = data.getIsSameAsPrevVersion();
if (StringUtils.isNotBlank(isSameAsPrevVersion)){
List<DictModel> dictItems = sysDictService.getDictItems("yn");
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(isSameAsPrevVersion)).findFirst();
if (optionalDictModel.isPresent()){
data.setIsSameAsPrevVersion(optionalDictModel.get().getValue());
}else {
errorList.add("是否与上一版相同不存在!");
}
}
String domainArea = data.getDomainArea();
if (StringUtils.isNotBlank(domainArea)){
boolean flag = true;
List<String> list = new ArrayList<>();
List<DictModel> dictItems = sysDictService.getDictItems("professional_field");
for (String str : domainArea.split(",")) {
Optional<DictModel> optionalDictModel = dictItems.stream()
.filter(dictModel -> dictModel.getText().equals(str)).findFirst();
if (!optionalDictModel.isPresent()){
errorList.add("专业领域不存在!");
flag = false;
break;
}
list.add(optionalDictModel.get().getValue());
}
if (flag){
data.setDomainArea(String.join(",", list));
}
}
String newCerImplementDate = data.getNewCerImplementDate();
if (StringUtils.isNotBlank(newCerImplementDate)){
for (String str : newCerImplementDate.split(",")) {
try {
dateFormat.parse(str);
} catch (ParseException e) {
errorList.add("新认证实施日期格式错误!");
break;
}
}
}
String registrationDate = data.getRegistrationDate();
if (StringUtils.isNotBlank(registrationDate)){
for (String str : registrationDate.split(",")) {
try {
dateFormat.parse(str);
} catch (ParseException e) {
errorList.add("注册日期格式错误!");
break;
}
}
}
return errorList;
}
/**
* excel表头校验
* @param file
* @param clazz
* @param titleRows
* @param i
*/
private void excelHeadVerify(MultipartFile file, Class<FlowImportExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
@Override
public void flowSave(StandardInterpretFlowDTO standardInterpretFlowDTO) {
// 处理业务数据
@@ -529,7 +904,7 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
case StandardInterpretCommon.REGULATORY_ENGINEER_START:
processStandardInterpretService.saveOrUpdate(processStandardInterpret);
for (ProcessStandardInterpretClause standardInterpretClause : processStandardInterpretClauseList) {
standardInterpretClause.setId(String.valueOf(SnowflakeUtils.snowflake()));
// standardInterpretClause.setId(String.valueOf(SnowflakeUtils.snowflake()));
standardInterpretClause.setDecompositionSource(processStandardInterpret.getDecompositionSource());
standardInterpretClause.setStandardInterpretId(standardInterpretId);
}
@@ -599,6 +974,37 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
// 不分发
processStandardInterpretClauseSublistService
.saveOrUpdateBatch(processStandardInterpretClauseSublistList);
// 判断是否有导入的数据,有则补齐对应中间表数据
List<ProcessStandardInterpretClause> newProcessStandardInterpretClauseList = new ArrayList<>();
for (ProcessStandardInterpretClauseSublist standardInterpretClauseSublist :
processStandardInterpretClauseSublistList) {
int count = processStandardInterpretClauseService.count(
new LambdaQueryWrapper<ProcessStandardInterpretClause>()
.eq(ProcessStandardInterpretClause::getStandardInterpretId,
standardInterpretId)
.eq(ProcessStandardInterpretClause::getClauseId,
standardInterpretClauseSublist.getClauseId()));
if (count <= 0){
ProcessStandardInterpretClause newProcessStandardInterpretClause =
new ProcessStandardInterpretClause();
String snowflake = String.valueOf(SnowflakeUtils.snowflake());
newProcessStandardInterpretClause.setId(snowflake);
newProcessStandardInterpretClause.setStandardInterpretId(standardInterpretId);
newProcessStandardInterpretClause.setClauseId(standardInterpretClauseSublist.getClauseId());
newProcessStandardInterpretClause.setDecompositionSource(
processStandardInterpret.getDecompositionSource());
newProcessStandardInterpretClauseList.add(newProcessStandardInterpretClause);
// 更新 标准解读流程_条款中间表_子表关联关系
processStandardInterpretClauseSublistService.update(
new LambdaUpdateWrapper<ProcessStandardInterpretClauseSublist>()
.eq(ProcessStandardInterpretClauseSublist::getId,
standardInterpretClauseSublist.getId())
.set(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId
, snowflake));
}
}
processStandardInterpretClauseService.saveOrUpdateBatch(newProcessStandardInterpretClauseList);
}
map.put(StandardInterpretCommon.PASS_FIRST,
@@ -673,4 +1079,30 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
return task;
}
private List<PartName> partNameGetLevelPath(List<PartName> partNames) {
List<PartName> list = new ArrayList<>();
// 一级节点
List<PartName> firstLevelList = partNames.stream()
.filter(o -> o.getParentCode().equals("Part"))
.collect(Collectors.toList());
queryPartNameChildren(firstLevelList, partNames, "", list);
return list;
}
private void queryPartNameChildren(List<PartName> firstLevelList, List<PartName> partNames, String levelPath,
List<PartName> list) {
for (PartName partName : firstLevelList) {
if (StringUtils.isBlank(levelPath)){
partName.setLevelPath(partName.getName());
}else {
partName.setLevelPath(levelPath + "/" + partName.getName());
}
list.add(partName);
List<PartName> children = partNames.stream()
.filter(v -> v.getParentCode().equals(partName.getCode())).collect(Collectors.toList());
if (!children.isEmpty()){
queryPartNameChildren(children, partNames, partName.getLevelPath(), list);
}
}
}
}
@@ -0,0 +1,131 @@
package com.jero.modules.activiti.process.standardinterpret.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @ClassName: FlowImportExcel
* @Description:
* @Author: yjz
* @Date: 2024-07-08 14:27
* @Version: 1.0
**/
@Data
public class FlowImportExcel {
/**条款号/标准编号*/
@ApiModelProperty(value = "条款号/标准编号")
@TableField(exist = false)
@Excel(name = "标准编号/条款号", width = 15)
private String itemNum;
/**条款标题/标准名称*/
@ApiModelProperty(value = "条款标题/标准名称")
@TableField(exist = false)
@Excel(name = "标准名称/条款标题", width = 15)
private String itemTitle;
/**译文*/
@ApiModelProperty(value = "译文")
@Excel(name = "译文", width = 15)
private String translation;
/**是否与上一版相同(字典:1:是,0:否)*/
@ApiModelProperty(value = "是否与上一版相同(字典:1:是,0:否)")
@Excel(name = "是否与上一版相同", width = 15)
private String isSameAsPrevVersion;
/**变化点说明*/
@ApiModelProperty(value = "相对上一版变化点说明")
@Excel(name = "相对上一版变化点说明", width = 15)
private String changeDescription;
/**法规注释*/
@ApiModelProperty(value = "法规注释")
@Excel(name = "法规注释", width = 15)
private String regulatoryNotes;
/**涉及系统/部件)*/
@ApiModelProperty(value = "涉及系统/部件)")
@Excel(name = "涉及系统/部件", width = 15)
private String keywords;
/**涉及系统/部件)*/
@ApiModelProperty(value = "关键控制器)")
@Excel(name = "关键控制器", width = 15)
private String keyController;
/**责任部门*/
@ApiModelProperty(value = "责任部门")
@Excel(name = "责任部门", width = 15)
private String responsibleDepartment;
/**关联部门*/
@ApiModelProperty(value = "关联部门")
@Excel(name = "关联部门", width = 15)
private String relatedDepartment;
/**适用车型*/
@ApiModelProperty(value = "适用车型")
@Excel(name = "适用车型", width = 15)
private String applications;
/**动力类型*/
@ApiModelProperty(value = "动力类型")
@Excel(name = "动力类型", width = 15)
private String powerType;
/**专业领域*/
@ApiModelProperty(value = "专业领域")
@Excel(name = "专业领域", width = 15)
private String domainArea;
/**新认证实施日期*/
@ApiModelProperty(value = "新认证实施日期")
@Excel(name = "新认证实施日期", width = 15)
private String newCerImplementDate;
/**注册日期*/
@ApiModelProperty(value = "注册日期")
@Excel(name = "注册日期", width = 15)
private String registrationDate;
/**企业标准*/
@ApiModelProperty(value = "企业标准")
@Excel(name = "企业标准", width = 15)
private String enterpriseStandard;
/**技术规范/设计指南*/
@ApiModelProperty(value = "技术规范/设计指南")
@Excel(name = "技术规范/设计指南", width = 15)
private String technicalSpecificationDesignGuide;
/**图纸模板*/
@ApiModelProperty(value = "图纸模板")
@Excel(name = "图纸模板", width = 15)
private String drawingTemplate;
/**技术协议模板*/
@ApiModelProperty(value = "技术协议模板")
@Excel(name = "技术协议模板", width = 15)
private String technicalAgreementTemplate;
/**校验报告模块/checklist*/
@ApiModelProperty(value = "校验报告模块/checklist")
@Excel(name = "校验报告模块/checklist", width = 15)
private String verificationReportTemplateChecklist;
/**DVP模板*/
@ApiModelProperty(value = "DVP模板")
@Excel(name = "DVP模板", width = 15)
private String dvpTemplate;
/**DFEMA*/
@ApiModelProperty(value = "DFEMA")
@Excel(name = "DFEMA", width = 15)
private String dfema;
/**关键技术分解表*/
@ApiModelProperty(value = "关键技术分解表")
@Excel(name = "关键技术分解表", width = 15)
private String keyTechnologyDecompositionTable;
/**其他文件或模板*/
@ApiModelProperty(value = "其他文件或模板")
@Excel(name = "其他文件或模板", width = 15)
private String otherDocumentsTemplates;
/**排查阶段*/
@ApiModelProperty(value = "排查阶段")
@Excel(name = "排查阶段", width = 15)
private java.lang.String investigationStage;
/**p3*/
@ApiModelProperty(value = "p3")
@Excel(name = "P3证明符合性的交付物名称", width = 15)
private String p3;
/**p5*/
@ApiModelProperty(value = "p5")
@Excel(name = "P5证明符合性的交付物名称", width = 15)
private String p5;
/**备注*/
@ApiModelProperty(value = "备注")
@Excel(name = "备注", width = 15)
private String remarks;
}