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
|
}
|