Commit 59480e71 authored by wangqiang's avatar wangqiang

采购计划自动化任务功能

parent ff8c0826
...@@ -22,4 +22,6 @@ public interface ExtPuchasePlanAttributeService<V extends ExtPuchasePlanAttribut ...@@ -22,4 +22,6 @@ public interface ExtPuchasePlanAttributeService<V extends ExtPuchasePlanAttribut
public String importPurchasePlan(InputStream inputStream,String projectId); public String importPurchasePlan(InputStream inputStream,String projectId);
public String exportPurchasePlanFile(HttpServletResponse response, List<String> ids) throws IOException; public String exportPurchasePlanFile(HttpServletResponse response, List<String> ids) throws IOException;
public String autoImportPurchasePlan(long id);
} }
...@@ -3,6 +3,10 @@ package com.yonde.dcs.plan.core.service.impl; ...@@ -3,6 +3,10 @@ package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.feign.DocCenterFeignService;
import com.yonde.dcs.document.feign.shadow.DxDocumentFeignShadow;
import com.yonde.dcs.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.vo.ExtPuchasePlanExcelVO; import com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO;
import com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner; import com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner;
...@@ -31,6 +35,7 @@ import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO; ...@@ -31,6 +35,7 @@ import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService; import com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService;
import com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository; import com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository;
...@@ -60,7 +65,9 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut ...@@ -60,7 +65,9 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
private FileManagerFeignService fileManagerFeignService; private FileManagerFeignService fileManagerFeignService;
@Autowired @Autowired
private SystemFileFeignService systemFileFeignService; private SystemFileFeignService systemFileFeignService;
@Qualifier("com.yonde.dcs.feign.expand.ExtDxDocumentServiceFeign")
@Autowired
private ExtDxDocumentServiceFeign docCenterFeignService;
@Override @Override
public String importPurchasePlan(InputStream inputStream,String projectId) { public String importPurchasePlan(InputStream inputStream,String projectId) {
...@@ -122,6 +129,40 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut ...@@ -122,6 +129,40 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
return ApiResult.SUCCESS; return ApiResult.SUCCESS;
} }
/**
* 计划文件签审通过之后,调用该方法,自动导入计划
* @param id 文档id
* @return
*/
@Override
public String autoImportPurchasePlan(long id) {
InputStream inputStream = null;
CustomMultipartFile multipartFile = null;
Long fileId = null;
DxDocumentVO dxDocumentVO = docCenterFeignService.getDocumentWithFiles(id);
if(!ObjectUtils.isEmpty(dxDocumentVO)){
try {
fileId = dxDocumentVO.getObjFileLinks().get(0).getTarget().getId();
multipartFile = fileManagerFeignService.feignDownloadIO(fileId);
} catch (IOException e) {
log.info("[自动导入采购计划] >>> 文件服务下载文档附件:{}--失败!", fileId);
throw new DxBusinessException("500", "文件服务文档附件失败:" + fileId);
}
try {
inputStream = new ByteArrayInputStream(multipartFile.getBytes());
importPurchasePlan(inputStream,dxDocumentVO.getDxContextId().toString());
} catch (IOException e) {
log.info("[自动导入采购计划] >>> 文件服务下载的文件:{}--转换为输入流失败!", fileId);
throw new DxBusinessException("500", "文件服务下载的文件转换为输入流失败:" + fileId);
}
}else {
log.info("根据计划文档id:" + id + "未查到相关数据");
}
return ApiResult.SUCCESS;
}
/** /**
* 数据转换,将PO转换成EXCEL-VO; * 数据转换,将PO转换成EXCEL-VO;
* @param content * @param content
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yonde.dcs</groupId> <groupId>com.yonde.dcs</groupId>
<artifactId>dcs-doc-feign</artifactId> <artifactId>dcs-doc-expand-feign</artifactId>
<version>4.1-20240919-RELEASE</version> <version>4.1-20240919-RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -2,6 +2,7 @@ package com.yonde.dcs.plan.feign; ...@@ -2,6 +2,7 @@ package com.yonde.dcs.plan.feign;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO; import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.feign.shadow.ExtPuchasePlanAttributeServiceFeignShadow; import com.yonde.dcs.plan.feign.shadow.ExtPuchasePlanAttributeServiceFeignShadow;
...@@ -16,4 +17,8 @@ import com.yonde.dcs.plan.feign.shadow.ExtPuchasePlanAttributeServiceFeignShadow ...@@ -16,4 +17,8 @@ import com.yonde.dcs.plan.feign.shadow.ExtPuchasePlanAttributeServiceFeignShadow
@FeignClient(value = "${dcs.feign.INET-PLAN}", path = "/ExtPuchasePlanAttribute") @FeignClient(value = "${dcs.feign.INET-PLAN}", path = "/ExtPuchasePlanAttribute")
public interface ExtPuchasePlanAttributeServiceFeign<V extends ExtPuchasePlanAttributeVO> extends ExtPuchasePlanAttributeServiceFeignShadow<V> { public interface ExtPuchasePlanAttributeServiceFeign<V extends ExtPuchasePlanAttributeVO> extends ExtPuchasePlanAttributeServiceFeignShadow<V> {
@ApiOperation("采购计划自动导入")
@GetMapping(value = "/autoImportPurchasePlan")
public String autoImportPurchasePlan( @RequestParam("id")long id);
} }
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