发票箱单导入调整;
							parent
							
								
									eb6a575312
								
							
						
					
					
						commit
						b5c15d34b0
					
				| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
package com.youchain.basicdata.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.Area;
 | 
			
		||||
import com.youchain.basicdata.domain.BillType;
 | 
			
		||||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.repository.*;
 | 
			
		||||
| 
						 | 
				
			
			@ -8,7 +7,7 @@ import com.youchain.basicdata.service.*;
 | 
			
		|||
import com.youchain.businessdata.domain.Asn;
 | 
			
		||||
import com.youchain.businessdata.domain.AsnDetail;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.BaseImport;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.invoicePackingImport;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.InvoicePackingImport;
 | 
			
		||||
import com.youchain.businessdata.repository.*;
 | 
			
		||||
import com.youchain.businessdata.service.*;
 | 
			
		||||
import com.youchain.exception.BadRequestException;
 | 
			
		||||
| 
						 | 
				
			
			@ -36,8 +35,6 @@ public class ImportAsnServiceImpl implements ImportAsnService {
 | 
			
		|||
 | 
			
		||||
    private final BillTypeRepository billTypeRepository;
 | 
			
		||||
 | 
			
		||||
    private final AreaService areaService;
 | 
			
		||||
 | 
			
		||||
    private final ItemService itemService;
 | 
			
		||||
 | 
			
		||||
    private final AsnService asnService;
 | 
			
		||||
| 
						 | 
				
			
			@ -105,10 +102,14 @@ public class ImportAsnServiceImpl implements ImportAsnService {
 | 
			
		|||
        String invoiceNo = cellValues.get("2-11");
 | 
			
		||||
 | 
			
		||||
        // 读取sheet数据
 | 
			
		||||
        List<invoicePackingImport> sheetData1 = FastExcelUtil.readExcelData(file, invoicePackingImport.class, 0, 5);
 | 
			
		||||
        List<InvoicePackingImport> sheet1Data = FastExcelUtil.readExcelData(file, InvoicePackingImport.class, 0, 24);
 | 
			
		||||
 | 
			
		||||
        // 读取sheet数据
 | 
			
		||||
        List<InvoicePackingImport> sheet2Data = FastExcelUtil.readExcelData(file, InvoicePackingImport.class, 1, 5);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //发票箱单数据处理
 | 
			
		||||
        List<BaseImport> dataList = invoicePackingDataProcess(invoiceNo, sheetData1);
 | 
			
		||||
        List<BaseImport> dataList = invoicePackingDataProcess(invoiceNo, sheet1Data,sheet2Data);
 | 
			
		||||
 | 
			
		||||
        //批量导入
 | 
			
		||||
        importAsnData(dataList);
 | 
			
		||||
| 
						 | 
				
			
			@ -136,8 +137,6 @@ public class ImportAsnServiceImpl implements ImportAsnService {
 | 
			
		|||
        //验证品番
 | 
			
		||||
        Map<String, Item> exitItemMap = validateItem(itemCodes);
 | 
			
		||||
 | 
			
		||||
        //库区
 | 
			
		||||
        Area area = areaService.findByCode(BaseStatus.DEFAULT_AREA);
 | 
			
		||||
 | 
			
		||||
        //单据类型
 | 
			
		||||
        BillType billType = billTypeRepository.findByName(BaseStatus.XDRK);
 | 
			
		||||
| 
						 | 
				
			
			@ -255,11 +254,19 @@ public class ImportAsnServiceImpl implements ImportAsnService {
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
        } else if ("template3".equals(templateType)) {
 | 
			
		||||
            List<String> requiredColumns = Arrays.asList("A-PROS\n" + "CASE NO", "KMT NO. PO&LN NO.", "PART NO.", "DESCRIPTION", "Q'TY", "JOB NO");
 | 
			
		||||
            List<String> headers = FastExcelUtil.readHeadContent(file, requiredColumns, 0, 4);
 | 
			
		||||
            List<String> requiredColumns = Collections.singletonList("(BOI)");
 | 
			
		||||
            List<String> headers = FastExcelUtil.readHeadContent(file, requiredColumns, 0, 23);
 | 
			
		||||
            if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) {
 | 
			
		||||
                throw new BadRequestException("发票箱单导入模板不正确,请确认模板信息");
 | 
			
		||||
                throw new BadRequestException("发票箱单第1个Sheet目录模板不正确,请确认模板信息");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            List<String> requiredColumns2 = Arrays.asList("A-PROS\n" + "CASE NO", "KMT NO. PO&LN NO.", "PART NO.", "DESCRIPTION", "Q'TY");
 | 
			
		||||
            List<String> headers2 = FastExcelUtil.readHeadContent(file, requiredColumns2, 1, 4);
 | 
			
		||||
            if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns2, headers2)) {
 | 
			
		||||
                throw new BadRequestException("发票箱单第2个Sheet目录模板不正确,请确认模板信息");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -329,22 +336,47 @@ public class ImportAsnServiceImpl implements ImportAsnService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    //发票箱单数据处理
 | 
			
		||||
    private static List<BaseImport> invoicePackingDataProcess(String invoiceNo, List<invoicePackingImport> sheetData1) {
 | 
			
		||||
        List<BaseImport> dataList = new ArrayList<>();
 | 
			
		||||
        for (invoicePackingImport data : sheetData1) {
 | 
			
		||||
            if (data.getCNo() == null) {
 | 
			
		||||
                break;
 | 
			
		||||
    private static List<BaseImport> invoicePackingDataProcess(String invoiceNo, List<InvoicePackingImport> sheet1Date, List<InvoicePackingImport> sheet2Date) {
 | 
			
		||||
        //处理sheet1数据
 | 
			
		||||
        List<InvoicePackingImport> newSheet1Date = new ArrayList<>();
 | 
			
		||||
        for (InvoicePackingImport item : sheet1Date) {
 | 
			
		||||
            if (item.getBoi().toUpperCase().contains("TOTAL")) {
 | 
			
		||||
                break; // 不区分大小写 遇到TOTAL则停止添加
 | 
			
		||||
            }
 | 
			
		||||
            newSheet1Date.add(item);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //处理sheet2数据
 | 
			
		||||
        List<InvoicePackingImport> newSheet2Date = new ArrayList<>();
 | 
			
		||||
        for (InvoicePackingImport item : sheet2Date) {
 | 
			
		||||
            if (item.getPartNo().toUpperCase().contains("PACKAGES")) {
 | 
			
		||||
                break; // 不区分大小写 遇到TOTAL则停止添加
 | 
			
		||||
            }
 | 
			
		||||
            newSheet2Date.add(item);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (newSheet1Date.size() != newSheet2Date.size()) {
 | 
			
		||||
            throw new BadRequestException("发票箱单模板中数据行数不一致");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<BaseImport> dataList = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < newSheet1Date.size(); i++) {
 | 
			
		||||
            InvoicePackingImport t1 = newSheet1Date.get(i);//sheet1中的列数据
 | 
			
		||||
 | 
			
		||||
            InvoicePackingImport t2 = newSheet2Date.get(i);//sheet2中的列数据
 | 
			
		||||
 | 
			
		||||
            BaseImport baseImport = BaseImport.builder()
 | 
			
		||||
                    .invoiceNo(invoiceNo)
 | 
			
		||||
                    .boi(data.getBoi())
 | 
			
		||||
                    .poNo(data.getPoNo())
 | 
			
		||||
                    .partNo(data.getPartNo())
 | 
			
		||||
                    .description(data.getDescription())
 | 
			
		||||
                    .qty(data.getQty())
 | 
			
		||||
                    .cNo(data.getCNo())
 | 
			
		||||
                    .boi(t1.getBoi())
 | 
			
		||||
                    .poNo(t2.getPoNo())
 | 
			
		||||
                    .partNo(t2.getPartNo())
 | 
			
		||||
                    .description(t2.getDescription())
 | 
			
		||||
                    .qty(t2.getQty())
 | 
			
		||||
                    .cNo(t2.getCNo())
 | 
			
		||||
                    .build();
 | 
			
		||||
            dataList.add(baseImport);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return dataList;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,22 +1,11 @@
 | 
			
		|||
package com.youchain.basicdata.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.Area;
 | 
			
		||||
import com.youchain.basicdata.domain.BillType;
 | 
			
		||||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.repository.BillTypeRepository;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.basicdata.service.*;
 | 
			
		||||
import com.youchain.businessdata.domain.Asn;
 | 
			
		||||
import com.youchain.businessdata.domain.AsnDetail;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.BaseImport;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.PointImport;
 | 
			
		||||
import com.youchain.businessdata.inputJson.imports.invoicePackingImport;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnDetailRepository;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AsnService;
 | 
			
		||||
import com.youchain.exception.BadRequestException;
 | 
			
		||||
import com.youchain.modules.system.domain.Dept;
 | 
			
		||||
import com.youchain.utils.*;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,12 @@ import lombok.NoArgsConstructor;
 | 
			
		|||
@Builder
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class invoicePackingImport {
 | 
			
		||||
public class InvoicePackingImport {
 | 
			
		||||
 | 
			
		||||
    @ExcelIgnore
 | 
			
		||||
    private String invoiceNo;
 | 
			
		||||
 | 
			
		||||
    @ExcelProperty("JOB NO")
 | 
			
		||||
    @ExcelProperty("(BOI)")
 | 
			
		||||
    private String boi;
 | 
			
		||||
 | 
			
		||||
    @ExcelProperty("KMT NO. PO&LN NO.")
 | 
			
		||||
		Loading…
	
		Reference in New Issue