import BaseController from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { TMSWayBill } from "../../entity/express/tms/tmsWayBill";
|
import { In } from "typeorm";
|
import { TMSRouterTask } from "../../entity/express/tmstask/tmsRouterTask";
|
|
/**
|
* 路由获取任务
|
*/
|
export default class RouterTaskController extends BaseController {
|
//#region EditStatus 修改状态
|
@Post()
|
public async editStatus() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
try {
|
if (!Array.isArray(body.wayBillCodes) || !body.wayBillCodes.length) {
|
this.info.result = false;
|
this.info.msg = "数据不存在";
|
ctx.body = this.info;
|
return;
|
}
|
|
await this.dbWrite.update(
|
TMSRouterTask,
|
{
|
wayBillCode: In(body.wayBillCodes)
|
},
|
{
|
taskStatus: body.taskStatus,
|
orderStatus: body.orderStatus
|
}
|
);
|
await this.dbWrite.update(
|
TMSWayBill,
|
{
|
wayBillCode: In(body.wayBillCodes)
|
},
|
{
|
orderStatus: body.orderStatus
|
}
|
);
|
this.info.result = true;
|
this.info.msg = "更新状态成功";
|
ctx.body = this.info;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "异常" + ex.message;
|
ctx.body = this.info;
|
}
|
}
|
//#endregion
|
|
//#region 获取运单路由
|
@Post()
|
public async getRouter() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
if (!Array.isArray(body.wayBillCodes) || !body.wayBillCodes.length) {
|
this.info.result = false;
|
this.info.msg = "数据不存在";
|
ctx.body = this.info;
|
return;
|
}
|
try {
|
for (var wayBillCode of body.wayBillCodes) {
|
await ctx.service.tms.routerHelper.doAllRouter(`wayBillCode='${wayBillCode}'`, true);
|
}
|
|
this.info.result = true;
|
this.info.msg = "执行完成";
|
|
ctx.body = this.info;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "异常" + ex;
|
ctx.body = this.info;
|
}
|
}
|
//#endregion
|
}
|