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.
1803 lines
75 KiB
1803 lines
75 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.BLL;
|
|
using QMAPP.FJC.Entity.FIS;
|
|
using QMAPP.Entity;
|
|
using QMFrameWork.Log;
|
|
using QMAPP.FJC.Entity;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.FJC.DAL.FIS;
|
|
using System.Data;
|
|
using QMAPP.FJC.BLL.Dict;
|
|
using QMAPP.MD.Entity;
|
|
using QMAPP.MD.DAL;
|
|
using QMAPP.FJC.DAL.ProductionPlan;
|
|
using QMAPP.FJC.Entity.ProductionPlan;
|
|
using QMFrameWork.Common.Util;
|
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
|
using QMAPP.FJC.DAL.TianJin;
|
|
|
|
namespace QMAPP.FJC.BLL.FIS
|
|
{
|
|
public class DoorPlankPlanBLL : BaseBLL
|
|
{
|
|
#region 获取信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public DataResult<OrderPlan> Get(OrderPlan model)
|
|
{
|
|
DataResult<OrderPlan> result = new DataResult<OrderPlan>();
|
|
try
|
|
{
|
|
result.Result = new DoorPlankPlanDAL().Get(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "订单计划信息逻辑层-获取信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// 获取FIS插单的位置
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public DataResult<OrderPlan> GetFISInsertPos(OrderPlan model)
|
|
{
|
|
DataResult<OrderPlan> result = new DataResult<OrderPlan>();
|
|
try
|
|
{
|
|
var dal= new DoorPlankPlanDAL();
|
|
var position =dal.Get(model);
|
|
if (position == null)
|
|
{
|
|
throw new Exception("获取FIS插单位置信息失败!");
|
|
}
|
|
if(!string.Equals(position.PLANSOURCE,EnumGeter.WORKORDERTYPE.FIS.GetHashCode().ToString()))
|
|
{
|
|
result.Msg = "只能选择FIS计划作为插单位置!";
|
|
result.IsSuccess = false;
|
|
return result;
|
|
}
|
|
result.Result = position;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "订单计划信息逻辑层-获取信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataResult<DataPage> GetList(OrderPlan condition, DataPage page)
|
|
{
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取订单计划信息列表
|
|
DataPage dataPage = new DoorPlankPlanDAL().GetList(condition, page);
|
|
List<OrderPlan> list = page.Result as List<OrderPlan>;
|
|
#region 显示类型
|
|
//处理字典信息
|
|
DictManageBLL dictPRODUCEREQUIRE = new DictManageBLL(DictKind.PRODUCEREQUIRE);
|
|
DictManageBLL dictPLANSOURCE = new DictManageBLL(DictKind.PLANSOURCE);
|
|
DictManageBLL dictPLANSTATE = new DictManageBLL(DictKind.PLAN_STATE);
|
|
foreach (var info in list)
|
|
{
|
|
info.PRODUCEREQUIRE = dictPRODUCEREQUIRE.GetDictValue(info.PRODUCEREQUIRE);
|
|
info.PLANSOURCE = dictPLANSOURCE.GetDictValue(info.PLANSOURCE);
|
|
info.PLAN_STATE = dictPLANSTATE.GetDictValue(info.PLAN_STATE);
|
|
}
|
|
#endregion
|
|
result.Result = dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-获取列表!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 信息是否重复
|
|
/// <summary>
|
|
/// 判断名称是否存在
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
public int ExistsOrderPlan(OrderPlan model)
|
|
{
|
|
try
|
|
{
|
|
return new DoorPlankPlanDAL().ExistsOrderPlan(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public DataResult<int> Insert(OrderPlan model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
model.PID = Guid.NewGuid().ToString();
|
|
model.PLAN_STATE = "0";
|
|
model.PLANSOURCE = model.PLANSOURCE;
|
|
//int no = new DoorPlankPlanDAL().GetNum(model);
|
|
//model.PLAN_SEQ = model.PLAN_DATE.ToString("yyyyMMdd") + no;
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = model.MATERIAL_CODE });
|
|
model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
string workcentercode = new WorkCellDAL().GetWorkcenter(model.ORDER_TYPE);
|
|
model.WORKCENTER_CODE = workcentercode;
|
|
if (model.WORKCENTER_CODE != "")
|
|
{
|
|
string factory = new FactoryDAL().GetFactoryWithWorkcenter(model.WORKCENTER_CODE);
|
|
model.FACTORY_CODE = factory;
|
|
}
|
|
QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
//QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
model.ROUTE_CODE = routecode != null ? routecode.ROUTE_CODE : "";
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
DoorPlankPlanDAL cmdDAL = new DoorPlankPlanDAL();
|
|
try
|
|
{
|
|
//if (ExistsOrderPlan(model) >0)
|
|
//{
|
|
// result.IsSuccess = false;
|
|
// result.Msg = Resource.MaterielCodeIsHave;
|
|
// return result;
|
|
//}
|
|
|
|
FISPlan condition = new FISPlan();
|
|
condition.PREFIX = "DP";
|
|
condition.DATASTR = model.PLAN_DATE.ToString("yyyyMMdd");
|
|
//获取流水号
|
|
FISPlan info = this.GetOrderPlanSeq(condition);
|
|
//计划单号
|
|
model.PLAN_NO = condition.PREFIX + condition.DATASTR + info.SEQSTR;
|
|
result.Result = new DoorPlankPlanDAL().Insert(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-插入信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public DataResult<int> TJInsert(OrderPlan model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
|
|
try
|
|
{
|
|
model.PID = Guid.NewGuid().ToString();
|
|
model.PLAN_STATE = "0";
|
|
model.PLANSOURCE = model.PLANSOURCE;
|
|
|
|
var materialcode = "";
|
|
if (model.MATERIAL_CODE.Substring(model.MATERIAL_CODE.Length - 1, 1) == "L" || model.MATERIAL_CODE.Substring(model.MATERIAL_CODE.Length - 1, 1) == "R")
|
|
{
|
|
if (model.MATERIAL_CODE.Contains("018D")|| model.MATERIAL_CODE.Contains("493D"))
|
|
{
|
|
materialcode = model.MATERIAL_CODE;
|
|
}
|
|
else
|
|
{
|
|
materialcode = model.MATERIAL_CODE.Substring(model.MATERIAL_CODE.Length - 1, 1);
|
|
}
|
|
|
|
}
|
|
else
|
|
materialcode = model.MATERIAL_CODE;
|
|
Pbom pbomcode = new PbomDAL().TJGet(new Pbom { MATERIAL_CODE = materialcode });
|
|
model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
|
|
string workcentercode = new WorkCellDAL().GetWorkcenter(model.ORDER_TYPE);
|
|
|
|
if (model.MATERIAL_CODE.Contains("018D"))
|
|
workcentercode = workcentercode.Replace("770B","018D");
|
|
|
|
if (model.MATERIAL_CODE.Contains("493D"))
|
|
workcentercode = workcentercode.Replace("770B", "493D");
|
|
|
|
model.WORKCENTER_CODE = workcentercode;
|
|
if (model.WORKCENTER_CODE != "")
|
|
{
|
|
string factory = new FactoryDAL().GetFactoryWithWorkcenter(model.WORKCENTER_CODE);
|
|
model.FACTORY_CODE = factory;
|
|
}
|
|
QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
//QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
|
|
var listMatral = new TJDoorPlankPlanDAL();
|
|
var ListMachine = listMatral.GetListMachine(model.MATERIAL_CODE);
|
|
if (ListMachine.Count <= 0)
|
|
{
|
|
model.ROUTE_CODE = routecode.ROUTE_CODE;
|
|
}
|
|
else
|
|
{
|
|
foreach (var MA in ListMachine)
|
|
{
|
|
if (MA.MATERIALNAME.Contains("左"))
|
|
{
|
|
if (model.MATERIAL_CODE.Contains("018"))
|
|
model.ROUTE_CODE = "DP_L_ASSEMBLY_018D";
|
|
else if (model.MATERIAL_CODE.Contains("493"))
|
|
model.ROUTE_CODE = "DP_L_ASSEMBLY_493D";
|
|
else if (model.MATERIAL_CODE.Contains("304"))
|
|
model.ROUTE_CODE = "DP_L_ASSEMBLY_304D";
|
|
else
|
|
{
|
|
if (MA.MATERIALNAME.Contains("304"))
|
|
model.ROUTE_CODE = "DP_L_ASSEMBLY_304D";
|
|
else
|
|
model.ROUTE_CODE = "DP_L_ASSEMBLY_770B";
|
|
}
|
|
|
|
}
|
|
else if (MA.MATERIALNAME.Contains("右"))
|
|
{
|
|
if (model.MATERIAL_CODE.Contains("018"))
|
|
model.ROUTE_CODE = "DP_R_ASSEMBLY_018D";
|
|
else if (model.MATERIAL_CODE.Contains("493"))
|
|
model.ROUTE_CODE = "DP_R_ASSEMBLY_493D";
|
|
else if (model.MATERIAL_CODE.Contains("304"))
|
|
model.ROUTE_CODE = "DP_R_ASSEMBLY_304D";
|
|
else
|
|
{
|
|
if (MA.MATERIALNAME.Contains("304"))
|
|
model.ROUTE_CODE = "DP_R_ASSEMBLY_304D";
|
|
else
|
|
model.ROUTE_CODE = "DP_R_ASSEMBLY_770B";
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//model.ROUTE_CODE = "DP_ASSEMBLY_770B";
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
DoorPlankPlanDAL cmdDAL = new DoorPlankPlanDAL();
|
|
FISPlan condition = new FISPlan();
|
|
condition.PREFIX = "DP";
|
|
condition.DATASTR = model.PLAN_DATE.ToString("yyyyMMdd");
|
|
//获取流水号
|
|
FISPlan info = this.GetOrderPlanSeq(condition);
|
|
//计划单号
|
|
model.PLAN_SEQ = info.SEQSTR;
|
|
model.PLAN_NO = condition.PREFIX + condition.DATASTR + info.SEQSTR;
|
|
result.Result = new DoorPlankPlanDAL().Insert(model);
|
|
|
|
//if (model.MATERIAL_CODE.Length <= 10)
|
|
//{
|
|
// //var listMatral = new TJDoorPlankPlanDAL();
|
|
// //var ListMachine = listMatral.GetListMachine(model.MATERIAL_CODE);
|
|
// foreach (var Machint in ListMachine)
|
|
// {
|
|
// model.PID = Guid.NewGuid().ToString();
|
|
// model.PLAN_STATE = "0";
|
|
// model.PLANSOURCE = model.PLANSOURCE;
|
|
// model.MATERIAL_CODE = Machint.MATERIALNO;
|
|
// model.MATERIAL_NAME = Machint.MATERIALNAME;
|
|
// Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = Machint.MATERIALNO });
|
|
// model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
// string workcentercode = new WorkCellDAL().GetWorkcenter(model.ORDER_TYPE);
|
|
// model.WORKCENTER_CODE = workcentercode;
|
|
// if (model.WORKCENTER_CODE != "")
|
|
// {
|
|
// string factory = new FactoryDAL().GetFactoryWithWorkcenter(model.WORKCENTER_CODE);
|
|
// model.FACTORY_CODE = factory;
|
|
// }
|
|
// QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(Machint.MATERIALNO);
|
|
// //QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
// model.ROUTE_CODE = routecode != null ? routecode.ROUTE_CODE : "";
|
|
// model.CREATEUSER = this.LoginUser.UserID;
|
|
// model.CREATEDATE = DateTime.Now;
|
|
// model.UPDATEUSER = model.CREATEUSER;
|
|
// model.UPDATEDATE = model.CREATEDATE;
|
|
// DoorPlankPlanDAL cmdDAL = new DoorPlankPlanDAL();
|
|
// FISPlan condition = new FISPlan();
|
|
// condition.PREFIX = "DP";
|
|
// condition.DATASTR = model.PLAN_DATE.ToString("yyyyMMdd");
|
|
// //获取流水号
|
|
// FISPlan info = this.GetOrderPlanSeq(condition);
|
|
// //计划单号
|
|
// model.PLAN_SEQ = info.SEQSTR;
|
|
// model.PLAN_NO = condition.PREFIX + condition.DATASTR + info.SEQSTR;
|
|
// result.Result = new DoorPlankPlanDAL().Insert(model);
|
|
// }
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-插入信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取流水号信息
|
|
/// <summary>
|
|
/// 获取流水号信息
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public FISPlan GetOrderPlanSeq(FISPlan condition)
|
|
{
|
|
FISPlan fisplan = new FISPlan();
|
|
OrderPlanDAL orderPlanDal = new OrderPlanDAL();
|
|
//根据表皮条码获取本体信息
|
|
|
|
try
|
|
{
|
|
fisplan = new OrderPlanDAL().GetOrderPlanSeq(condition);
|
|
//若存在记录,流水号加1,且更新
|
|
if (fisplan != null)
|
|
{
|
|
string seqstr = (Convert.ToInt32(fisplan.SEQSTR) + 1).ToString().PadLeft(3, '0');
|
|
fisplan.SEQSTR = seqstr;
|
|
//更新表T_AW_FISPLAN数据
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
orderPlanDal.BaseSession = session;
|
|
|
|
orderPlanDal.UpdateFisPlan(fisplan);
|
|
|
|
session.CommitTs();
|
|
}
|
|
}
|
|
//不存在则插入此日期信息
|
|
else
|
|
{
|
|
FISPlan planinfo = new FISPlan();
|
|
planinfo.PID = Guid.NewGuid().ToString();
|
|
planinfo.PREFIX = condition.PREFIX;
|
|
planinfo.DATASTR = condition.DATASTR;
|
|
planinfo.SEQSTR = "001";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
orderPlanDal.BaseSession = session;
|
|
|
|
orderPlanDal.InsertFisPlan(planinfo);
|
|
|
|
session.CommitTs();
|
|
}
|
|
return planinfo;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "仪表板逻辑层-获取流水号本体信息!"
|
|
});
|
|
throw ex;
|
|
}
|
|
return fisplan;
|
|
}
|
|
#endregion
|
|
|
|
#region 更新信息
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新行数</returns>
|
|
public DataResult<int> Update(OrderPlan model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
try
|
|
{
|
|
if (ExistsOrderPlan(model) > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "该订单号已经存在!";
|
|
return result;
|
|
}
|
|
|
|
if (model.COMPLETE_QTY > model.QTY)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "修改后的计划数量不能小于已完成数量!";
|
|
return result;
|
|
}
|
|
|
|
if (model.PLAN_STATE == EnumGeter.PLANSTATE.COMPLATED.GetHashCode().ToString())
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "订单已经完成不能进行修改!";
|
|
return result;
|
|
}
|
|
|
|
#region 如果修改后的计划数量等于完成数量,将计划状态更新为完成
|
|
if (model.QTY.Equals(model.COMPLETE_QTY))
|
|
{
|
|
model.PLAN_STATE = EnumGeter.PLANSTATE.COMPLATED.GetHashCode().ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 判断数量
|
|
|
|
OrderPlanDAL orderPlanDal = new OrderPlanDAL();
|
|
OrderPlan initialOrderPlan = orderPlanDal.Get(new OrderPlan { PID = model.PID });
|
|
string deleteWorkOrderSql = "";
|
|
List<WorkOrder> workOrderList = new List<WorkOrder>();
|
|
|
|
|
|
WorkOrderDAL workOrderDal = new WorkOrderDAL();
|
|
List<WorkOrder> list = workOrderDal.GetList(new WorkOrder() { ORDERPLANID = initialOrderPlan.PID });
|
|
|
|
|
|
//将计划数量调整变小,删除为生产的派工单
|
|
if ((initialOrderPlan.QTY - model.QTY) > 0)
|
|
{
|
|
|
|
int unProduceCount = list.Count(o => o.STATE == 0);
|
|
if (list.Count>0 && unProduceCount < (initialOrderPlan.QTY - model.QTY))
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = string.Format("该订单下已经加工的产品数量大于{0},请重新调整数量!", model.QTY);
|
|
return result;
|
|
}
|
|
|
|
deleteWorkOrderSql = string.Format("delete from T_PP_WORKORDER where pid in (select top {0} pid from T_PP_WORKORDER where ORDERPLANID='{1}' and state=0 order by SEQ desc )", (initialOrderPlan.QTY - model.QTY), initialOrderPlan.PID);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
|
|
if (list.Count > 0 && (model.QTY - initialOrderPlan.QTY) > 0)
|
|
{
|
|
workOrderList = this.PutOutOrderPlan(model, (model.QTY - initialOrderPlan.QTY), list.Count);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
orderPlanDal.BaseSession = session;
|
|
workOrderDal.BaseSession = session;
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = model.MATERIAL_CODE });
|
|
model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
|
|
orderPlanDal.Update(model);
|
|
if (string.IsNullOrEmpty(deleteWorkOrderSql) == false)
|
|
{
|
|
session.ExecuteSql(deleteWorkOrderSql, new List<DataParameter>().ToArray());
|
|
}
|
|
|
|
if (workOrderList.Count > 0)
|
|
{
|
|
foreach (var wo in workOrderList)
|
|
{
|
|
workOrderDal.Insert(wo);
|
|
}
|
|
}
|
|
|
|
session.CommitTs();
|
|
}
|
|
|
|
result.IsSuccess = true;
|
|
result.Msg = "修改成功!";
|
|
|
|
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;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>删除个数</returns>
|
|
public DataResult<int> Delete(string strs)
|
|
{
|
|
int count = 0;
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
|
|
WorkOrderDAL workOrderDal = new WorkOrderDAL();
|
|
OrderPlanDAL orderPlanDal = new OrderPlanDAL();
|
|
//校验未通过的订单
|
|
List<OrderPlan> validOrderList = new List<OrderPlan>();
|
|
//可以删除的订单
|
|
List<OrderPlan> deleteOrderList = new List<OrderPlan>();
|
|
foreach (string str in list)
|
|
{
|
|
OrderPlan op = orderPlanDal.Get(new OrderPlan() { PID = str });
|
|
//去T_PP_WORkORDER表查询此计划下的派工单是否有不为0(初始)状态的派工信息,若有则不让删除
|
|
int Num = workOrderDal.GetAllWorkOrder(str);
|
|
//如果订单初始化或是确认生产并且生产数量为0
|
|
if (op.PLAN_STATE == EnumGeter.PLANSTATE.INIT.GetHashCode().ToString()
|
|
|| (op.PLAN_STATE == EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString() && op.COMPLETE_QTY == 0 && Num == 0))
|
|
{
|
|
deleteOrderList.Add(op);
|
|
}
|
|
else
|
|
{
|
|
validOrderList.Add(op);
|
|
}
|
|
}
|
|
|
|
|
|
if (validOrderList.Count > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "只有初始化或是确认生产并且生产数量为0订单可以删除!";
|
|
return result;
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
orderPlanDal.BaseSession = session;
|
|
workOrderDal.BaseSession = session;
|
|
|
|
foreach (var op in deleteOrderList)
|
|
{
|
|
//删除订单
|
|
orderPlanDal.DeleteOrderPlan(op);
|
|
|
|
//删除订单下的派工单
|
|
workOrderDal.BatchDeleteByOrderPlan(new WorkOrder() { ORDERPLANID = op.PID });
|
|
}
|
|
|
|
session.CommitTs();
|
|
}
|
|
|
|
result.Result = count;
|
|
result.Msg = "订单删除成功!";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>删除个数</returns>
|
|
public int DeleteDoorPlankPlan(OrderPlan model)
|
|
{
|
|
int count = 0;
|
|
int number = new DoorPlankPlanDAL().DelCheck(model);
|
|
if (number > 0)
|
|
{
|
|
return count;
|
|
}
|
|
count = new DoorPlankPlanDAL().Delete(model);
|
|
return count;
|
|
}
|
|
#endregion
|
|
|
|
#region 发布
|
|
/// <summary>
|
|
/// 发布信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>发布个数</returns>
|
|
public DataResult<int> PutOut(string strs)
|
|
{
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
OrderPlanDAL orderPlandal = new OrderPlanDAL();
|
|
|
|
List<OrderPlan> validorderPlanList = new List<OrderPlan>();
|
|
List<OrderPlan> putOutPlanList = new List<OrderPlan>();
|
|
|
|
foreach (string str in list)
|
|
{
|
|
OrderPlan op = orderPlandal.Get(new OrderPlan { PID = str });
|
|
|
|
if (op.PLAN_STATE != EnumGeter.PLANSTATE.INIT.GetHashCode().ToString())
|
|
{
|
|
validorderPlanList.Add(op);
|
|
}
|
|
|
|
putOutPlanList.Add(op);
|
|
|
|
}
|
|
|
|
if (validorderPlanList.Count > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "只有初始状态下的订单能够进行发布!";
|
|
|
|
return result;
|
|
}
|
|
|
|
DataTable totalDt = GetWorkOrderTable();
|
|
foreach (var op in putOutPlanList)
|
|
{
|
|
op.PLAN_STATE = EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString();
|
|
op.UPDATEUSER = this.LoginUser.UserID;
|
|
totalDt = this.PutOutOrderPlan(op, totalDt);
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
IDbConnection dbConn = DbManager.MainConnectionInfo.Connection;
|
|
if (dbConn.State == ConnectionState.Closed)
|
|
{
|
|
dbConn.Open();
|
|
}
|
|
IDbTransaction ids = dbConn.BeginTransaction();
|
|
|
|
orderPlandal.BaseSession = session;
|
|
foreach (var op in putOutPlanList)
|
|
{
|
|
orderPlandal.Update(op);
|
|
}
|
|
|
|
session.DbHelper.BulkCopyData(totalDt, "T_PP_WORKORDER", dbConn, ids);
|
|
ids.Commit();
|
|
}
|
|
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发布信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>发布个数</returns>
|
|
public DataTable PutOutOrderPlan(OrderPlan info, DataTable workOrderDt)
|
|
{
|
|
WorkCellDAL workCelldal = new WorkCellDAL();
|
|
string pbomcode = info.PBOM_CODE;
|
|
List<ProcessRouteWorkCellSeq> list = workCelldal.GetFirstWorkCell(pbomcode);
|
|
var dicPRI = new DictManageBLL(Dict.DictKind.ORDERPRI);
|
|
//注入派工单信息
|
|
for (int i = 0; i < info.QTY; i++)
|
|
{
|
|
foreach (var seq in list)
|
|
{
|
|
DataRow workOrder = workOrderDt.NewRow();
|
|
|
|
workOrder["PID"] = Guid.NewGuid().ToString();
|
|
workOrder["ORDERPLANID"] = info.PID;
|
|
workOrder["ORDERPLAN_NO"] = (info.PLAN_NO.ToString() + (i + 1).ToString().PadLeft(4, '0'));
|
|
workOrder["ORDER_TYPE"] = info.PLANSOURCE;
|
|
workOrder["SEQ"] = (i + 1).ToString().PadLeft(6, '0');
|
|
if (info.PLANSOURCE == EnumGeter.WORKORDERTYPE.INSERT.GetHashCode().ToString())
|
|
{
|
|
workOrder["SEQ"] = info.PLAN_SEQ + (i + 1).ToString().PadLeft(3, '0');
|
|
}
|
|
workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE;
|
|
workOrder["PBOM_CODE"] = info.PBOM_CODE;
|
|
workOrder["QTY"] = 1;
|
|
workOrder["COMPLETE_QTY"] = 0;
|
|
workOrder["PLAN_DATE"] = info.PLAN_DATE;
|
|
workOrder["SHIFT_CODE"] = info.SHIFT_CODE;
|
|
workOrder["WORKCENTER_CODE"] = info.WORKCENTER_CODE;
|
|
workOrder["WORKCELL_CODE"] = seq.WORKCELL_CODE;
|
|
workOrder["WORKLOC_CODE"] = "";
|
|
workOrder["REMARK"] = "";
|
|
workOrder["EQPT_NAME"] = "";
|
|
workOrder["EQPT_CODE"] = "";
|
|
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
|
|
workOrder["PRI"] = dicPRI.GetDictValue(info.PLANSOURCE);
|
|
|
|
workOrderDt.Rows.Add(workOrder);
|
|
}
|
|
|
|
}
|
|
|
|
return workOrderDt;
|
|
}
|
|
|
|
public List<WorkOrder> PutOutOrderPlan(OrderPlan info, int number, int lastIndex)
|
|
{
|
|
List<WorkOrder> wolist = new List<WorkOrder>();
|
|
WorkCellDAL workCelldal = new WorkCellDAL();
|
|
string pbomcode = info.PBOM_CODE;
|
|
List<QMAPP.MD.Entity.ProcessRouteWorkCellSeq> list = workCelldal.GetFirstWorkCell(pbomcode);
|
|
var dicPRI = new DictManageBLL(Dict.DictKind.ORDERPRI);
|
|
|
|
//注入派工单信息
|
|
for (int i = 0; i < number; i++)
|
|
{
|
|
foreach (var seq in list)
|
|
{
|
|
WorkOrder wo = new WorkOrder();
|
|
wo.PID = Guid.NewGuid().ToString();
|
|
wo.ORDERPLANID = info.PID;
|
|
wo.ORDERPLAN_NO = (info.PLAN_NO.ToString() + (i + 1 + lastIndex).ToString().PadLeft(4, '0'));
|
|
wo.ORDER_TYPE = info.PLANSOURCE;
|
|
wo.SEQ = (i + 1 + lastIndex).ToString().PadLeft(6, '0');
|
|
wo.MATERIAL_CODE = info.MATERIAL_CODE;
|
|
wo.PBOM_CODE = info.PBOM_CODE;
|
|
wo.QTY = 1;
|
|
wo.COMPLETE_QTY = 0;
|
|
wo.PLAN_DATE = info.PLAN_DATE;
|
|
wo.SHIFT_CODE = info.SHIFT_CODE;
|
|
wo.WORKCENTER_CODE = info.WORKCENTER_CODE;
|
|
wo.WORKCELL_CODE = seq.WORKCELL_CODE;
|
|
wo.WORKLOC_CODE = "";
|
|
wo.REMARK = "";
|
|
wo.EQPT_NAME = "";
|
|
wo.EQPT_CODE = "";
|
|
wo.STATE = Convert.ToInt32(EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString());
|
|
wo.PRI = Convert.ToInt32(dicPRI.GetDictValue(info.PLANSOURCE));
|
|
wo.PRINTED = "0";
|
|
wolist.Add(wo);
|
|
}
|
|
|
|
}
|
|
|
|
return wolist;
|
|
}
|
|
#endregion
|
|
|
|
#region 发布
|
|
/// <summary>
|
|
/// 发布信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>发布个数</returns>
|
|
public DataResult<int> TJPutOut(string strs)
|
|
{
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
OrderPlanDAL orderPlandal = new OrderPlanDAL();
|
|
|
|
List<OrderPlan> validorderPlanList = new List<OrderPlan>();
|
|
List<OrderPlan> putOutPlanList = new List<OrderPlan>();
|
|
|
|
foreach (string str in list)
|
|
{
|
|
OrderPlan op = orderPlandal.Get(new OrderPlan { PID = str });
|
|
|
|
if (op.PLAN_STATE != EnumGeter.PLANSTATE.INIT.GetHashCode().ToString())
|
|
{
|
|
validorderPlanList.Add(op);
|
|
}
|
|
|
|
putOutPlanList.Add(op);
|
|
|
|
}
|
|
|
|
if (validorderPlanList.Count > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "只有初始状态下的订单能够进行发布!";
|
|
|
|
return result;
|
|
}
|
|
|
|
DataTable totalDt = GetWorkOrderTable();
|
|
foreach (var op in putOutPlanList)
|
|
{
|
|
op.PLAN_STATE = EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString();
|
|
op.UPDATEUSER = this.LoginUser.UserID;
|
|
totalDt = this.TJPutOutOrderPlan(op, totalDt);
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
IDbConnection dbConn = DbManager.MainConnectionInfo.Connection;
|
|
if (dbConn.State == ConnectionState.Closed)
|
|
{
|
|
dbConn.Open();
|
|
}
|
|
IDbTransaction ids = dbConn.BeginTransaction();
|
|
|
|
orderPlandal.BaseSession = session;
|
|
foreach (var op in putOutPlanList)
|
|
{
|
|
orderPlandal.Update(op);
|
|
}
|
|
|
|
session.DbHelper.BulkCopyData(totalDt, "T_PP_WORKORDER", dbConn, ids);
|
|
ids.Commit();
|
|
}
|
|
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发布信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>发布个数</returns>
|
|
public DataTable TJPutOutOrderPlan(OrderPlan info, DataTable workOrderDt)
|
|
{
|
|
WorkCellDAL workCelldal = new WorkCellDAL();
|
|
|
|
var dicPRI = new DictManageBLL(Dict.DictKind.ORDERPRI);
|
|
|
|
//if (list.Count <= 0)
|
|
//{
|
|
// return null;
|
|
//}
|
|
|
|
if (((info.MATERIAL_CODE.Substring(0, 4) == "493D" || info.MATERIAL_CODE.Substring(0,4) == "018D"|| info.MATERIAL_CODE.Substring(0, 4) == "278D") && info.MATERIAL_CODE.Length > 10)|| (info.MATERIAL_CODE.Substring(0, 3) == "770" && info.MATERIAL_CODE.Length > 7)|| info.MATERIAL_CODE.Length>=14)
|
|
{
|
|
string pbomcode = info.MATERIAL_CODE;
|
|
List<ProcessRouteWorkCellSeq> list = workCelldal.GetFirstWorkCell(pbomcode);
|
|
//左前、右前、左后、右后
|
|
for (int i = 0; i < info.QTY; i++)
|
|
{
|
|
DataRow workOrder = workOrderDt.NewRow();
|
|
|
|
workOrder["PID"] = Guid.NewGuid().ToString();
|
|
workOrder["ORDERPLANID"] = info.PID;
|
|
workOrder["ORDERPLAN_NO"] = (info.PLAN_NO.ToString() + (i + 1).ToString().PadLeft(4, '0'));
|
|
workOrder["ORDER_TYPE"] = info.PLANSOURCE;
|
|
workOrder["SEQ"] = (i + 1).ToString().PadLeft(6, '0');
|
|
if (info.PLANSOURCE == EnumGeter.WORKORDERTYPE.INSERT.GetHashCode().ToString())
|
|
{
|
|
workOrder["SEQ"] = info.PLAN_SEQ + (i + 1).ToString().PadLeft(3, '0');
|
|
}
|
|
workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE;
|
|
workOrder["PBOM_CODE"] = info.MATERIAL_CODE;
|
|
workOrder["QTY"] = 1;
|
|
workOrder["COMPLETE_QTY"] = 0;
|
|
workOrder["PLAN_DATE"] = info.PLAN_DATE;
|
|
workOrder["SHIFT_CODE"] = info.SHIFT_CODE;
|
|
workOrder["WORKCENTER_CODE"] = info.WORKCENTER_CODE;
|
|
if (info.ROUTE_CODE.Contains("DP_L"))
|
|
{
|
|
workOrder["WORKCELL_CODE"] = "DP_L_PREPARE1";
|
|
}
|
|
else if(info.ROUTE_CODE.Contains("DP_R"))
|
|
workOrder["WORKCELL_CODE"] = "DP_R_PREPARE1";
|
|
else
|
|
workOrder["WORKCELL_CODE"] = "PREPARE1";
|
|
|
|
workOrder["WORKLOC_CODE"] = "";
|
|
workOrder["REMARK"] = "";
|
|
workOrder["EQPT_NAME"] = "";
|
|
workOrder["EQPT_CODE"] = "";
|
|
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
|
|
workOrder["PRI"] = dicPRI.GetDictValue(info.PLANSOURCE);
|
|
|
|
workOrderDt.Rows.Add(workOrder);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//左侧、右侧 或 四个门一起打印
|
|
var list2 = "".Split(',');
|
|
var dal = new TJDoorPlankPlanDAL();
|
|
var MachineList = dal.GetListMachine(info.MATERIAL_CODE);
|
|
if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "L")
|
|
{
|
|
list2 = "FL,RL".Split(',');
|
|
}
|
|
else if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "R")
|
|
{
|
|
list2 = "FR,RR".Split(',');
|
|
}
|
|
else if ((info.MATERIAL_CODE.Length == 6 && info.MATERIAL_CODE.Substring(0,3) == "770")|| (info.MATERIAL_CODE.Length == 8 && info.MATERIAL_CODE.Substring(0, 4) == "018D"))
|
|
{
|
|
list2 = "FL,RL,FR,RR".Split(',');
|
|
}
|
|
|
|
for (int i = 0; i < info.QTY; i++)
|
|
{
|
|
foreach (var seq in list2)
|
|
{
|
|
DataRow workOrder = workOrderDt.NewRow();
|
|
|
|
workOrder["PID"] = Guid.NewGuid().ToString();
|
|
workOrder["ORDERPLANID"] = info.PID;
|
|
workOrder["ORDERPLAN_NO"] = (info.PLAN_NO.ToString() + (i + 1).ToString().PadLeft(4, '0'));
|
|
workOrder["ORDER_TYPE"] = info.PLANSOURCE;
|
|
workOrder["SEQ"] = (i + 1).ToString().PadLeft(6, '0');
|
|
if (info.PLANSOURCE == EnumGeter.WORKORDERTYPE.INSERT.GetHashCode().ToString())
|
|
{
|
|
workOrder["SEQ"] = info.PLAN_SEQ + (i + 1).ToString().PadLeft(3, '0');
|
|
}
|
|
//var BOMCODE = "";
|
|
|
|
//if (info.MATERIAL_CODE.Substring(0, 4) == "018D")
|
|
//{
|
|
// if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "L" || info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "R")
|
|
// {
|
|
// workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE.Substring(0, info.MATERIAL_CODE.Length - 1) + seq;
|
|
// BOMCODE = info.MATERIAL_CODE.Substring(0, info.MATERIAL_CODE.Length - 1) + seq;
|
|
// }
|
|
// else
|
|
// {
|
|
// workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE + "-" + seq;
|
|
// BOMCODE = info.MATERIAL_CODE + "-" + seq;
|
|
// }
|
|
//}
|
|
//else if (info.MATERIAL_CODE.Substring(0, 3) == "770")
|
|
//{
|
|
// if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "L" || info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "R")
|
|
// {
|
|
// workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE.Substring(0, info.MATERIAL_CODE.Length - 1) + seq;
|
|
// BOMCODE = info.MATERIAL_CODE.Substring(0, info.MATERIAL_CODE.Length - 1) + seq;
|
|
// }
|
|
// else
|
|
// {
|
|
// workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE + seq;
|
|
// BOMCODE = info.MATERIAL_CODE + seq;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE;
|
|
// BOMCODE = info.MATERIAL_CODE;
|
|
//}
|
|
|
|
var WEIZHI = "";
|
|
switch (seq)
|
|
{
|
|
case "LF":
|
|
WEIZHI = "左前";
|
|
break;
|
|
case "FL":
|
|
WEIZHI = "左前";
|
|
break;
|
|
case "LR":
|
|
WEIZHI = "左后";
|
|
break;
|
|
case "RL":
|
|
WEIZHI = "左后";
|
|
break;
|
|
case "RF":
|
|
WEIZHI = "右前";
|
|
break;
|
|
case "FR":
|
|
WEIZHI = "右前";
|
|
break;
|
|
case "RR":
|
|
WEIZHI = "右后";
|
|
break;
|
|
}
|
|
|
|
var Machine = MachineList.Where(p => p.MATERIALNAME.Contains(WEIZHI)).ToList();
|
|
if (Machine != null && Machine.Count > 0)
|
|
{
|
|
workOrder["MATERIAL_CODE"] = Machine[0].MATERIALNO;
|
|
workOrder["PBOM_CODE"] = Machine[0].MATERIALNO;
|
|
}
|
|
else
|
|
{
|
|
workOrder["PBOM_CODE"] = "";
|
|
workOrder["MATERIAL_CODE"] = "";
|
|
}
|
|
|
|
|
|
workOrder["QTY"] = 1;
|
|
workOrder["COMPLETE_QTY"] = 0;
|
|
workOrder["PLAN_DATE"] = info.PLAN_DATE;
|
|
workOrder["SHIFT_CODE"] = info.SHIFT_CODE;
|
|
workOrder["WORKCENTER_CODE"] = info.WORKCENTER_CODE;
|
|
if (WEIZHI.Contains("左"))
|
|
{
|
|
workOrder["WORKCELL_CODE"] = "DP_L_PREPARE1";
|
|
}
|
|
else if (WEIZHI.Contains("右"))
|
|
{
|
|
workOrder["WORKCELL_CODE"] = "DP_R_PREPARE1";
|
|
}
|
|
else
|
|
{
|
|
workOrder["WORKCELL_CODE"] = "PREPARE1";
|
|
}
|
|
|
|
workOrder["WORKLOC_CODE"] = "";
|
|
workOrder["REMARK"] = "";
|
|
workOrder["EQPT_NAME"] = "";
|
|
workOrder["EQPT_CODE"] = "";
|
|
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
|
|
workOrder["PRI"] = dicPRI.GetDictValue(info.PLANSOURCE);
|
|
|
|
workOrderDt.Rows.Add(workOrder);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//注入派工单信息
|
|
|
|
|
|
return workOrderDt;
|
|
}
|
|
|
|
public List<WorkOrder> TJPutOutOrderPlan(OrderPlan info, int number, int lastIndex)
|
|
{
|
|
List<WorkOrder> wolist = new List<WorkOrder>();
|
|
WorkCellDAL workCelldal = new WorkCellDAL();
|
|
string pbomcode = info.PBOM_CODE;
|
|
List<QMAPP.MD.Entity.ProcessRouteWorkCellSeq> list = workCelldal.GetFirstWorkCell(pbomcode);
|
|
var dicPRI = new DictManageBLL(Dict.DictKind.ORDERPRI);
|
|
|
|
//注入派工单信息
|
|
for (int i = 0; i < number; i++)
|
|
{
|
|
foreach (var seq in list)
|
|
{
|
|
WorkOrder wo = new WorkOrder();
|
|
wo.PID = Guid.NewGuid().ToString();
|
|
wo.ORDERPLANID = info.PID;
|
|
wo.ORDERPLAN_NO = (info.PLAN_NO.ToString() + (i + 1 + lastIndex).ToString().PadLeft(4, '0'));
|
|
wo.ORDER_TYPE = info.PLANSOURCE;
|
|
wo.SEQ = (i + 1 + lastIndex).ToString().PadLeft(6, '0');
|
|
wo.MATERIAL_CODE = info.MATERIAL_CODE;
|
|
wo.PBOM_CODE = info.PBOM_CODE;
|
|
wo.QTY = 1;
|
|
wo.COMPLETE_QTY = 0;
|
|
wo.PLAN_DATE = info.PLAN_DATE;
|
|
wo.SHIFT_CODE = info.SHIFT_CODE;
|
|
wo.WORKCENTER_CODE = info.WORKCENTER_CODE;
|
|
wo.WORKCELL_CODE = seq.WORKCELL_CODE;
|
|
wo.WORKLOC_CODE = "";
|
|
wo.REMARK = "";
|
|
wo.EQPT_NAME = "";
|
|
wo.EQPT_CODE = "";
|
|
wo.STATE = Convert.ToInt32(EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString());
|
|
wo.PRI = Convert.ToInt32(dicPRI.GetDictValue(info.PLANSOURCE));
|
|
wo.PRINTED = "0";
|
|
wolist.Add(wo);
|
|
}
|
|
|
|
}
|
|
|
|
return wolist;
|
|
}
|
|
#endregion
|
|
|
|
#region 导出数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(OrderPlan model)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = new DoorPlankPlanDAL().GetExportData(model);
|
|
DictManageBLL dictPRODUCEREQUIRE = new DictManageBLL(DictKind.PRODUCEREQUIRE);
|
|
DictManageBLL dictPLANSOURCE = new DictManageBLL(DictKind.PLANSOURCE);
|
|
DictManageBLL dictPLANSTATE = new DictManageBLL(DictKind.PLAN_STATE);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
//替换状态类别显示值
|
|
dr["PRODUCEREQUIRE"] = dictPRODUCEREQUIRE.GetDictValue(dr["PRODUCEREQUIRE"].ToString());
|
|
//info.PLANSOURCE = dictPLANSOURCE.GetDictValue(info.PLANSOURCE);
|
|
dr["PLANSOURCE"] = dictPLANSOURCE.GetDictValue(dr["PLANSOURCE"].ToString());
|
|
dr["PLAN_STATE"] = dictPLANSTATE.GetDictValue(dr["PLAN_STATE"].ToString());
|
|
}
|
|
//根据所选信息进行导出
|
|
if (string.IsNullOrEmpty(model.PIDList) == false)
|
|
{
|
|
model.PIDList = "'" + model.PIDList.Replace(":", "','") + "'";
|
|
DataView dv = new DataView(dt);
|
|
dv.RowFilter = "PID in (" + model.PIDList + ")";
|
|
dt = dv.ToTable();
|
|
}
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导入数据
|
|
/// <summary>
|
|
/// 导入Excel表数据
|
|
/// </summary>
|
|
/// <param name="list">Excel列表</param>
|
|
/// <param name="aramodel">区域信息</param>
|
|
/// <param name="plantmodel">工厂信息</param>
|
|
/// <param name="productbasicmodel">零件类别信息</param>
|
|
/// <returns>结果</returns>
|
|
public DataResult<ImportMessage> GetImportData(List<OrderPlan> list, Material materialmodel, QMAPP.FJC.Entity.Basic.MachineInfo machine, FJC.Entity.Basic.ProduceShift produceshiftmodel, QMAPP.MD.Entity.WorkCell workcellmodel)
|
|
{
|
|
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
|
DoorPlankPlanDAL cmDal = new DoorPlankPlanDAL();
|
|
List<OrderPlan> List = new List<OrderPlan>();
|
|
int index = 0;
|
|
int num = 0;
|
|
try
|
|
{
|
|
result.Result = new ImportMessage();
|
|
result.Result.Errors = new List<RowError>();
|
|
List<Material> materialinfo = null;
|
|
List<FJC.Entity.Basic.ProduceShift> produceshiftinfo = null;
|
|
List<QMAPP.FJC.Entity.Basic.MachineInfo> machineList = null;
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
///获取物料信息
|
|
materialinfo = new QMAPP.MD.BLL.MaterialBLL().GetNewMaterialList(materialmodel,workcellmodel);
|
|
//获取班次信息
|
|
produceshiftinfo = new QMAPP.FJC.BLL.Basic.ProduceShiftBLL().GetWorkcenterShifts(workcellmodel.WORKCENTER_CODE);
|
|
//获取设备信息
|
|
machineList = new QMAPP.FJC.BLL.Basic.MachineInfoBLL().GetMachineForOrderList(machine, workcellmodel);
|
|
//状态判断
|
|
foreach (OrderPlan ma in list)
|
|
{
|
|
index++;
|
|
num++;
|
|
//物料
|
|
Material areaMes = materialinfo.Find(a => a.MATERIAL_CODE == ma.MATERIAL_CODE);
|
|
if (areaMes != null)
|
|
{
|
|
ma.MATERIAL_CODE = areaMes.MATERIAL_CODE;
|
|
}
|
|
else
|
|
{
|
|
ma.MATERIAL_CODE = null;
|
|
result.Result.Errors.Add(new RowError(index, "物料信息不存在"));
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
//班次
|
|
FJC.Entity.Basic.ProduceShift plantMes = produceshiftinfo.Find(p => p.PRODUCESHIFTTCODE == ma.SHIFT_CODE);
|
|
if (plantMes != null)
|
|
{
|
|
ma.SHIFT_CODE = plantMes.PRODUCESHIFTTCODE;
|
|
}
|
|
else
|
|
{
|
|
ma.SHIFT_CODE = null;
|
|
result.Result.Errors.Add(new RowError(index, "班次信息不存在"));
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
//转变生产要求PRODUCEREQUIRE
|
|
if (ma.PRODUCEREQUIRE != null)
|
|
{
|
|
if (ma.PRODUCEREQUIRE.Equals("以数量为准"))
|
|
{
|
|
ma.PRODUCEREQUIRE = "0";
|
|
}
|
|
else if (ma.PRODUCEREQUIRE.Equals("以时间为准"))
|
|
{
|
|
ma.PRODUCEREQUIRE = "1";
|
|
}
|
|
else
|
|
{
|
|
ma.PRODUCEREQUIRE = null;
|
|
result.Result.Errors.Add(new RowError(index, "生产要求信息错误"));
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(ma.InfoError) == false)
|
|
{
|
|
ma.PID = null;
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
//修改改时根据主键等信息获取详细内容信息
|
|
OrderPlan oldInfo = cmDal.Get(ma);
|
|
if (oldInfo != null)
|
|
{
|
|
//更新
|
|
ma.PID = oldInfo.PID;
|
|
ma.PLAN_SEQ = oldInfo.PLAN_SEQ;
|
|
ma.FACTORY_CODE = oldInfo.FACTORY_CODE;
|
|
ma.WORKCENTER_CODE = oldInfo.WORKCENTER_CODE;
|
|
ma.PBOM_CODE = oldInfo.PBOM_CODE;
|
|
ma.ROUTE_CODE = oldInfo.ROUTE_CODE;
|
|
ma.PLAN_STATE = oldInfo.PLAN_STATE;
|
|
ma.PLANSOURCE = oldInfo.PLANSOURCE;
|
|
ma.CREATEUSER = oldInfo.CREATEUSER;
|
|
ma.CREATEDATE = oldInfo.CREATEDATE;
|
|
ma.UPDATEUSER = this.LoginUser.UserID;
|
|
ma.UPDATEDATE = oldInfo.UPDATEDATE;
|
|
ma.IsNewInfo = false;
|
|
result.Result.updateNum += 1;
|
|
}
|
|
else
|
|
{
|
|
//新增
|
|
oldInfo = new OrderPlan();
|
|
ma.PID = Guid.NewGuid().ToString();
|
|
ma.PLAN_NO = ma.PLAN_NO;
|
|
//int no = new DoorPlankPlanDAL().GetNum(ma) + (num - 1);
|
|
ma.PLAN_SEQ = ma.PLAN_NO.Substring(ma.PLAN_NO.Length-3,3);
|
|
ma.PLAN_STATE = EnumGeter.PLANSTATE.INIT.GetHashCode().ToString();
|
|
ma.MATERIAL_CODE = ma.MATERIAL_CODE;
|
|
ma.MACHINECODDE = ma.MACHINECODDE;
|
|
ma.QTY = ma.QTY;
|
|
//Pbom
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = ma.MATERIAL_CODE });
|
|
ma.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
//工艺路线
|
|
QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(ma.MATERIAL_CODE);
|
|
ma.ROUTE_CODE = routecode.ROUTE_CODE;
|
|
ma.PLAN_DATE = ma.PLAN_DATE;
|
|
ma.SHIFT_CODE = ma.SHIFT_CODE;
|
|
ma.PLANSOURCE = "1";
|
|
ma.PRODUCEREQUIRE = ma.PRODUCEREQUIRE;
|
|
ma.CREATEUSER = this.LoginUser.UserID;
|
|
ma.CREATEDATE = DateTime.Now;
|
|
ma.UPDATEUSER = ma.CREATEUSER;
|
|
ma.UPDATEDATE = ma.CREATEDATE;
|
|
//工作中心
|
|
string workcentercode = new WorkCellDAL().GetWorkcenter(workcellmodel.WORKCELL_CODE);
|
|
ma.WORKCENTER_CODE = workcentercode;
|
|
//工厂
|
|
string factory = new QMAPP.MD.DAL.FactoryDAL().GetFactoryWithWorkcenter(workcentercode);
|
|
ma.FACTORY_CODE = factory;
|
|
ma.IsNewInfo = true;
|
|
result.Result.insertNum += 1;
|
|
}
|
|
List.Add(ma);
|
|
}
|
|
}
|
|
//导入
|
|
cmDal.GetImportData(List);
|
|
result.Msg = "导入成功";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Ex = ex;
|
|
return result;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取产品表
|
|
/// <summary>
|
|
/// 获取产品表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private DataTable GetOrderPlanTable()
|
|
{
|
|
DataTable dt = new DataTable();
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PID", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "FACTORY_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_NO", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_SEQ", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_STATE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "MATERIAL_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PBOM_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "ROUTE_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "REMARK", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "QTY", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "COMPLETE_QTY", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_DATE", DataType = typeof(DateTime) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "SHIFT_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLANSOURCE", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PRODUCEREQUIRE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "CREATEDATE", DataType = typeof(DateTime) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "CREATEUSER", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "UPDATEDATE", DataType = typeof(DateTime) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "UPDATEUSER", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKCENTER_CODE", DataType = typeof(string) });
|
|
|
|
return dt;
|
|
}
|
|
|
|
private DataTable GetWorkOrderTable()
|
|
{
|
|
DataTable dt = new DataTable();
|
|
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PID", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "ORDERPLANID", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "ORDERPLAN_NO", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "ORDER_TYPE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "SEQ", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "MATERIAL_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PBOM_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "QTY", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "COMPLETE_QTY", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_DATE", DataType = typeof(DateTime) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "SHIFT_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKCENTER_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKCENTER_NAME", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKCELL_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKCELL_NAME", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "WORKLOC_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "REMARK", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "EQPT_NAME", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "EQPT_CODE", DataType = typeof(string) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "STATE", DataType = typeof(int) });
|
|
dt.Columns.Add(new DataColumn() { ColumnName = "PRI", DataType = typeof(int) });
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
#region 整车插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public DataResult<int> InsertWholeDoor(OrderPlan model, List<Material> materiallist)
|
|
{
|
|
List<OrderPlan> List = new List<OrderPlan>();
|
|
DataResult<int> result = new DataResult<int>();
|
|
DoorPlankPlanDAL cmdDAL = new DoorPlankPlanDAL();
|
|
cmdDAL.BaseSession = AppDataFactory.CreateMainSession();
|
|
string plan_Seq = "";
|
|
foreach (Material ma in materiallist)
|
|
{
|
|
OrderPlan planmodel = new OrderPlan();
|
|
planmodel.MATERIAL_CODE = ma.MATERIAL_CODE;
|
|
planmodel.PID = Guid.NewGuid().ToString();
|
|
|
|
planmodel.QTY = model.QTY;
|
|
planmodel.PLAN_DATE = model.PLAN_DATE;
|
|
planmodel.SHIFT_CODE = model.SHIFT_CODE;
|
|
planmodel.PRODUCEREQUIRE = "0";
|
|
|
|
|
|
planmodel.PLANSOURCE = model.PLANSOURCE;
|
|
planmodel.PLAN_STATE = "0";
|
|
//计划来源
|
|
planmodel.PLANSOURCE = model.PLANSOURCE;
|
|
|
|
//顺序号
|
|
OrderPlanSerial serial = new DoorPlankPlanDAL().GetNumSerial(model);
|
|
|
|
if (serial != null)
|
|
{
|
|
|
|
//流水号加1,补位
|
|
planmodel.PLAN_SEQ = (serial.SERIAL_NO + 1).ToString().PadLeft(3, '0');
|
|
//更新流水号
|
|
serial.SERIAL_NO = serial.SERIAL_NO + 1;
|
|
|
|
if (string.IsNullOrEmpty(plan_Seq))
|
|
{
|
|
plan_Seq = planmodel.PLAN_SEQ;
|
|
}
|
|
|
|
int no = new DoorPlankPlanDAL().UpdateSerial(serial);
|
|
}
|
|
else
|
|
{
|
|
OrderPlanSerial serialinfo = new OrderPlanSerial();
|
|
//若为空则插入流水号表信息
|
|
serialinfo.PID = Guid.NewGuid().ToString();
|
|
serialinfo.SERIAL_NO = 1;
|
|
serialinfo.SERIAL_TYPE = model.ORDER_TYPE;
|
|
serialinfo.SERIAL_DATE = model.PLAN_DATE.ToString("yyyyMMdd");
|
|
int num = new DoorPlankPlanDAL().InsertSerial(serialinfo);
|
|
//流水号补位
|
|
planmodel.PLAN_SEQ = (serialinfo.SERIAL_NO).ToString().PadLeft(3, '0');
|
|
|
|
if (string.IsNullOrEmpty(plan_Seq))
|
|
{
|
|
plan_Seq = planmodel.PLAN_SEQ;
|
|
}
|
|
}
|
|
|
|
string matype = ma.MATERIAL_TYPE_CODE;
|
|
string a = matype.Substring(matype.Length - 2, 1);
|
|
string b = matype.Substring(matype.Length - 1, 1);
|
|
string planSet = b + a;
|
|
//计划单号
|
|
planmodel.PLAN_NO = model.AsmSetCode+planSet + model.PLAN_DATE.ToString("yyMMdd") + planmodel.PLAN_SEQ + "SD";
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = planmodel.MATERIAL_CODE });
|
|
planmodel.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
string workcentercode = new WorkCellDAL().GetWorkcenter(model.ORDER_TYPE);
|
|
planmodel.WORKCENTER_CODE = workcentercode;
|
|
if (planmodel.WORKCENTER_CODE != "")
|
|
{
|
|
string factory = new FactoryDAL().GetFactoryWithWorkcenter(planmodel.WORKCENTER_CODE);
|
|
planmodel.FACTORY_CODE = factory;
|
|
}
|
|
QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(planmodel.MATERIAL_CODE);
|
|
//QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
planmodel.ROUTE_CODE = routecode != null ? routecode.ROUTE_CODE : "";
|
|
planmodel.CREATEUSER = this.LoginUser.UserID;
|
|
planmodel.CREATEDATE = DateTime.Now;
|
|
planmodel.UPDATEUSER = planmodel.CREATEUSER;
|
|
planmodel.UPDATEDATE = planmodel.CREATEDATE;
|
|
|
|
planmodel.PLAN_SEQ = plan_Seq;
|
|
|
|
List.Add(planmodel);
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
if (ExistsOrderPlan(model) > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.MaterielCodeIsHave;
|
|
return result;
|
|
}
|
|
result.Result = cmdDAL.InsertDoorPlan(List);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-插入信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 保存FIS插单
|
|
/// <summary>
|
|
/// 保存FIS插单
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public DataResult<int> SaveFISInsert(OrderPlan model, List<Material> materiallist,bool Publish)
|
|
{
|
|
List<OrderPlan> List = new List<OrderPlan>();
|
|
DataResult<int> result = new DataResult<int>();
|
|
DoorPlankPlanDAL cmdDAL = new DoorPlankPlanDAL();
|
|
cmdDAL.BaseSession = AppDataFactory.CreateMainSession();
|
|
var InsertNum = cmdDAL.GetMaxFISInsertNum(model) + 1;
|
|
foreach (Material ma in materiallist)
|
|
{
|
|
OrderPlan planmodel = new OrderPlan();
|
|
planmodel.MATERIAL_CODE = ma.MATERIAL_CODE;
|
|
planmodel.PID = Guid.NewGuid().ToString();
|
|
|
|
planmodel.QTY = model.QTY;
|
|
planmodel.PLAN_DATE = model.PLAN_DATE;
|
|
//planmodel.SHIFT_CODE = model.SHIFT_CODE;
|
|
planmodel.PRODUCEREQUIRE = "0";
|
|
|
|
planmodel.PLAN_STATE = "0";
|
|
//计划来源
|
|
planmodel.PLANSOURCE = model.PLANSOURCE;
|
|
//顺序号
|
|
planmodel.PLAN_SEQ = string.Format("{0}-{1:D1}", model.PLAN_SEQ, InsertNum);
|
|
var seqstr = model.PLAN_SEQ;
|
|
if (seqstr.Length < 4)
|
|
{
|
|
seqstr = seqstr.PadLeft(4, '0');
|
|
}
|
|
else if (seqstr.Length > 4)
|
|
{
|
|
seqstr = seqstr.Substring(seqstr.Length - 4);
|
|
}
|
|
string matype = ma.MATERIAL_TYPE_CODE;
|
|
|
|
//计划单号
|
|
planmodel.PLAN_NO = string.Format("DPINS{0:yyyyMMdd}{1}{2}{3:D1}",
|
|
model.PLAN_DATE,
|
|
matype.Substring(matype.Length - 2, 2),
|
|
seqstr,
|
|
InsertNum);
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = planmodel.MATERIAL_CODE });
|
|
planmodel.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
string workcentercode = new WorkCellDAL().GetWorkcenter(model.ORDER_TYPE);
|
|
planmodel.WORKCENTER_CODE = workcentercode;
|
|
if (planmodel.WORKCENTER_CODE != "")
|
|
{
|
|
string factory = new FactoryDAL().GetFactoryWithWorkcenter(planmodel.WORKCENTER_CODE);
|
|
planmodel.FACTORY_CODE = factory;
|
|
}
|
|
planmodel.CREATEUSER = this.LoginUser.UserID;
|
|
planmodel.CREATEDATE = DateTime.Now;
|
|
planmodel.UPDATEUSER = planmodel.CREATEUSER;
|
|
planmodel.UPDATEDATE = planmodel.CREATEDATE;
|
|
|
|
List.Add(planmodel);
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
if (ExistsOrderPlan(model) > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.MaterielCodeIsHave;
|
|
return result;
|
|
}
|
|
result.Result = cmdDAL.InsertDoorPlan(List);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-插入信息!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取列表(为了修改顺序号使用)
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataResult<DataPage> GetDoorPlankPlanList(OrderPlan condition, DataPage page)
|
|
{
|
|
condition.PIDList = "'" + condition.PIDList.Replace(":", "','") + "'";
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取信息列表
|
|
DataPage dataPage = new DoorPlankPlanDAL().GetDoorPlankPlanList(condition, page);
|
|
|
|
result.Result = dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "信息逻辑层-获取列表!"
|
|
});
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 更新顺序号信息
|
|
/// <summary>
|
|
/// 更新顺序号信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新个数</returns>
|
|
public DataResult<int> UpdateDoorPlankPlanSeq(OrderPlan orderplan)
|
|
{
|
|
int count = 0;
|
|
string[] list = orderplan.PIDList.Split(":".ToCharArray());
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
foreach (string str in list)
|
|
{
|
|
OrderPlan op = new OrderPlan();
|
|
op.PID = str;
|
|
op.PLAN_SEQ = orderplan.PLAN_SEQ;
|
|
result.Result += this.UpdateSeq(op);
|
|
}
|
|
|
|
result.Result = count;
|
|
result.Msg = "更新成功!";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新顺序号信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>删除个数</returns>
|
|
public int UpdateSeq(OrderPlan model)
|
|
{
|
|
int count = 0;
|
|
count = new DoorPlankPlanDAL().UpdateSeq(model);
|
|
return count;
|
|
}
|
|
#endregion
|
|
|
|
#region 门板计划物料号CD
|
|
/// <summary>
|
|
/// 门板计划物料号CD
|
|
/// </summary>
|
|
/// <param name="OrderType"></param>
|
|
/// <returns></returns>
|
|
public List<FISAssembly> GetMaterialDoorPlanForCD(FISAssembly info)
|
|
{
|
|
List<FISAssembly> result = new List<FISAssembly>();
|
|
try
|
|
{
|
|
result = new DoorPlankPlanDAL().GetMaterialDoorPlanForCD(info);
|
|
//转换高低配和颜色
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取本体信息
|
|
/// <summary>
|
|
/// 获取本体信息
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public FISAssembly GetFISMaterialInfoCD(string IdInfo)
|
|
{
|
|
FISAssembly Fisassmble = new FISAssembly();
|
|
//根据表皮条码获取本体信息
|
|
Fisassmble.Id = IdInfo;
|
|
try
|
|
{
|
|
List<FISAssembly> FisassmbleList = new DoorPlankPlanDAL().GetMaterialDoorPlanForCD(Fisassmble);
|
|
foreach (FISAssembly m in FisassmbleList)
|
|
{
|
|
Fisassmble.MESModulFL = m.MESModulFL;
|
|
Fisassmble.MESModulFR = m.MESModulFR;
|
|
Fisassmble.MESModulRL = m.MESModulRL;
|
|
Fisassmble.MESModulRR = m.MESModulRR;
|
|
Fisassmble.AsmSetCode = m.AsmSetCode;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "产品档案逻辑层-获取本体信息!"
|
|
});
|
|
throw ex;
|
|
}
|
|
return Fisassmble;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|