Commit 813cef9f authored by 侯彦文's avatar 侯彦文

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtPuchasePlanAttributeServiceImpl.java
parents 505a08da 0d23dee0
......@@ -68,6 +68,24 @@ public class ExtPuchasePlanAttributeController<V extends ExtPuchasePlanAttribute
public ApiResult autoImportPurchasePlan( @RequestParam("id")long id){
return ApiResult.ok(extPuchasePlanAttributeService.autoImportPurchasePlan(id),"采购计划自动导入成功");
}
/**
* 导入采购计划
*
* @param fileId
* @param projectId
* @param projectSecret
* @return
* @throws IOException
*/
@ApiOperation("校验上传的excel中的采购计划列表是否合法")
@PostMapping(value = "/verifyExcelDataIsValid")
public ApiResult verifyExcelDataIsValid(@RequestParam(value = "fileId",required = true)Long fileId,
@RequestParam(value ="projectId",required = true) String projectId,
@RequestParam(value ="projectSecret",required = true) String projectSecret)
throws IOException {
return ApiResult.ok(extPuchasePlanAttributeService.verifyExcelDataIsValid(fileId,projectId,projectSecret),"校验成功!");
}
}
package com.yonde.dcs.plan.core.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.util.ListUtils;
import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO;
import com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService;
import com.yonde.dcs.plan.core.util.CommonUtils;
import com.yonde.dcs.plan.core.util.UserUtils;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.basic.feign.expand.ExtDxContextProjectServiceFeign;
import com.yonde.dex.context.common.vo.DxContextProjectVO;
import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.dao.service.util.DxPageUtils;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.servlet.ServletContextListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Component
@Slf4j
public class PurchasePlanExcelDataVerifyListenner extends AnalysisEventListener<ExtPuchasePlanExcelVO> implements ServletContextListener {
private ExtPuchasePlanAttributeService extPuchasePlanAttributeService;
/**
* 每隔100条处理下,然后清理list ,方便内存回收
*/
private static final int BATCH_COUNT = 100;
private String projectId;
private String projectSecret;
/**
* 密级列别
*/
private Map<Integer,String> securityList = new ConcurrentHashMap();
/**
* excel数据行数
*/
private Integer excelDataRow = 0;
/**
* 错误信息列表
*/
private List<StringBuffer> errorList = new ArrayList<>();
private UserUtils userUtils;
/**
* 缓存的数据
*/
private List<ExtPuchasePlanExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
public PurchasePlanExcelDataVerifyListenner() {}
public PurchasePlanExcelDataVerifyListenner(String projectId,String projectSecret) {
this.extPuchasePlanAttributeService = ApplicationContextUtil.getBean(ExtPuchasePlanAttributeService.class);
this.userUtils = ApplicationContextUtil.getBean(UserUtils.class);
this.projectId = projectId;
this.projectSecret = projectSecret;
}
@Override
public void invoke(ExtPuchasePlanExcelVO extPuchasePlanExcelVO, AnalysisContext analysisContext) {
log.info("解析到一条数据:{}", extPuchasePlanExcelVO);
if(!CommonUtils.checkAllPropertiesIsEmpty(extPuchasePlanExcelVO)){
excelDataRow++;
cachedDataList.add(extPuchasePlanExcelVO);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 收尾工作,处理剩下的缓存数据。。。
log.info("sheet={} 所有数据解析完成!", analysisContext.readSheetHolder().getSheetName());
//校验表格中的数据是否合法
List<StringBuffer> errList = checkPurchasePlanExcelData();
if (errList.size() > 0) {
throw new DxBusinessException("-1", "导入采购计划数据有误!!" + errList.toString());
}
//清理list ,方便内存回收
cachedDataList.clear();
errorList.clear();
excelDataRow = 0;
}
/**
* @param exception
* @param context
* @throws Exception
*/
@Override
public void onException(Exception exception, AnalysisContext context) throws Exception {
log.error("======>>>解析异常:", exception);
throw exception;
}
/**
* 检查采购计划数据的合法性
*
* @return
*/
public List<StringBuffer> checkPurchasePlanExcelData() {
if (cachedDataList.size() > 0) {
for (ExtPuchasePlanExcelVO extPuchasePlanExcelVO : cachedDataList) {
StringBuffer errString = new StringBuffer();
//校验excel必填字段是否有效
verifyExcelRequiredFields(extPuchasePlanExcelVO,errString);
//校验新增,更新,删除的逻辑
if(!StringUtils.isEmpty(extPuchasePlanExcelVO.getOperation()) && !StringUtils.isEmpty(extPuchasePlanExcelVO.getPlanCode())){
ExtPuchasePlanAttributeVO extPuchasePlanAttributeVO = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode(),false);
if(Constants.EXCEL_ADD.equals(extPuchasePlanExcelVO.getOperation())){
if(!ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("解析到数据第"+excelDataRow+"行,新增计划编号:" + extPuchasePlanExcelVO.getPlanCode() + "已存在,不能重复导入,新增失败!!");
errorList.add(errString);
}
}else if(Constants.EXCEL_UPDATE.equals(extPuchasePlanExcelVO.getOperation())){
if(ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:"+extPuchasePlanExcelVO.getPlanCode()+"在数据库不存在,更新失败!!");
errorList.add(errString);
}
}else if(Constants.EXCEL_DELETE.equals(extPuchasePlanExcelVO.getOperation())){
if(ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:"+extPuchasePlanExcelVO.getPlanCode()+"在数据库不存在,删除失败!!");
errorList.add(errString);
}
}else{
errString.append("解析到数据第"+excelDataRow+",行无法识别该操作符:"+extPuchasePlanExcelVO.getOperation());
errorList.add(errString);
}
}else {
errString.append("解析到数据第"+excelDataRow+"行,的操作符或计划编码不能为空!");
errorList.add(errString);
}
}
}
return errorList;
}
/**
* //校验excel必填字段是否有效
* @param extPuchasePlanExcelVO
* @param errString
*/
private void verifyExcelRequiredFields(ExtPuchasePlanExcelVO extPuchasePlanExcelVO, StringBuffer errString) {
//外协项目不能为空
if(StringUtils.isEmpty(extPuchasePlanExcelVO.getOutsourceProjectName())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的外协(外购)项目名称不能为空");
errorList.add(errString);
return;
}
//采购技术提交时间不能为空
if(ObjectUtils.isEmpty(extPuchasePlanExcelVO.getPurDesignFileSubmitTime())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的采购文件提交时间不能为空");
errorList.add(errString);
return;
}
//合同签订时间不能为空
if(ObjectUtils.isEmpty(extPuchasePlanExcelVO.getContractActualSigningTime())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的合同签订时间不能为空");
errorList.add(errString);
return;
}
//合同交付时间不能为空
if(ObjectUtils.isEmpty(extPuchasePlanExcelVO.getContractActualDeliveryTime())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的合同交付时间不能为空");
errorList.add(errString);
return;
}
//采购技术负责人
if(StringUtils.isEmpty(extPuchasePlanExcelVO.getPurDesignFileManager())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的采购技术文件负责人不能为空");
errorList.add(errString);
return;
}else {
DxUserInfoVO dxUserInfoVO= userUtils.getUserByName(extPuchasePlanExcelVO.getPurDesignFileManager());
if(ObjectUtils.isEmpty(dxUserInfoVO)){
errString.append("解析到数据第"+excelDataRow+"行,计划文件编号为:" + extPuchasePlanExcelVO.getPlanCode() + "的采购技术负责人在系统中未查到!!");
errorList.add(errString);
return;
}else {
extPuchasePlanExcelVO.setPurDesignFileManager(String.valueOf(dxUserInfoVO.getId()));
}
}
if(StringUtils.isEmpty(extPuchasePlanExcelVO.getSecretCode())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的密级不能为空");
errorList.add(errString);
return;
} else {
//校验密级,计划密级不能大于项目密级
if(!CommonUtils.verifySecretLevel(projectSecret,extPuchasePlanExcelVO.getSecretCode())){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:" + extPuchasePlanExcelVO.getPlanCode() + "的密级不能大于项目密级");
errorList.add(errString);
return;
}
}
}
/**
* 根据计划编号查询计划
* @param planCode
* @param delete true已删除 false 未删除
* @return
*/
public ExtPuchasePlanAttributeVO getPurchasePlanByPlanCode(String planCode,Boolean delete){
SearchItems purchasePlanSearch = new SearchItems();
SearchItem planCodeFilter = new SearchItem("planCode", SearchItem.Operator.EQ, planCode, (Object)null);
SearchItem projectIdFilter = new SearchItem("dxContextId", SearchItem.Operator.EQ, projectId, (Object)null);
SearchItem deleteFilter = new SearchItem("deleted", SearchItem.Operator.EQ, delete, (Object)null);
purchasePlanSearch.addItem(planCodeFilter);
purchasePlanSearch.addItem(projectIdFilter);
purchasePlanSearch.addItem(deleteFilter);
SearchQueryCondition searchQuery = SearchQueryCondition.builder().searchItems(purchasePlanSearch).build();
//根据计划编号获取数据库中采购计划数据
//DxPageImpl<ExtPuchasePlanAttributeVO> dxPuchasePlanPage = extPuchasePlanAttributeService.findRecursion(SearchUtil.buildQuery("planCode", SearchItem.Operator.EQ, planCode));
DxPageImpl<ExtPuchasePlanAttributeVO> dxPuchasePlanPage = extPuchasePlanAttributeService.findRecursion(searchQuery);
if (!CollectionUtils.isEmpty(dxPuchasePlanPage.getContent())) {
ExtPuchasePlanAttributeVO extPurPlanForDB = DxPageUtils.getFirst(dxPuchasePlanPage);
return extPurPlanForDB;
}else {
log.info("根据计划编号:{},未查到相关计划",planCode);
}
return null;
}
}
......@@ -109,12 +109,12 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
extPuchasePlanAttributeService.saveRecursion(extPuchasePlanAttributeVO);
} else if (Constants.EXCEL_UPDATE.equals(extPuchasePlanExcelVO.getOperation())) { //更新
//根据计划编号获取采购计划
ExtPuchasePlanAttributeVO purPlanForDB = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode());
ExtPuchasePlanAttributeVO purPlanForDB = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode(),false);
purPlanForDB.setOperator(OperatorType.MODIFY);
extPuchasePlanAttributeService.saveRecursion(transformObject(purPlanForDB,extPuchasePlanExcelVO));
} else if (Constants.EXCEL_DELETE.equals(extPuchasePlanExcelVO.getOperation())) { //删除;
//根据计划编号获取采购计划
ExtPuchasePlanAttributeVO purPlanForDB = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode());
ExtPuchasePlanAttributeVO purPlanForDB = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode(),false);
purPlanForDB.setOperator(OperatorType.REMOVE);
extPuchasePlanAttributeService.remove(purPlanForDB.getId());
} else {
......@@ -175,24 +175,31 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
StringBuffer errString = new StringBuffer();
//校验excel必填字段是否有效
verifyExcelRequiredFields(extPuchasePlanExcelVO,errString);
//校验新增,更新,删除的逻辑
if(!StringUtils.isEmpty(extPuchasePlanExcelVO.getOperation()) && !StringUtils.isEmpty(extPuchasePlanExcelVO.getPlanCode())){
if(Constants.EXCEL_ADD.equals(extPuchasePlanExcelVO.getOperation()) && StringUtils.isNotEmpty(extPuchasePlanExcelVO.getPlanCode())){
ExtPuchasePlanAttributeVO extPuchasePlanAttributeVO = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode());
ExtPuchasePlanAttributeVO extPuchasePlanAttributeVO = getPurchasePlanByPlanCode(extPuchasePlanExcelVO.getPlanCode(),false);
if(Constants.EXCEL_ADD.equals(extPuchasePlanExcelVO.getOperation())){
if(!ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("新增计划编号:" + extPuchasePlanExcelVO.getPlanCode() + "已存在,不能重复导入!!");
errString.append("解析到数据第"+excelDataRow+"行,新增计划编号:" + extPuchasePlanExcelVO.getPlanCode() + "已存在,不能重复导入,新增失败!!");
errorList.add(errString);
}
}else if(Constants.EXCEL_UPDATE.equals(extPuchasePlanExcelVO.getOperation())){
if(ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:"+extPuchasePlanExcelVO.getPlanCode()+"在数据库不存在,更新失败!!");
errorList.add(errString);
}
}else if(Constants.EXCEL_DELETE.equals(extPuchasePlanExcelVO.getOperation())){
if(ObjectUtils.isEmpty(extPuchasePlanAttributeVO)){
errString.append("解析到数据第"+excelDataRow+"行,计划编号是:"+extPuchasePlanExcelVO.getPlanCode()+"在数据库不存在,删除失败!!");
errorList.add(errString);
}
}else if(Constants.EXCEL_UPDATE.equals(extPuchasePlanExcelVO.getOperation()) && StringUtils.isEmpty(extPuchasePlanExcelVO.getPlanCode())){
errString.append("更新计划编号:项目代号为" + extPuchasePlanExcelVO.getProjectCode() + "的计划编号不能为空");
errorList.add(errString);
}else if(Constants.EXCEL_DELETE.equals(extPuchasePlanExcelVO.getOperation()) && StringUtils.isEmpty(extPuchasePlanExcelVO.getPlanCode())){
errString.append("删除计划编号:项目代号为" + extPuchasePlanExcelVO.getProjectCode() + "的计划编号不能为空");
errorList.add(errString);
}else{
log.info("无法识别该操作符:"+extPuchasePlanExcelVO.getOperation());
errString.append("解析到数据第"+excelDataRow+",行无法识别该操作符:"+extPuchasePlanExcelVO.getOperation());
errorList.add(errString);
}
}else {
errString.append("项目代号为" + extPuchasePlanExcelVO.getProjectCode() + "的操作符不能为空");
errString.append("解析到数据第"+excelDataRow+"行,的操作符或计划编码不能为空");
errorList.add(errString);
}
......@@ -257,15 +264,18 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
/**
* 根据计划编号查询计划
* @param planCode
* @param deleteFlag true已删除 false未删除
* @return
*/
public ExtPuchasePlanAttributeVO getPurchasePlanByPlanCode(String planCode){
public ExtPuchasePlanAttributeVO getPurchasePlanByPlanCode(String planCode,boolean deleteFlag){
SearchItems purchasePlanSearch = new SearchItems();
SearchItem planCodeFilter = new SearchItem("planCode", SearchItem.Operator.EQ, planCode, (Object)null);
SearchItem projectIdFilter = new SearchItem("dxContextId", SearchItem.Operator.EQ, projectId, (Object)null);
SearchItem deleteFilter = new SearchItem("deleted", SearchItem.Operator.EQ, deleteFlag, (Object)null);
purchasePlanSearch.addItem(planCodeFilter);
purchasePlanSearch.addItem(projectIdFilter);
purchasePlanSearch.addItem(deleteFilter);
SearchQueryCondition searchQuery = SearchQueryCondition.builder().searchItems(purchasePlanSearch).build();
//根据计划编号获取数据库中采购计划数据
......
......@@ -24,4 +24,6 @@ public interface ExtPuchasePlanAttributeService<V extends ExtPuchasePlanAttribut
public String exportPurchasePlanFile(HttpServletResponse response, List<String> ids) throws IOException;
public String autoImportPurchasePlan(long id);
public String verifyExcelDataIsValid(Long fileId,String projectId,String projectSecret);
}
......@@ -3,18 +3,15 @@ package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.core.io.FileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.inet.dcs.document.feign.expand.ExtDxDocumentServiceFeign;
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.vo.ExtPuchasePlanAttributeVO;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO;
import com.yonde.dcs.plan.core.listener.PurchasePlanExcelDataVerifyListenner;
import com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner;
import com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository;
import com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService;
import com.yonde.dcs.plan.core.util.CommonUtils;
import com.yonde.dcs.plan.core.util.FileUtils;
import com.yonde.dcs.plan.core.util.ResourceHelper;
import com.yonde.dcs.plan.entity.po.ExtPuchasePlanAttribute;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
......@@ -25,20 +22,28 @@ import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dfs.feign.FileManagerFeignService;
import com.yonde.dex.dfs.feign.RepoFileFeignService;
import com.yonde.dex.systemfile.feign.SystemFileFeignService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService;
import com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository;
import com.yonde.dcs.plan.entity.po.ExtPuchasePlanAttribute;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* @description: ExtPuchasePlanAttribute-ServiceImpl
* @author: dexadmin
......@@ -65,7 +70,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
@Override
public String importPurchasePlan(InputStream inputStream, String projectId) {
public String importPurchasePlan(InputStream inputStream,String projectId) {
EasyExcel.read(inputStream, ExtPuchasePlanExcelVO.class,
new PurchasePlanExcelReadListenner(projectId))
.sheet()
......@@ -105,7 +110,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
throw new DxBusinessException("500", "文件服务下载的文件转换为输入流失败:" + fileId);
}
String dir = ResourceHelper.CreateTemDir().getPath();
String filePath = dir + Constants.PURCHASE_PLAN_EXCEL_NAME;
String filePath = dir+ Constants.PURCHASE_PLAN_EXCEL_NAME;
//创建采购计划列表.xlsx 文件
FileUtils.inputToFile(inputStream, filePath);
//向表格中写入数据
......@@ -126,8 +131,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
/**
* 计划文件签审通过之后,调用该方法,自动导入计划
*
* @param id 文档id
* @param id 文档id
* @return
*/
@Override
......@@ -137,7 +141,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
CustomMultipartFile multipartFile = null;
Long fileId = null;
DxDocumentVO dxDocumentVO = docCenterFeignService.getDocumentWithFiles(id);
if (!ObjectUtils.isEmpty(dxDocumentVO)) {
if(!ObjectUtils.isEmpty(dxDocumentVO)){
try {
//todo 取固定类型附件
fileId = dxDocumentVO.getObjFileLinks().get(0).getTarget().getId();
......@@ -148,21 +152,23 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
}
try {
inputStream = new ByteArrayInputStream(multipartFile.getBytes());
importPurchasePlan(inputStream, dxDocumentVO.getDxContextId().toString());
importPurchasePlan(inputStream,dxDocumentVO.getDxContextId().toString());
} catch (IOException e) {
log.info("[自动导入采购计划] >>> 文件服务下载的文件:{}--转换为输入流失败!", fileId);
throw new DxBusinessException("500", "文件服务下载的文件转换为输入流失败:" + fileId);
}
} else {
}else {
log.info("根据计划文档id:" + id + "未查到相关数据");
}
return ApiResult.SUCCESS;
}
/**
* 数据转换,将PO转换成EXCEL-VO;
*
* @param content
* @return
*/
......@@ -185,6 +191,32 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
}
return extPuchasePlanExcelVOList;
}
/**
* 在采购计划设计文件走流程之前校验一下主内容的excel表格中的数据是否有效
* @param fileId
* @param projectId
* @return
*/
@Override
public String verifyExcelDataIsValid(Long fileId, String projectId,String projectSecret) {
MultipartFile multipartFile = null;
InputStream inputStream = null;
try {
multipartFile = fileManagerFeignService.feignDownloadIO(fileId);
inputStream = new ByteArrayInputStream(multipartFile.getBytes());
} catch (IOException e) {
throw new DxBusinessException("-1","文件id:"+fileId+"在系统中未找到!");
}
EasyExcel.read(inputStream, ExtPuchasePlanExcelVO.class,
new PurchasePlanExcelDataVerifyListenner(projectId,projectSecret))
.sheet()
.doRead();
return ApiResult.SUCCESS;
}
}
package com.yonde.dcs.plan.core.util;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import lombok.extern.slf4j.Slf4j;
import mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......@@ -11,6 +14,7 @@ import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -120,4 +124,31 @@ public class CommonUtils {
}
return dictMap.get(key);
}
/**
* 校验密级等级
* @return
*/
public static Boolean verifySecretLevel(String sourceSecret,String targetSecret){
Map<Object,Object> secretMap= new LinkedHashMap<>();
secretMap.put("公开",1);
secretMap.put("非密",2);
secretMap.put("内部",3);
secretMap.put("秘密",4);
secretMap.put("机密",5);
Integer sourceLevel = (Integer) secretMap.get(sourceSecret);
Integer targetLevel = (Integer) secretMap.get(targetSecret);
if(ObjectUtils.isEmpty(sourceLevel)){
throw new DxBusinessException("-1","原密级不存在,请检查数据!");
}else if (ObjectUtils.isEmpty(targetLevel)){
throw new DxBusinessException("-1","目标密级不存在,请检查数据!");
}else {
if(targetLevel > sourceLevel){
return false;
}
return true;
}
}
}
\ No newline at end of file
......@@ -53,6 +53,11 @@
<artifactId>inet-doc-expand-feign</artifactId>
<version>4.1-20240919-RELEASE</version>
</dependency>
<dependency>
<groupId>com.yonde.dex</groupId>
<artifactId>dex-basic-service-expand-feign</artifactId>
<version>4.1-20240919-RELEASE</version>
</dependency>
<dependency>
<groupId>com.yonde.dex</groupId>
<artifactId>dex-basic-service-feign</artifactId>
......
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