import { default as BaseController } from "../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { BaseStorageArea } from "../../entity/basicInfo/base/baseStorageArea";
|
import { BaseStorageShelve } from "../../entity/basicInfo/position/baseStorageShelve";
|
import { vBaseProductPosition } from "../../entity/storage/product/vBaseProductPosition";
|
import { BasePosition } from "../../entity/basicInfo/base/basePosition";
|
/**
|
* 收货 - 收货计划单
|
*/
|
export default class PositionController extends BaseController {
|
//#region GetStorageAreaInfo 获得库区信息
|
/// <summary>
|
/// 加载下拉框数据
|
/// </summary>
|
/// <param name="reqInfo"></param>
|
/// <returns></returns>
|
///
|
@Post()
|
public async getStorageAreaInfo() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
|
let areaInfo = await this.dbRead.find(BaseStorageArea, {
|
where: {
|
userProduct_Id: userInfo.user_Id,
|
storage_Id: body.Id,
|
areaCode: body.code
|
}
|
});
|
|
this.info.result = true;
|
this.info.data = areaInfo;
|
ctx.body = this.info;
|
}
|
// #endregion
|
|
//#region GetStorageAreaList 获得库区列表
|
/// <summary>
|
/// 加载下拉框数据
|
/// </summary>
|
/// <param name="reqInfo"></param>
|
/// <returns></returns>
|
///
|
@Post()
|
public async getStorageAreaList() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
let areaList = await this.dbRead.find(BaseStorageArea, {
|
where: {
|
userProduct_Id: userInfo.user_Id,
|
storage_Id: body.Id
|
}
|
});
|
this.info.result = true;
|
this.info.data = areaList;
|
ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region LoadShelveList 获得库区信息
|
/// <summary>
|
/// 加载下拉框数据
|
/// </summary>
|
/// <param name="reqInfo"></param>
|
/// <returns></returns>
|
///
|
|
@Post()
|
public async loadShelveList() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let storageArea = await this.dbRead.find(BaseStorageArea, {
|
where: {
|
areaCode: body.Code,
|
storage_Id: body.Id
|
}
|
});
|
|
if (storageArea) {
|
this.info.result = true;
|
this.info.data = storageArea;
|
} else {
|
let areaInfo = await this.dbRead.find(BaseStorageShelve, {
|
where: {
|
areaCode: body.Code,
|
storage_Id: body.Id
|
}
|
});
|
this.info.result = true;
|
this.info.data = areaInfo;
|
}
|
ctx.body = this.info;
|
}
|
// #endregion
|
|
// #region GetPositionList 获得货位列表
|
/// <summary>
|
/// 加载下拉框数据
|
/// </summary>
|
/// <param name="reqInfo"></param>
|
/// <returns></returns>
|
///
|
@Post()
|
public async getPositionStorageList() {
|
let { ctx } = this;
|
let body = ctx.request.body;
|
let dataList = await this.dbRead.find(vBaseProductPosition, {
|
where: {
|
areaCode: body.Code,
|
storage_Id: body.Id,
|
positionName: body.name
|
}
|
});
|
|
this.info.result = true;
|
this.info.data = dataList;
|
ctx.body = this.info;
|
}
|
// #endregion
|
|
//#region GetStorageAreaList 批量修改长宽高
|
/// <summary>
|
/// 批量修改长宽高
|
/// </summary>
|
/// <param name="reqInfo"></param>
|
/// <returns></returns>
|
///
|
@Post()
|
public async updateAll() {
|
let { ctx } = this;
|
|
try {
|
let body = ctx.request.body;
|
let userInfo = await ctx.helper.userInfo();
|
var taskForm = body.taskForm;
|
|
if (body.ids.length != 0) {
|
for (let list of body.ids) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
} else if (body.areaCode && body.storage_Id && body.shelveCode && body.channelCode) {
|
let dataList = await this.dbRead.find(BasePosition, {
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
areaCode: body.areaCode,
|
storage_Id: body.storage_Id,
|
shelveCode: body.shelveCode,
|
channelCode: body.channelCode
|
}
|
});
|
for (let list of dataList) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list.position_Id
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
} else if (body.areaCode && body.storage_Id && body.shelveCode) {
|
let dataList = await this.dbRead.find(BasePosition, {
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
areaCode: body.areaCode,
|
storage_Id: body.storage_Id,
|
shelveCode: body.shelveCode
|
}
|
});
|
for (let list of dataList) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list.position_Id
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
} else if (body.areaCode && body.storage_Id && body.channelCode) {
|
let dataList = await this.dbRead.find(BasePosition, {
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
areaCode: body.areaCode,
|
storage_Id: body.storage_Id,
|
channelCode: body.channelCode
|
}
|
});
|
for (let list of dataList) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list.position_Id
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
} else if (body.areaCode && body.storage_Id) {
|
let dataList = await this.dbRead.find(BasePosition, {
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
areaCode: body.areaCode,
|
storage_Id: body.storage_Id
|
}
|
});
|
for (let list of dataList) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list.position_Id
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
} else if (body.storage_Id) {
|
let dataList = await this.dbRead.find(BasePosition, {
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
storage_Id: body.storage_Id
|
}
|
});
|
for (let list of dataList) {
|
await this.dbWrite.update(
|
BasePosition,
|
{
|
userProduct_Id: userInfo.userProduct_Id,
|
|
position_Id: list.position_Id
|
},
|
{
|
length: taskForm.length,
|
width: taskForm.width,
|
height: taskForm.height
|
}
|
);
|
}
|
}
|
|
this.info.msg = "修改成功!";
|
this.info.result = true;
|
ctx.body = this.info;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "错误信息:" + ex.message;
|
}
|
}
|
// #endregion
|
}
|