Browse Source

上传库存

master
liupopo 2 years ago
parent
commit
d65fa81b36
  1. 20
      supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue
  2. 148
      yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java

20
supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue

@ -61,10 +61,7 @@
ref="upload"
class="upload-demo"
:action="updateAction"
:on-change="handleChange"
:on-progress="handleProgress"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-success="handleSuccess"
:file-list="fileList"
:auto-upload="false"
@ -230,22 +227,7 @@
submitUpload() {
this.$refs.upload.submit()
},
handleRemove(file, fileList) {
console.log(file, fileList)
},
handlePreview(file) {
console.log('handlePreview', file)
},
handleChange(file) {
console.log(this.fileList)
},
handleProgress(event, file, fileList) {
// this.progressFlag = true; //
// this.loadProgress = parseInt(event.percent); //
// if (this.loadProgress >= 100) {
// this.loadProgress = 100
// setTimeout( () => {this.progressFlag = false}, 1000) //
// }
const _this = this
this.fullscreenloading = this.$loading({
lock: true,
@ -265,7 +247,7 @@
const rdata = resp.data
const _this = this
_this.fullscreenloading.text = '数据导入完成,进行汇总'
_this.uploadResultMesssage = '共导入数据:' + rdata.allNum + ' 条;符合监管条件的数据:' + rdata.validNum + ' 条;用时:' + rdata.durations + ' 毫秒。'
_this.uploadResultMesssage = '共导入数据:' + rdata.allNum + ' 条;普通商品数据:' + rdata.validNum + ' 条;烟草商品数据:' + rdata.errRowNum + ' 条;用时:' + rdata.durations + ' 毫秒。'
kchz()
.then(res => {

148
yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java

@ -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();

Loading…
Cancel
Save