天津投入产出系统后端
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.

1033 lines
39 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.Entity.TianJin;
using QMAPP.FJC.DAL.TianJin;
2 years ago
using QMAPP.FJC.Entity.Basic;
namespace QMAPP.FJC.BLL.TianJin
{
public class TJDoorPlankPlanBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<TJOrderPlan> Get(TJOrderPlan model)
{
DataResult<TJOrderPlan> result = new DataResult<TJOrderPlan>();
try
{
result.Result = new TJDoorPlankPlanDAL().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<TJOrderPlan> GetFISInsertPos(TJOrderPlan model)
{
DataResult<TJOrderPlan> result = new DataResult<TJOrderPlan>();
try
{
var dal= new TJDoorPlankPlanDAL();
//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 = null;
}
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(TJOrderPlan condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取订单计划信息列表
DataPage dataPage = new TJDoorPlankPlanDAL().GetList(condition, page);
//DataPage dataPage = new DataPage();
List<TJOrderPlan> list = page.Result as List<TJOrderPlan>;
#region 显示类型
//处理字典信息
DictManageBLL dictPLANSTATE = new DictManageBLL(DictKind.PLAN_STATE);
foreach (var info in list)
{
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(TJOrderPlan model)
{
try
{
return new TJDoorPlankPlanDAL().ExistsOrderPlan(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(TJOrderPlan model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
2 years ago
if(string.IsNullOrEmpty(model.PID))
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;
TJDoorPlankPlanDAL cmdDAL = new TJDoorPlankPlanDAL();
model.MATERIAL_NAME = cmdDAL.GetMATERIALNAME(model.MATERIAL_CODE);
try
{
//获取流水号
var SEQSTR = this.GetOrderPlanSeq(model);
model.PLAN_SEQ = SEQSTR;
//计划单号
model.PLAN_NO = "DP" + model.PLAN_DATE.ToString("yyyyMMdd") + SEQSTR;
result.Result = new TJDoorPlankPlanDAL().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="condition"></param>
/// <returns></returns>
public string GetOrderPlanSeq(TJOrderPlan condition)
{
TJOrderPlan fisplan = new TJOrderPlan();
TJOrderPlanDAL TJOrderPlanDAL = new TJOrderPlanDAL();
//根据表皮条码获取本体信息
try
{
fisplan = new TJOrderPlanDAL().GetOrderPlanSeq(condition);
//若存在记录,流水号加1,且更新
if (fisplan != null)
{
return (Convert.ToInt32(fisplan.PLAN_SEQ) + 1).ToString().PadLeft(3, '0');
}
//不存在则插入此日期信息
else
{
return "001";
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "仪表板逻辑层-获取流水号本体信息!"
});
throw ex;
}
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(TJOrderPlan model)
{
DataResult<int> result = new DataResult<int>();
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (model.PLAN_STATE != "0")
{
result.IsSuccess = false;
result.Msg = "计划已经下发,无法修改!";
return result;
}
#region 判断数量
TJDoorPlankPlanDAL cmdDAL = new TJDoorPlankPlanDAL();
model.MATERIAL_NAME = cmdDAL.GetMATERIALNAME(model.MATERIAL_CODE);
//获取流水号
var SEQSTR = this.GetOrderPlanSeq(model);
model.PLAN_SEQ = SEQSTR;
//计划单号
model.PLAN_NO = "DP" + model.PLAN_DATE.ToString("yyyyMMdd") + SEQSTR;
TJOrderPlanDAL TJOrderPlanDAL = new TJOrderPlanDAL();
#endregion
using (IDataSession session = AppDataFactory.CreateMainSession())
{
TJOrderPlanDAL.Update(model);
}
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;
DataResult<int> result = new DataResult<int>();
try
{
TJWorkOrderDAL TJworkOrderDal = new TJWorkOrderDAL();
TJOrderPlanDAL TJOrderPlanDAL = new TJOrderPlanDAL();
//可以删除的订单
List<TJOrderPlan> deleteOrderList = new List<TJOrderPlan>();
3 years ago
if (!string.IsNullOrEmpty(strs))
{
3 years ago
foreach (var str in strs.Split(':'))
{
TJOrderPlan op = TJOrderPlanDAL.Get(new TJOrderPlan() { PID = str });
int Num = TJworkOrderDal.GetAllWorkOrder(str);
if (op.PLAN_STATE == EnumGeter.PLANSTATE.INIT.GetHashCode().ToString()
|| (op.PLAN_STATE == EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString() && Num == 0))
{
//删除订单
TJOrderPlanDAL.DeleteOrderPlan(op);
TJworkOrderDal.BatchDeleteByOrderPlan(new TJWorkOrder() { ORDERPLANID = op.PID });
count++;
}
else
{
result.IsSuccess = false;
result.Msg = $"只有初始化或是确认生产并且生产数量为0订单可以删除!成功删除{count}条计划!";
return result;
}
}
}
3 years ago
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(TJOrderPlan model)
{
int count = 0;
int number = new TJDoorPlankPlanDAL().DelCheck(model);
if (number > 0)
{
return count;
}
count = new TJDoorPlankPlanDAL().Delete(model);
return count;
}
#endregion
#region 发布
/// <summary>
/// 发布信息
/// </summary>
/// <param name=""></param>
/// <returns>发布个数</returns>
public DataResult<int> PutOut(string strs)
{
DataResult<int> result = new DataResult<int>();
try
{
TJOrderPlanDAL TJOrderPlanDAL = new TJOrderPlanDAL();
List<TJOrderPlan> validorderPlanList = new List<TJOrderPlan>();
3 years ago
var strlist = strs.Split(':');
foreach(var t in strlist)
{
3 years ago
TJOrderPlan op = TJOrderPlanDAL.Get(new TJOrderPlan { PID = t });
3 years ago
if (op.PLAN_STATE != EnumGeter.PLANSTATE.INIT.GetHashCode().ToString())
{
result.IsSuccess = false;
result.Msg = "只有初始状态下的订单能够进行发布!";
3 years ago
return result;
}
3 years ago
DataTable totalDt = GetWorkOrderTable();
op.PLAN_STATE = EnumGeter.PLANSTATE.COMMIT.GetHashCode().ToString();
op.UPDATEUSER = this.LoginUser.UserID;
totalDt = this.PutOutOrderPlan(op, totalDt);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
3 years ago
IDbConnection dbConn = DbManager.MainConnectionInfo.Connection;
if (dbConn.State == ConnectionState.Closed)
{
dbConn.Open();
}
IDbTransaction ids = dbConn.BeginTransaction();
TJOrderPlanDAL.Update(op);
session.DbHelper.BulkCopyData(totalDt, "T_PP_TJFY_WORKORDER", dbConn, ids);
ids.Commit();
}
3 years ago
result.IsSuccess = true;
}
3 years ago
return result;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 发布信息
/// </summary>
/// <param name="">信息</param>
/// <returns>发布个数</returns>
public DataTable PutOutOrderPlan(TJOrderPlan info, DataTable workOrderDt)
{
WorkCellDAL workCelldal = new WorkCellDAL();
3 years ago
if (info.MATERIAL_CODE.Length > 8)
{
3 years ago
for (int i = 0; i < info.QTY; i++)
{
3 years ago
DataRow workOrder = workOrderDt.NewRow();
workOrder["PID"] = Guid.NewGuid().ToString();
workOrder["ORDERPLANID"] = info.PID;
3 years ago
workOrder["ORDERPLAN_NO"] = (info.PLAN_NO.ToString() + (i + 1).ToString().PadLeft(4, '0'));
workOrder["SEQ"] = info.PLAN_NO.Substring(info.PLAN_NO.Length - 2, 2) + (i + 1).ToString().PadLeft(4, '0');
workOrder["MATERIAL_CODE"] = info.MATERIAL_CODE;
workOrder["MATERIAL_NAME"] = info.MATERIAL_NAME;
workOrder["PLAN_DATE"] = info.PLAN_DATE;
workOrder["PRODUCTCODE"] = "";
3 years ago
if (info.MATERIAL_NAME.Contains("左前"))
{
workOrder["MOULD_CODE"] = "LF";
}
else if (info.MATERIAL_NAME.Contains("左后"))
{
workOrder["MOULD_CODE"] = "LR";
}
else if (info.MATERIAL_NAME.Contains("右前"))
{
workOrder["MOULD_CODE"] = "RF";
}
else if (info.MATERIAL_NAME.Contains("右后"))
{
workOrder["MOULD_CODE"] = "RR";
}
workOrder["LINENO"] = info.LINENO;
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
workOrder["UPDATEDATE"] = DateTime.Now.ToString();
workOrderDt.Rows.Add(workOrder);
}
}
3 years ago
else
{
3 years ago
var list = "".Split(',');
3 years ago
var dal = new TJDoorPlankPlanDAL();
var MachineList = dal.GetListMachine(info.MATERIAL_CODE);
3 years ago
if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "L")
{
list = "LF,LR".Split(',');
}
else if (info.MATERIAL_CODE.Substring(info.MATERIAL_CODE.Length - 1, 1) == "R")
{
list = "RF,RR".Split(',');
}
else if (info.MATERIAL_CODE.Length == 6)
{
list = "LF,LR,RF,RR".Split(',');
}
3 years ago
//注入派工单信息
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["SEQ"] = info.PLAN_NO.Substring(info.PLAN_NO.Length - 2, 2) + (i + 1).ToString().PadLeft(4, '0');
var WEIZHI = "";
switch (seq)
{
case "LF":
WEIZHI = "左前";
break;
case "LR":
WEIZHI = "左后";
break;
case "RF":
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;
}
else
workOrder["MATERIAL_CODE"] = "";
workOrder["MATERIAL_NAME"] = info.MATERIAL_NAME;
workOrder["PLAN_DATE"] = info.PLAN_DATE;
workOrder["PRODUCTCODE"] = "";
workOrder["MOULD_CODE"] = seq;
workOrder["LINENO"] = info.LINENO;
workOrder["STATE"] = EnumGeter.WORKPLANSTATE.INIT.GetHashCode().ToString();
workOrder["UPDATEDATE"] = DateTime.Now.ToString();
workOrderDt.Rows.Add(workOrder);
}
}
}
return workOrderDt;
}
3 years ago
public static string GET_MATERIAL_CODE(string MOULD_CODE,string MATERIAL_CODE)
{
return "";
}
//public List<WorkOrder> PutOutOrderPlan(TJOrderPlan 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(TJOrderPlan model)
{
try
{
//DataTable dt = new TJDoorPlankPlanDAL().GetExportData(model);
DataTable dt = new DataTable();
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());
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导入数据 --Web-导入计划
/// <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<TJOrderPlan> 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>();
TJDoorPlankPlanDAL cmDal = new TJDoorPlankPlanDAL();
List<TJOrderPlan> List = new List<TJOrderPlan>();
int index = 0;
int num = 0;
try
{
result.Result = new ImportMessage();
result.Result.Errors = new List<RowError>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
3 years ago
var SEQSTR = this.GetOrderPlanSeq(list[0]);
foreach (TJOrderPlan ma in list)
{
3 years ago
SEQSTR = (Convert.ToInt32(SEQSTR) + index).ToString().PadLeft(3, '0');
index++;
num++;
3 years ago
ma.PLAN_SEQ = Convert.ToInt32(SEQSTR).ToString();
ma.LINENO = "770";
//计划单号
3 years ago
ma.PLAN_NO = "DP" + ma.PLAN_DATE.ToString("yyyyMMdd") + SEQSTR.PadLeft(3,'0');
TJDoorPlankPlanDAL cmdDAL = new TJDoorPlankPlanDAL();
ma.MATERIAL_NAME = cmdDAL.GetMATERIALNAME(ma.MATERIAL_CODE);
//修改改时根据主键等信息获取详细内容信息
TJOrderPlan oldInfo = cmDal.Get(ma);
3 years ago
if (oldInfo != null)
{
//更新
ma.PID = oldInfo.PID;
ma.PLAN_SEQ = oldInfo.PLAN_SEQ;
ma.MATERIAL_CODE = oldInfo.MATERIAL_CODE;
ma.MATERIAL_NAME = oldInfo.MATERIAL_NAME;
ma.PLAN_STATE = oldInfo.PLAN_STATE;
ma.LINENO = oldInfo.LINENO;
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 TJOrderPlan();
ma.PID = Guid.NewGuid().ToString();
ma.PLAN_STATE = EnumGeter.PLANSTATE.INIT.GetHashCode().ToString();
ma.CREATEUSER = this.LoginUser.UserID;
ma.CREATEDATE = DateTime.Now;
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 = "SEQ", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "MATERIAL_CODE", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "MATERIAL_NAME", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "PLAN_DATE", DataType = typeof(DateTime) });
dt.Columns.Add(new DataColumn() { ColumnName = "PRODUCTCODE", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "STATE", DataType = typeof(int) });
dt.Columns.Add(new DataColumn() { ColumnName = "MOULD_CODE", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "LINENO", DataType = typeof(string) });
dt.Columns.Add(new DataColumn() { ColumnName = "UPDATEDATE", DataType = typeof(string) });
return dt;
}
#endregion
#region 保存FIS插单
/// <summary>
/// 保存FIS插单
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
//public DataResult<int> SaveFISInsert(TJOrderPlan model, List<Material> materiallist,bool Publish)
//{
// List<TJOrderPlan> List = new List<TJOrderPlan>();
// DataResult<int> result = new DataResult<int>();
// TJDoorPlankPlanDAL cmdDAL = new TJDoorPlankPlanDAL();
// cmdDAL.BaseSession = AppDataFactory.CreateMainSession();
// var InsertNum = cmdDAL.GetMaxFISInsertNum(model) + 1;
// foreach (Material ma in materiallist)
// {
// TJOrderPlan planmodel = new TJOrderPlan();
// 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(TJOrderPlan condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new TJDoorPlankPlanDAL().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(TJOrderPlan TJOrderPlan)
{
int count = 0;
DataResult<int> result = new DataResult<int>();
try
{
//foreach (string str in list)
//{
// TJOrderPlan op = new TJOrderPlan();
// op.PID = str;
// op.PLAN_SEQ = TJOrderPlan.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(TJOrderPlan model)
{
int count = 0;
count = new TJDoorPlankPlanDAL().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 TJDoorPlankPlanDAL().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 TJDoorPlankPlanDAL().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
2 years ago
public List<Materiel> GetListMachine(string MaterielCode)
{
try
{
var dal = new TJDoorPlankPlanDAL();
return dal.GetAllMachine(MaterielCode);
}
catch
{
return null;
}
}
}
}