songnan.zhang
3 years ago
16 changed files with 1909 additions and 72 deletions
@ -0,0 +1,667 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using QMAPP.BLL; |
|||
using QMAPP.FJC.Entity.ProductionPlan; |
|||
using QMAPP.FJC.DAL.ProductionPlan; |
|||
using QMFrameWork.Data; |
|||
using QMAPP.Entity; |
|||
using System.Data; |
|||
using QMAPP.FJC.Entity.Operation; |
|||
using QMAPP.FJC.Entity.FIS; |
|||
using QMAPP.FJC.DAL.TianJin; |
|||
using QMAPP.FJC.Entity.TianJin; |
|||
|
|||
namespace QMAPP.FJC.BLL.TianJin |
|||
{ |
|||
/// <summary>
|
|||
/// 模块名称:派工单
|
|||
/// 作 者:张鹏
|
|||
/// 编写日期:2017年10月24日
|
|||
/// </summary>
|
|||
public class TJWorkOrderBLL : BaseBLL |
|||
{ |
|||
|
|||
#region 获取信息
|
|||
/// <summary>
|
|||
/// 获取信息
|
|||
/// </summary>
|
|||
/// <param name="">条件</param>
|
|||
/// <returns>信息</returns>
|
|||
public WorkOrder Get(WorkOrder info) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().Get(info); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 获取列表
|
|||
/// <summary>
|
|||
/// 获取列表
|
|||
/// </summary>
|
|||
/// <param name="condition">条件</param>
|
|||
/// <param name="page">数据页</param>
|
|||
/// <returns>数据页</returns>
|
|||
public DataPage GetList(WorkOrder condition, DataPage page) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().GetList(condition, page); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// 获取指定工序的生产计划清单
|
|||
/// </summary>
|
|||
/// <param name="workcellcode">工序编码</param>
|
|||
/// <param name="filter">过滤选项:0全部;1隐藏挂起;2只看挂起</param>
|
|||
/// <returns></returns>
|
|||
public List<WorkOrder> GetOrderInCell(string workcellcode,int filter, DataPage dataPage) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().GetOrderInCell(workcellcode,filter,dataPage.PageSize); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="orderplanno"></param>
|
|||
/// <returns></returns>
|
|||
public List<WorkOrder> GetOrderInfo(string orderplanno) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().GetWorkOrderInfo(orderplanno); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
public List<WorkOrder> GetOrderUnPrinted(string RouteCode, int filter, DataPage dataPage,string Direction) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().GetOrderUnPrinted(RouteCode, Direction, filter, dataPage.PageSize); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
public int SetOrderPrinted(string orderpid) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().SetOrderPrinted(orderpid); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取指定工序下待完成计划数量
|
|||
/// </summary>
|
|||
/// <param name="workcellcode">工序编码</param>
|
|||
/// <param name="shift">班次</param>
|
|||
/// <param name="date">日期</param>
|
|||
/// <returns></returns>
|
|||
public int GetOrderCountInCell(string workcellcode, string shift) |
|||
{ |
|||
try |
|||
{ |
|||
var date = DateTime.Now; |
|||
return new TWorkOrderDAL().GetOrderCountInCell(workcellcode, shift, date); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取工作中心当日的总计划数量
|
|||
/// </summary>
|
|||
/// <param name="workcentercode">工作中心</param>
|
|||
/// <returns></returns>
|
|||
public int GetDayPlanCount(string workcentercode) |
|||
{ |
|||
try |
|||
{ |
|||
var date = DateTime.Now; |
|||
return new TWorkOrderDAL().GetDayPlanCount(workcentercode, date); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取计划标签数据
|
|||
/// </summary>
|
|||
/// <param name="workorderid"></param>
|
|||
/// <returns></returns>
|
|||
public Entity.View.PlanLabel GetPlanLabel(string workorderid) |
|||
{ |
|||
Entity.View.PlanLabel labeldata = new Entity.View.PlanLabel(); |
|||
TWorkOrderDAL dal = new TWorkOrderDAL(); |
|||
var order = dal.Get(new WorkOrder { PID = workorderid }); |
|||
if (order == null) |
|||
{ |
|||
throw new Exception("获取工单信息失败!"); |
|||
} |
|||
|
|||
labeldata.BOM = order.PBOM_CODE; |
|||
labeldata.PN = order.MATERIAL_CODE; |
|||
labeldata.SEQ = order.SEQ; |
|||
labeldata.PlanDate = order.PLAN_DATE.ToString("yyyy-MM-dd HH:mm:ss"); |
|||
switch (order.ORDER_TYPE) |
|||
{ |
|||
case "0": |
|||
{ |
|||
labeldata.PlanType = "FIS"; |
|||
break; |
|||
} |
|||
case "1": |
|||
{ |
|||
labeldata.PlanType = "STOCK"; |
|||
break; |
|||
} |
|||
case "2": |
|||
{ |
|||
labeldata.PlanType = "INSERT"; |
|||
break; |
|||
} |
|||
} |
|||
var plandal = new DAL.FIS.OrderPlanDAL(); |
|||
var plan = plandal.Get(new Entity.FIS.OrderPlan { PID = order.ORDERPLANID }); |
|||
if (plan == null) |
|||
{ |
|||
throw new Exception("获取计划信息异常!"); |
|||
} |
|||
labeldata.PlanNo = plan.PLAN_NO; |
|||
|
|||
|
|||
if (order.ORDER_TYPE == "0") |
|||
{ |
|||
var fisdal = new DAL.FIS.FISOrderDAL(); |
|||
var fis = fisdal.GetByPlan(plan.PLAN_NO, plan.MATERIAL_CODE); |
|||
if (fis == null) |
|||
{ |
|||
throw new Exception("获取FIS信息异常!"); |
|||
} |
|||
labeldata.VIN = fis.VIN; |
|||
labeldata.KIN = fis.KIN; |
|||
} |
|||
else |
|||
{ |
|||
labeldata.VIN = "N/A"; |
|||
labeldata.KIN = "N/A"; |
|||
} |
|||
var materialdal = new MD.DAL.MaterialDAL(); |
|||
var material = materialdal.Get(new MD.Entity.Material { MATERIAL_CODE = order.MATERIAL_CODE }); |
|||
if (material == null) |
|||
{ |
|||
throw new Exception("获取物料信息异常!"); |
|||
} |
|||
labeldata.HBType = material.HBTYPE; |
|||
labeldata.ProjectCode = material.PROJECTCODE; |
|||
labeldata.Color = material.COLOR; |
|||
labeldata.ProdName = material.MATERIAL_NAME; |
|||
return labeldata; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取计划标签数据
|
|||
/// </summary>
|
|||
/// <param name="workorderid"></param>
|
|||
/// <returns></returns>
|
|||
public Entity.View.PlanLabel GetPlanLabelBindProdut(Product Product) |
|||
{ |
|||
Entity.View.PlanLabel labeldata = new Entity.View.PlanLabel(); |
|||
|
|||
var plandal = new DAL.FIS.OrderPlanDAL(); |
|||
var plan = plandal.Get(new Entity.FIS.OrderPlan { PID = Product.PLAN_ID }); |
|||
if (plan == null) |
|||
{ |
|||
throw new Exception("获取计划信息异常!"); |
|||
} |
|||
labeldata.BOM = plan.PBOM_CODE; |
|||
labeldata.PN = plan.MATERIAL_CODE; |
|||
|
|||
labeldata.PlanDate = plan.PLAN_DATE.ToString("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
TWorkOrderDAL dal = new TWorkOrderDAL(); |
|||
var order = dal.GetOneByProduct(Product.PRODUCTCODE); |
|||
if (order != null) |
|||
{ |
|||
labeldata.SEQ = order.SEQ; |
|||
} |
|||
else |
|||
{ |
|||
labeldata.SEQ = "N/A"; |
|||
} |
|||
switch (plan.PLANSOURCE) |
|||
{ |
|||
case "0": |
|||
{ |
|||
labeldata.PlanType = "FIS"; |
|||
break; |
|||
} |
|||
case "1": |
|||
{ |
|||
labeldata.PlanType = "STOCK"; |
|||
break; |
|||
} |
|||
case "2": |
|||
{ |
|||
labeldata.PlanType = "INSERT"; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
labeldata.PlanNo = plan.PLAN_NO; |
|||
|
|||
|
|||
if (plan.PLANSOURCE == "0") |
|||
{ |
|||
var fisdal = new DAL.FIS.FISOrderDAL(); |
|||
var fis = fisdal.GetByPlan(plan.PLAN_NO, plan.MATERIAL_CODE); |
|||
if (fis == null) |
|||
{ |
|||
throw new Exception("获取FIS信息异常!"); |
|||
} |
|||
labeldata.VIN = fis.VIN; |
|||
labeldata.KIN = fis.KIN; |
|||
} |
|||
else |
|||
{ |
|||
labeldata.VIN = "N/A"; |
|||
labeldata.KIN = "N/A"; |
|||
} |
|||
var materialdal = new MD.DAL.MaterialDAL(); |
|||
var material = materialdal.Get(new MD.Entity.Material { MATERIAL_CODE = plan.MATERIAL_CODE }); |
|||
if (material == null) |
|||
{ |
|||
throw new Exception("获取物料信息异常!"); |
|||
} |
|||
labeldata.HBType = material.HBTYPE; |
|||
labeldata.ProjectCode = material.PROJECTCODE; |
|||
labeldata.Color = material.COLOR; |
|||
labeldata.ProdName = material.MATERIAL_NAME; |
|||
return labeldata; |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region 信息是否重复
|
|||
/// <summary>
|
|||
/// 判断名称是否存在
|
|||
/// </summary>
|
|||
/// <param name="">信息</param>
|
|||
/// <returns>true:已存在;fasel:不存在。</returns>
|
|||
public bool Exists(WorkOrder info) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().Exists(info); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region 插入信息
|
|||
/// <summary>
|
|||
/// 插入信息(单表)
|
|||
/// </summary>
|
|||
/// <param name="">信息</param>
|
|||
/// <returns>插入行数</returns>
|
|||
public DataResult<int> Insert(WorkOrder info) |
|||
{ |
|||
DataResult<int> result = new DataResult<int>(); |
|||
try |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(info.PID)) |
|||
{ |
|||
info.PID = Guid.NewGuid().ToString(); |
|||
} |
|||
TWorkOrderDAL cmdDAL = new TWorkOrderDAL(); |
|||
result.Result = new TWorkOrderDAL().Insert(info); |
|||
result.IsSuccess = true; |
|||
return result; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 更新信息
|
|||
/// <summary>
|
|||
/// 更新信息
|
|||
/// </summary>
|
|||
/// <param name="">信息</param>
|
|||
/// <returns>更新行数</returns>
|
|||
public DataResult<int> Update(WorkOrder info) |
|||
{ |
|||
DataResult<int> result = new DataResult<int>(); |
|||
try |
|||
{ |
|||
result.Result = new TWorkOrderDAL().Update(info); |
|||
result.IsSuccess = true; |
|||
return result; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// 挂起工单
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public int SuspendOrder(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (int.Equals(order.STATE, 2)) |
|||
{ |
|||
throw new Exception("不可将状态为执行中的工单挂起!"); |
|||
} |
|||
order.STATE = 4; |
|||
} |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.Update(orders); |
|||
} |
|||
/// <summary>
|
|||
/// 取消挂起
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
public int CancelSuspend(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (!int.Equals(order.STATE, 4)) |
|||
{ |
|||
throw new Exception("只可取消状态为挂起状态的工单!"); |
|||
} |
|||
order.STATE = 1; |
|||
} |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.Update(orders); |
|||
} |
|||
/// <summary>
|
|||
/// 回收工单
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
public int TakeBack(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (!int.Equals(order.STATE, 4)) |
|||
{ |
|||
throw new Exception("只可回收状态为挂起状态的工单!"); |
|||
} |
|||
//order.ORDER_TYPE = "1";
|
|||
order.PRI = 1; |
|||
order.STATE = 0; |
|||
} |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.Update(orders); |
|||
} |
|||
/// <summary>
|
|||
/// 重置工单
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
public int ResetOrder(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
var first = orders.FirstOrDefault(); |
|||
if (first != null) |
|||
{ |
|||
QMAPP.MD.DAL.WorkCellDAL workCelldal = new QMAPP.MD.DAL.WorkCellDAL(); |
|||
string pbomcode = first.PBOM_CODE; |
|||
QMAPP.MD.Entity.ProcessRouteWorkCellSeq workcell = workCelldal.GetFirstWorkCell(pbomcode).FirstOrDefault(); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (!int.Equals(order.STATE, 4)) |
|||
{ |
|||
throw new Exception("只可重置状态为挂起状态的工单!"); |
|||
} |
|||
//order.ORDER_TYPE = "1";
|
|||
order.WORKCELL_CODE = workcell.WORKCELL_CODE; |
|||
order.PRI = 1; |
|||
order.STATE = 0; |
|||
} |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.Update(orders); |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 忽略FIS断号
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
public int IgnoreFISBreak(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
var first = orders.FirstOrDefault(); |
|||
var plans = new List<OrderPlan>(); |
|||
var plandal = new DAL.FIS.OrderPlanDAL(); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (!int.Equals(order.ORDER_TYPE, "0")) |
|||
{ |
|||
throw new Exception("只可对FIS工单进行忽略断号操作!"); |
|||
} |
|||
var plan = plandal.Get(new OrderPlan { PID = order.ORDERPLANID }); |
|||
if (plan != null) |
|||
{ |
|||
plan.IGNORE_FISBREAK = "1"; |
|||
plandal.Update(plan); |
|||
plans.Add(plan); |
|||
} |
|||
} |
|||
return plans.Count; |
|||
|
|||
} |
|||
/// <summary>
|
|||
/// 删除工单
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
public int DeleteOrder(List<string> orderid) |
|||
{ |
|||
var orders = GetListByID(orderid.ToArray()); |
|||
foreach (var order in orders) |
|||
{ |
|||
if (!int.Equals(order.STATE, 4)) |
|||
{ |
|||
throw new Exception("只可删除状态为挂起状态的工单!"); |
|||
} |
|||
//order.STATE = 1;
|
|||
} |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.Delete(orders); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 根据主键获取列表
|
|||
/// </summary>
|
|||
/// <param name="orderid"></param>
|
|||
/// <returns></returns>
|
|||
private List<WorkOrder> GetListByID(params string[] orderid) |
|||
{ |
|||
var dal = new TWorkOrderDAL(); |
|||
return dal.GetListByID(orderid); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region 删除
|
|||
/// <summary>
|
|||
/// 删除信息
|
|||
/// </summary>
|
|||
/// <param name="">主键串</param>
|
|||
/// <returns>删除个数</returns>
|
|||
public DataResult<int> DeleteArray(string strs) |
|||
{ |
|||
int count = 0; |
|||
DataResult<int> result = new DataResult<int>(); |
|||
string[] list = strs.Split(":".ToCharArray()); |
|||
try |
|||
{ |
|||
foreach (string str in list) |
|||
{ |
|||
count += this.Delete(new WorkOrder { PID = str }); |
|||
} |
|||
result.Result = count; |
|||
result.IsSuccess = true; |
|||
return result; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除信息
|
|||
/// </summary>
|
|||
/// <param name="">信息</param>
|
|||
/// <returns>删除个数</returns>
|
|||
public int Delete(WorkOrder info) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().Delete(info); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 导出数据
|
|||
/// <summary>
|
|||
/// 获取导出的数据
|
|||
/// </summary>
|
|||
/// <param name="">查询条件</param>
|
|||
/// <returns>数据</returns>
|
|||
public DataTable GetExportData(WorkOrder info) |
|||
{ |
|||
try |
|||
{ |
|||
return new TWorkOrderDAL().GetExportData(info); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 导入数据
|
|||
/// <summary>
|
|||
/// 导入数据
|
|||
/// </summary>
|
|||
/// <param name="list">数据</param>
|
|||
/// <returns>导入结果</returns>
|
|||
public DataResult<ImportMessage> ImportData(List<WorkOrder> list) |
|||
{ |
|||
DataResult<ImportMessage> result = new DataResult<ImportMessage>(); |
|||
TWorkOrderDAL cmDal = new TWorkOrderDAL(); |
|||
List<WorkOrder> List = new List<WorkOrder>(); |
|||
int index = 0; |
|||
try |
|||
{ |
|||
result.Result = new ImportMessage(); |
|||
result.Result.Errors = new List<RowError>(); |
|||
using (IDataSession session = AppDataFactory.CreateMainSession()) |
|||
{ |
|||
//状态判断
|
|||
foreach (WorkOrder ma in list) |
|||
{ |
|||
index++; |
|||
if (!string.IsNullOrEmpty(ma.InfoError)) |
|||
{ |
|||
ma.PID = null; |
|||
result.Result.failureNum += 1; |
|||
continue; |
|||
} |
|||
//修改改时根据主键等信息获取详细内容信息
|
|||
WorkOrder oldInfo = cmDal.Get(ma); |
|||
if (oldInfo != null) |
|||
{ |
|||
//更新
|
|||
ma.PID = oldInfo.PID; |
|||
ma.IsNewInfo = false; |
|||
result.Result.updateNum += 1; |
|||
} |
|||
else |
|||
{ |
|||
//新增
|
|||
oldInfo = new WorkOrder(); |
|||
if (string.IsNullOrWhiteSpace(ma.PID)) |
|||
{ |
|||
ma.PID = Guid.NewGuid().ToString(); |
|||
} |
|||
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
|
|||
} |
|||
} |
File diff suppressed because it is too large
Binary file not shown.
Loading…
Reference in new issue