//#region
|
import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { PurchaseOrder } from "../../entity/inbound/purchase/purchaseOrder";
|
import { PurchaseOrderList } from "../../entity/inbound/purchase/purchaseOrderList";
|
import { In } from "typeorm";
|
//#endregion
|
|
/**
|
* 返修合格标签打印
|
*/
|
export default class OrderFxController extends BaseController {
|
//#region getOrderInfo 根据器具编号获取入库单
|
@Post()
|
public async getOrderInfo() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
if (!body.plateCode) {
|
this.info.result = false;
|
this.info.msg = `扫描器具编号不能为空`;
|
ctx.body = this.info;
|
return;
|
}
|
try {
|
let mainInfo = await this.dbRead.findOne(PurchaseOrder, {
|
plateCode: body.plateCode,
|
repairType: In(["焊装待返修", "冲压待返修"])
|
});
|
|
if (!mainInfo) {
|
this.info.result = false;
|
this.info.msg = `${body.plateCode}没有可用的单据`;
|
ctx.body = this.info;
|
return;
|
}
|
let details = await this.dbRead.find(PurchaseOrderList, {
|
order_Id: mainInfo.order_Id
|
});
|
|
this.info.data = mainInfo;
|
this.info.data2 = details;
|
this.info.result = true;
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region getXzInfo 入库异常修正
|
@Post()
|
public async getXzInfo() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
if (!body.plateCode) {
|
this.info.result = false;
|
this.info.msg = `扫描器具编号不能为空`;
|
ctx.body = this.info;
|
return;
|
}
|
try {
|
let mainInfo = await this.dbRead.findOne(PurchaseOrder, {
|
plateCode: body.plateCode,
|
statusText: In(["新建"])
|
});
|
|
if (!mainInfo) {
|
this.info.result = false;
|
this.info.msg = `${body.plateCode}没有可用的单据`;
|
ctx.body = this.info;
|
return;
|
}
|
let details = await this.dbRead.find(PurchaseOrderList, {
|
order_Id: mainInfo.order_Id
|
});
|
|
this.info.data = mainInfo;
|
this.info.data2 = details;
|
this.info.result = true;
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
}
|