Commit 113def65 authored by wangqiang's avatar wangqiang

IED计划删除时,删除技术文件和流程任务的功能开发

parent 81604937
...@@ -4,13 +4,19 @@ import com.alibaba.excel.context.AnalysisContext; ...@@ -4,13 +4,19 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.util.StringUtils; import com.alibaba.excel.util.StringUtils;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.feign.expand.ExtDxDocumentServiceFeign;
import com.yonde.dcs.plan.common.constants.Constants; import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.utils.SearchUtil; import com.yonde.dcs.plan.common.utils.SearchUtil;
import com.yonde.dcs.plan.common.vo.ExtIEDPlanDocLinkVO;
import com.yonde.dcs.plan.common.vo.ExtIEDPlanExcelVO; import com.yonde.dcs.plan.common.vo.ExtIEDPlanExcelVO;
import com.yonde.dcs.plan.common.vo.ExtIEDPlanVO; import com.yonde.dcs.plan.common.vo.ExtIEDPlanVO;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO; import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
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.WorkFlowUtil;
import com.yonde.dcs.plan.entity.po.ExtIEDPlanDocLink;
import com.yonde.dex.basedata.data.search.SearchItem; import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems; import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition; import com.yonde.dex.basedata.data.search.SearchQueryCondition;
...@@ -19,13 +25,18 @@ import com.yonde.dex.basedata.entity.data.OperatorType; ...@@ -19,13 +25,18 @@ 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.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;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -35,7 +46,9 @@ import java.util.List; ...@@ -35,7 +46,9 @@ import java.util.List;
public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcelVO> { public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcelVO> {
private ExtIEDPlanService extIEDPlanService; private ExtIEDPlanService extIEDPlanService;
private ExtIEDPlanDocLinkService extIEDPlanDocLinkService;
private ExtDxDocumentServiceFeign extDxDocumentServiceFeign;
private WorkFlowUtil workFlowUtil;
/** /**
* 每隔100条处理下,然后清理list ,方便内存回收 * 每隔100条处理下,然后清理list ,方便内存回收
*/ */
...@@ -71,6 +84,9 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -71,6 +84,9 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
public IEDPlanExcelListenner(String projectId) { public IEDPlanExcelListenner(String projectId) {
this.extIEDPlanService = ApplicationContextUtil.getBean(ExtIEDPlanService.class); this.extIEDPlanService = ApplicationContextUtil.getBean(ExtIEDPlanService.class);
this.extIEDPlanDocLinkService = ApplicationContextUtil.getBean(ExtIEDPlanDocLinkService.class);
this.workFlowUtil = ApplicationContextUtil.getBean(WorkFlowUtil.class);
this.extDxDocumentServiceFeign = ApplicationContextUtil.getBean(ExtDxDocumentServiceFeign.class);
this.projectId = projectId; this.projectId = projectId;
} }
...@@ -88,6 +104,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -88,6 +104,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) { public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 收尾工作,处理剩下的缓存数据。。。 // 收尾工作,处理剩下的缓存数据。。。
...@@ -110,7 +127,21 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -110,7 +127,21 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
extIEDPlanService.saveRecursion(extIEDPlanVOForDB); extIEDPlanService.saveRecursion(extIEDPlanVOForDB);
} else { //删除 } else { //删除
ExtIEDPlanVO extIEDPlanVOForDB = getIEDPlanByFileNumber(extIEDPlanExcelVO.getFileNumber()); ExtIEDPlanVO extIEDPlanVOForDB = getIEDPlanByFileNumber(extIEDPlanExcelVO.getFileNumber());
extIEDPlanService.remove(extIEDPlanVOForDB.getId()); if(extIEDPlanVOForDB.getState().equals(Constants.PLAN_STATE_UNOPENED)){
//删除计划 --如果是未开启状态,表示还未启动计划;所以没有技术文件及流程,所以不用删除技术文件及流程,只删除计划。
extIEDPlanService.remove(extIEDPlanVOForDB.getId());
}else {
//删除计划
extIEDPlanService.remove(extIEDPlanVOForDB.getId());
//删除技术文件
DxDocumentVO dxDocumentVO= getDocmentVoByPlanId(extIEDPlanVOForDB.getId());
extDxDocumentServiceFeign.delete(dxDocumentVO.getId());
//删除流程
workFlowUtil.stopWf(dxDocumentVO);
}
} }
} }
...@@ -162,20 +193,34 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -162,20 +193,34 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
} }
//如果是新增,查看一下数据库中是不是已经存在 //如果是新增,查看一下数据库中是不是已经存在
if (Constants.EXCEL_ADD.equals(extIEDPlanExcelVO.getOperation())) { if (Constants.EXCEL_ADD.equals(extIEDPlanExcelVO.getOperation())) {
//文件编码、文件代号、管理系统编码只要有一个存在就不能新增。 //文件编码、文件代号、管理系统编码只要有一个为删除存在就不能新增。
ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndFileCodeAndSystemNumber(extIEDPlanExcelVO.getFileNumber(),extIEDPlanExcelVO.getFileCode(),extIEDPlanExcelVO.getSystemNumber()); ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndFileCodeAndSystemNumber(extIEDPlanExcelVO.getFileNumber(),extIEDPlanExcelVO.getFileCode(),extIEDPlanExcelVO.getSystemNumber());
if (!ObjectUtils.isEmpty(extIEDPlanVO)) { if (!ObjectUtils.isEmpty(extIEDPlanVO)) {
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()); // ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),true);
if(!ObjectUtils.isEmpty(extIEDPlanVO) && Constants.COMPLETE.equals(extIEDPlanVO.getState())){ // if(!ObjectUtils.isEmpty(extIEDPlanVO)){
// errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "未查到相关数据,删除失败!");
// errorList.add(errorString);
// }
ExtIEDPlanVO iedPlan = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),false);
//已完成的计划不允许删除
if(!ObjectUtils.isEmpty(iedPlan) && Constants.COMPLETE.equals(iedPlan.getState())){
errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "已完成的计划不能删除!"); errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "已完成的计划不能删除!");
errorList.add(errorString); errorList.add(errorString);
} }
//未完成的计划且技术文件不是待审阅状态不允许删除
if(Constants.UNFINISHED.equals(iedPlan.getState()) ){
DxDocumentVO dxDocumentVO = getDocmentVoByPlanId(iedPlan.getId());
if(!Constants.PENDING_REVIEW.equals(dxDocumentVO.getState())){
errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "的状态是未完成且审阅状态是"+getStateValue(dxDocumentVO.getState())+"不能删除!");
errorList.add(errorString);
}
}
}else { }else {
ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber()); ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),true);
if (!ObjectUtils.isEmpty(extIEDPlanVO) && 1 == extIEDPlanVO.getDeleted()) { if (!ObjectUtils.isEmpty(extIEDPlanVO) && 1 == extIEDPlanVO.getDeleted()) {
errorString.append("解析到数据第"+excelDataRow+"行,更新IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "已被删除,更新或删除失败!"); errorString.append("解析到数据第"+excelDataRow+"行,更新IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "已被删除,更新或删除失败!");
errorList.add(errorString); errorList.add(errorString);
...@@ -206,7 +251,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -206,7 +251,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
extIEDPlanVO.setPhase(extIEDPlanExcelVO.getPhase()); extIEDPlanVO.setPhase(extIEDPlanExcelVO.getPhase());
if(!ObjectUtils.isEmpty(extIEDPlanExcelVO.getAuditTime())){ if(!ObjectUtils.isEmpty(extIEDPlanExcelVO.getAuditTime())){
try { try {
LocalDateTime auditTime = LocalDateTime.parse(extIEDPlanExcelVO.getAuditTime()); LocalDateTime auditTime =LocalDateTime.of(LocalDate.parse(extIEDPlanExcelVO.getAuditTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalTime.MIDNIGHT);
extIEDPlanVO.setAuditTime(auditTime); extIEDPlanVO.setAuditTime(auditTime);
}catch (Exception e){ }catch (Exception e){
throw new DxBusinessException("-1","审核时间格式不正确!"); throw new DxBusinessException("-1","审核时间格式不正确!");
...@@ -215,7 +260,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -215,7 +260,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
} }
if(!ObjectUtils.isEmpty(extIEDPlanExcelVO.getFileSubmitTime())){ if(!ObjectUtils.isEmpty(extIEDPlanExcelVO.getFileSubmitTime())){
try { try {
LocalDateTime submitTime = LocalDateTime.parse(extIEDPlanExcelVO.getFileSubmitTime()); LocalDateTime submitTime =LocalDateTime.of(LocalDate.parse(extIEDPlanExcelVO.getFileSubmitTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalTime.MIDNIGHT);
extIEDPlanVO.setFileSubmitTime(submitTime); extIEDPlanVO.setFileSubmitTime(submitTime);
}catch (Exception e){ }catch (Exception e){
throw new DxBusinessException("-1","文件提交时间格式不正确!"); throw new DxBusinessException("-1","文件提交时间格式不正确!");
...@@ -273,8 +318,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -273,8 +318,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
.item(new SearchItem("fileCode", SearchItem.Operator.EQ, fileCode, (Object)null)) .item(new SearchItem("fileCode", SearchItem.Operator.EQ, fileCode, (Object)null))
.item(new SearchItem("systemNumber", SearchItem.Operator.EQ, systemNumber, (Object)null)) .item(new SearchItem("systemNumber", SearchItem.Operator.EQ, systemNumber, (Object)null))
.operator(SearchItems.BooleanOperator.OR).build()) .operator(SearchItems.BooleanOperator.OR).build())
.item(new SearchItem("dxContextId", SearchItem.Operator.EQ, projectId, (Object)null)).operator(SearchItems.BooleanOperator.AND).build() .item(new SearchItem("dxContextId", SearchItem.Operator.EQ, projectId, (Object)null))
).build(); .item(new SearchItem("deleted", SearchItem.Operator.EQ, false, (Object)null))
.operator(SearchItems.BooleanOperator.AND)
.build()
).build();
//根据文件编号查询IED计划 //根据文件编号查询IED计划
// DxPageImpl<ExtIEDPlanVO> IEDPlanPage = extIEDPlanService.findRecursion(SearchUtil.buildQuery("fileNumber", SearchItem.Operator.EQ, fileNumber)); // DxPageImpl<ExtIEDPlanVO> IEDPlanPage = extIEDPlanService.findRecursion(SearchUtil.buildQuery("fileNumber", SearchItem.Operator.EQ, fileNumber));
...@@ -293,12 +342,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -293,12 +342,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
* @param fileNumber * @param fileNumber
* @return * @return
*/ */
private ExtIEDPlanVO getIEDPlanByFileNumberAndDeleted(String fileNumber) { private ExtIEDPlanVO getIEDPlanByFileNumberAndDeleted(String fileNumber,Boolean deleted) {
SearchQueryCondition condition = SearchQueryCondition.builder() SearchQueryCondition condition = SearchQueryCondition.builder()
.searchItems(SearchItems.builder() .searchItems(SearchItems.builder()
.item(new SearchItem("fileNumber", SearchItem.Operator.EQ, fileNumber, null)) .item(new SearchItem("fileNumber", SearchItem.Operator.EQ, fileNumber, null))
.item(new SearchItem("deleted", SearchItem.Operator.EQ, 1, null)) .item(new SearchItem("deleted", SearchItem.Operator.EQ, deleted, null))
.build()) .build())
.build(); .build();
...@@ -312,5 +361,24 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel ...@@ -312,5 +361,24 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
} }
return null; return null;
} }
public DxDocumentVO getDocmentVoByPlanId(Long planId){
DxPageImpl iedDocLinkPage = extIEDPlanDocLinkService.findRecursion(SearchUtil.buildQuery("sourceId",SearchItem.Operator.EQ,planId));
if(!ObjectUtils.isEmpty(iedDocLinkPage.getContent())){
ExtIEDPlanDocLinkVO extIEDPlanDocLink = (ExtIEDPlanDocLinkVO) iedDocLinkPage.getContent().get(0);
DxPageImpl docPage = extDxDocumentServiceFeign.findRecursion(SearchUtil.buildQuery("id", SearchItem.Operator.EQ, extIEDPlanDocLink.getTargetId()));
return (DxDocumentVO) docPage.getContent().get(0);
}
return null;
}
/**
* 状态英文转中文
* @param state
* @return
*/
public String getStateValue(String state){
return CommonUtils.searchDictDataValueByDictCode(Constants.OBJ_STATUS, state);
}
} }
...@@ -192,7 +192,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan ...@@ -192,7 +192,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
//文件编号 //文件编号
dxDocumentVO.setNumber(extIEDPlanVO.getFileNumber()); dxDocumentVO.setNumber(extIEDPlanVO.getFileNumber());
//文件名称
dxDocumentVO.setName(extIEDPlanVO.getFileName());
Map<String, Object> dynamicAttrs = new HashMap<>(); Map<String, Object> dynamicAttrs = new HashMap<>();
//文件代号 //文件代号
dynamicAttrs.put("fileNumber", extIEDPlanVO.getFileCode()); dynamicAttrs.put("fileNumber", extIEDPlanVO.getFileCode());
......
...@@ -271,5 +271,17 @@ public class WorkFlowUtil { ...@@ -271,5 +271,17 @@ public class WorkFlowUtil {
return processInfoVO; return processInfoVO;
} }
public boolean stopWf(DxDocumentVO doc){
DxWfProcessSearchVO dxWfProcessSearchVO = new DxWfProcessSearchVO();
dxWfProcessSearchVO.setPboClass(DxDocumentVO.class.getName());
dxWfProcessSearchVO.setPboId(doc.getVersionId());
Page<DxWfProcessVO> processList = wfcProcessFeign.getProcessList(dxWfProcessSearchVO, 1, 10);
if (!CollectionUtils.isEmpty(processList.getContent())) {
wfcProcessFeign.stopProcess( processList.getContent().get(0).getId());
return true;
}
return false;
}
} }
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