SGGL_SHJ/SGGL/BLL/HJGL/PreDesign/ProductionSchedulingPlanSer...

191 lines
8.9 KiB
C#
Raw Normal View History

2025-06-04 22:46:21 +08:00
using Model;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// 排产计划
/// </summary>
public class ProductionSchedulingPlanService
{
/// <summary>
/// 根据主键获取排产计划
/// </summary>
/// <param name="productionSchedulingPlanId"></param>
/// <returns></returns>
public static Model.HJGL_ProductionSchedulingPlan GetProductionSchedulingPlanById(string productionSchedulingPlanId)
{
return Funs.DB.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProductionSchedulingPlanId == productionSchedulingPlanId);
}
2025-10-23 16:35:37 +08:00
/// <summary>
/// 根据单位工程、流水段、材质、口径获取排产计划
/// </summary>
/// <param name="loginProjectId"></param>
/// <param name="flowingSection"></param>
/// <param name="unitWorkId"></param>
/// <param name="material"></param>
/// <param name="caliber"></param>
/// <returns></returns>
2025-06-09 17:20:34 +08:00
public static Model.HJGL_ProductionSchedulingPlan GetProductionSchedulingPlan(string loginProjectId, string flowingSection, string unitWorkId, string material, string caliber)
2025-06-04 22:46:21 +08:00
{
2025-08-04 10:44:32 +08:00
return Funs.DB.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProjectId == loginProjectId && e.FlowNum == flowingSection && e.PipelineId == unitWorkId && e.Material == material && e.Caliber == caliber);
2025-06-04 22:46:21 +08:00
}
2025-10-23 16:35:37 +08:00
/// <summary>
/// 根据单位工程、流水段获取排产计划信息
/// </summary>
/// <param name="loginProjectId"></param>
/// <param name="flowingSection"></param>
/// <param name="unitWorkId"></param>
/// <returns></returns>
public static List<Model.HJGL_ProductionSchedulingPlan> GetProductionSchedulingPlanByFlowingSection(string loginProjectId, string flowingSection, string unitWorkId)
{
return (from x in Funs.DB.HJGL_ProductionSchedulingPlan where x.ProjectId == loginProjectId && x.FlowNum == flowingSection && x.PipelineId == unitWorkId select x).ToList();
}
/// <summary>
/// 根据单位工程获取排产计划信息
/// </summary>
/// <param name="loginProjectId"></param>
/// <param name="unitWorkId"></param>
/// <returns></returns>
public static List<Model.HJGL_ProductionSchedulingPlan> GetProductionSchedulingPlanByUnitWorkId(string loginProjectId, string unitWorkId)
2025-10-09 09:30:37 +08:00
{
2025-10-23 16:35:37 +08:00
return (from x in Funs.DB.HJGL_ProductionSchedulingPlan where x.ProjectId == loginProjectId && x.PipelineId == unitWorkId select x).ToList();
2025-10-09 09:30:37 +08:00
}
2025-06-09 17:20:34 +08:00
/// <summary>
/// 增加排产计划
/// </summary>
/// <param name="plan"></param>
public static void AddProductionSchedulingPlan(Model.HJGL_ProductionSchedulingPlan plan)
2025-06-04 22:46:21 +08:00
{
SGGLDB db = Funs.DB;
Model.HJGL_ProductionSchedulingPlan newPlan = new HJGL_ProductionSchedulingPlan();
newPlan.ProductionSchedulingPlanId = plan.ProductionSchedulingPlanId;
newPlan.ProjectId = plan.ProjectId;
newPlan.PipelineId = plan.PipelineId;
newPlan.FlowNum = plan.FlowNum;
newPlan.MainItemName = plan.MainItemName;
newPlan.Material = plan.Material;
newPlan.Caliber = plan.Caliber;
newPlan.Dain = plan.Dain;
newPlan.TotalDyne = plan.TotalDyne;
newPlan.TotalPriority = plan.TotalPriority;
newPlan.PriorityTotalDyne = plan.PriorityTotalDyne;
newPlan.PlanStartDate = plan.PlanStartDate;
newPlan.PlanEndDate = plan.PlanEndDate;
newPlan.Days = plan.Days;
newPlan.AvgDailyWorkload = plan.Days;
2025-06-09 17:20:34 +08:00
newPlan.CompletedCount = plan.CompletedCount;
newPlan.CompletedRate = plan.CompletedRate;
newPlan.TotalCompletedRate = plan.TotalCompletedRate;
2025-09-24 15:27:48 +08:00
newPlan.OnDayCompleteDyne = plan.OnDayCompleteDyne;
newPlan.NextDayCompleteDyne = plan.NextDayCompleteDyne;
2025-06-04 22:46:21 +08:00
db.HJGL_ProductionSchedulingPlan.InsertOnSubmit(newPlan);
db.SubmitChanges();
}
/// <summary>
/// 修改排产计划
/// </summary>
/// <param name="plan"></param>
public static void UpdateProductionSchedulingPlan(Model.HJGL_ProductionSchedulingPlan plan)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_ProductionSchedulingPlan newPlan = db.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProductionSchedulingPlanId == plan.ProductionSchedulingPlanId);
if (newPlan != null)
{
newPlan.PipelineId = plan.PipelineId;
newPlan.FlowNum = plan.FlowNum;
newPlan.MainItemName = plan.MainItemName;
newPlan.Material = plan.Material;
newPlan.Caliber = plan.Caliber;
newPlan.Dain = plan.Dain;
newPlan.TotalDyne = plan.TotalDyne;
newPlan.TotalPriority = plan.TotalPriority;
newPlan.PriorityTotalDyne = plan.PriorityTotalDyne;
newPlan.PlanStartDate = plan.PlanStartDate;
newPlan.PlanEndDate = plan.PlanEndDate;
newPlan.Days = plan.Days;
newPlan.AvgDailyWorkload = plan.AvgDailyWorkload;
2025-06-09 17:20:34 +08:00
newPlan.CompletedCount = plan.CompletedCount;
newPlan.CompletedRate = plan.CompletedRate;
newPlan.TotalCompletedRate = plan.TotalCompletedRate;
2025-08-04 10:44:32 +08:00
newPlan.OnDayCompleteDyne = plan.OnDayCompleteDyne;
newPlan.NextDayCompleteDyne = plan.NextDayCompleteDyne;
2025-06-04 22:46:21 +08:00
try
{
db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
}
catch (System.Data.Linq.ChangeConflictException ex)
{
foreach (System.Data.Linq.ObjectChangeConflict occ in db.ChangeConflicts)
{
//以下是解决冲突的三种方法,选一种即可
// 使用当前数据库中的值覆盖Linq缓存中实体对象的值
occ.Resolve(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
// 使用Linq缓存中实体对象的值覆盖当前数据库中的值
occ.Resolve(System.Data.Linq.RefreshMode.KeepCurrentValues);
// 只更新实体对象中改变的字段的值,其他的保留不变
occ.Resolve(System.Data.Linq.RefreshMode.KeepChanges);
}
// 这个地方要注意Catch方法中我们前面只是指明了怎样来解决冲突这个地方还需要再次提交更新这样的话值 //才会提交到数据库。
db.SubmitChanges();
}
}
}
/// <summary>
/// 根据主键删除排产计划
/// </summary>
/// <param name="productionSchedulingPlanId"></param>
public static void DeleteProductionSchedulingPlanById(string productionSchedulingPlanId)
{
SGGLDB db = Funs.DB;
Model.HJGL_ProductionSchedulingPlan plan = db.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProductionSchedulingPlanId == productionSchedulingPlanId);
if (plan != null)
{
db.HJGL_ProductionSchedulingPlan.DeleteOnSubmit(plan);
db.SubmitChanges();
}
}
2025-07-23 13:27:58 +08:00
/// <summary>
/// 根据单位工程删除排产计划
/// </summary>
/// <param name="projectId"></param>
/// <param name="unitWorkName"></param>
public static void DeleteProductionSchedulingPlanByUnitWork(string projectId, string unitWorkName)
2025-07-23 13:27:58 +08:00
{
SGGLDB db = Funs.DB;
var q = (from x in db.HJGL_ProductionSchedulingPlan where x.ProjectId == projectId && x.MainItemName == unitWorkName select x).ToList();
if (q.Count > 0)
{
db.HJGL_ProductionSchedulingPlan.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
/// <summary>
/// 根据单位工程、流水号删除排产计划
/// </summary>
/// <param name="projectId"></param>
/// <param name="unitWorkName"></param>
/// <param name="flowNum"></param>
public static void DeleteProductionSchedulingPlanByUnitWorkIdAndFlowNum(string projectId, string unitWorkName, string flowNum)
{
SGGLDB db = Funs.DB;
var q = (from x in db.HJGL_ProductionSchedulingPlan where x.ProjectId == projectId && x.MainItemName == unitWorkName && x.FlowNum == flowNum select x).ToList();
if (q.Count > 0)
{
db.HJGL_ProductionSchedulingPlan.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
2025-06-04 22:46:21 +08:00
}
}