import BaseService from "../baseService";
|
import { BaseStorage } from "../../entity/basicInfo/base/baseStorage";
|
import { BasePosition } from "../../entity/basicInfo/base/basePosition";
|
import { Not } from "typeorm";
|
|
/**
|
* 仓库信息Service
|
*/
|
export default class StorageService extends BaseService {
|
//#region 创建仓库时自动增加收货位和理货位
|
public async onAddSaveAfter(dataInfo: BaseStorage, isAdd: boolean) {
|
let userInfo = await this.userInfo;
|
if (isAdd) {
|
// 自动增加收货位
|
let posInfo = new BasePosition();
|
posInfo.storage_Id = dataInfo.storage_Id;
|
posInfo.storageName = dataInfo.storageName;
|
posInfo.parentId = 0;
|
posInfo.positionName = "收货位";
|
posInfo.positionType = 4;
|
posInfo.isFreeze = 0;
|
posInfo.isLocked = 0;
|
posInfo.isMixProduct = 1;
|
posInfo.enable = 1;
|
|
posInfo.createDate = new Date();
|
posInfo.createID = userInfo.user_Id;
|
posInfo.creator = userInfo.userTrueName;
|
|
posInfo.platCorpName = dataInfo.platCorpName;
|
posInfo.platUserCode = dataInfo.platUserCode;
|
posInfo.platUserName = dataInfo.platUserName;
|
posInfo.platUser_Id = dataInfo.platUser_Id;
|
posInfo.userProductAlias = dataInfo.userProductAlias;
|
posInfo.userProductCode = dataInfo.userProductCode;
|
posInfo.userProduct_Id = dataInfo.userProduct_Id;
|
this.dbWrite.save(posInfo);
|
|
// 自动增加下架理货位
|
posInfo = new BasePosition();
|
posInfo.storage_Id = dataInfo.storage_Id;
|
posInfo.storageName = dataInfo.storageName;
|
posInfo.parentId = 0;
|
posInfo.positionName = "下架理货位";
|
posInfo.positionType = 5;
|
posInfo.isFreeze = 0;
|
posInfo.isLocked = 0;
|
posInfo.isMixProduct = 1;
|
posInfo.enable = 1;
|
|
posInfo.createDate = new Date();
|
posInfo.createID = userInfo.user_Id;
|
posInfo.creator = userInfo.userTrueName;
|
|
posInfo.platCorpName = dataInfo.platCorpName;
|
posInfo.platUserCode = dataInfo.platUserCode;
|
posInfo.platUserName = dataInfo.platUserName;
|
posInfo.platUser_Id = dataInfo.platUser_Id;
|
posInfo.userProductAlias = dataInfo.userProductAlias;
|
posInfo.userProductCode = dataInfo.userProductCode;
|
posInfo.userProduct_Id = dataInfo.userProduct_Id;
|
this.dbWrite.save(posInfo);
|
}
|
}
|
//#endregion
|
//#region 保存前时间
|
public async onAddSaveBefore(t: BaseStorage, isAdd: boolean) {
|
// let userInfo = await this.userInfo;
|
this.info.result = true;
|
let userInfo = await this.userInfo;
|
//判断条码是否重复
|
if (isAdd) {
|
let contractInfo = await this.dbRead.findOne(BaseStorage, {
|
userProduct_Id: userInfo.userProduct_Id,
|
storageName: t.storageName,
|
});
|
if (contractInfo) {
|
this.info.result = false;
|
this.info.msg = `当前仓库名称${t.storageName}已存在不允许重复添加,无法添加!`;
|
}
|
} else {
|
let contractInfo = await this.dbRead.findOne(BaseStorage, {
|
userProduct_Id: t.userProduct_Id,
|
storageName: t.storageName,
|
storage_Id: Not(t.storage_Id),
|
});
|
if (contractInfo) {
|
this.info.result = false;
|
this.info.msg = `当前仓库名称${t.storageName}已存在不允许重复添加,无法添加!`;
|
}
|
}
|
return this.info;
|
}
|
//#endregion
|
}
|