|
@@ -1,17 +1,5 @@
|
|
|
package com.lote.wms.instock.order.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import com.lote.wms.common.config.SystemConfig;
|
|
|
import com.lote.wms.common.model.Message;
|
|
|
import com.lote.wms.common.utils.BeanUtil;
|
|
@@ -24,6 +12,13 @@ import com.lote.wms.instock.order.entity.queryvo.InOrderQueryVo;
|
|
|
import com.lote.wms.instock.order.entity.resultvo.InOrderResultVo;
|
|
|
import com.lote.wms.instock.order.service.InOrderExportService;
|
|
|
import com.lote.wms.instock.order.service.InOrderService;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class InOrderExportServiceImpl implements InOrderExportService {
|
|
@@ -92,6 +87,85 @@ public class InOrderExportServiceImpl implements InOrderExportService {
|
|
|
return Message.fail("系统异常,请稍后重试!");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Message exportReceiptDetail(InOrderQueryVo vo) {
|
|
|
+
|
|
|
+ BeanUtil.trimString(InOrderQueryVo.class, vo);
|
|
|
+
|
|
|
+ if (!StringUtil.isEmpty(vo.getOrderNos())) {
|
|
|
+ vo.setOrderNoList(Arrays.asList(vo.getOrderNos().replaceAll("[\\s,;'\\.\"。,]+", " ").split(" ")));
|
|
|
+ }
|
|
|
+ if (Objects.isNull(vo.getIdList()) || vo.getIdList().size() == 0) {
|
|
|
+ return Message.fail("请先选择入库单导出。");
|
|
|
+ }
|
|
|
+ List<InOrderResultVo> inOrderResultVoList = inOrderMapper.selectForExportReceiptDetail(vo);// 获得所有的入库单
|
|
|
+ if (Objects.isNull(inOrderResultVoList) || inOrderResultVoList.size() == 0) {
|
|
|
+ return Message.fail("所选择的入库单无收货明细,请先完成收货。");
|
|
|
+ }
|
|
|
+
|
|
|
+ int countForExport = inOrderResultVoList.size();
|
|
|
+ Sheet sheet = null;
|
|
|
+
|
|
|
+ String headCnStrList[] = new String[]{"入库单号", "仓库代码", "货主代码", "入库类型", "供应商代码", "运输方式", "跟踪号码", "商品SKU", "商品条码",
|
|
|
+ "商品名称","商品品质","收货数量", "生产日期", "保质天数", "过期时间", "批次号", "批次号规则", "收货人","收货时间" };
|
|
|
+
|
|
|
+ List<String> headCnList = Arrays.asList(headCnStrList);
|
|
|
+
|
|
|
+ try {
|
|
|
+ sheet = POIExcelUtil.createSheet("入库单收货明细", headCnList);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 转换成行
|
|
|
+ List<String[]> row = parseRowByReceiptDetail(inOrderResultVoList, headCnList);
|
|
|
+ // 保存到excel中
|
|
|
+ POIExcelUtil.addRows(sheet, row);
|
|
|
+
|
|
|
+ // 保存到临时文件返回路径 TODO
|
|
|
+ try {
|
|
|
+ // 随机生成文件
|
|
|
+ String fileName = UUID.randomUUID().toString() + ".xlsx";
|
|
|
+ File tempFile = new File(systemConfig.getRuntimeFileDir() + "/inorder/");
|
|
|
+ if (!tempFile.exists()) {
|
|
|
+ tempFile.mkdirs();
|
|
|
+ }
|
|
|
+ String fileNameAndPath = systemConfig.getRuntimeFileDir() + "/inorder/" + fileName;
|
|
|
+ POIExcelUtil.saveToFile(sheet, fileNameAndPath);
|
|
|
+
|
|
|
+ // 上传文件服务器
|
|
|
+ String downUrl = FileServerClient.fileUpload(systemConfig.getFileServerUrl(), fileNameAndPath);
|
|
|
+ return Message.success(downUrl);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Message.fail("系统异常,请稍后重试!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String[]> parseRowByReceiptDetail(List<InOrderResultVo> inOrderResultVoList, List<String> headCnList) {
|
|
|
+ // String headCnStrList[] = new String[]{"入库单号", "仓库代码", "货主代码", "入库类型", "供应商代码", "运输方式", "跟踪号码", "商品SKU", "商品条码",
|
|
|
+ // "商品名称","商品品质","收货数量", "生产日期", "保质天数", "过期时间", "批次号", "批次号规则", "收货人","收货时间" };
|
|
|
+ List<String[]> rows = new ArrayList<>();
|
|
|
+ for (InOrderResultVo inOrderResultVo : inOrderResultVoList) {
|
|
|
+ String[] row = new String[headCnList.size()];
|
|
|
+ row[0] = inOrderResultVo.getOrderNo1();
|
|
|
+ row[1] = inOrderResultVo.getWarehouseCode();
|
|
|
+ row[2] = inOrderResultVo.getCustomerCode();
|
|
|
+ row[3] = inOrderResultVo.getTypeName();
|
|
|
+ row[4] = inOrderResultVo.getSupplierCode();
|
|
|
+ row[5] = inOrderResultVo.getShipwayCode();
|
|
|
+ row[6] = inOrderResultVo.getTrackingNo1();
|
|
|
+ row[7] = inOrderResultVo.getSku();
|
|
|
+ row[8] = inOrderResultVo.getBarcode();
|
|
|
+ row[9] = inOrderResultVo.getCustomerCode();
|
|
|
+ row[10] = inOrderResultVo.getTypeName();
|
|
|
+ row[11] = inOrderResultVo.getRemark();
|
|
|
+ row[12] = inOrderResultVo.getShipwayCode();
|
|
|
+ row[13] = inOrderResultVo.getTrackingNo1();
|
|
|
+
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+
|
|
|
private List<String[]> parseRow(List<InOrderResultVo> selectByExport, List<String> headCnList) {
|
|
|
List<String[]> rows = new ArrayList<>();
|
|
|
for (InOrderResultVo inOrderResultVo : selectByExport) {
|