import BaseService from "../baseService";
|
import { ResultInfo } from "../../public/commonInterface";
|
import { BaseProductPlaceHolder } from "../../entity/storage/storage/baseProductPlaceHolder";
|
import { StorageOuter } from "../../entity/storage/operation/storageOuter";
|
import { StorageOuterList } from "../../entity/storage/operation/storageOuterList";
|
|
export default class StorageService extends BaseService {
|
//#region 终止
|
public async stop(): Promise<ResultInfo> {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
const className = "其他出库";
|
|
try {
|
let idValues = body.idValues;
|
if (!Array.isArray(idValues)) {
|
this.info.result = false;
|
this.info.msg = "没有可执行的数据";
|
return this.info;
|
}
|
|
for (var idValue of idValues) {
|
let dataInfo = await this.dbRead.findOne(StorageOuter, idValue);
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "单据不存在";
|
return this.info;
|
}
|
|
let statusText = dataInfo.statusText;
|
if (["新建", "审核成功"].indexOf(statusText) < 0) {
|
this.info.result = false;
|
this.info.msg = "只有【新建, 审核成功】才允许终止操作";
|
return this.info;
|
}
|
|
//执行中止操作
|
await this.dbWrite.delete(BaseProductPlaceHolder, {
|
mainID: idValue,
|
className: className,
|
userProduct_Id: userInfo.userProduct_Id
|
});
|
await this.dbWrite.update(
|
StorageOuterList,
|
{
|
outer_Id: dataInfo.outer_Id,
|
userProduct_Id: userInfo.userProduct_Id
|
},
|
{
|
lackStorage: 0
|
}
|
);
|
await this.dbWrite.update(
|
StorageOuter,
|
{
|
outer_Id: dataInfo.outer_Id,
|
userProduct_Id: userInfo.userProduct_Id
|
},
|
{
|
statusText: "终止",
|
sortingStatus: 1,
|
sortingDate: null,
|
auditing: 0,
|
modifyID: userInfo.user_Id,
|
modifier: userInfo.userTrueName
|
}
|
);
|
}
|
this.info.result = true;
|
this.info.msg = "终止成功";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "终止失败" + error.message;
|
}
|
|
return this.info;
|
}
|
//#endregion
|
|
//#region 开启
|
public async open(): Promise<ResultInfo> {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
|
try {
|
let idValues = body.idValues;
|
if (!Array.isArray(idValues)) {
|
this.info.result = false;
|
this.info.msg = "没有可执行的数据";
|
return this.info;
|
}
|
|
for (var idValue of idValues) {
|
let dataInfo = await this.dbRead.findOne(StorageOuter, idValue);
|
if (!dataInfo) {
|
this.info.result = false;
|
this.info.msg = "单据不存在";
|
return this.info;
|
}
|
|
await this.dbWrite.update(
|
StorageOuter,
|
{
|
outer_Id: dataInfo.outer_Id,
|
userProduct_Id: userInfo.userProduct_Id
|
},
|
{
|
statusText: "新建",
|
sortingStatus: 1,
|
sortingDate: null,
|
auditing: 0,
|
modifyID: userInfo.user_Id,
|
modifier: userInfo.userTrueName
|
}
|
);
|
|
this.info.result = true;
|
this.info.msg = "开启成功,单据需要重新审核、分拣操作!";
|
}
|
|
this.info.result = true;
|
this.info.msg = "开启成功";
|
} catch (error) {
|
this.info.result = false;
|
this.info.msg = "开启失败" + error.message;
|
}
|
|
return this.info;
|
}
|
//#endregion
|
}
|