|
|
@ -221,154 +221,6 @@ public class GdInventoryOkService extends MybatisBaseService<GdInventoryOkMapper |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
private RowHandler createRowHandler(GdInventoryLog gdlog) { |
|
|
|
return new RowHandler() { |
|
|
|
private static final int BATCH_COUNT = 900; |
|
|
|
private List<GdInventoryOk> toInsertList = new ArrayList<>(); |
|
|
|
private List<GdInventoryYc> toInsertListYc = new ArrayList<>(); |
|
|
|
private List<GdInventoryLogErr> errList = new ArrayList<>(); |
|
|
|
private int x = 0, y = 0, z = 0, errnum = 0; |
|
|
|
private int num = 0, numyc = 0; |
|
|
|
private String odate = null; |
|
|
|
|
|
|
|
private Map<String, Object> readMapFromRow(List<Object> r) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("orgCode", r.get(0));// 企业组织机构代码证
|
|
|
|
map.put("warehouseCode", "" + r.get(1));// 仓库/门店编号
|
|
|
|
map.put("warehouseName", r.get(2)); // 仓库/门店名称
|
|
|
|
map.put("prodCode", "" + r.get(7)); // 商品编码
|
|
|
|
map.put("prodBarCode", r.get(8));// 商品条码
|
|
|
|
map.put("prodName", r.get(9)); // 商品名称
|
|
|
|
map.put("warehouseType", r.get(10)); // 仓库类型
|
|
|
|
map.put("prodNum", r.get(11)); // 商品数量
|
|
|
|
map.put("prodValue", r.get(12)); // 商品货值
|
|
|
|
map.put("suppliderName", r.get(13)); // 供应商
|
|
|
|
map.put("datadate", r.get(14)); // 数据日期
|
|
|
|
|
|
|
|
|
|
|
|
map.put("typeCode", r.get(3)); // 类别编号
|
|
|
|
map.put("typeName", r.get(4)); // 类别名称
|
|
|
|
map.put("typeOne", r.get(5)); // 一级类别名称
|
|
|
|
map.put("typeTwo", r.get(6)); // 二级类别名称
|
|
|
|
|
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
private GdInventoryLogErr createErrorInfo(List<Object> r, String errInfo) { |
|
|
|
GdInventoryLogErr gile = new GdInventoryLogErr(); |
|
|
|
gile.setRowNum(x + 1); |
|
|
|
gile.setErrInfo(errInfo); |
|
|
|
gile.setFileFullPath(gdlog.getFileFullPath()); |
|
|
|
gile.setRowContent(JSONUtil.toJsonStr(r)); |
|
|
|
gile.setProdCode("" + r.get(7)); |
|
|
|
gile.setProdName("" + r.get(9)); |
|
|
|
gile.setProdNum("" + r.get(11)); |
|
|
|
gile.setProdValue("" + r.get(12)); |
|
|
|
gile.setSupplierCode(""); |
|
|
|
gile.setSupplierName("" + r.get(13)); |
|
|
|
gile.setOrderDate(odate); |
|
|
|
return gile; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean checkYcProd(String typeCode) { |
|
|
|
if (StrUtil.isBlank(typeCode)) |
|
|
|
return false; |
|
|
|
if (typeCode.length() < 4) |
|
|
|
return false; |
|
|
|
String subCode = typeCode.substring(0, 4); |
|
|
|
return "0811".equals(subCode) || "0813".equals(subCode) || "0815".equals(subCode); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handle(int sheetIndex, long rowIndex, List<Object> r) { |
|
|
|
if (rowIndex > 0) { |
|
|
|
String typeCode = "" + r.get(3); |
|
|
|
String prodCode = "" + r.get(7); |
|
|
|
String warehouseCode = "" + r.get(1); |
|
|
|
|
|
|
|
if (StrUtil.isBlank(odate)) { |
|
|
|
odate = "" + r.get(14); |
|
|
|
gdlog.setOrderDate(odate); |
|
|
|
} |
|
|
|
|
|
|
|
// System.out.println(",X:" + x + ",prodCode:" + prodCode);
|
|
|
|
|
|
|
|
if (gdRescategoryProdService.containsCode(prodCode) && storeIndexService.containsCodeWithOneNoJmd(warehouseCode)) { |
|
|
|
GdInventoryOk ok = new GdInventoryOk(); |
|
|
|
Map<String, Object> map = readMapFromRow(r); |
|
|
|
|
|
|
|
try { |
|
|
|
BeanUtil.fillBeanWithMap(map, ok, true); |
|
|
|
toInsertList.add(ok); |
|
|
|
y++; |
|
|
|
} catch (Exception e) { |
|
|
|
errnum++; |
|
|
|
GdInventoryLogErr gile = createErrorInfo(r, e.getMessage()); |
|
|
|
errList.add(gile); |
|
|
|
} |
|
|
|
|
|
|
|
if (990 == num) { |
|
|
|
GdInventoryOkService.this.saveBatch(toInsertList); |
|
|
|
num = 0; |
|
|
|
toInsertList.clear(); |
|
|
|
} else { |
|
|
|
num++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (checkYcProd(prodCode) && storeInfoService.containsCodeOfYcNoJmd(warehouseCode)) { |
|
|
|
GdInventoryYc yc = new GdInventoryYc(); |
|
|
|
Map<String, Object> map = readMapFromRow(r); |
|
|
|
|
|
|
|
try { |
|
|
|
BeanUtil.fillBeanWithMap(map, yc, true); |
|
|
|
toInsertListYc.add(yc); |
|
|
|
z++; |
|
|
|
} catch (Exception e) { |
|
|
|
errnum++; |
|
|
|
GdInventoryLogErr gile = createErrorInfo(r, e.getMessage()); |
|
|
|
errList.add(gile); |
|
|
|
} |
|
|
|
|
|
|
|
if (990 == numyc) { |
|
|
|
gdInventoryYcService.saveBatch(toInsertListYc); |
|
|
|
numyc = 0; |
|
|
|
toInsertListYc.clear(); |
|
|
|
} else { |
|
|
|
numyc++; |
|
|
|
} |
|
|
|
} |
|
|
|
x++; |
|
|
|
// System.out.println(",X:" + x + ",Y:" + y);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handleCell(int sheetIndex, long rowIndex, int cellIndex, Object value, CellStyle xssfCellStyle) { |
|
|
|
RowHandler.super.handleCell(sheetIndex, rowIndex, cellIndex, value, xssfCellStyle); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void doAfterAllAnalysed() { |
|
|
|
if (toInsertList != null && !toInsertList.isEmpty()) { |
|
|
|
GdInventoryOkService.this.saveBatch(toInsertList); |
|
|
|
} |
|
|
|
if (toInsertListYc != null && !toInsertListYc.isEmpty()) { |
|
|
|
gdInventoryYcService.saveBatch(toInsertListYc); |
|
|
|
} |
|
|
|
if (errList != null && !errList.isEmpty()) { |
|
|
|
gdInventoryLogErrService.saveBatch(errList); |
|
|
|
} |
|
|
|
|
|
|
|
gdlog.setAllNum(x); |
|
|
|
gdlog.setValidNum(y); |
|
|
|
gdlog.setErrRowNum(errnum); |
|
|
|
RowHandler.super.doAfterAllAnalysed(); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean kchz() { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
|
|
|
|