15 changed files with 536 additions and 6 deletions
@ -0,0 +1,358 @@ |
|||||
|
using MESClassLibrary.BLL.Log; |
||||
|
using MESClassLibrary.DAL.ZPPlan; |
||||
|
using MESClassLibrary.EFModel; |
||||
|
using MESClassLibrary.Model; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace MESClassLibrary.BLL.BasicInfo |
||||
|
{ |
||||
|
public class ZP_MK_PlanBLL |
||||
|
{ |
||||
|
readonly BasicBLL<tb_ZP_MK_Plan> db = new BasicBLL<tb_ZP_MK_Plan>(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="md"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public bool AddInfo(tb_ZP_MK_Plan md) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var now = DateTime.Now; |
||||
|
md.ID = Guid.NewGuid().ToString(); |
||||
|
md.CreateTime = now; |
||||
|
md.OrderNo = now.ToString("yyyyMMdd"); |
||||
|
md.State = 0; |
||||
|
md.ProductCount = 0; |
||||
|
md.BadCount = 0; |
||||
|
md.Item = GetItem(md.OrderNo); |
||||
|
var result = db.AddInfo(md); |
||||
|
return result; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private int GetItem(string orderNo) |
||||
|
{ |
||||
|
var lastItem = db.Search(q => q.OrderNo == orderNo, q => q.CreateTime).LastOrDefault(); |
||||
|
return lastItem == null ? 1 : (lastItem.Item.Value + 1); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="md"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public bool UpdateInfo(tb_ZP_MK_Plan md, ref string msg) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var data = db.SearchInfoByID(md.ID); |
||||
|
if (data.State == 3) |
||||
|
{ |
||||
|
msg = "该计划已经完成"; |
||||
|
return false; |
||||
|
} |
||||
|
if (data.ProductCount.GetValueOrDefault(0).CompareTo(md.OrderCount) > 0) |
||||
|
{ |
||||
|
msg = "计划数量不能小于完成数量"; |
||||
|
return false; |
||||
|
} |
||||
|
if (data.ProductCount.GetValueOrDefault(0) == 0) |
||||
|
{ |
||||
|
//data.StationID = md.StationID;
|
||||
|
data.PartNo = md.PartNo; |
||||
|
data.OrderDate = md.OrderDate; |
||||
|
} |
||||
|
|
||||
|
//data.IsOneMore = md.IsOneMore;
|
||||
|
data.OrderCount = md.OrderCount; |
||||
|
data.OrderName = md.OrderName; |
||||
|
return db.UpdateInfo(data); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
msg = ex.ToString(); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="md"></param>
|
||||
|
/// <param name="flag"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public bool DeleteInfo(tb_ZP_MK_Plan md) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
return db.DelInfo(md); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询全部信息分页
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public string SearchInfoAll(int page, |
||||
|
int pagesize, |
||||
|
string startTime, |
||||
|
string endTime, |
||||
|
string partNo) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
string jsonStr = "[]"; |
||||
|
int total = 0;//总行数
|
||||
|
IEnumerable<tb_ZP_MK_Plan> list = SearchDB(startTime, endTime, partNo); |
||||
|
if (list.Any()) |
||||
|
{ |
||||
|
List<ZP_MK_PlanModel> modelList = new List<ZP_MK_PlanModel>(); |
||||
|
total = list.Count(); |
||||
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize); |
||||
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)); |
||||
|
|
||||
|
ProductBLL prodBll = new ProductBLL(); |
||||
|
var prodList = prodBll.SearchAll(); |
||||
|
//StationBLL stationBll = new StationBLL();
|
||||
|
//var stationList = stationBll.SearchAll();
|
||||
|
|
||||
|
foreach (var item in list) |
||||
|
{ |
||||
|
var prodInfo = prodList.Where(q => q.PartNo == item.PartNo).FirstOrDefault(); |
||||
|
//var stationInfo = stationList.Where(q => q.StationID == item.StationID).FirstOrDefault();
|
||||
|
|
||||
|
ZP_MK_PlanModel zpm = Tool.Mapper<ZP_MK_PlanModel, tb_ZP_MK_Plan>(item); |
||||
|
//zpm.StationNo = stationInfo == null ? "" : stationInfo.StationNo;
|
||||
|
zpm.ProductName = prodInfo == null ? "" : prodInfo.ProductName; |
||||
|
|
||||
|
modelList.Add(zpm); |
||||
|
} |
||||
|
|
||||
|
JsonDataModel<ZP_MK_PlanModel> md = new JsonDataModel<ZP_MK_PlanModel> |
||||
|
{ |
||||
|
total = total.ToString(), |
||||
|
rows = modelList |
||||
|
}; |
||||
|
jsonStr = md.ToSerializer(); |
||||
|
} |
||||
|
|
||||
|
return jsonStr; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<ZP_MK_PlanModel> SearchByCreateTime(string startTime, string endTime, string partNo) |
||||
|
{ |
||||
|
IEnumerable<tb_ZP_MK_Plan> list = SearchDB(startTime, endTime, partNo); |
||||
|
List<ZP_MK_PlanModel> modelList = new List<ZP_MK_PlanModel>(); |
||||
|
if (list.Any()) |
||||
|
{ |
||||
|
ProductBLL prodBll = new ProductBLL(); |
||||
|
var prodList = prodBll.SearchAll(); |
||||
|
StationBLL stationBll = new StationBLL(); |
||||
|
var stationList = stationBll.SearchAll(); |
||||
|
|
||||
|
foreach (var item in list) |
||||
|
{ |
||||
|
var prodInfo = prodList.Where(q => q.PartNo == item.PartNo).FirstOrDefault(); |
||||
|
//var stationInfo = stationList.Where(q => q.StationID == item.StationID).FirstOrDefault();
|
||||
|
|
||||
|
ZP_MK_PlanModel zpm = Tool.Mapper<ZP_MK_PlanModel, tb_ZP_MK_Plan>(item); |
||||
|
//zpm.StationNo = stationInfo == null ? "" : stationInfo.StationNo;
|
||||
|
zpm.ProductName = prodInfo == null ? "" : prodInfo.ProductName; |
||||
|
|
||||
|
modelList.Add(zpm); |
||||
|
} |
||||
|
} |
||||
|
return modelList; |
||||
|
} |
||||
|
|
||||
|
public IEnumerable<tb_ZP_MK_Plan> SearchDB(string startTime, string endTime, string partNo) |
||||
|
{ |
||||
|
DateTime st, et; |
||||
|
if (!DateTime.TryParse(startTime, out st)) st = DateTime.MinValue; |
||||
|
if (!DateTime.TryParse(endTime, out et)) et = DateTime.MaxValue; |
||||
|
|
||||
|
IEnumerable<tb_ZP_MK_Plan> list; |
||||
|
if (string.IsNullOrEmpty(partNo)) |
||||
|
{ |
||||
|
list = db.Search( |
||||
|
q => (q.CreateTime >= st && |
||||
|
q.CreateTime <= et) && |
||||
|
q.State != 3, |
||||
|
q => q.CreateTime); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
list = db.Search(q => q.PartNo != null && q.PartNo.Contains(partNo) && q.State == 0, q => q.CreateTime); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询全部信息
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public List<tb_ZP_MK_Plan> SearchAll() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var s_list = db.SearchAllInfo(); |
||||
|
return s_list; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID查询信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public tb_ZP_MK_Plan SearchInfoByID(string id) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
return db.SearchInfoByID(id); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public DataTable GetProductingPlan(string station) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal=new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.GetProductingPlan(station); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public DataTable GetProductingPlan1(string station,string orderNo) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.GetProductingPlan1(station,orderNo); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public DataTable GetPlan(string station, int flag, string planTime) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.GetPlan(station, flag,planTime); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public bool updateQty(ZPPlanModel md) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.updateQty(md); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public bool updateBad(ZPPlanModel md) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.updateBad(md); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public DataTable SearchPlanInfo(string planID) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.SearchPlanInfo(planID); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public DataTable SearchOrderNo(string orderno) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
ZPPlanDAL dal = new ZPPlanDAL(); |
||||
|
|
||||
|
return dal.SearchOrderNo(orderno); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod()); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// 此代码已从模板生成。
|
||||
|
//
|
||||
|
// 手动更改此文件可能导致应用程序出现意外的行为。
|
||||
|
// 如果重新生成代码,将覆盖对此文件的手动更改。
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace MESClassLibrary.EFModel |
||||
|
{ |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
public partial class tb_ZP_MK_Plan |
||||
|
{ |
||||
|
public string ID { get; set; } |
||||
|
public string OrderNo { get; set; } |
||||
|
public string OrderName { get; set; } |
||||
|
public Nullable<System.DateTime> OrderDate { get; set; } |
||||
|
public Nullable<int> Item { get; set; } |
||||
|
public string Station { get; set; } |
||||
|
public string Line { get; set; } |
||||
|
public string PartNo { get; set; } |
||||
|
public Nullable<int> OrderCount { get; set; } |
||||
|
public Nullable<int> ProductCount { get; set; } |
||||
|
public Nullable<int> State { get; set; } |
||||
|
public Nullable<int> BadCount { get; set; } |
||||
|
public Nullable<System.DateTime> CreateTime { get; set; } |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
using MESClassLibrary.EFModel; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace MESClassLibrary.Model |
||||
|
{ |
||||
|
public class ZP_MK_PlanModel : tb_ZP_MK_Plan |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 工位名称
|
||||
|
/// </summary>
|
||||
|
public string StationNo { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 零件名称
|
||||
|
/// </summary>
|
||||
|
public string ProductName { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue