import { srm, tran, rgv } from "../public/webServiceHelper";
|
import { Post } from "egg-shell-decorators";
|
import BaseController from "./baseController";
|
import * as mssql from "mssql";
|
import { PurchaseShelve } from "../entity/inbound/purchase/purchaseShelve";
|
|
export default class WcfController extends BaseController {
|
//#region entry
|
@Post()
|
public async entry() {
|
let { ctx } = this;
|
let data: any;
|
try {
|
console.log("this.body.type =", this.body.type);
|
console.log("this.body.method =", this.body.method);
|
console.log("this.body.params =", this.body.params);
|
if (this.body.type === "srm") {
|
data = await srm[this.body.method](this.body.params);
|
this.info.result = true;
|
this.info.data = data;
|
if (this.body.method === "isTaskFinish" && Number(data.IsTaskFinishResult) === 1) {
|
// 码垛机上架完成执行入库操作
|
await this.enterStorage();
|
}
|
} else if (this.body.type === "tran") {
|
data = await tran[this.body.method](this.body.params);
|
this.info.result = true;
|
this.info.data = data;
|
if (this.body.method === "isPassed" && "" + data.IsPassedResult === "true") {
|
// 外形检测通过后,先分配空货位
|
await this.sortPosition();
|
}
|
} else if (this.body.type === "rgv") {
|
data = await rgv[this.body.method](this.body.params);
|
this.info.result = true;
|
this.info.data = data;
|
} else {
|
this.info.result = false;
|
this.info.msg = "类型未定义";
|
}
|
|
ctx.body = this.info;
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = error.message;
|
ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 分配货位
|
private async sortPosition() {
|
try {
|
let orderInfo = await this.dbRead.findOne(PurchaseShelve, 5930);
|
orderInfo.positionName = "03-19-03";
|
orderInfo.onShelveStatus = "在途中";
|
await this.dbWrite.save(orderInfo);
|
this.info.msg = "确认入库成功";
|
this.info.result = true;
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
}
|
//#endregion
|
|
//#region 确认入库
|
private async enterStorage() {
|
try {
|
const connection: any = await this.dbWrite.connection;
|
let request = new mssql.Request(connection.driver.master);
|
request.input("order_Id", 5930);
|
request.input("user_Id", 1);
|
request.input("userTrueName", "码垛机");
|
request.output("outMsg", mssql.NVarChar(2000));
|
let result = await request.execute("sp_Purchase_Order_OneKeyShelve");
|
let outMsg = result.output.outMsg;
|
if (outMsg != null && outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
} else {
|
this.info.msg = "确认入库成功";
|
this.info.result = true;
|
}
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
}
|
//#endregion
|
}
|