天津投入产出系统后端
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.
 
 
 
 
 
 

303 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.FJC.Entity.Operation;
using QMAPP.Entity;
using QMFrameWork.Data;
using QMAPP.FJC.DAL.Operation;
using QMAPP.FJC.Entity;
using QMFrameWork.Log;
using QMAPP.FJC.Entity.WIPManage;
using QMFrameWork.Common.Serialization;
using QMAPP.FJC.DAL.WarehouseManage;
using QMAPP.FJC.BLL.Dict;
namespace QMAPP.FJC.BLL.WarehouseManage
{
/// <summary>
/// 模块编号:M13-4
/// 作 用:入库(工控机)逻辑层
/// 作 者:王丹丹
/// 编写日期:2015年07月15日
///</summary>
public class InWarehouseBLL : BaseBLL
{
#region 入库操作(零件)
/// <summary>
/// 入库操作(零件)
/// </summary>
/// <param name="product">条件</param>
public DataResult ProductOutWarehouse(Product product)
{
DataResult result = new DataResult();
ProductDAL productDal=new ProductDAL();
InWarehouseDAL inWarehouseDal = new InWarehouseDAL();
WIPInRecorder inrecorder = new WIPInRecorder();
int count=0;
try
{
if (product.OUTFLAG != EnumGeter.OUTFLAG.EXCEPTIONOUT.GetHashCode().ToString())
{
result.IsSuccess = false;
result.Msg = Resource.ProductIsNotExceptionOut;
return result;
}
if (product.USINGSTATE != EnumGeter.USINGSTATE.UNUSED.GetHashCode().ToString())
{
result.IsSuccess = false;
result.Msg = Resource.ProductIsUsed;
return result;
}
product.OUTFLAG = EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString();
#region 基本信息
//string json = JsonConvertHelper.GetDeserialize<Product>(product.ToString());
inrecorder.PID = Guid.NewGuid().ToString();
inrecorder.PRODUCTTYPE = product.PRODUCTTYPE;
inrecorder.PRODUCTCODE = product.PRODUCTCODE;
inrecorder.PROCESSTYPE = product.CURRENTPROCESS;
inrecorder.COUNT = product.CAPACITY-product.USINGCOUNT;
inrecorder.MACHINECODDE = product.MACHINECODDE;
inrecorder.MACHINENAME = product.MACHINENAME;
inrecorder.PRODUCESHIFTTCODE = product.PRODUCESHIFTTCODE;
inrecorder.PRODUCESHIFTNAME = product.PRODUCESHIFTNAME;
inrecorder.PRODUCELINE = product.PRODUCELINE;
inrecorder.INTIME = DateTime.Now;
inrecorder.CREATEUSER = LoginUser.UserID;
inrecorder.CREATEDATE = DateTime.Now;
inrecorder.UPDATEUSER = inrecorder.CREATEUSER;
inrecorder.UPDATEDATE = inrecorder.CREATEDATE;
#endregion
using (IDataSession session = AppDataFactory.CreateMainSession())
{
productDal.BaseSession = session;
inWarehouseDal.BaseSession = session;
session.OpenCon();
//更新零件入库标记
count = new ProductDAL().Update(product);
//插入入库记录
count = inWarehouseDal.Insert(inrecorder);
session.CommitTs();
}
if (count == 0)
{
result.IsSuccess = false;
result.Msg = Resource.OutWarehouseIsNotSuccess;
return result;
}
result.IsSuccess = true;
result.Msg = Resource.InWarehouseIsSuccess;
return result;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "入库(工控机)逻辑层-入库条码校验(工控机)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
}
#endregion
#region 入库操作(本体)
/// <summary>
/// 入库操作(本体)
/// </summary>
/// <param name="main">条件</param>
public DataResult MainOutWarehouse(Main main)
{
DataResult result = new DataResult();
MainDAL mainDal = new MainDAL();
InWarehouseDAL inWarehouseDal = new InWarehouseDAL();
WIPInRecorder inrecorder = new WIPInRecorder();
int count = 0;
try
{
if (main.OUTFLAG != EnumGeter.OUTFLAG.EXCEPTIONOUT.GetHashCode().ToString())
{
result.IsSuccess = false;
result.Msg = Resource.ProductIsNotExceptionOut;
return result;
}
main.OUTFLAG = EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString();
#region 基本信息
//string json = JsonConvertHelper.GetDeserialize<Product>(product.ToString());
inrecorder.PID = Guid.NewGuid().ToString();
inrecorder.PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString();
inrecorder.PRODUCTCODE = main.EPIDERMISCODE;
inrecorder.PROCESSTYPE = main.CURRENTPROCESS;
inrecorder.COUNT = 1;
inrecorder.MACHINECODDE = main.MACHINECODDE;
inrecorder.PRODUCESHIFTTCODE = main.PRODUCESHIFTTCODE;
inrecorder.PRODUCESHIFTNAME = main.PRODUCESHIFTNAME;
inrecorder.PRODUCELINE = main.PRODUCELINE;
inrecorder.INTIME = DateTime.Now;
inrecorder.CREATEUSER = LoginUser.UserID;
inrecorder.CREATEDATE = DateTime.Now;
inrecorder.UPDATEUSER = inrecorder.CREATEUSER;
inrecorder.UPDATEDATE = inrecorder.CREATEDATE;
#endregion
using (IDataSession session = AppDataFactory.CreateMainSession())
{
mainDal.BaseSession = session;
inWarehouseDal.BaseSession = session;
session.OpenCon();
//更新本体入库标记
count = new MainDAL().Update(main);
//插入入库记录
count = inWarehouseDal.Insert(inrecorder);
session.CommitTs();
}
if (count == 0)
{
result.IsSuccess = false;
result.Msg = Resource.OutWarehouseIsNotSuccess;
return result;
}
result.IsSuccess = true;
result.Msg = Resource.InWarehouseIsSuccess;
return result;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "入库(工控机)逻辑层-入库条码校验(工控机)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
}
#endregion
#region 获取零件信息
/// <summary>
/// 获取零件信息
/// </summary>
/// <param name="product">条件</param>
public DataResult<Product> GetProductInfo(Product product)
{
DataResult<Product> result = new DataResult<Product>();
List<Product> listProduct = new List<Product>();
try
{
listProduct = new ProductDAL().GetList(product);
if (listProduct.Count == 0)
{
result.IsSuccess = false;
result.Msg = Resource.OperationProNotFound;
return result;
}
product = listProduct[0];
#region 转换零件状态、当前工序、零件类别、零件状态显示类型
DictManageBLL dictOutFlagBll = new DictManageBLL(DictKind.OUTFLAG);
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
//入库状态
product.OUTFLAGNAME = dictOutFlagBll.GetDictValue(product.OUTFLAG);
//当前工序
product.CURRENTPROCESSNAME = dictProcessTypeBll.GetDictValue(product.CURRENTPROCESS);
//零件类别
product.PRODUCTTYPENAME = dictProductTypeBll.GetDictValue(product.PRODUCTTYPE);
//零件状态
product.STATUSNAME = dictProductStatusBll.GetDictValue(product.STATUS);
#endregion
result.Result = listProduct[0];
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "入库(工控机)逻辑层-获取零件信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
}
#endregion
#region 获取本体信息
/// <summary>
/// 获取本体信息
/// </summary>
/// <param name="product">条件</param>
public DataResult<Main> GetMainInfo(Main main)
{
DataResult<Main> result = new DataResult<Main>();
try
{
main = new MainDAL().GetMainForOutwarehouse(main);
if (main==null)
{
result.IsSuccess = false;
result.Msg = Resource.OperationMainNotFound;
return result;
}
#region 转换零件状态、当前工序、零件类别显示类型
DictManageBLL dictOutFlagBll = new DictManageBLL(DictKind.OUTFLAG);
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
//入库状态
main.OUTFLAGNAME = dictOutFlagBll.GetDictValue(main.OUTFLAG);
//当前工序
main.CURRENTPROCESSNAME = dictProcessTypeBll.GetDictValue(main.CURRENTPROCESS);
//零件类别
main.PRODUCTTYPENAME = dictProductTypeBll.GetDictValue(EnumGeter.ProductType.biaopi.GetHashCode().ToString());
//零件状态
main.STATUSNAME = dictProductStatusBll.GetDictValue(main.STATUS);
#endregion
result.Result = main;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "入库(工控机)逻辑层-获取本体信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
}
#endregion
}
}