schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
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
import { default as BaseController } from "../../baseController";
import { Post } from "egg-shell-decorators";
import { TaskQueue } from "../../../entity/basicInfo/base/taskQueue";
import { In } from "typeorm";
// import { Like } from "typeorm";
// import { BasePosition } from "../../../entity/basicInfo/base/basePosition";
 
export default class brandNameController extends BaseController {
  //#region
  /**
   * 根据仓库获取货位管理里面的通道号
   */
  @Post()
  public async getRelation() {
    let userInfo = await this.userInfo;
    // var dataList = await this.dbRead.find(BasePosition, {
    //   select: ["channelCode"],
    //   where: {
    //     userProduct_Id: userInfo.userProduct_Id,
    //     storageName: Like("%" + this.body.name + "%")
    //   }
    // });
    var sql = `SELECT DISTINCT(channelCode) as channelCode FROM Base_Position 
      WHERE   channelCode is not NULL AND StorageName ='${this.body.name}' AND UserProduct_Id = '${userInfo.userProduct_Id}'`;
    var dataList = await this.dbRead.query(sql);
    if (dataList.length == 0) {
      this.info.result = false;
    } else {
      this.info.result = true;
      this.info.data = dataList.map(item => {
        return {
          label: item.channelCode,
          value: item.channelCode,
          channelCode: item.channelCode
        };
      });
    }
 
    this.ctx.body = this.info;
  }
  //#endregion
  //#region
  /**
   * 改变权重
   */
  @Post()
  public async changeOrderNumber() {
    let { ctx } = this;
    let body = ctx.request.body;
    // 更新主表合计
    let sql = `
        update Task_Queue set orderNumber=${body.orderNumber} where task_Id in(${body.orderIdList});
        `;
    await this.dbWrite.query(sql);
    this.info.result = true;
    this.ctx.body = this.info;
  }
  //#endregion
 
  //#endregion
 
  //#region
  /**
   * 改变权重上升
   */
  @Post()
  public async taskUpper() {
    let { ctx } = this;
    let body = ctx.request.body;
    // 更新主表合计
    let sql = `
        update Task_Queue set orderNumber= isnull(orderNumber,0)+1 where task_Id in(${body.orderIdList});
        `;
    await this.dbWrite.query(sql);
    this.info.result = true;
    this.ctx.body = this.info;
  }
  //#endregion
 
  //#region
  /**
   * 改变权重下降
   */
  @Post()
  public async tasklLower() {
    let { ctx } = this;
    let body = ctx.request.body;
    // 更新主表合计
    let sql = `
        update Task_Queue set orderNumber= isnull(orderNumber,0)-1 where task_Id in(${body.orderIdList});
        `;
    await this.dbWrite.query(sql);
    this.info.result = true;
    this.ctx.body = this.info;
  }
  //#endregion
 
  //#region 修改目标位
  @Post()
  public async updateToPosition() {
    try {
      let { ctx } = this;
      let body = ctx.request.body;
      let taskForm = body.taskForm;
      // 查询要修改的库存
      // var positionList = await this.dbRead.findOne(vBaseProductPosition, {
      //   productPosition_Id: this.body.ids
      // });
      var taskQueueList = await this.dbRead.find(TaskQueue, {
        task_Id: In(body.ids)
      });
      // 更新目标位
      for (var item of taskQueueList) {
        if (item.taskType !== "4") {
          this.info.result = false;
          this.info.msg = `只有常规出库才可以修改目标位`;
          ctx.body = this.info;
          return;
        }
      }
      await this.dbWrite.update(
        TaskQueue,
        {
          task_Id: In(body.ids)
        },
        {
          toPositionName: taskForm.toPositionName
        }
      );
      // 添加日志
      // let userLog = new SysUserLog();
      // userLog.operateType = "库存明细";
      // userLog.action = "修改物料-" + taskForm.productCode + ",库存量:" + taskForm.productStorage + "货位是:" + taskForm.positionName;
      // userLog.iP = this.ctx.request.ip;
      // userLog.userTrueName = userInfo.userTrueName;
 
      // await this.setAccountInfo(userLog);
      // await this.dbWrite.save(userLog);
      this.info.result = true;
      this.info.msg = "操作完成!";
    } catch (ex) {
      this.info.result = false;
      this.info.msg = "错误消息:" + ex.message;
    }
    this.ctx.body = this.info;
  }
  //#endregion
}