using HH.WMS.BLL;
|
using HH.WMS.BLL.Basic;
|
using HH.WMS.BLL.SysMgr;
|
using HH.WMS.Common;
|
using HH.WMS.Entitys;
|
using HH.WMS.Entitys.Algorithm;
|
using HH.WMS.Entitys.Common;
|
using HH.WMS.WebApi.Areas.Common.Controllers;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Web;
|
//using System.Net;
|
//using System.Net.Http;
|
using System.Web.Http;
|
|
namespace HH.WMS.WebApi.Areas.Sys.Controllers
|
{
|
public class StockInitController : BaseController
|
{
|
|
|
|
#region Xml文件导入
|
/// <summary>
|
/// Xml文件导入
|
/// </summary>
|
/// <param name="entity">审批实体</param>
|
/// <returns></returns>
|
/// <History>[HANHE(XDL)] CREATED BY 2018-11-30</History>
|
[HttpPost]
|
public OperateResult SaveStockInit()
|
{
|
try
|
{
|
Stream ipstream = HttpContext.Current.Request.InputStream;
|
StreamReader sr = new StreamReader(ipstream);
|
string pDataStr = sr.ReadToEnd();
|
PostEntity dataEntity = JsonConvert.DeserializeObject<PostEntity>(pDataStr);
|
OperateResult or = new OperateResult();
|
return ValidateToken(dataEntity.TokenId, t =>
|
{
|
//最终实体
|
List<ImportTemplateEntity> importTempList = new List<ImportTemplateEntity>();
|
|
string stream = Util.ToString(dataEntity.PostData);// entityStr.streamStr.ToString();
|
|
importTempList = JsonConvert.DeserializeObject<List<ImportTemplateEntity>>(stream);
|
|
List<TN_AB_STOCKEntity> stockList = BLLCreator.Create<TN_WMS_STOCKBLL>().GetStockList();
|
|
var stockEntityList = stockList.Where(x => x.CN_S_STOCK_CODE == importTempList[0].CN_S_STOCK_CODE).ToList();
|
|
if (stockEntityList.Any())
|
{
|
if (stockEntityList[0].CN_C_IS_INIT != Constants.N)
|
{
|
return OperateResult.Error("初始化失败!仓库必须是未初始化状态!");
|
}
|
}
|
|
|
or = BLLCreator.Create<StockInitBLL>().SaveStockInit(importTempList, t);
|
|
|
return or;
|
|
});
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message);
|
}
|
}
|
#endregion
|
}
|
}
|