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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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
}