using HH.WMS.BLL;
|
using HH.WMS.BLL.AllQuery;
|
using HH.WMS.BLL.Basic;
|
using HH.WMS.BLL.External;
|
using HH.WMS.BLL.InStock;
|
using HH.WMS.BLL.OutStock;
|
using HH.WMS.Common;
|
using HH.WMS.DAL;
|
using HH.WMS.DAL.Algorithm;
|
using HH.WMS.DAL.Basic;
|
using HH.WMS.DAL.InStock;
|
using HH.WMS.Entitys;
|
using HH.WMS.Entitys.Basic;
|
using HH.WMS.Entitys.Common;
|
using HH.WMS.Entitys.Entitys;
|
using HH.WMS.Entitys.External;
|
using HH.WMS.Utils;
|
using HH.WMS.WebApi.Areas.Common.Controllers;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Web;
|
using System.Web.Http;
|
|
namespace HH.WMS.WebApi.Areas.AllQuery.Controllers
|
{
|
/// <summary>
|
/// 库存统计Controller
|
/// </summary>
|
public class InventoryController : BaseController
|
{
|
#region 出入库业务查询
|
/// <summary>
|
/// 出入库业务查询
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetOrderBussList(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
//IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
|
//timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
result = BLLCreator.Create<InventoryBll>().GetOrderBussList(searchModel.PageIndex, searchModel.PageSize, searchModel.SearchCondition);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 库存统计查询
|
/// <summary>
|
/// 库存统计查询
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetInventoryList(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
return BLLCreator.Create<InventoryBll>().GetInventoryList(searchModel, true);
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
|
/// <summary>
|
/// 库存查询不分页
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2019-1-20</History>
|
[HttpPost]
|
public OperateResult GetInventoryListExport(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
return BLLCreator.Create<InventoryBll>().GetInventoryList(searchModel, false);
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 汇总指定日期内的出入库业务量
|
/// <summary>
|
/// 汇总指定日期内的出入库业务量
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <param name="orderBy"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(dbs)] created 2018/12/2</History>
|
public OperateResult GetBussLine(int day)
|
{
|
return ValidateToken(x =>
|
{
|
DataTable dt = null;
|
try
|
{
|
dt = BLLCreator.Create<InventoryBll>().GetBussLine(day);
|
return OperateResult.Succeed("", dt);
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 获取货位的历史上下架记录
|
/// <summary>
|
/// 获取货位的历史上下架记录
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetLocationHistory(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetLocationHistory(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 获取货位的历史上下架记录 巨星
|
/// <summary>
|
/// 获取货位的历史上下架记录
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetLocationHistoryJx(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetLocationHistoryJx(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 查询货位库存
|
/// <summary>
|
/// 查询货位库存
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetLocationInventoryList(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetLocationInventoryList(searchModel, false);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
[HttpPost]
|
public OperateResult GetLocationInventoryListJx(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetLocationInventoryListJx(searchModel, false);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
|
[HttpPost]
|
public OperateResult GetLocationInventoryExport(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetLocationInventoryList(searchModel, true);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
//[HttpPost]
|
//public OperateResult HistoryLine(SearchModel searchModel)
|
//{
|
// return ValidateToken(searchModel.TokenId, x =>
|
// {
|
// try
|
// {
|
// OperateResult result;
|
// result = BLLCreator.Create<InventoryBll>().HistoryLine(searchModel);
|
// return result;
|
// }
|
// catch (Exception ex)
|
// {
|
// return OperateResult.Error(ex.Message.ToString());
|
// }
|
// });
|
//}
|
|
#region 查询盘点报表
|
/// <summary>
|
/// 查询盘点报表
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2019-1-10</History>
|
[HttpPost]
|
public OperateResult GetCheckDtl(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetCheckDtl(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 汇总查询盘点报表
|
/// <summary>
|
/// 汇总查询盘点报表
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2019-1-10</History>
|
[HttpPost]
|
public OperateResult GetCheckDtlTotal(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetCheckDtlTotal(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 物料盘点汇总
|
/// <summary>
|
/// 物料盘点汇总
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2019-1-10</History>
|
[HttpPost]
|
public OperateResult GetItemCheckDtl(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetItemCheckDtl(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 物料盘点数量金额汇总
|
/// <summary>
|
/// 物料盘点数量金额汇总
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2019-1-10</History>
|
[HttpPost]
|
public OperateResult GetItemCheckDtlTotal(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetCheckDtlTotal(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
#endregion
|
|
#region 更新记录
|
/// <summary>
|
/// 更新记录
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public OperateResult GetVersionLog()
|
{
|
return ValidateToken(t =>
|
{
|
var updateLogList = BLLCreator.Create<InventoryBll>().GetVersionLog().Where(x => x.CN_T_UPDATE.HasValue);
|
var ul = updateLogList.Select(x =>
|
{
|
return new
|
{
|
version = x.CN_S_VERSION,
|
title = "更新时间:" + x.CN_T_UPDATE.Value.ToString("yyyy-MM-dd"),
|
content = x.CN_S_CONTENT,
|
order = x.CN_N_ORDER
|
};
|
});
|
var result = ul.GroupBy(x => new
|
{
|
x.version,
|
x.title
|
}).Select(y => new
|
{
|
title = y.Key.version + " " + y.Key.title,
|
update = y.AsEnumerable().OrderBy(o => o.order).Select(s => new
|
{
|
content = s.order + "、" + s.content
|
})
|
});
|
return OperateResult.Succeed(null, result);
|
});
|
}
|
#endregion
|
|
[HttpGet]
|
public OperateResult OutItemBoardData()
|
{
|
return ValidateToken(t =>
|
{
|
//待出库和已复验的所有出库单
|
var outMst = BLLCreator.CreateDapper<TN_WM_OUT_MSTEntity>().GetList(new
|
{
|
CN_S_STATE = new List<string>() { Constants.State_WaitOut, Constants.State_Rechecked }
|
});
|
//出库单子表
|
var outDtl = BLLCreator.CreateDapper<TN_WM_OUT_DTLEntity>().GetList(new
|
{
|
CN_S_OP_NO = outMst.Select(x => x.CN_S_OP_NO).ToList()
|
});
|
//波次主表
|
var waveMst = BLLCreator.CreateDapper<TN_WM_WAVE_MSTEntity>().GetList(new
|
{
|
CN_S_WAVE_NO = outMst.Select(x => x.CN_S_WAVE_CODE).ToList()
|
});
|
var result = outMst.Select(x =>
|
{
|
var currentDtl = outDtl.FindAll(y => y.CN_S_OP_NO == x.CN_S_OP_NO);
|
string pickState = "待拣";
|
if (x.CN_S_STATE == Constants.State_Rechecked)
|
{
|
pickState = "已拣";
|
}
|
else
|
{
|
var waveEntity = waveMst.Find(w => w.CN_S_WAVE_NO == x.CN_S_WAVE_CODE);
|
if (waveEntity != null && waveEntity.CN_S_STATE != Constants.Sorting_Stay && waveEntity.CN_S_STATE != Constants.Sorting_Being)
|
pickState = "已拣";
|
}
|
return new
|
{
|
OpNo = x.CN_S_OP_NO,
|
FromNo = x.CN_S_FROM_NO,
|
Customer = x.CN_S_CUSTOMER_NAME,
|
PickState = pickState,
|
Items = currentDtl.Select(m => new
|
{
|
ItemCode = m.CN_S_ITEM_CODE,
|
ItemName = m.CN_S_ITEM_NAME,
|
ItemModel = m.CN_S_MODEL,
|
ProductNo = m.CN_S_PRODUCTION_BATCH,
|
Qty = m.CN_F_QUANTITY,
|
Unit = m.CN_S_MEASURE_UNIT
|
})
|
};
|
});
|
return OperateResult.Succeed(null, result);
|
});
|
}
|
|
|
#region 恢复到正常
|
|
[HttpGet]
|
public IHttpActionResult LocationToNormal(string locationCode, string state)
|
{
|
Log.Info("恢复到正常", "接收参数为:" + locationCode + state);
|
var result = new OperateResult();
|
|
if (string.IsNullOrEmpty(state))
|
state = "";
|
|
if (state.Equals("扫码异常"))
|
{
|
result = BLLCreator.Create<TN_WM_LOCATION_EXTBLL>().UpdateState(locationCode.Trim(), "正常", "");
|
}
|
else
|
{
|
//更新货位状态到正常,空
|
result = BLLCreator.Create<TN_WM_LOCATION_EXTBLL>().UpdateState(locationCode.Trim(), "正常", "");
|
}
|
|
|
return Json(result);
|
}
|
|
#endregion
|
|
#region 解绑货位
|
|
[HttpGet]
|
public IHttpActionResult LocationToUnBind(string locationCode, string state)
|
{
|
try
|
{
|
Log.Detail("解绑货位", "接收参数为locationCode:" + locationCode + " state为:" + state);
|
|
locationCode = locationCode.Trim();
|
var objLocation = BLLCreator.Create<TN_WM_B_TRAY_LOCATIONBLL>().GetDetailByLocationCode(locationCode).FirstOrDefault();
|
var result = BLLCreator.Create<DapperBLL<TN_WM_B_TRAY_LOCATIONEntity>>().Delete(new { CN_S_LOCATION_CODE = locationCode });
|
Log.Detail("解绑货位", "删除托盘货位关联结果:" + JsonConvert.SerializeObject(result));
|
if (!result.Success)
|
{
|
return Json(result);
|
}
|
|
AutoBomLocationEntity locationModel = DALCreator.Create<TN_WMS_LOCATIONDAL>().GetModel(locationCode);
|
BLLCreator.Create<TN_WM_B_LOCATION_CHANGEBLL>().AddStateChange(locationCode, "空取异常", "正常", "恢复正常", "WMS", "", "", locationModel.CN_S_STOCK_CODE, locationModel.CN_S_AREA_CODE, null);
|
|
//删除托盘产品关联
|
result = DALCreator.Create<TN_WM_B_TRAY_ITEM_RELDAL>().DeleteTrayItem(" CN_S_TRAY_CODE='" + objLocation.CN_S_TRAY_CODE + "' ", null);
|
Log.Detail("解绑货位", "删除托盘产品关联结果:" + JsonConvert.SerializeObject(result));
|
return Json(result);
|
}
|
catch (Exception ex)
|
{
|
Log.Info("LocationToUnBind error", ex.Message);
|
return Json(OperateResult.Error(ex.Message));
|
}
|
}
|
|
#endregion
|
|
#region 绑定托盘货位物料
|
|
[HttpGet]
|
public IHttpActionResult LocationToBind(string locationCode, string trayCode, string materialCode)
|
{
|
locationCode = locationCode.Trim();
|
var result = new SqlExecuteResult { Success = true };
|
|
AutoBomItemEntity materialEntity = BLLCreator.Create<TN_WMS_ITEMBLL>().GetItem(materialCode);
|
|
TN_WM_B_TRAY_INFOEntity trayEntity = BLLCreator.Create<DapperBLL<TN_WM_B_TRAY_INFOEntity>>().GetSingleEntity(new { CN_S_TRAY_CODE = trayCode }); //DALCreator.Create<TN_WM_B_TRAY_INFODAL>().GetModel(trayCode);
|
|
TN_WM_B_TRAY_ITEM_RELEntity entity = new TN_WM_B_TRAY_ITEM_RELEntity();
|
entity.CN_S_TRAY_CODE = trayCode;
|
entity.CN_S_TRAY_GRID = "1";
|
entity.CN_S_ITEM_CODE = materialEntity.CN_S_ITEM_CODE;
|
entity.CN_S_ITEM_NAME = materialEntity.CN_S_ITEM_NAME;
|
entity.CN_S_ITEM_STATE = "合格";
|
entity.CN_S_TRAY_TYPE = "托盘";
|
entity.CN_GUID = Guid.NewGuid().ToString();
|
entity.CN_F_QUANTITY = 1;
|
entity.CN_T_CREATE = DateTime.Now;
|
entity.CN_T_MODIFY = DateTime.Now;
|
|
result = DAOManager.ExecuteTransaction(trans =>
|
{
|
|
//删除原托盘中绑定的物料
|
var transResult = DALCreator.Create<TN_WM_B_TRAY_ITEM_RELDAL>().DeleteTrayItem(" CN_S_TRAY_CODE='" + trayCode + "' ", trans);
|
//result = BLLCreator.Create<TN_WM_B_TRAY_ITEM_RELBLL>().DeleteItemRel(" and CN_S_TRAY_CODE = '" + trayCode + "'", trans);
|
if (transResult.Success)
|
{
|
//添加托盘料架关联
|
transResult = BLLCreator.Create<DapperBLL<TN_WM_B_TRAY_ITEM_RELEntity>>().Add(entity);
|
//result = BLLCreator.Create<TN_WM_B_TRAY_ITEM_RELBLL>().(new List<TN_WM_B_TRAY_ITEM_RELEntity> { entity }, null);
|
}
|
if (!transResult.Success)
|
{
|
DAOManager.RollbackTransaction(trans);
|
return new SqlExecuteResult { Success = transResult.Success };
|
}
|
//添加托盘货位关联
|
transResult = BLLCreator.Create<TN_WM_B_TRAY_LOCATIONBLL>().AddTrayLocationRelation(trayCode, locationCode, new Redis.ReisModel.RedisUserEntity(), "");
|
if (!transResult.Success)
|
{
|
DAOManager.RollbackTransaction(trans);
|
}
|
return new SqlExecuteResult { Success = transResult.Success };
|
});
|
|
return Json(result);
|
}
|
|
#endregion
|
|
#region 宇寿需求变更20190926 新增业务汇总查询
|
|
/// <summary>
|
/// 获取货位的历史上下架记录
|
/// </summary>
|
/// <param name="searchModel"></param>
|
/// <returns></returns>
|
/// <History>[Hanhe(DBS)] CREATED BY 2018-12-03</History>
|
[HttpPost]
|
public OperateResult GetInventorySummary(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().GetInventorySummary(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
|
[HttpPost]
|
public OperateResult ExportInventorySummary(SearchModel searchModel)
|
{
|
return ValidateToken(searchModel.TokenId, x =>
|
{
|
try
|
{
|
OperateResult result;
|
result = BLLCreator.Create<InventoryBll>().ExportInventorySummary(searchModel);
|
return result;
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message.ToString());
|
}
|
});
|
}
|
|
#endregion
|
}
|
}
|