Commit 2799f0ae authored by wei's avatar wei 🎱

Merge remote-tracking branch 'origin/master'

parents a7e52580 a15529bc
...@@ -91,7 +91,7 @@ public class ExtPuchasePlanExcelVO { ...@@ -91,7 +91,7 @@ public class ExtPuchasePlanExcelVO {
/** /**
* 计划编码 * 计划编码
*/ */
@ExcelProperty(value = {"采购计划","计划编*"},index = 8) @ExcelProperty(value = {"采购计划","计划编*"},index = 8)
@ColumnWidth(20) @ColumnWidth(20)
private String planCode; private String planCode;
...@@ -103,19 +103,6 @@ public class ExtPuchasePlanExcelVO { ...@@ -103,19 +103,6 @@ public class ExtPuchasePlanExcelVO {
@ColumnWidth(20) @ColumnWidth(20)
private String note; private String note;
public static void main(String[] args) {
List<ExtPuchasePlanExcelVO> list = new ArrayList<>();
for (int i=0;i<=1;i++){
ExtPuchasePlanExcelVO extPuchasePlanExcelVO = new ExtPuchasePlanExcelVO();
extPuchasePlanExcelVO.setNote("测试"+i);
list.add(extPuchasePlanExcelVO);
}
EasyExcel.write(
"F:\\yangyi\\项目\\清华核研院\\核研院设计文档及原型\\采购计划导入模板333.xlsx", ExtPuchasePlanExcelVO.class)
.sheet("采购计划").doWrite(list);
}
} }
...@@ -15,6 +15,7 @@ import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO; ...@@ -15,6 +15,7 @@ import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import com.yonde.dcs.plan.core.service.ExtIEDPlanDocLinkService; import com.yonde.dcs.plan.core.service.ExtIEDPlanDocLinkService;
import com.yonde.dcs.plan.core.service.ExtIEDPlanService; import com.yonde.dcs.plan.core.service.ExtIEDPlanService;
import com.yonde.dcs.plan.core.util.CommonUtils; import com.yonde.dcs.plan.core.util.CommonUtils;
import com.yonde.dcs.plan.core.util.UserUtils;
import com.yonde.dcs.plan.core.util.WorkFlowUtil; import com.yonde.dcs.plan.core.util.WorkFlowUtil;
import com.yonde.dcs.plan.entity.po.ExtIEDPlanDocLink; import com.yonde.dcs.plan.entity.po.ExtIEDPlanDocLink;
import com.yonde.dex.basedata.data.search.SearchItem; import com.yonde.dex.basedata.data.search.SearchItem;
...@@ -25,6 +26,8 @@ import com.yonde.dex.basedata.entity.data.OperatorType; ...@@ -25,6 +26,8 @@ import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.exception.DxBusinessException; import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dao.service.util.ApplicationContextUtil; import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.dao.service.util.DxPageUtils; import com.yonde.dex.dao.service.util.DxPageUtils;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.wfc.common.vo.DxWfProcessVO; import com.yonde.dex.wfc.common.vo.DxWfProcessVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -47,6 +50,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -47,6 +50,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
private ExtIEDPlanDocLinkService extIEDPlanDocLinkService; private ExtIEDPlanDocLinkService extIEDPlanDocLinkService;
private ExtDxDocumentServiceFeign extDxDocumentServiceFeign; private ExtDxDocumentServiceFeign extDxDocumentServiceFeign;
private WorkFlowUtil workFlowUtil; private WorkFlowUtil workFlowUtil;
private UserUtils userUtils;
/** /**
* 每隔100条处理下,然后清理list ,方便内存回收 * 每隔100条处理下,然后清理list ,方便内存回收
*/ */
...@@ -85,6 +89,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -85,6 +89,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
this.extIEDPlanDocLinkService = ApplicationContextUtil.getBean(ExtIEDPlanDocLinkService.class); this.extIEDPlanDocLinkService = ApplicationContextUtil.getBean(ExtIEDPlanDocLinkService.class);
this.workFlowUtil = ApplicationContextUtil.getBean(WorkFlowUtil.class); this.workFlowUtil = ApplicationContextUtil.getBean(WorkFlowUtil.class);
this.extDxDocumentServiceFeign = ApplicationContextUtil.getBean(ExtDxDocumentServiceFeign.class); this.extDxDocumentServiceFeign = ApplicationContextUtil.getBean(ExtDxDocumentServiceFeign.class);
this.userUtils = ApplicationContextUtil.getBean(UserUtils.class);
this.projectId = projectId; this.projectId = projectId;
} }
...@@ -182,23 +187,8 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -182,23 +187,8 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
StringBuffer errorString = new StringBuffer(); StringBuffer errorString = new StringBuffer();
//校验数据 //校验数据
if (!StringUtils.isEmpty(extIEDPlanExcelVO.getOperation()) && !StringUtils.isEmpty(extIEDPlanExcelVO.getFileNumber())) { if (!StringUtils.isEmpty(extIEDPlanExcelVO.getOperation()) && !StringUtils.isEmpty(extIEDPlanExcelVO.getFileNumber())) {
if (!operationList.contains(extIEDPlanExcelVO.getOperation())) { //校验excel必填字段是否有效
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的操作符无法识别!!"); verifyExcelRequiredFields(extIEDPlanExcelVO,errorString);
errorList.add(errorString);
return;
}
//文件代号不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getFileCode())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的文件代号不能为空!!");
errorList.add(errorString);
return;
}
//管理系统编码不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getSystemNumber())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的管理信息系统编码不能为空!!");
errorList.add(errorString);
return;
}
//如果是新增,查看一下数据库中是不是已经存在 //如果是新增,查看一下数据库中是不是已经存在
if (Constants.EXCEL_ADD.equals(extIEDPlanExcelVO.getOperation())) { if (Constants.EXCEL_ADD.equals(extIEDPlanExcelVO.getOperation())) {
//文件编码、文件代号、管理系统编码只要有一个为删除存在就不能新增。 //文件编码、文件代号、管理系统编码只要有一个为删除存在就不能新增。
...@@ -207,7 +197,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -207,7 +197,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
errorString.append("解析到数据第"+excelDataRow+"行,新增IED计划的文件编号、文件代号或者管理信息系统编码已存在,不能重复添加!"); errorString.append("解析到数据第"+excelDataRow+"行,新增IED计划的文件编号、文件代号或者管理信息系统编码已存在,不能重复添加!");
errorList.add(errorString); errorList.add(errorString);
} }
}else if (Constants.EXCEL_DELETE.equals(extIEDPlanExcelVO.getOperation())){//删除时校验 }else if (Constants.EXCEL_DELETE.equals(extIEDPlanExcelVO.getOperation())){
// ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),true); // ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),true);
// if(!ObjectUtils.isEmpty(extIEDPlanVO)){ // if(!ObjectUtils.isEmpty(extIEDPlanVO)){
// errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "未查到相关数据,删除失败!"); // errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "未查到相关数据,删除失败!");
...@@ -436,4 +426,84 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -436,4 +426,84 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
extDxDocumentServiceFeign.saveRecursion(dxDocumentVO); extDxDocumentServiceFeign.saveRecursion(dxDocumentVO);
} }
/**
* 校验excel必填字段
* @param extIEDPlanExcelVO
* @param errorString
*/
public void verifyExcelRequiredFields(ExtIEDPlanExcelVO extIEDPlanExcelVO,StringBuffer errorString){
if (!operationList.contains(extIEDPlanExcelVO.getOperation())) {
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的操作符无法识别!!");
errorList.add(errorString);
return;
}
//文件代号不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getFileCode())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的文件代号不能为空!!");
errorList.add(errorString);
return;
}
//管理系统编码不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getSystemNumber())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的管理信息系统编码不能为空!!");
errorList.add(errorString);
return;
}
//文件提交时间不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getFileSubmitTime())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的提交时间不能为空!!");
errorList.add(errorString);
return;
}
//编写者不能为空
if(StringUtils.isEmpty(extIEDPlanExcelVO.getEditor())){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的编写者不能为空!!");
errorList.add(errorString);
return;
}else {
DxUserInfoVO dxUserInfoVO= userUtils.getUserByName(extIEDPlanExcelVO.getEditor());
if(ObjectUtils.isEmpty(dxUserInfoVO)){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的编写者在系统中未查到!!");
errorList.add(errorString);
return;
}else {
extIEDPlanExcelVO.setEditor(String.valueOf(dxUserInfoVO.getId()));
}
}
//审核不是空,判断该用户是否存在,存在的话,将用户id保存
if(!StringUtils.isEmpty(extIEDPlanExcelVO.getAuditor())){
DxUserInfoVO dxUserInfoVO= userUtils.getUserByName(extIEDPlanExcelVO.getAuditor());
if(ObjectUtils.isEmpty(dxUserInfoVO)){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的审核者在系统中未查到!!");
errorList.add(errorString);
return;
}else {
extIEDPlanExcelVO.setAuditor(String.valueOf(dxUserInfoVO.getId()));
}
}
//审定不是空,判断该用户是否存在,存在的话,将用户id保存
if(!StringUtils.isEmpty(extIEDPlanExcelVO.getInvestigator())){
DxUserInfoVO dxUserInfoVO= userUtils.getUserByName(extIEDPlanExcelVO.getInvestigator());
if(ObjectUtils.isEmpty(dxUserInfoVO)){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的审定者在系统中未查到!!");
errorList.add(errorString);
return;
}else {
extIEDPlanExcelVO.setInvestigator(String.valueOf(dxUserInfoVO.getId()));
}
}
//批准不是空,判断该用户是否存在,存在的话,将用户id保存
if(!StringUtils.isEmpty(extIEDPlanExcelVO.getRatifier())){
DxUserInfoVO dxUserInfoVO= userUtils.getUserByName(extIEDPlanExcelVO.getRatifier());
if(ObjectUtils.isEmpty(dxUserInfoVO)){
errorString.append("解析到数据第"+excelDataRow+"行文件编号为:" + extIEDPlanExcelVO.getFileNumber() + "的审定者在系统中未查到!!");
errorList.add(errorString);
return;
}else {
extIEDPlanExcelVO.setRatifier(String.valueOf(dxUserInfoVO.getId()));
}
}
}
} }
...@@ -74,6 +74,7 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan ...@@ -74,6 +74,7 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
@Autowired @Autowired
private ExtIEDPlanDocLinkService extIEDPlanDocLinkService; private ExtIEDPlanDocLinkService extIEDPlanDocLinkService;
@Override @Override
public String importIEDPlan(InputStream inputStream, String projectId) { public String importIEDPlan(InputStream inputStream, String projectId) {
EasyExcel.read(inputStream, ExtIEDPlanExcelVO.class, EasyExcel.read(inputStream, ExtIEDPlanExcelVO.class,
...@@ -201,6 +202,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan ...@@ -201,6 +202,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
dynamicAttrs.put("systemCode", extIEDPlanVO.getSystemNumber()); dynamicAttrs.put("systemCode", extIEDPlanVO.getSystemNumber());
//阶段 //阶段
dynamicAttrs.put("phase", extIEDPlanVO.getPhase()); dynamicAttrs.put("phase", extIEDPlanVO.getPhase());
//编写者
dynamicAttrs.put("editor", extIEDPlanVO.getEditor());
//设置动态属性 //设置动态属性
dxDocumentVO.setDynamicAttrs(dynamicAttrs); dxDocumentVO.setDynamicAttrs(dynamicAttrs);
//设备号 //设备号
...@@ -208,6 +211,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan ...@@ -208,6 +211,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
//创建时间 //创建时间
dxDocumentVO.setCreateTime(LocalDateTime.now()); dxDocumentVO.setCreateTime(LocalDateTime.now());
//设置扩展属性 //设置扩展属性
//项目代号
//todo wq项目代号暂时还未取到
dxDocumentVO.setDxDocumentExpand(dxDocumentExpand); dxDocumentVO.setDxDocumentExpand(dxDocumentExpand);
dxDocumentVO.setOperator(OperatorType.ADD); dxDocumentVO.setOperator(OperatorType.ADD);
DxDocumentVO dxDocumentVOForDB = extDxDocumentServiceFeign.saveRecursion(dxDocumentVO); DxDocumentVO dxDocumentVOForDB = extDxDocumentServiceFeign.saveRecursion(dxDocumentVO);
...@@ -259,7 +264,6 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan ...@@ -259,7 +264,6 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
return ApiResult.SUCCESS; return ApiResult.SUCCESS;
} }
} }
package com.yonde.dcs.plan.core.util;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 用户信息工具类
*/
@Component
public class UserUtils {
@Autowired
private DxUserInfoFeign dxUserInfoFeign;
public DxUserInfoVO getUserByName(String name){
return dxUserInfoFeign.getUserByName(name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment