import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { PurchaseShelve } from "../../entity/inbound/purchase/purchaseShelve";
|
import * as sql from "mssql";
|
import { In } from "typeorm";
|
import { SysUserLog } from "../../entity/sys/core/sysUserLog";
|
|
/**
|
* 收货 - 上架
|
*/
|
export default class ShelveController extends BaseController {
|
//#region 强制上架完成 forceShelve
|
@Post()
|
public async forceShelve() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
try {
|
// if (!Array.isArray(body.shelve_Ids) || body.shelve_Ids.length) {
|
// this.info.msg = "数据不存在";
|
// this.info.result = false;
|
// ctx.body = this.info;
|
// return;
|
// }
|
if (!body.shelve_Ids) {
|
this.info.msg = "数据不存在";
|
this.info.result = false;
|
ctx.body = this.info;
|
return;
|
}
|
|
await this.dbWrite.update(
|
PurchaseShelve,
|
{
|
shelve_Id: In(body.shelve_Ids)
|
},
|
{
|
onShelveStatus: "上架完成"
|
}
|
);
|
this.info.result = true;
|
this.info.msg = "强制上架完成";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
|
//#region 取消上架 cancelShelve
|
@Post()
|
public async cancelShelve() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
|
const connection: any = await this.dbWrite.connection;
|
let request = new sql.Request(connection.driver.master);
|
request.input("shelve_Ids", body.shelve_Ids);
|
request.output("outMsg", sql.NVarChar(2000));
|
let result = await request.execute("sp_Purchase_Shelve_Cancel");
|
let outMsg = result.output.outMsg;
|
|
if (outMsg) {
|
this.info.msg = outMsg;
|
this.info.result = false;
|
} else {
|
this.info.msg = "上架撤销成功";
|
this.info.result = true;
|
}
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 审核 singleConfirm
|
@Post()
|
public async singleConfirm() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
|
if (!Array.isArray(body.idValues) || body.idValues.length) {
|
this.info.msg = "数据不存在";
|
this.info.result = false;
|
ctx.body = this.info;
|
return;
|
}
|
|
let outMsg = [];
|
for (let idValue of body.idValues) {
|
const connection: any = await this.dbWrite.connection;
|
let request = new sql.Request(connection.driver.master);
|
request.input("shelve_Id", idValue);
|
request.input("user_Id", userInfo.user_Id);
|
request.input("menu_Id", body.menu_Id);
|
request.output("outMsg", sql.NVarChar(2000));
|
let result = await request.execute("sp_Purchase_Shelve_Check");
|
outMsg.push(result.output.outMsg);
|
}
|
|
if (outMsg) {
|
this.info.msg = outMsg.join("<br/>");
|
this.info.result = false;
|
} else {
|
this.info.msg = "确认上架成功";
|
this.info.result = true;
|
}
|
ctx.body = this.info;
|
//#endregion
|
}
|
|
//#region 入库指令 shelveOrder
|
@Post()
|
public async shelveOrder() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
try {
|
await this.dbWrite.update(
|
PurchaseShelve,
|
{
|
shelve_Id: body.shelve_Id
|
},
|
{
|
onShelveStatus: "待上架"
|
}
|
);
|
this.info.result = true;
|
this.info.msg = "入库操作完成";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "错误:" + error.message;
|
}
|
|
ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
//#region 删除身份证信息
|
@Post()
|
public async deleteShelveCode() {
|
try {
|
let userInfo = await this.userInfo;
|
// 根据id删除
|
await this.dbWrite.delete(PurchaseShelve, {
|
shelve_Id: In(this.body.ids)
|
});
|
// 添加日志
|
let userLog = new SysUserLog();
|
userLog.operateType = "码盘上架查询";
|
userLog.action = "删除单号:-" + this.body.shelveCode;
|
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
|
}
|