天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

370 lines
12 KiB

using System;
using System.Collections.Generic;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.FJC.BLL.Dict;
using QMAPP.FJC.DAL.ProduceManage;
using QMAPP.FJC.Entity.ProduceManage;
using QMFrameWork.Data;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
using QMAPP.MD.Entity.TianJin;
using QMAPP.FJC.DAL.TianJin;
using System.Data;
namespace QMAPP.FJC.BLL.TianJin
{
/// <summary>
/// 模块名称:天津--仓库信息
/// 作 者:张松男
/// 编写日期:2022年02月15日
/// </summary>
public class StorageBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Storage> Get(Storage model)
{
DataResult<Storage> result = new DataResult<Storage>();
try
{
result.Result = new StorageDAL().Get(model);
result.IsSuccess = true;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "获取异常";
}
return result;
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(Storage condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
DataPage dataPage = new StorageDAL().GetList(condition, page);
result.IsSuccess = true;
result.Result = dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "获取列表异常!";
}
return result;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<Storage> GetAllList()
{
try
{
//获取信息列表
return new StorageDAL().GetALL();
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
throw ex;
}
}
#endregion
public DataResult<int> SelectCount(string ProductCode)
{
DataResult<int> result = new DataResult<int>();
StorageDAL cmdDAL = new StorageDAL();
result.Result = cmdDAL.SelectCount(ProductCode);
return result;
}
#region 入库信息
/// <summary>
/// 入库信息
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Storage info)
{
DataResult<int> result = new DataResult<int>();
try
{
//基本信息
info.PID = Guid.NewGuid().ToString();
info.CREATEUSER = this.LoginUser.UserName;
info.CREATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = info.CREATEUSER;
info.UPDATEDATE = info.CREATEDATE;
//返迁入库,状态从前端传入 State=3
if (string.IsNullOrEmpty(info.State))
info.State = "1";
StorageDAL cmdDAL = new StorageDAL();
result.Result = cmdDAL.Insert(info);
var storageLog = new StorageLog();
storageLog.PID = Guid.NewGuid().ToString();
storageLog.CREATEUSER = this.LoginUser.UserName;
storageLog.CREATEDATE = DateTime.Now.ToString();
storageLog.UPDATEUSER = info.CREATEUSER;
storageLog.UPDATEDATE = info.CREATEDATE;
storageLog.State = "1";
storageLog.ProductCode = info.ProductCode;
storageLog.MATERIALCODE = info.MATERIALCODE;
storageLog.MATERIALNAME = info.MATERIALNAME;
storageLog.InStorageType = info.InStorageType;
//storageLog
StorageLogDAL cmdDALlog = new StorageLogDAL();
cmdDALlog.Insert(storageLog);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 出库信息
/// <summary>
/// 出库信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult Update(Storage model)
{
DataResult result = new DataResult();
result.IsSuccess = true;
try
{
Storage info = new Storage();
if (!string.IsNullOrEmpty(model.ProductCode))
{
info = new StorageDAL().Get(model.ProductCode);
}
if (!string.IsNullOrEmpty(model.PID))
{
info = new StorageDAL().GetPID(model.PID);
}
//条码涉及到返迁入库,条码会有重复的可能
//if (info.State == "2")
//{
// result.IsSuccess = false;
// result.Msg = $"条码{model.ProductCode}在{info.UPDATEDATE}已进行过出库操作!";
// return result;
//}
int temp = 0;
//基本信息
if (!string.IsNullOrEmpty(model.State))
{
info.UPDATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = this.LoginUser.UserName;
info.State = model.State;
temp = new StorageDAL().Update(info);
var storageLog2 = new StorageLog();
storageLog2.PID = Guid.NewGuid().ToString();
storageLog2.CREATEUSER = this.LoginUser.UserName;
storageLog2.CREATEDATE = DateTime.Now.ToString();
storageLog2.UPDATEUSER = info.CREATEUSER;
storageLog2.UPDATEDATE = info.CREATEDATE;
storageLog2.State = model.State;
storageLog2.ProductCode = info.ProductCode;
storageLog2.MATERIALCODE = info.MATERIALCODE;
storageLog2.MATERIALNAME = info.MATERIALNAME;
storageLog2.InStorageType = info.InStorageType;
StorageLogDAL cmdDALlog2 = new StorageLogDAL();
cmdDALlog2.Insert(storageLog2);
}
else
{
info.State = "2";
info.UPDATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = this.LoginUser.UserName;
info.OutStorageType = model.OutStorageType;
temp = new StorageDAL().Update(info);
var storageLog = new StorageLog();
storageLog.PID = Guid.NewGuid().ToString();
storageLog.CREATEUSER = this.LoginUser.UserName;
storageLog.CREATEDATE = DateTime.Now.ToString();
storageLog.UPDATEUSER = info.CREATEUSER;
storageLog.UPDATEDATE = info.CREATEDATE;
storageLog.State = "2";
storageLog.ProductCode = info.ProductCode;
storageLog.MATERIALCODE = info.MATERIALCODE;
storageLog.MATERIALNAME = info.MATERIALNAME;
storageLog.InStorageType = info.InStorageType;
StorageLogDAL cmdDALlog = new StorageLogDAL();
cmdDALlog.Insert(storageLog);
}
if (temp == 0)
{
result.IsSuccess = false;
result.Msg = "更新失败!";
return result;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "更新异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "更新异常";
}
return result;
}
#endregion
#region 出库信息
/// <summary>
/// 出库信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult Delete(string strs)
{
DataResult result = new DataResult();
result.IsSuccess = true;
try
{
int temp = 0;
if (!string.IsNullOrEmpty(strs))
{
foreach (var str in strs.Split(':'))
{
Storage info = new Storage();
info = new StorageDAL().GetPID(str);
//基本信息
info.UPDATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = this.LoginUser.UserName;
info.State = "5";
temp += new StorageDAL().Update(info);
var storageLog2 = new StorageLog();
storageLog2.PID = Guid.NewGuid().ToString();
storageLog2.CREATEUSER = this.LoginUser.UserName;
storageLog2.CREATEDATE = DateTime.Now.ToString();
storageLog2.UPDATEUSER = info.CREATEUSER;
storageLog2.UPDATEDATE = info.CREATEDATE;
storageLog2.State = "5";
storageLog2.ProductCode = info.ProductCode;
storageLog2.MATERIALCODE = info.MATERIALCODE;
storageLog2.MATERIALNAME = info.MATERIALNAME;
storageLog2.InStorageType = "管理员删除";
StorageLogDAL cmdDALlog2 = new StorageLogDAL();
cmdDALlog2.Insert(storageLog2);
}
}
if (temp == 0)
{
result.IsSuccess = false;
result.Msg = "更新失败!";
return result;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "更新异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "更新异常";
}
return result;
}
#endregion
#region 导出数据
/// <summary>
/// 获取导出的数据
/// </summary>
/// <param name="user">查询条件</param>
/// <returns>数据</returns>
public DataTable GetExportData(Storage model)
{
try
{
return new StorageDAL().GetExportData(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "导出库存信息"
});
throw ex;
}
}
#endregion
}
}