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

451 lines
14 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;
namespace QMAPP.FJC.BLL.ProduceManage
{
/// <summary>
/// 模块编号:M4-1
/// 作 用:生产记录逻辑层
/// 作 者:张敬贺
/// 编写日期:2015年06月04日
///</summary>
public class ProducePlanBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<ProducePlan> Get(ProducePlan model)
{
DataResult<ProducePlan> result = new DataResult<ProducePlan>();
try
{
result.Result = new ProducePlanDAL().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(ProducePlan condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new ProducePlanDAL().GetList(condition, page);
#region 转换工序类别显示类型
List<ProducePlan> list = dataPage.Result as List<ProducePlan>;
//处理字典信息
DictManageBLL dictPROCESSTYPE = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictPRODUCTTYPE = new DictManageBLL(DictKind.PRODUCTTYPE);
DictManageBLL dictPLANSTATUS = new DictManageBLL(DictKind.PLANSTATUS);
DictManageBLL dictCREATETYPE = new DictManageBLL(DictKind.CREATETYPE);
DictManageBLL dictCOLOR = new DictManageBLL(DictKind.COLOR);
DictManageBLL dictHB = new DictManageBLL(DictKind.HAndL);
foreach (var info in list)
{
//替换工序类别显示值
info.PROCESSTYPE = dictPROCESSTYPE.GetDictValue(info.PROCESSTYPE);
//替换零件类别显示值
info.PRODUCTTYPE = dictPRODUCTTYPE.GetDictValue(info.PRODUCTTYPE);
//替换计划状态显示值
info.PLANSTATUS = dictPLANSTATUS.GetDictValue(info.PLANSTATUS);
//替换生产状态显示值
info.CREATETYPE = dictCREATETYPE.GetDictValue(info.CREATETYPE);
//颜色
info.COLOR = dictCOLOR.GetDictValue(info.COLOR);
//高低配
info.HB = dictHB.GetDictValue(info.HB);
}
#endregion
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<ProducePlan> GetAllList(ProducePlan condition)
{
try
{
//获取信息列表
List<ProducePlan> list = new ProducePlanDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "生产记录获取列表异常!"
});
throw ex;
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<ProducePlan> GetTotal(ProducePlan condition)
{
try
{
List<ProducePlan> list;
//获取信息列表
if (EnumGeter.ProductType.benti.GetHashCode().ToString().Equals(condition.PRODUCTTYPE))
{
list = new ProducePlanDAL().GetTotalMain(condition);
}
else
{
list = new ProducePlanDAL().GetTotalProduct(condition);
}
return list;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "生产记录获取列表异常!"
});
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult Insert(ProducePlan model)
{
DataResult result = new DataResult();
ProducePlanDAL ppDAL = new ProducePlanDAL();
try
{
result.IsSuccess = true;
//基本信息
model.PID = Guid.NewGuid().ToString();
model.PLANSTATUS = QMAPP.FJC.Entity.EnumGeter.PLANSTATUS.INITIALIZATION.GetHashCode().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
model.PASTFLAG = "0";
model.CREATETYPE = "1";
model.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
#region 生成生产计划号
string planCode = ppDAL.GetPlanCode();
if (planCode == "")
{
model.PLANCODE = "B9" + DateTime.Now.ToString("yyyyMMdd") + "001";
}
else
{
model.PLANCODE = planCode.Substring(0, 10) + (Convert.ToInt32(planCode.Substring(10)) + 1);
int zeroNum = 13 - model.PLANCODE.Length;
string zero = "";
for (int i = 0; i < zeroNum; i++)
{
zero += "0";
}
model.PLANCODE = model.PLANCODE.Substring(0, 10) + zero + model.PLANCODE.Substring(10);
}
#endregion
int temp = ppDAL.Insert(model);
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 Update(ProducePlan model)
{
DataResult result = new DataResult();
result.IsSuccess = true;
try
{
ProducePlan info = new ProducePlanDAL().Get(model);
//基本信息
info.PROCESSTYPE = model.PROCESSTYPE;
info.PRODUCTTYPE = model.PRODUCTTYPE;
info.PRODUCECOUNT = model.PRODUCECOUNT;
info.MEMO = model.MEMO;
info.UPDATEUSER = this.LoginUser.UserID;
int temp = new ProducePlanDAL().Update(info);
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;
int count = 0;
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
bool isComplent= this.ExisteStatus(new ProducePlan { PID = str });
if (isComplent == true)
{
result.IsSuccess = false;
result.Msg = Resource.PlanIsComplent;
return result;
}
}
foreach (string str in list)
{
count += this.DeleteInfo(new ProducePlan { PID = str });
}
if (count != list.Length)
{
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.Msg = "生产记录删除异常!";
result.Ex = ex;
}
return result;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteInfo(ProducePlan model)
{
int count = 0;
try
{
count = new ProducePlanDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 完成计划
/// <summary>
/// 完成计划
/// </summary>
/// <param name=""></param>
/// <returns>完成计划</returns>
public DataResult ProductOver(string str)
{
DataResult result = new DataResult();
result.IsSuccess = true;
int count = 0;
try
{
ProducePlan info = new ProducePlanDAL().Get(new ProducePlan { PID = str });
if (info.PLANSTATUS == EnumGeter.PLANSTATUS.COMPLETED.GetHashCode().ToString())
{
result.IsSuccess = false;
result.Msg = Resource.PlanNoMoreComplent;
return result;
}
//基本信息
info.PLANSTATUS = QMAPP.FJC.Entity.EnumGeter.PLANSTATUS.COMPLETED.GetHashCode().ToString();
info.UPDATEUSER = this.LoginUser.UserID;
count += new ProducePlanDAL().Update(info);
if (count == 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.Msg = "完成生产记录异常!";
result.Ex = ex;
}
return result;
}
#endregion
#region 校验生产计划是否完成
/// <summary>
/// 校验生产计划是否完成
/// </summary>
/// <returns></returns>
public bool ExisteStatus(ProducePlan model)
{
try
{
model = new ProducePlanDAL().Get(model);
if (model.PLANSTATUS == EnumGeter.PLANSTATUS.COMPLETED.GetHashCode().ToString())
{
return true;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "生产记录逻辑层-校验生产计划是否完成"
});
}
return false;
}
#endregion
}
}