using HH.WMS.BLL;
using HH.WMS.BLL.Basic;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Basic;
using HH.WMS.Entitys.Common;
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.Net;
using System.Net.Http;
using System.Web.Http;
namespace HH.WMS.WebApi.Areas.Basic
{
public class LotInfoController : BaseController
{
///
/// 分页获取批次列表
///
/// 页码
/// 页显示条数
///
/// [HANHE(XDL)] CREATED BY 2018-12-03
[HttpGet]
public OperateResult GetLotList(int pageIndex, int pageSize)
{
try
{
return ValidateToken(x =>
{
var list = BLLCreator.Create().GetLotList(pageIndex, pageSize);
return list;
});
}
catch (Exception ex)
{
return OperateResult.Error(ex.Message);
}
}
#region 查询批次
///
/// 查询批次
///
/// 查询实体
///
[HttpPost]
public string GetLotList(SearchModel searchModel)
{
return ValidateToken(searchModel.TokenId, m =>
{
OperateResult resultInfo = GetTokenInfo(searchModel.TokenId);
if (!resultInfo.Success) return JsonConvert.SerializeObject(resultInfo);
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
long total;
DataTable dt = BLLCreator.Create().GetLotList(searchModel, out total);
OperateResult pagingList = OperateResult.Succeed("", new
{
rows = dt,
total = total
});
return JsonConvert.SerializeObject(pagingList, timeFormat);
});
}
#endregion
[HttpGet]
public string GetLotInfoList()
{
return ValidateToken(m =>
{
try
{
List lotList = BLLCreator.Create>().GetList();
return JsonConvert.SerializeObject(lotList);
}
catch (Exception ex)
{
return "";
}
});
}
///
/// U8服务调用
///
/// 批次集合
///
[HttpPost]
public string AddLotInfo(List lotInfoList)
{
OperateResult or = BLLCreator.Create>().AddRange(lotInfoList);
return JsonConvert.SerializeObject(or);
}
}
}