发票箱单导入调整;
parent
eb6a575312
commit
b5c15d34b0
|
|
@ -1,6 +1,5 @@
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Area;
|
|
||||||
import com.youchain.basicdata.domain.BillType;
|
import com.youchain.basicdata.domain.BillType;
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.repository.*;
|
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.Asn;
|
||||||
import com.youchain.businessdata.domain.AsnDetail;
|
import com.youchain.businessdata.domain.AsnDetail;
|
||||||
import com.youchain.businessdata.inputJson.imports.BaseImport;
|
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.repository.*;
|
||||||
import com.youchain.businessdata.service.*;
|
import com.youchain.businessdata.service.*;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
|
@ -36,8 +35,6 @@ public class ImportAsnServiceImpl implements ImportAsnService {
|
||||||
|
|
||||||
private final BillTypeRepository billTypeRepository;
|
private final BillTypeRepository billTypeRepository;
|
||||||
|
|
||||||
private final AreaService areaService;
|
|
||||||
|
|
||||||
private final ItemService itemService;
|
private final ItemService itemService;
|
||||||
|
|
||||||
private final AsnService asnService;
|
private final AsnService asnService;
|
||||||
|
|
@ -105,10 +102,14 @@ public class ImportAsnServiceImpl implements ImportAsnService {
|
||||||
String invoiceNo = cellValues.get("2-11");
|
String invoiceNo = cellValues.get("2-11");
|
||||||
|
|
||||||
// 读取sheet数据
|
// 读取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);
|
importAsnData(dataList);
|
||||||
|
|
@ -136,12 +137,10 @@ public class ImportAsnServiceImpl implements ImportAsnService {
|
||||||
//验证品番
|
//验证品番
|
||||||
Map<String, Item> exitItemMap = validateItem(itemCodes);
|
Map<String, Item> exitItemMap = validateItem(itemCodes);
|
||||||
|
|
||||||
//库区
|
|
||||||
Area area = areaService.findByCode(BaseStatus.DEFAULT_AREA);
|
|
||||||
|
|
||||||
//单据类型
|
//单据类型
|
||||||
BillType billType = billTypeRepository.findByName(BaseStatus.XDRK);
|
BillType billType = billTypeRepository.findByName(BaseStatus.XDRK);
|
||||||
Dept dept=UserUtils.getDept();
|
Dept dept = UserUtils.getDept();
|
||||||
Map<String, Asn> asnMap = new HashMap<>();
|
Map<String, Asn> asnMap = new HashMap<>();
|
||||||
List<Asn> insertToAsn = new ArrayList<>();//批量新增ASN
|
List<Asn> insertToAsn = new ArrayList<>();//批量新增ASN
|
||||||
List<AsnDetail> insertToAsnDetail = new ArrayList<>();//批量新增asnDetail
|
List<AsnDetail> insertToAsnDetail = new ArrayList<>();//批量新增asnDetail
|
||||||
|
|
@ -159,11 +158,11 @@ public class ImportAsnServiceImpl implements ImportAsnService {
|
||||||
Asn asn;
|
Asn asn;
|
||||||
if (asnMap.containsKey(code)) {
|
if (asnMap.containsKey(code)) {
|
||||||
asn = asnMap.get(code);
|
asn = asnMap.get(code);
|
||||||
asn.setOrderQuantity(asn.getOrderQuantity() +Double.parseDouble(orderQty));
|
asn.setOrderQuantity(asn.getOrderQuantity() + Double.parseDouble(orderQty));
|
||||||
} else {
|
} else {
|
||||||
asn = Asn.builder()
|
asn = Asn.builder()
|
||||||
.relatedBill1(relatedBill1)
|
.relatedBill1(relatedBill1)
|
||||||
.code(codeUtils.getCode_yyMMdd(billType.getPrefix()+'-', 3))
|
.code(codeUtils.getCode_yyMMdd(billType.getPrefix() + '-', 3))
|
||||||
.cusCode(code)
|
.cusCode(code)
|
||||||
.status(BizStatus.OPEN)
|
.status(BizStatus.OPEN)
|
||||||
.orderDate(new Timestamp(new Date().getTime()))
|
.orderDate(new Timestamp(new Date().getTime()))
|
||||||
|
|
@ -255,11 +254,19 @@ public class ImportAsnServiceImpl implements ImportAsnService {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("template3".equals(templateType)) {
|
} 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> requiredColumns = Collections.singletonList("(BOI)");
|
||||||
List<String> headers = FastExcelUtil.readHeadContent(file, requiredColumns, 0, 4);
|
List<String> headers = FastExcelUtil.readHeadContent(file, requiredColumns, 0, 23);
|
||||||
if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) {
|
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) {
|
private static List<BaseImport> invoicePackingDataProcess(String invoiceNo, List<InvoicePackingImport> sheet1Date, List<InvoicePackingImport> sheet2Date) {
|
||||||
List<BaseImport> dataList = new ArrayList<>();
|
//处理sheet1数据
|
||||||
for (invoicePackingImport data : sheetData1) {
|
List<InvoicePackingImport> newSheet1Date = new ArrayList<>();
|
||||||
if (data.getCNo() == null) {
|
for (InvoicePackingImport item : sheet1Date) {
|
||||||
break;
|
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()
|
BaseImport baseImport = BaseImport.builder()
|
||||||
.invoiceNo(invoiceNo)
|
.invoiceNo(invoiceNo)
|
||||||
.boi(data.getBoi())
|
.boi(t1.getBoi())
|
||||||
.poNo(data.getPoNo())
|
.poNo(t2.getPoNo())
|
||||||
.partNo(data.getPartNo())
|
.partNo(t2.getPartNo())
|
||||||
.description(data.getDescription())
|
.description(t2.getDescription())
|
||||||
.qty(data.getQty())
|
.qty(t2.getQty())
|
||||||
.cNo(data.getCNo())
|
.cNo(t2.getCNo())
|
||||||
.build();
|
.build();
|
||||||
dataList.add(baseImport);
|
dataList.add(baseImport);
|
||||||
|
|
||||||
}
|
}
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,11 @@
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Area;
|
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.domain.Point;
|
||||||
import com.youchain.basicdata.repository.BillTypeRepository;
|
|
||||||
import com.youchain.basicdata.repository.PointRepository;
|
import com.youchain.basicdata.repository.PointRepository;
|
||||||
import com.youchain.basicdata.service.*;
|
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.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.exception.BadRequestException;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class invoicePackingImport {
|
public class InvoicePackingImport {
|
||||||
|
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
private String invoiceNo;
|
private String invoiceNo;
|
||||||
|
|
||||||
@ExcelProperty("JOB NO")
|
@ExcelProperty("(BOI)")
|
||||||
private String boi;
|
private String boi;
|
||||||
|
|
||||||
@ExcelProperty("KMT NO. PO&LN NO.")
|
@ExcelProperty("KMT NO. PO&LN NO.")
|
||||||
Loading…
Reference in New Issue