|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:库存调整模块Service层
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
|
|
|
public class StockAdjustDefineService : BaseService<SysStock>, IStockAdjustDefineService
|
|
|
{
|
|
|
private readonly IStockAdjustDefineRepository repository;
|
|
|
|
|
|
public StockAdjustDefineService(IStockAdjustDefineRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
public List<SysStock> GetAllData(string _where)
|
|
|
{
|
|
|
return repository.GetAllData(_where);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将记录插入到历史库存表
|
|
|
/// </summary>
|
|
|
/// <param name="LotNo">编号</param>
|
|
|
/// <returns></returns>
|
|
|
public bool MoveStock(string LotNo)
|
|
|
{
|
|
|
return repository.MoveStock(LotNo);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断箱号是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="carton_no">箱号</param>
|
|
|
/// <returns>ture 不存在 false 存在</returns>
|
|
|
public bool IsExist(string carton_no)
|
|
|
{
|
|
|
return repository.IsExist(carton_no);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断库存表中该库位信息是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="locate_id">库位ID</param>
|
|
|
/// <returns>ture 不存在 false 存在</returns>
|
|
|
public bool Exist(string locateID)
|
|
|
{
|
|
|
return repository.Exist(locateID);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新库位是否为空的状态
|
|
|
/// </summary>
|
|
|
/// <param name="locateID">库位编号</param>
|
|
|
public void UpdateLocateEmpty(string locateID)
|
|
|
{
|
|
|
repository.UpdateLocateEmpty(locateID);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 批量调整库存
|
|
|
/// </summary>
|
|
|
/// <param name="dt">需要调整的数据集</param>
|
|
|
/// <returns></returns>
|
|
|
public string AdjustStock(List<StockAdjustDefine> dt, int userID)
|
|
|
{
|
|
|
return repository.AdjustStock(dt,userID);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 变更事务状态
|
|
|
/// </summary>
|
|
|
/// <param name="lotNo"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool TransType(string lotNo, ref DataTable dt)
|
|
|
{
|
|
|
return repository.TransType(lotNo);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新
|
|
|
/// </summary>
|
|
|
/// <param name="qty">数量</param>
|
|
|
/// <param name="lot_no">箱号</param>
|
|
|
/// <returns></returns>
|
|
|
public bool update(string qty, string lot_no)
|
|
|
{
|
|
|
return repository.update(qty, lot_no);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="inputStream">文件全路径</param>
|
|
|
/// <param name="userInfo">登录用户信息</param>
|
|
|
public Hashtable ReadExcelFile(List<StockAdjustDefine> inputStream, int userId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
try
|
|
|
{
|
|
|
string message = "";
|
|
|
Hashtable resault = new Hashtable();
|
|
|
|
|
|
Hashtable Cache = new Hashtable();
|
|
|
|
|
|
if (inputStream == null || inputStream.Count == 0)
|
|
|
{
|
|
|
message = "没有需要调整的数据";
|
|
|
resault.Add("message", message);
|
|
|
return resault;
|
|
|
}
|
|
|
|
|
|
if (AdjustStock(inputStream, userId) == "OK")
|
|
|
{
|
|
|
message = "调整完成!";
|
|
|
resault.Add("message", message);
|
|
|
return resault;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "调整失败!";
|
|
|
resault.Add("message", message);
|
|
|
return resault;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.Add("message", "导入失败");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |