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.
1523 lines
64 KiB
1523 lines
64 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.BLL;
|
|
using QMAPP.Entity;
|
|
using QMAPP.FJC.Entity.FIS;
|
|
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.Basic;
|
|
using QMAPP.FJC.Entity.ProductionPlan;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.DAL.ProductionPlan;
|
|
using QMFrameWork.Common.Util;
|
|
//using QMAPP.FJC.Entity.FileCopy.FIS;
|
|
using System.Globalization;
|
|
using System.Text.RegularExpressions;
|
|
using QMAPP.FJC.Entity.TianJin;
|
|
using QMAPP.FJC.DAL.TianJin;
|
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
|
|
|
namespace QMAPP.FJC.BLL.TianJin
|
|
{
|
|
/// <summary>
|
|
/// 注塑计划管理
|
|
/// </summary>
|
|
public class TJPaoMoPlanBLL : BaseBLL
|
|
{
|
|
#region 获取信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public DataResult<TJPaoMoPlan> Get(TJPaoMoPlan model)
|
|
{
|
|
DataResult<TJPaoMoPlan> result = new DataResult<TJPaoMoPlan>();
|
|
try
|
|
{
|
|
result.Result = new TJPaoMoPlanDAL().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;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataResult<DataPage> GetList(TJPaoMoPlan condition, DataPage page)
|
|
{
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取订单计划信息列表
|
|
page = new TJPaoMoPlanDAL().GetList(condition, page);
|
|
|
|
List<TJPaoMoPlan> list = page.Result as List<TJPaoMoPlan>;
|
|
|
|
#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 = page;
|
|
}
|
|
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(TJPaoMoPlan model)
|
|
{
|
|
try
|
|
{
|
|
return new TJPaoMoPlanDAL().ExistsOrderPlan(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public DataResult<int> Insert(TJPaoMoPlan model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
model.PID = Guid.NewGuid().ToString();
|
|
model.PLAN_STATE = "0";
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
if (model.QTY <= model.COMPLETE_QTY)
|
|
model.PLAN_STATE = "3";
|
|
TJPaoMoPlanDAL cmdDAL = new TJPaoMoPlanDAL();
|
|
try
|
|
{
|
|
if (ExistsOrderPlan(model) > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "该订单号已经存在!";
|
|
return result;
|
|
}
|
|
|
|
//流水号信息
|
|
FISPlan condition = new FISPlan();
|
|
condition.PREFIX = "PM";
|
|
condition.DATASTR = model.PLAN_DATE.ToString("yyyy-MM-dd");
|
|
string DATASTR = model.PLAN_DATE.ToString("yyyyMMdd");
|
|
|
|
//获取流水号
|
|
FISPlan info = this.GetOrderPlanSeq(condition);
|
|
|
|
model.PLAN_NO = condition.PREFIX + DATASTR + info.SEQSTR;
|
|
model.PLAN_SEQ = info.SEQSTR;
|
|
|
|
result.Result = new TJPaoMoPlanDAL().Insert(model);
|
|
|
|
//痕迹表
|
|
FISPlanRecord record = new FISPlanRecord();
|
|
|
|
record.PID = Guid.NewGuid().ToString();
|
|
record.MID = model.PID;
|
|
record.PLAN_NO = model.PLAN_NO;
|
|
record.MATERIAL_CODE = model.MATERIAL_CODE;
|
|
record.PLAN_QTY = model.QTY;
|
|
record.OPERATION_TYPE = "0";
|
|
record.CREATEUSER = model.CREATEUSER;
|
|
record.CREATEDATE = model.CREATEDATE;
|
|
|
|
int no = new TJPaoMoPlanDAL().InsertRecord(record);
|
|
|
|
}
|
|
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> Update(TJPaoMoPlan 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 判断数量
|
|
|
|
TJPaoMoPlanDAL TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
TJPaoMoPlan initialOrderPlan = TJPaoMoPlanDAL.Get(new TJPaoMoPlan { PID = model.PID });
|
|
string deleteWorkOrderSql = "";
|
|
List<WorkOrder> workOrderList = new List<WorkOrder>();
|
|
|
|
WorkOrderDAL workOrderDal = new WorkOrderDAL();
|
|
|
|
//将计划数量调整变小,删除为生产的派工单
|
|
if ((initialOrderPlan.QTY - model.QTY) > 0)
|
|
{
|
|
deleteWorkOrderSql = string.Format("delete from T_PP_WORKORDER where pid in (select top {0} pid from T_PP_WORKORDER where ORDERPLANID='{1}' and COMPLETE_QTY=0 )", (initialOrderPlan.QTY - model.QTY), initialOrderPlan.PID);
|
|
}
|
|
else
|
|
{
|
|
List<WorkOrder> list = workOrderDal.GetList(new WorkOrder() { ORDERPLANID = initialOrderPlan.PID });
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
WorkOrder wo = list.First();
|
|
|
|
//将计划数量调整变大
|
|
for (int i = 0; i < (model.QTY - initialOrderPlan.QTY); i++)
|
|
{
|
|
WorkOrder inWO = BindHelper.CopyToModel<WorkOrder, WorkOrder>(wo, false);//CopyToModel<WorkOrder, WorkOrder>(wo);
|
|
inWO.PID = Guid.NewGuid().ToString();
|
|
inWO.COMPLETE_QTY = 0;
|
|
workOrderList.Add(inWO);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
TJPaoMoPlanDAL.BaseSession = session;
|
|
workOrderDal.BaseSession = session;
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = model.MATERIAL_CODE });
|
|
if (pbomcode!=null)
|
|
{
|
|
//model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
}
|
|
|
|
|
|
TJPaoMoPlanDAL.Update(model);
|
|
|
|
#region 插入修改信息痕迹表
|
|
//插入修改信息痕迹表
|
|
FISPlanRecord record = new FISPlanRecord();
|
|
|
|
record.PID = Guid.NewGuid().ToString();
|
|
record.MID = model.PID;
|
|
record.PLAN_NO = model.PLAN_NO;
|
|
record.MATERIAL_CODE = model.MATERIAL_CODE;
|
|
record.PLAN_QTY = model.QTY;
|
|
record.OPERATION_TYPE = "1";
|
|
record.CREATEUSER = model.CREATEUSER;
|
|
record.CREATEDATE = model.CREATEDATE;
|
|
|
|
int no = new TJPaoMoPlanDAL().InsertRecord(record);
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
|
|
private WorkOrder CopyToModel<T1, T2>(WorkOrder wo)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
#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
|
|
{
|
|
TJPaoMoPlanDAL TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
WorkOrderDAL workOrderDal = new WorkOrderDAL();
|
|
//校验未通过的订单
|
|
List<TJPaoMoPlan> validOrderList = new List<TJPaoMoPlan>();
|
|
//可以删除的订单
|
|
List<TJPaoMoPlan> deleteOrderList = new List<TJPaoMoPlan>();
|
|
foreach (string str in list)
|
|
{
|
|
TJPaoMoPlan op = TJPaoMoPlanDAL.Get(new TJPaoMoPlan() { 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();
|
|
TJPaoMoPlanDAL.BaseSession = session;
|
|
workOrderDal.BaseSession = session;
|
|
|
|
foreach (var op in deleteOrderList)
|
|
{
|
|
//删除订单
|
|
TJPaoMoPlanDAL.DeleteOrderPlan(op);
|
|
//新增删除情况下的痕迹表信息
|
|
#region 插入修改信息痕迹表
|
|
//插入修改信息痕迹表
|
|
FISPlanRecord record = new FISPlanRecord();
|
|
|
|
record.PID = Guid.NewGuid().ToString();
|
|
record.MID = op.PID;
|
|
record.PLAN_NO = op.PLAN_NO;
|
|
record.MATERIAL_CODE = op.MATERIAL_CODE;
|
|
record.PLAN_QTY = op.QTY;
|
|
record.OPERATION_TYPE = "2";
|
|
record.CREATEUSER = op.CREATEUSER;
|
|
record.CREATEDATE = op.CREATEDATE;
|
|
|
|
int no = new TJPaoMoPlanDAL().InsertRecord(record);
|
|
#endregion
|
|
|
|
//删除订单下的派工单
|
|
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 DeleteOrderPlan(TJPaoMoPlan model)
|
|
{
|
|
int count = 0;
|
|
int number = new TJPaoMoPlanDAL().DelCheck(model);
|
|
if (number > 0)
|
|
{
|
|
return count;
|
|
}
|
|
count = new TJPaoMoPlanDAL().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
|
|
{
|
|
TJPaoMoPlanDAL TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
|
|
List<TJPaoMoPlan> validorderPlanList = new List<TJPaoMoPlan>();
|
|
List<TJPaoMoPlan> putOutPlanList = new List<TJPaoMoPlan>();
|
|
|
|
foreach (string str in list)
|
|
{
|
|
TJPaoMoPlan op = TJPaoMoPlanDAL.Get(new TJPaoMoPlan { 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;
|
|
IDbTransaction ids = dbConn.BeginTransaction();
|
|
|
|
TJPaoMoPlanDAL.BaseSession = session;
|
|
foreach (var op in putOutPlanList)
|
|
{
|
|
TJPaoMoPlanDAL.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(TJPaoMoPlan info, DataTable workOrderDt)
|
|
{
|
|
WorkCellDAL workCelldal = new WorkCellDAL();
|
|
string pbomcode = info.MATERIAL_CODE;
|
|
List<QMAPP.MD.Entity.ProcessRouteWorkCellSeq> list = workCelldal.GetFirstWorkCell(pbomcode);
|
|
|
|
//注入派工单信息
|
|
for (int i = 0; i < info.QTY; i++)
|
|
{
|
|
if (list.Count > 0)
|
|
{
|
|
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"] = EnumGeter.WORKORDERTYPE.STOCK.GetHashCode().ToString();
|
|
workOrder["SEQ"] = (i + 1).ToString();
|
|
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();
|
|
|
|
workOrderDt.Rows.Add(workOrder);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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"] = EnumGeter.WORKORDERTYPE.STOCK.GetHashCode().ToString();
|
|
workOrder["SEQ"] = (i + 1).ToString();
|
|
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["WORKLOC_CODE"] = "";
|
|
workOrder["REMARK"] = "";
|
|
workOrder["EQPT_NAME"] = "";
|
|
workOrder["EQPT_CODE"] = "";
|
|
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
|
|
|
|
workOrderDt.Rows.Add(workOrder);
|
|
}
|
|
|
|
}
|
|
|
|
return workOrderDt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入TJPaoMoPlan
|
|
/// 写serveice和事物,重写方法.zxd20171101
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>发布个数</returns>
|
|
//public int InsertOrderPlanAndWorkOrder(TJPaoMoPlan model,IDataSession tempSession)
|
|
//{
|
|
// var TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
// TJPaoMoPlanDAL.BaseSession = tempSession;
|
|
// int count = 0;
|
|
// //给ordePlan赋值
|
|
// ///////////////////
|
|
// //Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = model.MATERIAL_CODE });
|
|
// //if (pbomcode != null)
|
|
// //{
|
|
// // model.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
// //}
|
|
// //QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(model.MATERIAL_CODE);
|
|
// //if (routecode != null)
|
|
// //{
|
|
// // model.ROUTE_CODE = routecode.ROUTE_CODE;
|
|
// //}
|
|
// //string workcentercode = new WorkCellDAL().GetWorkcenterWithMaterial(model.MATERIAL_CODE);
|
|
// //if (workcentercode != null)
|
|
// //{
|
|
// // model.WORKCENTER_CODE = workcentercode;
|
|
// //}
|
|
// //赋值新session后插入 zxd20171101
|
|
// TJPaoMoPlanDAL.Insert(model);
|
|
|
|
|
|
// //获取当前PID下注塑计划数量
|
|
// TJPaoMoPlan info = TJPaoMoPlanDAL.Get(model);
|
|
// DataTable workOrderDt = GetWorkOrderTable();
|
|
// int number = TJPaoMoPlanDAL.PutOutCheck(model);
|
|
// if (number == 1)
|
|
// {
|
|
// return count;
|
|
// }
|
|
|
|
// var wodDal = new WorkOrderDAL();
|
|
// List<QMAPP.MD.Entity.ProcessRouteWorkCellSeq> list = new WorkCellDAL().GetFirstWorkCell(model.PBOM_CODE);
|
|
|
|
// wodDal.BaseSession = tempSession;
|
|
// //注入派工单信息
|
|
// for (int i = 0; i < info.QTY; i++)
|
|
// {
|
|
// //DataRow workOrder = workOrderDt.NewRow();
|
|
// var workOrder = new WorkOrder();
|
|
|
|
// 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 = EnumGeter.WORKORDERTYPE.FIS.GetHashCode().ToString();
|
|
// workOrder.SEQ = info.PLAN_SEQ;
|
|
// 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;
|
|
// //WorkCell workcellcode = new WorkCellDAL().Get(new WorkCell { WORKCENTER_CODE = info.WORKCENTER_CODE });
|
|
// workOrder.WORKCELL_CODE = (list.Count > 0) ? list[0].WORKCELL_CODE : "";
|
|
// workOrder.WORKLOC_CODE = "";
|
|
// workOrder.REMARK = "";
|
|
// workOrder.EQPT_NAME = "";
|
|
// workOrder.EQPT_CODE = "";
|
|
// workOrder.STATE = EnumGeter.WORKPLANSTATE.INIT.GetHashCode();
|
|
// workOrder.PRI = 0;
|
|
// //workOrder.UPDATEDATE=DateTime.Now;
|
|
// workOrder.PRINTED = "0";
|
|
// wodDal.Insert(workOrder);
|
|
// //workOrderDt.Rows.Add(workOrder);
|
|
// }
|
|
// count = TJPaoMoPlanDAL.PutOutBaseSession(model, workOrderDt);
|
|
// return count;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 导出数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(TJPaoMoPlan model)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = new TJPaoMoPlanDAL().GetExportData(model);
|
|
|
|
DictManageBLL dictPRODUCEREQUIRE = new DictManageBLL(DictKind.PRODUCEREQUIRE);
|
|
DictManageBLL dictPLANSTATE = new DictManageBLL(DictKind.PLAN_STATE);
|
|
DictManageBLL dictPLANSOURCE = new DictManageBLL(DictKind.PLANSOURCE);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
//替换状态类别显示值
|
|
dr["PRODUCEREQUIRE"] = dictPRODUCEREQUIRE.GetDictValue(dr["PRODUCEREQUIRE"].ToString());
|
|
dr["PLAN_STATE"] = dictPLANSTATE.GetDictValue(dr["PLAN_STATE"].ToString());
|
|
dr["PLANSOURCE"] = dictPLANSOURCE.GetDictValue(dr["PLANSOURCE"].ToString());
|
|
}
|
|
|
|
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<TJPaoMoPlan> list, Material condition, MachineInfo machine, ProduceShift produceshiftmodel, WorkCell workcellmodel)
|
|
//{
|
|
// DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
|
// TJPaoMoPlanDAL cmDal = new TJPaoMoPlanDAL();
|
|
// cmDal.BaseSession = AppDataFactory.CreateMainSession();
|
|
// List<TJPaoMoPlan> List = new List<TJPaoMoPlan>();
|
|
// List<WorkOrder> workOrderList = new List<WorkOrder>();
|
|
|
|
// DataTable orderDt = GetOrderPlanTable();
|
|
// DataTable workOrderDt = GetWorkOrderTable();
|
|
// int index = 0;
|
|
// int num = 0;
|
|
// try
|
|
// {
|
|
// result.Result = new ImportMessage();
|
|
// result.Result.Errors = new List<RowError>();
|
|
// List<Material> materialinfo = null;
|
|
// List<ProduceShift> produceshiftinfo = null;
|
|
// List<MachineInfo> machineList = null;
|
|
// ///获取物料信息(PBOM表)
|
|
// materialinfo = new QMAPP.MD.BLL.MaterialBLL().GetMaterialForOrder(workcellmodel.WORKCELL_CODE);
|
|
// //获取班次信息
|
|
// produceshiftinfo = new QMAPP.FJC.BLL.Basic.ProduceShiftBLL().GetWorkcenterShifts(workcellmodel.WORKCENTER_CODE);
|
|
// //获取设备信息
|
|
// machineList = new QMAPP.FJC.BLL.Basic.MachineInfoBLL().GetMachineForOrderList(machine, workcellmodel);
|
|
|
|
|
|
// foreach (TJPaoMoPlan ma in list)
|
|
// {
|
|
// if (string.IsNullOrEmpty(ma.InfoError))
|
|
// {
|
|
// #region 状态判断
|
|
// index++;
|
|
// num++;
|
|
// //物料
|
|
// Material areaMes = materialinfo.Find(a => a.MATERIAL_CODE == ma.MATERIAL_CODE.Trim());
|
|
// 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;
|
|
// }
|
|
// //班次
|
|
// //Shift plantMes = produceshiftinfo.Find(p => p.SHIFT_CODE == ma.SHIFT_CODE.Trim());
|
|
// //if (plantMes != null)
|
|
// //{
|
|
// // ma.SHIFT_CODE = plantMes.SHIFT_CODE;
|
|
// //}
|
|
// //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.Trim().Equals("以数量为准"))
|
|
// {
|
|
// ma.PRODUCEREQUIRE = "0";
|
|
// }
|
|
// else if (ma.PRODUCEREQUIRE.Trim().Equals("以时间为准"))
|
|
// {
|
|
// ma.PRODUCEREQUIRE = "1";
|
|
// }
|
|
// else
|
|
// {
|
|
// ma.PRODUCEREQUIRE = null;
|
|
// result.Result.Errors.Add(new RowError(index, "生产要求信息错误"));
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
// }
|
|
|
|
// //设备
|
|
// MachineInfo machineMes = machineList.Find(c => c.MACHINECODDE == ma.MACHINECODDE.Trim());
|
|
// if (machineMes != null)
|
|
// {
|
|
// ma.MACHINECODDE = ma.MACHINECODDE;
|
|
// }
|
|
// else
|
|
// {
|
|
// ma.MACHINECODDE = null;
|
|
// result.Result.Errors.Add(new RowError(index, "设备信息不存在"));
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
|
|
// //if (machineList.Count(o => o.MACHINECODDE.Trim() == ma.MACHINECODDE.ToUpper()) > 0)
|
|
// //{
|
|
// // ma.MACHINECODDE = ma.MACHINECODDE;
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // ma.MACHINECODDE = null;
|
|
// // result.Result.Errors.Add(new RowError(index, "设备不符"));
|
|
// // result.Result.failureNum += 1;
|
|
// // continue;
|
|
// //}
|
|
|
|
// #region 时间
|
|
// //计划日期
|
|
// DateTime dateTime = new DateTime();
|
|
// bool convertResult = DateTime.TryParse(ma.PLAN_DATEIN, out dateTime);
|
|
// if (!convertResult)
|
|
// {
|
|
// result.Result.Errors.Add(new RowError(index, "计划日期格式错误!"));
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
// else
|
|
// {
|
|
// DateTimeFormatInfo dtFormat1 = new DateTimeFormatInfo();
|
|
// dtFormat1.ShortDatePattern = "yyyy/MM/dd";
|
|
// ma.PLAN_DATE = Convert.ToDateTime(ma.PLAN_DATEIN, dtFormat1);
|
|
// }
|
|
// //开始日期
|
|
// bool convertResultstart = DateTime.TryParse(ma.STARTTIMEIN, out dateTime);
|
|
// if (!convertResultstart)
|
|
// {
|
|
// result.Result.Errors.Add(new RowError(index, "开始日期格式错误!"));
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
// else
|
|
// {
|
|
// DateTimeFormatInfo dtFormat2 = new DateTimeFormatInfo();
|
|
// dtFormat2.ShortDatePattern = "yyyy/MM/dd hh:mm:ss";
|
|
// ma.STARTTIME = Convert.ToDateTime(ma.STARTTIMEIN, dtFormat2);
|
|
// }
|
|
|
|
// //截止日期
|
|
// bool convertResultend = DateTime.TryParse(ma.ENDTIMEIN, out dateTime);
|
|
// if (!convertResultend)
|
|
// {
|
|
// result.Result.Errors.Add(new RowError(index, "截止日期格式错误!"));
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
// else
|
|
// {
|
|
// DateTimeFormatInfo dtFormat3 = new DateTimeFormatInfo();
|
|
// dtFormat3.ShortDatePattern = "yyyy/MM/dd hh:mm:ss";
|
|
// ma.ENDTIME = Convert.ToDateTime(ma.ENDTIMEIN, dtFormat3);
|
|
// }
|
|
|
|
// #endregion
|
|
|
|
// #endregion
|
|
// }
|
|
// if (string.IsNullOrEmpty(ma.InfoError) == false)
|
|
// {
|
|
// ma.PID = null;
|
|
// result.Result.failureNum += 1;
|
|
// continue;
|
|
// }
|
|
|
|
|
|
// //修改改时根据主键等信息获取详细内容信息
|
|
// //TJPaoMoPlan oldInfo = cmDal.GetInfo(ma);
|
|
|
|
// #region 注释掉另一种导入增加和更新
|
|
// //增加
|
|
// //DataRow odr = orderDt.NewRow();
|
|
// //odr["PID"] = Guid.NewGuid().ToString();
|
|
// //odr["FACTORY_CODE"] = "";
|
|
// //odr["PLAN_NO"] = "";
|
|
// //odr["PLAN_SEQ"] = "";
|
|
// //odr["PLAN_STATE"] = EnumGeter.PLANSTATE.INIT.GetHashCode().ToString();
|
|
// //odr["MATERIAL_CODE"] = ma.MATERIAL_CODE;
|
|
// //odr["PBOM_CODE"] = "";
|
|
// //odr["QTY"] = ma.QTY;
|
|
// //odr["COMPLETE_QTY"] = ma.QTY;
|
|
// //odr["PLAN_DATE"] = ma.PLAN_DATE;
|
|
// //odr["SHIFT_CODE"] = "";
|
|
// //odr["PLANSOURCE"] = DBNull.Value;
|
|
// //odr["PRODUCEREQUIRE"] = ma.PRODUCEREQUIRE;
|
|
// //odr["CREATEDATE"] = System.DateTime.Now;
|
|
// //odr["CREATEUSER"] = this.LoginUser.UserID;
|
|
// //odr["UPDATEDATE"] = System.DateTime.Now;
|
|
// //odr["UPDATEUSER"] = this.LoginUser.UserID;
|
|
// //odr["WORKCENTER_CODE"] = "ZS";
|
|
// //orderDt.Rows.Add(odr);
|
|
|
|
// //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
|
|
// //{
|
|
// #endregion
|
|
|
|
// //新增
|
|
// //oldInfo = new TJPaoMoPlan();
|
|
// ma.PID = Guid.NewGuid().ToString();
|
|
// //ma.PLAN_NO = ma.PLAN_NO;
|
|
|
|
// //FISPlan planinfo = new FISPlan();
|
|
// //planinfo.PREFIX = "IN";
|
|
// ////planinfo.DATASTR = ma.PLAN_DATE.ToString("yyyyMMdd");
|
|
// //////获取流水号
|
|
// //planinfo = this.GetOrderPlanSeq(planinfo);
|
|
// //planinfo.DATASTR = ma.PLAN_DATE.ToString("yyyyMMdd");
|
|
// //ma.PLAN_NO = planinfo.PREFIX + planinfo.DATASTR + planinfo.SEQSTR;
|
|
|
|
// //ma.PLAN_NO = planinfo.PREFIX+ma.PLAN_NO;
|
|
|
|
// //int no = new DoorPlankPlanDAL().GetNum(ma) + (num - 1);
|
|
// //ma.PLAN_SEQ = ma.PLAN_DATE.ToString("yyyyMMdd") + no;
|
|
// 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 });
|
|
// if (pbomcode != null)
|
|
// {
|
|
// ma.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
// }
|
|
// //工艺路线
|
|
// QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(ma.MATERIAL_CODE);
|
|
// if (routecode != null)
|
|
// {
|
|
// 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);
|
|
// #region 注入派工单信息(已注释)
|
|
// ////注入派工单信息
|
|
// //for (int i = 0; i < ma.QTY; i++)
|
|
// //{
|
|
// // DataRow workOrder = workOrderDt.NewRow();
|
|
|
|
// // workOrder["PID"] = Guid.NewGuid().ToString();
|
|
// // workOrder["ORDERPLANID"] = odr["PID"];
|
|
// // workOrder["ORDERPLAN_NO"] = (odr["PLAN_NO"].ToString() + (i + 1).ToString().PadLeft(4, '0'));
|
|
// // workOrder["ORDER_TYPE"] = EnumGeter.WORKORDERTYPE.PROCEDURE.GetHashCode().ToString();
|
|
// // workOrder["SEQ"] = (i + 1).ToString();
|
|
// // workOrder["MATERIAL_CODE"] = ma.MATERIAL_CODE;
|
|
|
|
// // workOrder["PBOM_CODE"] = "";
|
|
// // workOrder["QTY"] = 1;
|
|
// // workOrder["COMPLETE_QTY"] = 0;
|
|
// // workOrder["PLAN_DATE"] = ma.PLAN_DATE;
|
|
// // workOrder["SHIFT_CODE"] = "";
|
|
|
|
// // workOrder["WORKCENTER_CODE"] = "";
|
|
|
|
// // workOrder["WORKCELL_CODE"] = "";
|
|
// // workOrder["WORKLOC_CODE"] = "";
|
|
// // workOrder["REMARK"] = "";
|
|
// // workOrder["EQPT_NAME"] = "";
|
|
// // workOrder["EQPT_CODE"] = "";
|
|
// // workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
|
|
|
|
// // workOrderDt.Rows.Add(workOrder);
|
|
// //}
|
|
// #endregion
|
|
// }
|
|
|
|
// 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(int) });
|
|
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) });
|
|
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
#region 根据WINFORM修改订单状态
|
|
/// <summary>
|
|
/// 根据WINFORM修改订单状态
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新个数</returns>
|
|
public DataResult<int> ChangeOrderPlan(TJPaoMoPlan info)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
try
|
|
{
|
|
TJPaoMoPlanDAL TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
|
|
List<TJPaoMoPlan> ChangePlanList = new List<TJPaoMoPlan>();
|
|
List<TJPaoMoPlan> validOrderList = new List<TJPaoMoPlan>();
|
|
TJPaoMoPlan op = TJPaoMoPlanDAL.Get(new TJPaoMoPlan() { MATERIAL_CODE = info.MATERIAL_CODE, PLAN_STATES = (EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString() + ',' + EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString()) });
|
|
if (op == null)
|
|
{
|
|
result.IsSuccess = false;
|
|
return result;
|
|
}
|
|
//如果订单初始化或是确认生产
|
|
if (op.PLAN_STATE == EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString()
|
|
|| op.PLAN_STATE == EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString() )
|
|
{
|
|
ChangePlanList.Add(op);
|
|
}
|
|
else
|
|
{
|
|
validOrderList.Add(op);
|
|
}
|
|
|
|
if (validOrderList.Count > 0)
|
|
{
|
|
result.IsSuccess = false;
|
|
return result;
|
|
}
|
|
|
|
//更新TJPaoMoPlan相应字段
|
|
//if (op.PLAN_STATE == EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString())
|
|
//{
|
|
// op.PLAN_STATE = EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString();
|
|
// op.COMPLETE_QTY = op.COMPLETE_QTY + 1;
|
|
//}
|
|
//else if (op.COMPLETE_QTY + 1 < op.QTY && op.PLAN_STATE == EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString())
|
|
//{
|
|
// op.PLAN_STATE = EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString();
|
|
// op.COMPLETE_QTY = op.COMPLETE_QTY + 1;
|
|
//}
|
|
//else if (op.COMPLETE_QTY + 1 >= op.QTY && op.PLAN_STATE == EnumGeter.PLANSTATE.CREATING.GetHashCode().ToString())
|
|
//{
|
|
// op.PLAN_STATE = EnumGeter.PLANSTATE.COMPLATED.GetHashCode().ToString();
|
|
// op.COMPLETE_QTY = op.COMPLETE_QTY + 1;
|
|
//}
|
|
//更新workorder相应字段
|
|
WorkOrderDAL workOrderDal = new WorkOrderDAL();
|
|
WorkOrder wo = workOrderDal.GetworkOrderInfo(new WorkOrder() { ORDERPLANID = op.PID });
|
|
if(wo.PID!=null)
|
|
{
|
|
wo.COMPLETE_QTY = 1;
|
|
wo.STATE = 3;
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
TJPaoMoPlanDAL.BaseSession = session;
|
|
workOrderDal.BaseSession = session;
|
|
|
|
//更新订单
|
|
TJPaoMoPlanDAL.ChangeOrderPlan(op);
|
|
|
|
//更新订单下的派工单
|
|
workOrderDal.ChangeByOrderPlan(wo);
|
|
session.CommitTs();
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取订单信息
|
|
/// <summary>
|
|
/// 获取订单信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public TJPaoMoPlan GetOrderPlantState(TJPaoMoPlan condition)
|
|
{
|
|
TJPaoMoPlan result = new TJPaoMoPlan();
|
|
try
|
|
{
|
|
result = new TJPaoMoPlanDAL().Get(condition);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region GetBreakFIS
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void GetBreakFIS()
|
|
{
|
|
DAL.ProductionPlan.WorkOrderDAL workorderdal = new DAL.ProductionPlan.WorkOrderDAL();
|
|
|
|
//获取当前工序优先级最高的工单
|
|
var workorder = workorderdal.GetMatchOrders("");
|
|
if (workorder.Count > 0)
|
|
{
|
|
if (string.Equals(workorder[0].ORDER_TYPE, "0")) //如果为FIS工单
|
|
{
|
|
//获取前一个FIS计划顺序号
|
|
var lastseqstr = workorderdal.GetLastFISSEQ(workorder[0].PLAN_DATE, workorder[0].WORKCENTER_CODE);
|
|
if (!string.IsNullOrEmpty(lastseqstr))
|
|
{
|
|
int maxseq = 1999;
|
|
int minseq = 1;
|
|
int lastseq = int.Parse(lastseqstr);
|
|
int currentseq = int.Parse(workorder[0].SEQ);
|
|
if (lastseq < maxseq)
|
|
{
|
|
if (currentseq - lastseq > 1)
|
|
{
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (currentseq != minseq)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取流水号信息
|
|
/// <summary>
|
|
/// 获取流水号信息
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public FISPlan GetOrderPlanSeq(FISPlan condition)
|
|
{
|
|
FISPlan fisplan = new FISPlan();
|
|
TJPaoMoPlanDAL TJPaoMoPlanDAL = new TJPaoMoPlanDAL();
|
|
//根据表皮条码获取本体信息
|
|
|
|
try
|
|
{
|
|
fisplan = new TJPaoMoPlanDAL().GetOrderPlanSeq(condition);
|
|
//若存在记录,流水号加1,且更新
|
|
if (fisplan != null)
|
|
{
|
|
string seqstr = (Convert.ToInt32(fisplan.SEQSTR) + 1).ToString().PadLeft(4, '0');
|
|
fisplan.SEQSTR = seqstr;
|
|
//更新表T_AW_FISPLAN数据
|
|
|
|
}
|
|
//不存在则插入此日期信息
|
|
else
|
|
{
|
|
FISPlan planinfo = new FISPlan();
|
|
planinfo.PID = Guid.NewGuid().ToString();
|
|
planinfo.PREFIX = condition.PREFIX;
|
|
planinfo.DATASTR = condition.DATASTR;
|
|
planinfo.SEQSTR = "0001";
|
|
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="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
//public DataResult<DataPage> FisPlanRecordList(FISPlanRecord condition, DataPage page)
|
|
//{
|
|
// DataResult<DataPage> result = new DataResult<DataPage>();
|
|
// try
|
|
// {
|
|
// //获取生产版本项目信息列表
|
|
// DataPage dataPage = new TJPaoMoPlanDAL().FisPlanRecordList(condition, page);
|
|
|
|
// #region 转换使用状态显示类型
|
|
// List<FISPlanRecord> operatorList = dataPage.Result as List<FISPlanRecord>;
|
|
|
|
// DictManageBLL dictOPERATORSTATE = new DictManageBLL(DictKind.OperatioType);
|
|
// foreach (var info in operatorList)
|
|
// {
|
|
// info.OPERATION_TYPE = dictOPERATORSTATE.GetDictValue(info.OPERATION_TYPE);
|
|
// }
|
|
// #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;
|
|
// return result;
|
|
// }
|
|
// result.IsSuccess = true;
|
|
// return result;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 计划操作记录
|
|
|
|
//public DataResult<DataPage> GetTraceList(OrderPlanTrace condition, DataPage page)
|
|
//{
|
|
// DataResult<DataPage> result = new DataResult<DataPage>();
|
|
// try
|
|
// {
|
|
// //获取订单计划信息列表
|
|
// page = new TJPaoMoPlanDAL().GetTraceList(condition, page);
|
|
|
|
// List<OrderPlanTrace> list = page.Result as List<OrderPlanTrace>;
|
|
|
|
// #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 = page;
|
|
// }
|
|
// 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;
|
|
//}
|
|
//public DataTable GetExportDataTrace(OrderPlanTrace model)
|
|
//{
|
|
// try
|
|
// {
|
|
// DataTable dt = new TJPaoMoPlanDAL().GetExportDataTrace(model);
|
|
|
|
// DictManageBLL dictPRODUCEREQUIRE = new DictManageBLL(DictKind.PRODUCEREQUIRE);
|
|
// DictManageBLL dictPLANSTATE = new DictManageBLL(DictKind.PLAN_STATE);
|
|
// DictManageBLL dictPLANSOURCE = new DictManageBLL(DictKind.PLANSOURCE);
|
|
// foreach (DataRow dr in dt.Rows)
|
|
// {
|
|
// //替换状态类别显示值
|
|
// dr["PRODUCEREQUIRE"] = dictPRODUCEREQUIRE.GetDictValue(dr["PRODUCEREQUIRE"].ToString());
|
|
// dr["PLAN_STATE"] = dictPLANSTATE.GetDictValue(dr["PLAN_STATE"].ToString());
|
|
// dr["PLANSOURCE"] = dictPLANSOURCE.GetDictValue(dr["PLANSOURCE"].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
|
|
|
|
public DataResult<TJPaoMoPlan> GetPlanWithOrderNo(string orderno, bool CreateIfNotExists)
|
|
{
|
|
string regexp_full = "^D\\d{2}\\w+[RF][LR]\\d{2}(10|11|12|0[1-9])(30|31|2\\d|1\\d|0[1-9])\\w\\d{5}$";
|
|
string regexp_prefix = "^D\\d{2}\\w+(?=[RF][LR]\\d{6})";
|
|
string regexp_position = "[RF][LR](?=\\d{6})";
|
|
string regexp_date = "(?<=[RF][LR])\\d{2}(10|11|12|0[1-9])(30|31|2\\d|1\\d|0[1-9])";
|
|
string regexp_seq = "\\d{5}$";
|
|
|
|
var plandal = new TJPaoMoPlanDAL();
|
|
var workorderdal = new DAL.ProductionPlan.WorkOrderDAL();
|
|
//Entity.FIS.TJPaoMoPlan plan = null;
|
|
Entity.ProductionPlan.WorkOrder order = null;
|
|
order = workorderdal.GetOneByOrderNO(orderno);
|
|
|
|
if (order == null)
|
|
{
|
|
if (!Regex.IsMatch(orderno, regexp_full))
|
|
{
|
|
var plan = plandal.Get(new TJPaoMoPlan { PLAN_NO = orderno.Substring(0, orderno.Length - 4) });
|
|
if (plan != null)
|
|
{
|
|
return new DataResult<TJPaoMoPlan> { Result = plan, IsSuccess = true, MsgCode = "1" };
|
|
}
|
|
else
|
|
{
|
|
return new DataResult<TJPaoMoPlan> { IsSuccess = false, Ex = new Exception("未查询到此FIS条码对应的计划工单,此工单可能已完成或删除!") };
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var plan = plandal.Get(new TJPaoMoPlan { PLAN_NO = orderno });
|
|
if (plan != null)
|
|
{
|
|
return new DataResult<TJPaoMoPlan> { Result = plan, IsSuccess = true, MsgCode = "1" };
|
|
}
|
|
}
|
|
string codeprefix = Regex.Match(orderno, regexp_prefix).Value;
|
|
string positioncode = Regex.Match(orderno, regexp_position).Value;
|
|
string date = Regex.Match(orderno, regexp_date).Value;
|
|
string seq = Regex.Match(orderno, regexp_seq).Value;
|
|
|
|
string materialcode = new DAL.FIS.FISPhraseDAL().GetMESModulCode(codeprefix, positioncode);
|
|
if (string.IsNullOrWhiteSpace(materialcode))
|
|
{
|
|
return new DataResult<TJPaoMoPlan> { IsSuccess = false, Ex = new Exception("FIS码未能识别,FIS短语字典配置不准确或未更新!") };
|
|
|
|
//throw new ;
|
|
}
|
|
|
|
DateTime plandate
|
|
= new DateTime(2000 + int.Parse(date.Substring(0, 2))
|
|
, int.Parse(date.Substring(2, 2))
|
|
, int.Parse(date.Substring(4, 2)));
|
|
|
|
var nplan = new TJPaoMoPlan
|
|
{
|
|
CREATEDATE = DateTime.Now,
|
|
//COMPLETE_QTY = 0,
|
|
CREATEUSER = "",
|
|
MATERIAL_CODE = materialcode,//////////////////
|
|
PID = Guid.NewGuid().ToString(),
|
|
PLAN_DATE = plandate,////////////
|
|
PLAN_NO = orderno,
|
|
PLAN_SEQ = seq,//////////////////
|
|
PLAN_STATE = "1",
|
|
//PLANSOURCE = "0",
|
|
QTY = 1,
|
|
UPDATEUSER = "",
|
|
UPDATEDATE = DateTime.Now,
|
|
};
|
|
|
|
Pbom pbomcode = new PbomDAL().Get(new Pbom { MATERIAL_CODE = nplan.MATERIAL_CODE });
|
|
//if (pbomcode != null)
|
|
//{
|
|
// nplan.PBOM_CODE = pbomcode.PBOM_CODE;
|
|
//}
|
|
QMAPP.MD.Entity.ProcessRoute routecode = new QMAPP.MD.DAL.ProcessRouteDAL().RouteWithMaterial(nplan.MATERIAL_CODE);
|
|
//if (routecode != null)
|
|
//{
|
|
// nplan.ROUTE_CODE = routecode.ROUTE_CODE;
|
|
//}
|
|
string workcentercode = new WorkCellDAL().GetWorkcenterWithMaterial(nplan.MATERIAL_CODE);
|
|
//if (workcentercode != null)
|
|
//{
|
|
// nplan.WORKCENTER_CODE = workcentercode;
|
|
//}
|
|
//赋值新session后插入 zxd20171101
|
|
if (CreateIfNotExists)
|
|
{
|
|
plandal.Insert(nplan);
|
|
return new DataResult<TJPaoMoPlan> { Result = nplan, IsSuccess = true, MsgCode = "1" };
|
|
}
|
|
return new DataResult<TJPaoMoPlan> { Result = nplan, IsSuccess = true, MsgCode = "0" };
|
|
}
|
|
else
|
|
{
|
|
var plan = plandal.GetOne(new TJPaoMoPlan { PID = order.ORDERPLANID });
|
|
return new DataResult<TJPaoMoPlan> { Result = plan, IsSuccess = true, MsgCode = "1" };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|