333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//#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
}