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
import BaseController from "../baseController";
import { Post } from "egg-shell-decorators";
import { ExpressQZPortOrder } from '../../entity/express/ldg/expressQZPortOrder';
 
export default class expressLdgOrder extends BaseController {
  //#region 通过陆地港推送运单 pushOrderByLdg
  /// <summary>
  ///通过陆地港推送运单 pushOrderByLdg
  /// </summary>
  /// <returns>返回获取快递单号结果</returns>
  ///
  @Post()
  public async pushOrderByLdg() {
    let { ctx } = this;
    let body = ctx.request.body;
    try {
      //#region 校验数据
 
      if (!body.orderIdList) {
        this.info.result = false;
        this.info.msg = "至少选择一条记录!";
        ctx.body = this.info;
        return;
      }
      //#endregion
      let orderIdList = body.orderIdList.split(",");
      var aLLSuccess = true;
      var msg = "返回信息:";
      for (let orderId of orderIdList) {
        let info = null;
        info = await ctx.service.express.ldgHelper.pushOrderByLgd(orderId);
        if (!info.result) {
          aLLSuccess = false;
        }
        msg = msg + info.msg;
      }
      this.info.result = aLLSuccess;
      this.info.msg = msg;
      ctx.body = this.info;
      return;
    } catch (ex) {
      this.info.result = false;
      this.info.msg = ex.message;
      ctx.body = this.info;
      return;
    }
  }
  //    #endregion
 
  // #region 通过陆地港轮询获取所有泉州顺丰圆通快递单号, 用于作业调度使用 getLdgExpressCodeByNode
  public async getLdgExpressCodeByNode() {
    let { ctx } = this;
    // let body = ctx.request.body;
    try {
      // var pageIndex = body.pageIndex
      var infoStr = await ctx.service.tms.routerHelper.getLdgExpressCodeByNode();
      this.info.result = infoStr.result;
      this.info.msg = infoStr.msg;
      ctx.body = this.info;
      return;
    } catch (ex) {
      this.info.result = false;
      this.info.msg = ex.message;
      ctx.body = this.info;
      return;
    }
  }
  // #endregion
 
  // #region 获取路由
  @Post()
  public async getRouter() {
    let { ctx } = this;
    // let body = ctx.request.body;
    try {
      let orderCodeList = this.body.orderCodeList;
      for (let expressNo of orderCodeList) {
        let orderInfo = await this.dbRead.findOne(ExpressQZPortOrder, {
          orderCode: expressNo
        });
        if(orderInfo.expressCorpName=="陆地港顺丰"){
          this.info.msg = await ctx.service.express.ldgHelper.getRoute(orderInfo.mailno);
        }
        else if(orderInfo.expressCorpName=="陆地港圆通")
        {
          var ldgResultInfo = await ctx.service.express.ldgHelper.getRouteByYT(orderInfo.mailno);
          this.info.msg = ldgResultInfo.msg;
        }
      }
      this.info.result = true;
      ctx.body = this.info;
    } catch (ex) {
      this.info.result = false;
      this.info.msg = ex.message;
      ctx.body = this.info;
    }
  }
  // #endregion
}