import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { StorageAdjustList } from "../../entity/storage/adjust/storageAdjustList";
|
import * as sql from "mssql";
|
import * as XLSX from "xlsx";
|
import * as path from "path";
|
import { BaseProductInfo } from "../../entity/basicInfo/base/baseProductInfo";
|
import { isNumber } from "util";
|
import moment = require("moment");
|
import { StorageAdjust } from "../../entity/storage/adjust/storageAdjust";
|
import { BasePosition } from "../../entity/basicInfo/base/basePosition";
|
|
export default class StorageAdjustController extends BaseController {
|
//#region GetData
|
@Post()
|
public async getData() {
|
let { ctx } = this;
|
|
let body = ctx.request.body;
|
this.info = await ctx.service.storage.positionTransfer.getProductPositionGroupData(
|
body.originalPositionName,
|
body.targetPositionName,
|
body.storage_Id
|
);
|
if (!this.info.result) {
|
this.info.result = false;
|
this.info.msg = this.info.msg;
|
} else {
|
this.info.result = true;
|
this.info.dynamic = this.info.data;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 审核
|
@Post()
|
public async auditing() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
let idValue = body.idValue;
|
if (!idValue) {
|
this.info.result = false;
|
this.info.msg = "信息不存在";
|
return;
|
}
|
try {
|
let Adjustlist = await this.dbRead.find(StorageAdjustList, idValue);
|
if (Adjustlist.length <= 0) {
|
this.info.msg = "明细为空不能审核!";
|
this.info.result = false;
|
return;
|
}
|
if (body.auditing == 2) {
|
const connection: any = await this.dbWrite.connection;
|
let request = new sql.Request(connection.driver.master);
|
request.input("User_Id", userInfo.user_Id);
|
request.input("Adjust_Id", idValue);
|
request.output("outMsg", sql.NVarChar(2000));
|
// cmd.CommandTimeout = 60 * 10;
|
let result = await request.execute("sp_Storage_Adjust_Sorting");
|
let outMsg = result.output.outMsg;
|
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
|
//执行确认操作
|
const connectiont: any = await this.dbWrite.connection;
|
request = new sql.Request(connectiont.driver.master);
|
request.input("modifier", userInfo.userTrueName);
|
request.input("adjust_Id", idValue);
|
request.output("outMsg", sql.NVarChar(2000));
|
try {
|
let result = await request.execute("sp_Storage_Adjust_Check");
|
|
outMsg = result.output.outMsg;
|
} catch (e) {
|
this.info.msg = "执行错误:" + e.message;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
ctx.body = this.info;
|
return;
|
}
|
this.info.result = true;
|
this.info.msg = "审核成功!";
|
}
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region auditingAssemble
|
@Post()
|
public async auditingAssemble() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
let idValue = body.idValue;
|
|
if (!idValue) {
|
this.info.result = false;
|
this.info.msg = "信息不存在";
|
return;
|
}
|
try {
|
let Adjustlist = await this.dbRead.find(StorageAdjustList, idValue);
|
if (Adjustlist.length <= 0) {
|
this.info.msg = "明细为空不能审核!";
|
this.info.result = false;
|
return;
|
}
|
if (body.auditing == 2) {
|
const connection: any = await this.dbWrite.connection;
|
let request = new sql.Request(connection.driver.master);
|
request.input("User_Id", userInfo.user_Id);
|
request.input("Assemble_Id", idValue);
|
request.output("outMsg", sql.NVarChar(2000));
|
// cmd.CommandTimeout = 60 * 10;
|
let result = await request.execute("sp_Storage_Assemble_Sorting");
|
let outMsg = result.output.outMsg;
|
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
|
//执行确认操作
|
const connectiont: any = await this.dbWrite.connection;
|
request = new sql.Request(connectiont.driver.master);
|
request.input("User_Id", userInfo.user_Id);
|
request.input("Assemble_Id", idValue);
|
request.input("UserTrueName", userInfo.userTrueName);
|
// request.output("outMsg", sql.NVarChar(2000));
|
try {
|
let result = await request.execute("sp_Storage_Assemble_Check");
|
outMsg = result.output.outMsg;
|
} catch (e) {
|
this.info.msg = "执行错误:," + e.message;
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
return this.info;
|
}
|
this.info.result = true;
|
this.info.msg = "审核成功!";
|
}
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 批量添加新库存物料
|
@Post()
|
public async batchAdd() {
|
// let { ctx } = this;
|
// let body = ctx.request.body;
|
// let userInfo = await ctx.helper.userInfo();
|
// let idField = body.idField;
|
// let dataList = (body.data.trim('\r').Replace("\r", ""), "\n");
|
// let index = 0;
|
// let sql ="";
|
// let msg ="";
|
// let adjust = await this.dbRead.findOne(StorageAdjust, body.adjust_Id);
|
// let productCodeList = "";
|
// let dtNew = null;
|
// let newdt = null;
|
// let dataPurchase = null;
|
// for (let item of dataList)
|
// {
|
// let itemList = item.split("\t,, ");
|
// if (itemList.length == 1) continue;
|
// if (itemList.length < 3) {
|
// this.info.result = false;
|
// msg += "<br/>第" + (index + 1) + "行数据格式不正确!";
|
// index++;
|
// continue;
|
// }
|
// // let dt = await this.dbRead.find(BasePosition,{
|
// // storage_Id: adjust.storage_Id,
|
// // })
|
// // ${ saleOuter.outer_Id }
|
// sql = `SELECT PositionName FROM dbo.Base_Position WHERE storage_Id='" +${adjust.storage_Id} + "' AND PositionName='" +${itemList[0]} + @"'`;
|
// let dt= await this.dbWrite.query(sql);
|
// if (dt.Rows.Count != 1) {
|
// msg += "<br/>第" + (index + 1) + "行数据货位【" + itemList[0] + "】不存在!";
|
// index++;
|
// continue;
|
// }
|
// let dtSku = await this.dbRead.find(vBaseProductInfoSKU,{
|
// ProductCode: itemList[1]
|
// });
|
// if (dtSku.Rows.Count != 1) {
|
// msg += "<br/>第" + (index + 1) + "行数据物料编号【" + itemList[1] + "】不存在!";
|
// index++;
|
// continue;
|
// }
|
// let ProductCode = itemList[1];
|
// let checkQuantity = itemList[2];
|
// if (productCodeList) productCodeList += "','";
|
// productCodeList += ProductCode;
|
// sql = `SELECT SUM(productStorage) AS productStorage FROM Base_ProductPosition WHERE ProductCode='" +${itemList[1]} + "' AND PositionName='" + ${itemList[0]} + "' and storage_Id='" + ${adjust.storage_Id} + "' and consignorCode='" +${adjust.consignorCode} + "' and provider_Id='" + ${adjust.provider_Id} +"'`;
|
// let newdt = await this.dbRead.query(sql);
|
// if (newdt.Rows.Count != 1) {
|
// msg += "<br/>第" + (index + 1) + "行数据,在仓库此货位下货主为:" + adjust.consignorCode + ",供应商为:" + adjust.adjustCode + "的,物料编号为:【" + itemList[1] + "】不存在,请核对物料信息!";
|
// index++;
|
// continue;
|
// }
|
// sql = `SELECT purchasePrice, purchaseMoney FROM Base_ProductPosition WHERE ProductCode='" + ${itemList[1]} + "' AND PositionName='" + ${itemList[0]} + "' and storage_Id='" + ${adjust.storage_Id} + "' and consignorCode='" + ${adjust.consignorCode} + "' and provider_Id='" + ${adjust.provider_Id} + "'`;
|
// let dataPurchase = await this.dbRead.query(sql);
|
// let purchaseMoney = 0;//账面成本额
|
// let purchasePrice = 0;//进货价
|
// for (let moneyRow of dataPurchase)
|
// {
|
// purchaseMoney = moneyRow["purchaseMoney"];
|
// purchasePrice = moneyRow["purchasePrice"];
|
// }
|
// let productStorage = 0;
|
// for (let newRow of newdt)
|
// {
|
// productStorage = newRow["productStorage"].GetInt();
|
// }
|
// let ProfitQuantity = 0;
|
// let lossQuantity = 0;
|
// if (checkQuantity.length > productStorage)//盘点数量大于账面库存量
|
// {
|
// ProfitQuantity = checkQuantity.length - productStorage;
|
// }
|
// if (checkQuantity.length < productStorage)//盘点数量小于账面库存量
|
// {
|
// lossQuantity = productStorage - checkQuantity.length;
|
// }
|
// let profitMoney = 0;//盘盈金额
|
// let lossMoney = 0;//盘亏金额
|
// purchaseMoney = purchaseMoney * productStorage;
|
// profitMoney = ProfitQuantity * purchaseMoney;
|
// lossMoney = lossQuantity * purchaseMoney;
|
// sql =`
|
// SELECT Product_Id, ProductCode, ProductName, ProductModel, ProductSpec, SmallUnit, BigUnit, " +${productStorage} + @" as productStorage, " + ${purchaseMoney} + @" as purchaseMoney,
|
// UnitConvert, UnitConvertText, '" +${itemList[0]} + @"' AS PositionName, " + ${purchasePrice} + @" as purchasePrice,
|
// " + ${checkQuantity} + @" AS checkQuantity,
|
// " + ${ProfitQuantity} + @" AS ProfitQuantity, " + ${lossQuantity} + @" AS lossQuantity, " + ${profitMoney} + @" as profitMoney,
|
// " + ${lossMoney} + @" as lossMoney
|
// FROM dbo.vBase_ProductInfo_SKU
|
// WHERE ProductCode = '" + ${ProductCode} + "'`;
|
// dt = await this.dbRead.query(sql);
|
// if (dtNew == null) {
|
// dtNew = dt;
|
// }
|
// else {
|
// dtNew.Merge(dt);
|
// }
|
// index++;
|
// }
|
// if (index > 0) {
|
// sql = @"
|
// DECLARE @ProductCode NVARCHAR(max);
|
// SET @ProductCode='';
|
// SELECT @ProductCode=ProductCode + ',' FROM dbo.vBase_ProductInfo_SKU WHERE ProductCode IN('" + productCodeList + @"') AND provider_Id IS NULL;
|
// SELECT @ProductCode AS ProductCode; ";
|
// string noProvider = Storage_AdjustRepository.Instance.DataContext.ExecuteScalar(CommandType.Text, sql).GetString();
|
// if (noProvider.IsNotNullOrEmpty()) {
|
// msg += "<br/>物料编号为【" + noProvider.Trim(',') + "】供应商不存在,请在物料信息中设置供应商!";
|
// }
|
// if (msg.IsNotNullOrEmpty()) //校验存在错误
|
// {
|
// this.info.result = false;
|
// //info.Data = string.Empty;
|
// info.Msg = msg;
|
// }
|
// else {
|
// this.info.result = true;
|
// //info.Data = DataTableHelper.DataTableToJson(dtNew);
|
// info.Msg = "加载成功!";
|
// foreach(DataRow row in dtNew.Rows)
|
// {
|
// string PositionName = row["PositionName"].ToString();
|
// string checkQuantity = row["checkQuantity"].ToString();
|
// string ProductCode = row["ProductCode"].ToString();
|
// string purchasePrice = row["purchasePrice"].ToString();
|
// string lossQuantity = row["lossQuantity"].ToString();
|
// string ProfitQuantity = row["ProfitQuantity"].ToString();
|
// string profitMoney = row["profitMoney"].ToString();
|
// string lossMoney = row["lossMoney"].ToString();
|
// string productStorage = row["productStorage"].ToString();
|
// string purchaseMoney = row["purchaseMoney"].ToString();
|
// string SmallUnit = row["SmallUnit"].ToString();
|
// sql = @"
|
// INSERT INTO Storage_AdjustList
|
// (Adjust_Id, Product_Id, ProductCode, ProductName, ProductModel, ProductSpec, SmallUnit, purchasePrice,
|
// PositionName, productStorage, purchaseMoney, checkQuantity,
|
// ProfitQuantity, profitMoney, lossQuantity, lossMoney,
|
// CreateID, Creator, CreateDate)
|
// SELECT " + reqInfo.Adjust_Id + @" AS Adjust_Id, Product_Id, ProductCode, ProductName, ProductModel, ProductSpec, '" + SmallUnit + @"', " + purchasePrice + @" as purchasePrice,
|
// '" + PositionName + @"' AS PositionName, " + productStorage + @" AS productStorage,
|
// " + purchaseMoney + @" AS purchaseMoney, " + checkQuantity + @" AS checkQuantity,
|
// " + ProfitQuantity + @" AS ProfitQuantity, " + profitMoney + @" AS profitMoney, " + lossQuantity + @" as lossQuantity, " + lossMoney + @" as lossMoney,
|
// " + UserHelper.UserInfo.User_Id + " as CreateID, '" + UserHelper.UserInfo.UserTrueName + @"' as Creator, getdate() as CreateDate
|
// FROM dbo.vBase_ProductInfo_SKU
|
// WHERE ProductCode = '" + ProductCode + @"'; ";
|
// Storage_AdjustlistRepository.Instance.ExeSql(sql);
|
// }
|
// //更新求和
|
// sql = @"
|
// UPDATE Storage_Adjust
|
// SET TotalProductStorage = T.TotalProductStorage, TotalPurchaseMoney = T.TotalPurchaseMoney,
|
// TotalCheckQuantity = T.TotalCheckQuantity, TotalProfitQuantity = T.TotalProfitQuantity,
|
// TotalProfitMoney = T.TotalProfitMoney,
|
// TotalLossQuantity = T.TotalLossQuantity,
|
// TotalLossMoney = T.TotalLossMoney
|
// FROM(
|
// SELECT Adjust_Id, TotalProductStorage = SUM(productStorage), TotalPurchaseMoney = SUM(purchaseMoney), TotalCheckQuantity = SUM(checkQuantity),
|
// TotalProfitQuantity = SUM(ProfitQuantity), TotalProfitMoney = SUM(profitMoney),
|
// TotalLossQuantity = SUM(lossQuantity), TotalLossMoney = SUM(lossMoney)
|
// FROM Storage_AdjustList
|
// WHERE Adjust_Id = " + reqInfo.Adjust_Id + @"
|
// GROUP BY Adjust_Id
|
// ) T, Storage_Adjust
|
// WHERE t.Adjust_Id = dbo.Storage_Adjust.Adjust_Id
|
// AND dbo.Storage_Adjust.Adjust_Id = " + reqInfo.Adjust_Id + @"
|
// ";
|
// Storage_AdjustlistRepository.Instance.ExeSql(sql);
|
// }
|
// }
|
// else {
|
// this.info.result = false;
|
// info.Msg = "加载失败!";
|
// }
|
// return info;
|
}
|
//#endregion
|
|
//#region 库存调整明细导出
|
/// <summary>
|
/// 库存调整明细导出
|
/// </summary>
|
/// <param name="body"></param>
|
/// <returns></returns>
|
@Post()
|
public async exportList() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
|
try {
|
let sql = "";
|
sql = `SELECT
|
productCode AS '物料编号',productName AS '物料名称',productSpec AS '物料规格',productModel AS '物料条码',positionName AS '货位',
|
productStorage AS '账面库存量', placeholderStorage AS '占位数量',smallUnit AS '小单位',purchasePrice AS '进货价',
|
purchaseMoney AS '账面成本额',checkQuantity AS '盘点数量',profitQuantity AS '盘盈数量',profitMoney AS '盘盈金额',lossQuantity AS '盘亏数量',
|
lossMoney AS '盘亏金额',lackStorage AS '缺货数量',weight AS '单位重量',totalWeight AS '库存重量',sortingStatus AS '分拣状态',
|
productAttribute AS '物料属性',produceDate AS '生产日期',shelfLifeDay AS '保质期天数',plateCode AS '拍号',containerNo AS '集装箱号',originPlace AS '原产地',batchNumber AS '批次号',inStorageDate AS '入库日期',remark AS '备注'
|
FROM Storage_Adjustlist
|
WHERE Adjustlist_Id IN(select col from dbo.split(@0, ','))`;
|
|
let transferList: Array<any> = await this.dbRead.query(sql, [body.ids]);
|
|
let root = path.resolve();
|
let url = "/download/库存调整明细数据.xlsx";
|
let fileName = root + url.replace(/\//g, path.sep);
|
let pathToCreate = fileName.substring(0, fileName.lastIndexOf(path.sep));
|
ctx.helper.mkdir(pathToCreate);
|
|
// wayBillList = wayBillList.splice(0, 0, {
|
// "分运单号":"xxxxxx"
|
// }, {"申报类型": "xxxxsssss"}, {});
|
let jsonWorkSheet = XLSX.utils.json_to_sheet(transferList);
|
// 构造workBook
|
let workBook = {
|
SheetNames: ["数据"],
|
Sheets: {
|
数据: jsonWorkSheet
|
}
|
};
|
XLSX.writeFile(workBook, fileName);
|
|
this.info.result = true;
|
this.info.data = {
|
url: url
|
};
|
this.info.msg = "导出成功!";
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 导入库存调整Excel
|
@Post()
|
public async importExcel() {
|
setTimeout(async () => {
|
await this.importExcelWork();
|
}, 0);
|
|
this.info.result = true;
|
this.info.msg = "开始导入...";
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region importExcelWork
|
private async importExcelWork() {
|
let { ctx } = this;
|
let userInfo = await this.userInfo;
|
let body = ctx.request.body;
|
let redis = ctx.app.redis.clients.get("common"); // 将消息放入redis缓存
|
let fileUrl = body.fileUrl;
|
redis.expire(body.key, 5 * 60);
|
if (!this.body.adjust_Id) {
|
this.setMsg("请先保存后再进行导入操作", "red");
|
this.setMsg("-1");
|
return;
|
}
|
if (!fileUrl) {
|
this.setMsg("上传文件不存在", "red");
|
this.setMsg("-1");
|
return;
|
}
|
if (!body.key) {
|
this.setMsg("上传key不存在", "red");
|
this.setMsg("-1");
|
return;
|
}
|
|
try {
|
let rootPath = path.resolve(); // 获得根目录
|
let filePath = rootPath + path.sep + fileUrl.replace(/\//gi, path.sep); // 上传文件路径
|
var workbook = XLSX.readFile(filePath); //整个 excel 文档
|
var sheetNames = workbook.SheetNames; //获取所有工作薄名
|
var sheet1 = workbook.Sheets[sheetNames[0]]; //根据工作薄名获取工作薄
|
let dataList = XLSX.utils.sheet_to_json(sheet1); // 获得当前sheet表单数据转为json格式
|
|
//#region 验证数据正确性
|
this.info.result = true;
|
if (!dataList.length) {
|
this.setMsg("没有可导入的数据", "red");
|
this.setMsg("-1");
|
return;
|
}
|
//#endregion
|
|
let adjust = await this.dbRead.findOne(StorageAdjust, {
|
adjust_Id: this.body.adjust_Id
|
});
|
let i = 1;
|
let dataRows = []; // 数据集合
|
for (let row of dataList) {
|
i++;
|
let prodInfo = await this.dbRead.findOne(BaseProductInfo, {
|
productCode: row["物料编号"],
|
userProduct_Id: userInfo.userProduct_Id
|
});
|
|
if (!prodInfo) {
|
this.setMsg(`第${i}行、${row["物料编号"]}在物料基础信息中不存在`, "red");
|
}
|
let positionName = row["货位名称"];
|
let Position = await this.dbRead.find(BasePosition, {
|
positionName: positionName,
|
storageName: adjust.storageName
|
});
|
if (!Position) {
|
this.setMsg(`第${i}行、${row["货位名称"]}在,${adjust.storageName}不存在`, "red");
|
}
|
let produceDate = row["生产日期"];
|
if (produceDate) {
|
if (!isNumber(produceDate)) {
|
this.setMsg(`第${i}行、${produceDate}在生产日期格式不正确`, "red");
|
} else {
|
produceDate = moment(new Date(1900, 0, produceDate - 1));
|
produceDate = produceDate.toDate();
|
// data.produceDate = d.toDate();
|
}
|
}
|
|
let inStorageDate = row["入库日期"];
|
if (inStorageDate) {
|
if (!isNumber(inStorageDate)) {
|
this.setMsg(`第${i}行,${inStorageDate}在生产日期格式不正确`, "red");
|
} else {
|
inStorageDate = moment(new Date(1900, 0, inStorageDate - 1));
|
inStorageDate = inStorageDate.toDate();
|
}
|
}
|
let weight = row["单位重量"];
|
let checkQuantity = row["盘点数量"];
|
let totalWeight = row["库存重量"];
|
if (!weight) {
|
weight = checkQuantity ? totalWeight / checkQuantity : 0;
|
}
|
let data = {
|
adjust_Id: body.adjust_Id,
|
createID: userInfo.user_Id,
|
creator: userInfo.userTrueName,
|
positionName: row["货位名称"],
|
product_Id: prodInfo.product_Id,
|
productCode: row["物料编号"],
|
productName: row["物料名称"],
|
productModel: row["条形码"],
|
productSpec: row["物料规格"],
|
productStorage: row["账面库存量"],
|
placeholderStorage: row["占位数量"],
|
smallUnit: row["小单位"],
|
purchasePrice: row["进货价"],
|
purchaseMoney: row["账面成本额"],
|
checkQuantity: checkQuantity,
|
profitQuantity: row["盘盈数量"],
|
profitMoney: row["盘盈金额"],
|
lossQuantity: row["盘亏数量"],
|
lossMoney: row["盘亏金额"],
|
lackStorage: row["缺货数量"],
|
weight: weight,
|
totalWeight: totalWeight,
|
sortingStatus: row["分拣状态"],
|
productAttribute: row["物料属性"],
|
produceDate: produceDate,
|
shelfLifeDay: row["保质期天数"],
|
plateCode: row["拍号"],
|
containerNo: row["集装箱号"],
|
originPlace: row["原产地"],
|
batchNumber: row["批次号"],
|
inStorageDate: inStorageDate,
|
remark: row["备注"]
|
};
|
//#region // 校验数据
|
if (!data.productCode) {
|
this.setMsg(`第${i}行、物料编号不能为空`, "red");
|
}
|
if (!data.productName) {
|
this.setMsg(`第${i}行、物料名称不能为空`, "red");
|
}
|
if (!data.productModel) {
|
this.setMsg(`第${i}行、条形码不能为空`, "red");
|
}
|
if (!data.positionName) {
|
this.setMsg(`第${i}行、货位不能为空`, "red");
|
}
|
if (data.shelfLifeDay) {
|
if (!isNumber(data.shelfLifeDay)) {
|
this.setMsg(`第${i}行、保质期天数必须是数字`, "red");
|
}
|
}
|
// if (!data.originPlace) {
|
// this.setMsg(`第${i}行,原产地值为空`, "red");
|
// }
|
dataRows.push(data);
|
}
|
//#endregion
|
|
if (this.isMsgError) {
|
this.setMsg(`导入数据有错误,请处理好重新导入`, "red");
|
this.setMsg("-1");
|
return;
|
}
|
i = 1;
|
let successCount = 0;
|
let updateCount = 0;
|
let rows = []; // 准备更新或者新增的数据
|
for (let data of dataRows) {
|
i++;
|
successCount++;
|
rows.push(data);
|
if (i % 100 === 0) {
|
await this.dbWrite.save(StorageAdjustList, rows);
|
rows = [];
|
}
|
}
|
if (rows.length > 0) {
|
await this.dbWrite.save(StorageAdjustList, rows);
|
rows = [];
|
}
|
this.setMsg(`导入成功,新增${successCount}条,更新${updateCount}条`, "blue");
|
} catch (ex) {
|
this.setMsg("出现异常:" + ex.message, "red");
|
this.info.result = false;
|
}
|
this.setMsg("-1");
|
}
|
//#endregion
|
}
|