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
import BaseController from "../baseController";
import { TMSWayBill } from "../../entity/express/tms/tmsWayBill";
import { TMSPortTemplate } from "../../entity/express/tms/tmsPortTemplate";
import { BasePrintTemplate } from "../../entity/sys/print/basePrintTemplate";
import { TMSSortingPanelLog } from "../../entity/express/panel/tmsSortingPanelLog";
import { Post } from "egg-shell-decorators";
 
/**
 * 组板操作
 */
export default class PanelController extends BaseController {
  //#region PC组板
  /// <summary>
  /// 校验并生产PC组板
  /// </summary>
  /// <returns></returns>
  @Post()
  public async checkPCPanel() {
    try {
      //#region 校验信息
      if (!this.body.wayBillCode) {
        this.info.result = false;
        this.info.msg = "运单编号不能为空";
        this.ctx.body = this.info;
        return;
      }
      //#endregion
 
      // 运单信息
      let waybill = await this.dbRead.findOne(TMSWayBill, {
        wayBillCode: this.body.wayBillCode
      });
      if (waybill == null) {
        this.info.msg = "运单号不存在";
        this.info.result = false;
        this.ctx.body = this.info;
        return;
      }
 
      if (this.body.port_Id > 0 && waybill.port_Id != this.body.port_Id) {
        this.info.msg = "当前运单号和选择口岸不匹配!";
        this.info.result = false;
        this.ctx.body = this.info;
        return;
      }
 
      //#region 获取快递模板Id
      let template = await this.dbRead.findOne(TMSPortTemplate, {
        portName: waybill.portName,
        expressCorp_Id: waybill.expressCorp_Id
      });
      if (template == null) {
        this.info.result = false;
        this.info.msg = "口岸未设置快递模板";
        this.ctx.body = this.info;
        return;
      }
 
      let btemp = await this.dbRead.findOne(BasePrintTemplate, {
        printTemplate_Id: template.faceBillTemplateID
      });
      if (btemp == null) {
        this.info.result = false;
        this.info.msg = "快递模板不存在";
        this.ctx.body = this.info;
        return;
      }
      //#endregion
 
      this.info = await this.ctx.service.tms.sortingHelper.checkRule(this.body.wayBillCode, "PC组板");
      //模块ID
      this.info.dynamic = btemp.menu_Id;
      if (this.info.result) {
        let wayBillInfo: TMSWayBill = this.info.data as TMSWayBill;
        if (wayBillInfo.printNum != null) {
          wayBillInfo.printNum += 1;
        } else {
          wayBillInfo.printNum = 1;
        }
        wayBillInfo.abnormalReason = this.info.msg;
        await this.dbWrite.update(TMSWayBill, wayBillInfo.wayBill_Id, {
          printNum: ++wayBillInfo.printNum,
          abnormalReason: this.info.msg
        });
 
        //添加运单追踪记录
        this.ctx.service.tms.wayBillHelper.setStatusHistory(
          wayBillInfo,
          "流水线组板",
          wayBillInfo.orderStatus,
          "出库扫描完毕,等待发往机场"
        );
        let log = new TMSSortingPanelLog();
        log.wayBillCode = wayBillInfo.wayBillCode;
        log.wayBillWeight = wayBillInfo.weight;
        log.message = wayBillInfo.abnormalReason;
        log.planDropOffPort = wayBillInfo.planDropOffPort;
        log.actualDropOffPort = wayBillInfo.actualDropOffPort;
        log.userProduct_Id = 1007;
        log.userProductCode = "100000001";
        log.userProductAlias = "WmsSaaS云仓系统";
        log.platUser_Id = 1;
        log.platCorpName = "澳德";
        log.platUserCode = "PT20180001";
        await this.dbWrite.save(log);
      } else {
        if (this.info.data != null) {
          let wayBillInfo: TMSWayBill = this.info.data as TMSWayBill;
          if (wayBillInfo.printNum != null) {
            wayBillInfo.printNum += 1;
          } else {
            wayBillInfo.printNum = 1;
          }
          wayBillInfo.abnormalReason = this.info.msg;
          await this.dbWrite.update(TMSWayBill, wayBillInfo.wayBill_Id, {
            printNum: ++wayBillInfo.printNum,
            abnormalReason: this.info.msg
          });
          this.ctx.service.tms.wayBillHelper.setStatusHistory(
            wayBillInfo,
            "PC组板",
            wayBillInfo.orderStatus + wayBillInfo.abnormalReason
          ); //添加运单追踪记录
          let log = new TMSSortingPanelLog();
          log.wayBillCode = wayBillInfo.wayBillCode;
          log.wayBillWeight = wayBillInfo.weight;
          log.message = wayBillInfo.abnormalReason;
          log.planDropOffPort = wayBillInfo.planDropOffPort;
          log.actualDropOffPort = wayBillInfo.actualDropOffPort;
          log.userProduct_Id = 1007;
          log.userProductCode = "100000001";
          log.userProductAlias = "WmsSaaS云仓系统";
          log.platUser_Id = 1;
          log.platCorpName = "澳德";
          log.platUserCode = "PT20180001";
          await this.dbWrite.save(log);
        }
      }
    } catch (ex) {
      this.info.result = false;
      this.info.msg = ex.message;
    }
    this.ctx.body = this.info;
  }
  //#endregion
}