243 lines
		
	
	
		
			9.2 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			243 lines
		
	
	
		
			9.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace BLL
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    /// <summary>
							 | 
						|||
| 
								 | 
							
								    /// 领料计划录入
							 | 
						|||
| 
								 | 
							
								    /// </summary>
							 | 
						|||
| 
								 | 
							
								    public static class UsingPlanService
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键获取领料计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlanId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static Model.Weld_UsingPlan GetUsingPlanById(string usingPlanId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return Funs.DB.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 增加领料计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlan"></param>
							 | 
						|||
| 
								 | 
							
								        public static void AddUsingPlan(Model.Weld_UsingPlan usingPlan)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = new Model.Weld_UsingPlan();
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.UsingPlanId = usingPlan.UsingPlanId;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.WeldId = usingPlan.WeldId;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.ProjectId = usingPlan.ProjectId;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.WorkAreaId = usingPlan.WorkAreaId;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.UsePosition = usingPlan.UsePosition;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.TeamGroupId = usingPlan.TeamGroupId;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.STE_ID = usingPlan.STE_ID;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.STE_Name = usingPlan.STE_Name;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.Amount = usingPlan.Amount;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.UsingUnit = usingPlan.UsingUnit;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.UsingManOne = usingPlan.UsingManOne;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.UsingManTwo = usingPlan.UsingManTwo;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.InPutDate = usingPlan.InPutDate;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.OrderDate = usingPlan.OrderDate;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.OrderTime = usingPlan.OrderTime;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.CancelDate = usingPlan.CancelDate;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.IsCancel = usingPlan.IsCancel;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.CancelResult = usingPlan.CancelResult;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.IsSubmit = usingPlan.IsSubmit;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.InPutMan = usingPlan.InPutMan;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.IsSteelStru = usingPlan.IsSteelStru;
							 | 
						|||
| 
								 | 
							
								            newUsingPlan.Type = usingPlan.Type;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            db.Weld_UsingPlan.InsertOnSubmit(newUsingPlan);
							 | 
						|||
| 
								 | 
							
								            db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改领料计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlan"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateUsingPlan(Model.Weld_UsingPlan usingPlan)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlan.UsingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.WeldId = usingPlan.WeldId;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.ProjectId = usingPlan.ProjectId;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.WorkAreaId = usingPlan.WorkAreaId;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.UsePosition = usingPlan.UsePosition;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.TeamGroupId = usingPlan.TeamGroupId;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.STE_ID = usingPlan.STE_ID;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.STE_Name = usingPlan.STE_Name;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.Amount = usingPlan.Amount;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.UsingManOne = usingPlan.UsingManOne;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.UsingManTwo = usingPlan.UsingManTwo;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.UsingUnit = usingPlan.UsingUnit;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.InPutDate = usingPlan.InPutDate;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.OrderDate = usingPlan.OrderDate;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.OrderTime = usingPlan.OrderTime;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.CancelDate = usingPlan.CancelDate;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsCancel = usingPlan.IsCancel;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.CancelResult = usingPlan.CancelResult;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsSubmit = usingPlan.IsSubmit;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.InPutMan = usingPlan.InPutMan;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsSteelStru = usingPlan.IsSteelStru;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 领料计划提交
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlanId"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateIsSubmit(string usingPlanId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsSubmit = true;
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改领料计划完成确认
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlan"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateIsFinish(string usingPlanId, string finishMan)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.FinishMan = finishMan;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsFinish = true;
							 | 
						|||
| 
								 | 
							
								               
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改领料计划作废
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlan"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateIsCancel(string usingPlanId, string cancelResult)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.CancelResult = cancelResult;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsCancel = true;
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.CancelDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改领料计划是否完成
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlanId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="isFinish"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateUsingPlanIsFinish(string usingPlanId,bool? isFinish)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsFinish = isFinish;
							 | 
						|||
| 
								 | 
							
								               
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键删除领料计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlanId"></param>
							 | 
						|||
| 
								 | 
							
								        public static void DeleteUsingPlanById(string usingPlanId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan usingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (usingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                db.Weld_UsingPlan.DeleteOnSubmit(usingPlan);
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据焊材ID获取领料计划录入数量
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="weldId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static int GetUsingPlanByWeldId(string weldId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return (from x in Funs.DB.Weld_UsingPlan where x.WeldId == weldId select x).Count();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据焊工ID获取领料计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="welderId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Weld_UsingPlan> GetUsingPlanByWelderId(string welderId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return (from x in Funs.DB.Weld_UsingPlan where x.UsingManOne == welderId select x).ToList();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 判断预约次数是否已满(10分钟暂定4个)
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="inPutDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="orderTime"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static bool IsFullOrderTime(DateTime? inPutDate, string orderTime)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            bool isFull = false;
							 | 
						|||
| 
								 | 
							
								            var q = from x in Funs.DB.Weld_UsingPlan where x.InPutDate == inPutDate && x.OrderTime == orderTime select x;
							 | 
						|||
| 
								 | 
							
								            if (q.Count() >= 4)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                isFull = true;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return isFull;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取焊工当天领用计划
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="welderId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="curDate"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Weld_UsingPlan> GetWelderCurTimePlan(string welderId, DateTime? orderDate, string orderTime)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var q = (from x in Funs.DB.Weld_UsingPlan
							 | 
						|||
| 
								 | 
							
								                     where x.UsingManOne == welderId && x.OrderDate == orderDate && x.OrderTime == orderTime
							 | 
						|||
| 
								 | 
							
								                          && x.IsCancel == false
							 | 
						|||
| 
								 | 
							
								                     select x).ToList();
							 | 
						|||
| 
								 | 
							
								            return q;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 更新是否需要确认
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="usingPlanId"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateIsNeedConfirm(string usingPlanId,bool? isNeed)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UsingPlan newUsingPlan = db.Weld_UsingPlan.FirstOrDefault(e => e.UsingPlanId == usingPlanId);
							 | 
						|||
| 
								 | 
							
								            if (newUsingPlan != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUsingPlan.IsNeedConfirm = isNeed;
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |