import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { SaleOrderList } from "../../entity/outbound/sale/saleOrderList";
|
import { vBaseProductPlaceHolder } from "../../entity/storage/storage/vBaseProductPlaceHolder";
|
import { BaseProductPosition } from "../../entity/storage/product/baseProductPosition";
|
import { BaseProductPlaceHolder } from "../../entity/storage/storage/baseProductPlaceHolder";
|
import { SaleOrder } from "../../entity/outbound/sale/saleOrder";
|
|
/**
|
* 出库 - 扫描操作
|
*/
|
export default class OutScanController extends BaseController {
|
//#region 保存扫描结果(完全打包)
|
/**
|
* 保存扫描结果(完全打包)
|
*/
|
@Post()
|
public async saveScan() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
this.info = await ctx.service.outbound.outScanService.saveScan(body.batchCode, body.expressCode, body.wrapperBarcode, body.isNoScanBatchCode);
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 保存扫描结果(部分打包)
|
@Post()
|
public async partialSaveScan() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
this.info = await ctx.service.outbound.outScanService.partialSaveScan(
|
body.batchCode,
|
body.expressCode,
|
body.wrapperBarcode,
|
body.newExpressCode,
|
body.list,
|
body.isNoScanBatchCode
|
);
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 根据条码获取物料图片
|
|
/**
|
* 根据条码获取物料图片
|
*/
|
@Post()
|
public async getProductImg() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
this.info = await ctx.service.outbound.outScanService.getProductImg(body.orderCode);
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 获取快递单对应的销售订单的信息 GetData
|
@Post()
|
public async getData() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
//也可以是 销售订单号,因为有可能生成波次以后,没有打印面单,所以扫描不了快递单号,
|
//但是打印了捡配单,可以扫描销售单号
|
let expressCode = body.expressCode;
|
let batchCode = body.batchCode;
|
let isNoScanBatchCode = true; //不需要波次
|
|
try {
|
this.info = await ctx.service.outbound.outScanService.getData(expressCode, batchCode, isNoScanBatchCode);
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 保存扫描结果(部分打包)
|
/**
|
* 部分打包
|
*/
|
@Post()
|
public async outPartialSaveScan() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let isNoScanBatchCode = true; //无波次号扫描
|
let batchCode = null;
|
let expressCode = body.expressCode;
|
let wrapperBarcode = body.wrapperBarcode;
|
let newExpressCode = body.newExpressCode;
|
let weight = body.weight || 0;
|
|
//每个订单明细的扫描数量
|
let dynamicData = body.data; //[{"orderList_Id":"10459","scanCount":2}]
|
let list: Array<any> = [];
|
|
try {
|
for (var model of dynamicData) {
|
let orderlist_id = model.orderList_Id;
|
let orderCode = model.orderCode;
|
let order_Id = model.order_Id;
|
let caseNumber = model.caseNumber;
|
let scancount = model.scanCount;
|
let weight = model.weight || 0;
|
let totalWeight = model.totalWeight || 0;
|
|
list.push({
|
orderList_Id: orderlist_id,
|
order_Id: order_Id,
|
orderCode: orderCode,
|
caseNumber: caseNumber,
|
scanCount: scancount,
|
weight: weight,
|
totalWeight: totalWeight
|
});
|
}
|
this.info = await ctx.service.outbound.outScanService.partialSaveScan(
|
batchCode,
|
expressCode,
|
wrapperBarcode,
|
newExpressCode,
|
list,
|
isNoScanBatchCode,
|
0
|
);
|
|
//#region 扫描成功后的操作
|
if (this.info.result) {
|
//扫描成功生成揽收信息
|
await ctx.service.tms.wayBillHelper.createWayBillReceive(expressCode, weight);
|
}
|
//#endregion
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 按订单扫描出库 GetOrderData
|
@Post()
|
public async getOrderData() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let expressCode = body.expressCode;
|
|
try {
|
this.info = await ctx.service.outbound.outScanService.getOrderData(expressCode);
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 按订单扫描出库 保存扫描结果(部分打包)
|
/**
|
* 部分打包
|
*/
|
@Post()
|
public async orderPartialSaveScan() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let expressCode = body.expressCode;
|
let wrapperBarcode = body.wrapperBarcode;
|
let newExpressCode = body.newExpressCode;
|
let totalPackage = body.totalPackage;
|
let totalVolume = body.totalVolume;
|
|
try {
|
//每个订单明细的扫描数量
|
let data = body.data;
|
if (!Array.isArray(data)) {
|
this.info.result = false;
|
this.info.msg = "扫描明细不能为空";
|
ctx.body = this.info;
|
return;
|
}
|
|
let list: Array<any> = [];
|
for (var model of data) {
|
let orderlist_id = model.orderList_Id;
|
let orderCode = model.orderCode;
|
let order_Id = model.order_Id;
|
let caseNumber = model.caseNumber;
|
let scancount = model.scanCount;
|
let weight = model.weight || 0;
|
let totalWeight = model.totalWeight;
|
list.push({
|
orderList_Id: orderlist_id,
|
order_Id: order_Id,
|
orderCode: orderCode,
|
caseNumber: caseNumber,
|
scanCount: scancount,
|
weight: weight,
|
totalWeight: totalWeight
|
});
|
}
|
this.info = await ctx.service.outbound.outScanService.orderPartialSaveScan(
|
totalPackage,
|
totalVolume,
|
expressCode,
|
wrapperBarcode,
|
newExpressCode,
|
list
|
);
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
ctx.body = this.info;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 扫描物流单出库 - 根据物流单获得出库单明细数据接口
|
@Post()
|
public async getSaleOuterExpress() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let expressCode = body.expressCode;
|
|
try {
|
this.info = await ctx.service.outbound.outScanService.getSaleOuterData(expressCode);
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 扫描物流单出库保存
|
@Post()
|
public async saveSaleOuterExpress() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let storage_Id = body.storage_Id; // 仓库ID
|
let expressCode = body.expressCode; //出库单号
|
try {
|
this.info = await ctx.service.outbound.outScanService.saveSaleOrderCode(storage_Id, expressCode);
|
} catch (error) {
|
this, (this.info.result = false);
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 妥投相关-获取妥投出库订单明细
|
@Post()
|
public async getSaleOrderList() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let orderCode = body.orderCode; //出库单号
|
try {
|
this.info = await ctx.service.outbound.outScanService.getSaleOrderDetaliList(orderCode);
|
} catch (error) {
|
this, (this.info.result = false);
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 妥投相关-确认妥投
|
@Post()
|
public async saveSaleOrderTuotou() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let orderCode = body.orderCode; //出库单号
|
let dataArray = body.orderList;
|
try {
|
this.info = await ctx.service.outbound.outScanService.saveSaleOrderTuotou(orderCode, dataArray);
|
} catch (error) {
|
this, (this.info.result = false);
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 出库扫描EU-出库
|
@Post()
|
public async saveEuOut() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let order_Id = body.order_Id; //出库单id
|
let orderInfoList = await this.dbRead
|
.createQueryBuilder(SaleOrderList, "t")
|
.where("order_Id=:order_Id", {
|
order_Id: order_Id
|
})
|
.getMany();
|
for (var orderInfo of orderInfoList) {
|
// 查找明细所有占位
|
|
let holdList = await this.dbRead
|
.createQueryBuilder(vBaseProductPlaceHolder, "t")
|
.where("mainID=:mainID and detailID=:detailID and className='销售订单'", {
|
mainID: order_Id,
|
detailID: orderInfo.orderList_Id
|
})
|
.getMany();
|
|
for (var holdInfo of holdList) {
|
// 库存数量削减
|
holdInfo.productPosition_Id;
|
var productPosition = await this.dbRead
|
.createQueryBuilder(BaseProductPosition, "t")
|
.where("productPosition_Id=:productPosition_Id", {
|
productPosition_Id: holdInfo.productPosition_Id
|
})
|
.getOne();
|
productPosition.productStorage = productPosition.productStorage - holdInfo.placeholderStorage;
|
await this.dbWrite.save(productPosition);
|
|
// 清除明细占位
|
var hold = await this.dbRead
|
.createQueryBuilder(BaseProductPlaceHolder, "t")
|
.where("placeholder_Id=:placeholder_Id", {
|
placeholder_Id: holdInfo.placeholder_Id
|
})
|
.getOne();
|
hold.placeholderStorage = 0;
|
await this.dbWrite.save(hold);
|
}
|
|
// 更新出库单状态
|
let saleOrderInfo = await this.dbRead
|
.createQueryBuilder(SaleOrder, "t")
|
.where("order_Id=:order_Id", {
|
order_Id: order_Id
|
})
|
.getOne();
|
saleOrderInfo.statusText = "发运完成";
|
saleOrderInfo.statusID = 12;
|
await this.dbWrite.save(saleOrderInfo);
|
}
|
|
try {
|
} catch (error) {
|
this, (this.info.result = false);
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
}
|
//#endregion
|
}
|