import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
/**
|
* LPN - 入库扫描
|
*/
|
export default class EnterlpnScanController extends BaseController {
|
//#region
|
/**
|
* 获取采购单号数据,添加厂家拍号作为查询条件
|
*/
|
// @Post()
|
// public async getPurchaseInfoByCode() {
|
// let { ctx } = this;
|
// let body = ctx.request.body;
|
// let orderCode = body.orderCode; // 预到货单号
|
// if (!orderCode) {
|
// this.info.result = false;
|
// this.info.msg = "预到货单号不能为空!";
|
// this.ctx.body = this.info;
|
// return;
|
// }
|
// try {
|
// ctx.service.inbound.inScanService.isOnShelve = body.isOnShelve;
|
// this.info = await ctx.service.inbound.inScanService.getPurchaseOrderData(orderCode);
|
// ctx.body = this.info;
|
// } catch (error) {
|
// this.info.result = false;
|
// this.info.msg = "错误:" + error.message;
|
// }
|
// this.ctx.body = this.info;
|
// }
|
//#endregion
|
//#region
|
/**
|
* Lpn入库保存
|
*/
|
@Post()
|
public async purchaseEnterLpnSave() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
let orderCode = body.orderCode; // 预到货单号
|
let lpnCode = body.lpnCode; // Lpn号
|
let datalist = body.datalist; // 预到货明细
|
if (!orderCode) {
|
this.info.result = false;
|
this.info.msg = "预到货单号不能为空!";
|
this.ctx.body = this.info;
|
return;
|
}
|
if (!lpnCode) {
|
this.info.result = false;
|
this.info.msg = "Lpn号不能为空!";
|
this.ctx.body = this.info;
|
return;
|
}
|
try {
|
this.info = await ctx.service.inbound.enterlpnScanService.purchaseEnterSaveLpn(lpnCode, orderCode, datalist, userInfo.user_Id);
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region //Lpn上架扫描
|
@Post()
|
public async getShelveInfoByLpnCode() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let lpnCode = body.lpnCode; // 预到货单号
|
if (!lpnCode) {
|
this.info.result = false;
|
this.info.msg = "Lpn号不能为空!";
|
this.ctx.body = this.info;
|
return;
|
}
|
try {
|
this.info = await ctx.service.inbound.enterlpnScanService.getPurchaseEnterLpnData(lpnCode);
|
let strList = [];
|
for (let item of this.info.data["orderList"]) {
|
// 根据LpnCode获取最近上架货位
|
var positionNameResult = await ctx.service.inbound.enterlpnScanService.comboboxLpn(item.lpnCode, item.enterList_Id);
|
if (positionNameResult.result) {
|
if (positionNameResult.data) {
|
item.positionName = positionNameResult.data[0].name;
|
}
|
}
|
strList.push(item);
|
}
|
this.info.result = true;
|
this.info.data = strList;
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region //Lpn上架扫描-保存
|
@Post()
|
public async confirmOnShelveLpn() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
let lpnCode = body.lpnCode; // 上架单号
|
let datalist = body.datalist; // 明细
|
if (!lpnCode) {
|
this.info.result = false;
|
this.info.msg = "Lpn号不能为空!";
|
this.ctx.body = this.info;
|
return;
|
}
|
if (datalist.length == 0) {
|
this.info.result = false;
|
this.info.msg = "已扫描数量不能全部为零!";
|
return this.info;
|
}
|
try {
|
this.info = await ctx.service.inbound.enterlpnScanService.purchaseEnterLpnSave(lpnCode, datalist, userInfo);
|
// if(this.info.result)
|
// {
|
// //启动分拣
|
// setTimeout(async () => {
|
// for (let id of body.selectIDs) {
|
// const connection: any = await this.dbWrite.connection;
|
// let request = new sql.Request(connection.driver.master);
|
// request.input("order_Id", id);
|
// request.input("user_Id", userInfo.user_Id);
|
// request.output("outMsg", sql.NVarChar(2000));
|
// let result = await request.execute("sp_Sale_Order_Sorting");
|
// let outMsg = result.output.outMsg;
|
// if (outMsg != null && outMsg) {
|
// this.info.msg = outMsg;
|
// this.info.result = false;
|
// }
|
// }
|
// }, 0);
|
// }
|
//#region 更新最后操作时间
|
let sql = `UPDATE dbo.Sys_User SET PDAOperateDate=GETDATE() WHERE user_Id=@0`;
|
await this.dbRead.query(sql, [userInfo.user_Id]);
|
//#endregion
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
}
|