| | |
| | | using System.Globalization; |
| | | using Tiger.Business.MES.WorkAction; |
| | | using System.Collections; |
| | | using Tiger.IBusiness.MES.WorkAction; |
| | | using Dm.parser; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | public WorkBatch CurBatch { get; set; } |
| | | public IWorkBatch WorkBatch => CurBatch; |
| | | public List<MES_WIP_DATA> CurWipSNs { get; set; } = new(); |
| | | public List<MES_WIP_DATA> LastWipSNs { get; set; } = new(); |
| | | public string CurSN => (CurWipSNs.Any() ? (CurWipSNs.First().TRAY_SN.IsNullOrEmpty() ? CurWipSNs.First().SN : CurWipSNs.First().TRAY_SN) : ""); |
| | | public List<MES_WIP_HIS> CurWipSNHiss { get; set; } = new(); |
| | | public List<MES_WIP_DFT> CurDefects { get; set; } = new(); |
| | |
| | | } |
| | | var wb = new WorkBatch(input.OrderNo).Init(CurLine.LINE_CODE); |
| | | WoContext.WoBatchDic.Add(wb.Batch.BATCH_NO, wb); |
| | | batchNo = wb.Batch.BATCH_NO; |
| | | } |
| | | CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE, batchNo); |
| | | if (!OperInfoDic.ContainsKey(CurBatch.Batch.BATCH_NO)) |
| | |
| | | throw dbTran.ErrorException; |
| | | } |
| | | } |
| | | //记录最后成功过站的条码 |
| | | LastWipSNs.Clear(); |
| | | LastWipSNs.AddRange(CurWipSNs); |
| | | } |
| | | |
| | | protected void DoSaveToDB() |
| | |
| | | /// <returns></returns> |
| | | public BAS_LABEL_TEMP SetLabelVariables(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_TEMP label, IWorkAction action) |
| | | { |
| | | return SetLabelVariables(labelPVs, label, action, null); |
| | | } |
| | | |
| | | public BAS_LABEL_TEMP SetLabelVariables(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_TEMP label, IWorkAction action, WipPkg? CurPkg) |
| | | { |
| | | foreach (var item in label.Variables.OrderBy(q => q.VAR_TYPE == BAS_LABEL_VAR.VAR_TYPEs.BarcodeGenerate.GetValue() ? 0 : 1)) |
| | | { |
| | | switch (item.VAR_TYPE.GetEnum<BAS_LABEL_VAR.VAR_TYPEs>()) |
| | |
| | | item.Value = item.VAR_VALUE; |
| | | break; |
| | | case BAS_LABEL_VAR.VAR_TYPEs.ProcessVariable: |
| | | item.Value = GetPrintProcessValue(labelPVs, item, label.Variables, action); |
| | | item.Value = GetPrintProcessValue(labelPVs, item, label.Variables, action, CurPkg); |
| | | break; |
| | | case BAS_LABEL_VAR.VAR_TYPEs.DateVariable: |
| | | item.Value = DateTime.Now.ToString(item.VAR_VALUE); |
| | |
| | | /// <param name="labelPVs">过程变量列表</param> |
| | | /// <param name="lv">标签模板变量</param> |
| | | /// <returns></returns> |
| | | public string GetPrintProcessValue(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_VAR lv, List<BAS_LABEL_VAR> lvars, IWorkAction curAction) |
| | | public string GetPrintProcessValue(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_VAR lv, List<BAS_LABEL_VAR> lvars, IWorkAction curAction, WipPkg? CurPkg) |
| | | { |
| | | var pv = labelPVs.FirstOrDefault(q => q.VAR_CODE == lv.VAR_VALUE); |
| | | if (!pv.IsNullOrEmpty()) |
| | |
| | | { |
| | | case "GetSN": |
| | | return CurSN; |
| | | case "GetItemCode": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ITEM_CODE); |
| | | case "GetBAS_ITEM": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.CUST_PROD_CODE); |
| | | case "GetItemName": |
| | |
| | | case "GetPackNumber": |
| | | return GetLabelVarWo(lv, WorkBatch.WO.ORDER_NO); |
| | | case "GetBoxQR": |
| | | return curAction is PackingAction ? GetBoxCode(lvars, curAction as PackingAction) : ""; |
| | | return GetCardOrBoxQR(GetBoxCode(), curAction, CurPkg); |
| | | case "GetCardQR": |
| | | return curAction is PackingAction ? GetCardOrBoxQR(GetCardCode(lvars), lvars, curAction as PackingAction) : ""; |
| | | return GetCardOrBoxQR("", curAction, CurPkg); |
| | | case "GetCardSN": |
| | | List<string> minPkgList = new List<string>(); |
| | | var _pkaction = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (_pkaction != null) |
| | | if (!CurPkg.IsNullOrEmpty()) |
| | | { |
| | | minPkgList = GetMinPkgList(_pkaction); |
| | | minPkgList = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | else |
| | | { |
| | | var _pkaction = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (!_pkaction.IsNullOrEmpty()) |
| | | { |
| | | minPkgList = GetMinPkgList(_pkaction); |
| | | } |
| | | } |
| | | return string.Join("\r\n", minPkgList); |
| | | case "GetDescription": |
| | |
| | | return GetLabelVarWo(lv, WorkBatch.WO.Customer?.CUST_NAME_CN); |
| | | case "GetHWDate": |
| | | List<string> list = new List<string>(); |
| | | var _action = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (_action != null) |
| | | if (!CurPkg.IsNullOrEmpty()) |
| | | { |
| | | list = GetMinPkgList(_action); |
| | | list = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | else |
| | | { |
| | | var _action = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (_action != null) |
| | | { |
| | | list = _action.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | } |
| | | return GetHuaWeiWeek(WorkBatch.Batch.ORDER_NO, list); |
| | | case "GetQty": |
| | | List<string> qtylist = new List<string>(); |
| | | var _qtyAction = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (_qtyAction != null) |
| | | if (!CurPkg.IsNullOrEmpty()) |
| | | { |
| | | qtylist = GetMinPkgList(_qtyAction); |
| | | qtylist = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | return $"{qtylist.Count}PCS"; |
| | | else |
| | | { |
| | | if (curAction is PackingAction) |
| | | { |
| | | qtylist = (curAction as PackingAction).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | if (curAction is PrintInStoreLabel) |
| | | { |
| | | qtylist = (curAction as PrintInStoreLabel).CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | } |
| | | return $"{qtylist.Count}"; |
| | | case "GetModel": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Model); |
| | | case "GetInput": |
| | |
| | | case "GetLOTNO": |
| | | string _lotnos = ""; |
| | | var _orderAction = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (_orderAction != null) |
| | | if (!CurPkg.IsNullOrEmpty()) |
| | | { |
| | | var snList = _orderAction.GetMinPackageList(_orderAction.CurPkg.Item).Select(q => q.FLOW_SN).ToList(); |
| | | if (!snList.Any()) |
| | | qtylist = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | } |
| | | else |
| | | { |
| | | if (_orderAction != null) |
| | | { |
| | | snList.Add(_orderAction.CurPkg.CustSN.FLOW_SN); |
| | | var snList = _orderAction.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | if (!snList.Any()) |
| | | { |
| | | snList.Add(_orderAction.CurPkg.CustSN?.FLOW_SN); |
| | | } |
| | | _lotnos = string.Join(",", Biz.Db.Queryable<MES_CUST_SN>() |
| | | .Where((q) => snList.Contains(q.FLOW_SN)) |
| | | .Select((q) => q.WORK_ORDER).Distinct().ToList()); |
| | | return _lotnos; |
| | | } |
| | | _lotnos = string.Join(",", Biz.Db.Queryable<MES_CUST_SN>() |
| | | .Where((q) => snList.Contains(q.FLOW_SN)) |
| | | .Select((q) => q.WORK_ORDER).Distinct().ToList()); |
| | | return _lotnos; |
| | | } |
| | | return ""; |
| | | case "GetNOTES": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Remark); |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo?.Remark); |
| | | case "GetXH": |
| | | return GetCardCode(lvars); |
| | | return ""; |
| | | case "GetCardNo": |
| | | return ""; |
| | | return $"{Context["CurWaitShipmentCarton"].ToInt32() + 1}"; |
| | | case "GetCardTotal": |
| | | return ""; |
| | | var total = ""; |
| | | var _curaction = curAction is PackingAction ? curAction as PackingAction : null; |
| | | if (!_curaction.IsNullOrEmpty()) { |
| | | total = $"{Math.Ceiling(Context["CurShipQty"].ToDecimal()/_curaction.PkgRule.GetTotalQty().ToDecimal())}"; |
| | | } |
| | | return total; |
| | | case "GetModelSpec": //Model+空格+SPEC, |
| | | return GetLabelVarWo(lv, $"{WorkBatch.Product.ExtInfo?.Model} {WorkBatch.Product.SPEC}"); |
| | | case "GetDATE": |
| | |
| | | private List<string> GetMinPkgList(PackingAction action) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | if (action.CurPkg.Item.PKG_LEVEL == 1) |
| | | if (action.CurPkg.IsNullOrEmpty()) |
| | | { |
| | | list.Add(CurSN); |
| | | } |
| | | else |
| | | { |
| | | list = action.GetMinPackageList(action.CurPkg.Item).Select(q => q.SN).ToList(); |
| | | list = action.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList(); |
| | | } |
| | | return list; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 获取白盒条码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetBoxCode(List<BAS_LABEL_VAR> lvars, PackingAction action) |
| | | private string GetBoxCode() |
| | | { |
| | | var boxCode = Biz.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | return GetCardOrBoxQR(boxCode, lvars, action); |
| | | return Biz.CodeRule["WhiteBoxNo"]?.Generate("W", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取箱条码 |
| | | /// </summary> |
| | | /// <param name="lvars"></param> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetCardCode(List<BAS_LABEL_VAR> lvars) |
| | | private string GetCardCode() |
| | | { |
| | | var cardCode = Biz.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | return cardCode; |
| | | return Biz.CodeRule["CartonNo"]?.Generate("B", $"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="lvars"></param> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetCardOrBoxQR(string code, List<BAS_LABEL_VAR> lvars, PackingAction action) |
| | | private string GetCardOrBoxQR(string code, IWorkAction action, WipPkg? CurPkg) |
| | | { |
| | | var minPkgList = action.GetMinPackageList(action.CurPkg.Item).Select(q => q.SN); |
| | | List<string> minPkgList = new List<string>(); |
| | | var itemCode = ""; |
| | | double weight = 0; |
| | | var unit = ""; |
| | | if (!CurPkg.IsNullOrEmpty()) |
| | | { |
| | | minPkgList = CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | itemCode = CurPkg.CustSN?.ITEM_CODE; |
| | | weight = CurPkg.WeightInfo.Weight; |
| | | unit = CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg"; |
| | | } |
| | | else |
| | | { |
| | | if (action is PackingAction) |
| | | { |
| | | var pkg = action as PackingAction; |
| | | //minPkgList = pkg.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList(); |
| | | minPkgList = pkg.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | itemCode = pkg.CurPkg.CustSN?.ITEM_CODE; |
| | | weight = pkg.CurPkg.WeightInfo.Weight; |
| | | unit = pkg.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg"; |
| | | } |
| | | if (action is PrintInStoreLabel) |
| | | { |
| | | var print = action as PrintInStoreLabel; |
| | | //minPkgList = print.CurPkg.Item.GetMinPackageList().Select(q => q.SN).ToList(); |
| | | minPkgList = print.CurPkg.Item.GetWipSnList().Select(q => q.Value).ToList(); |
| | | itemCode = print.CurPkg.CustSN?.ITEM_CODE; |
| | | weight = print.CurPkg.WeightInfo.Weight; |
| | | unit = print.CurPkg.WeightInfo.Unit?.ToUpper() ?? "kg"; |
| | | } |
| | | } |
| | | var wo = WorkBatch.Batch.ORDER_NO; |
| | | var snList = string.Join("\r\n", minPkgList); |
| | | if (snList.IsNullOrEmpty()) { snList = $"{CurSN}"; } |
| | | var itemCode = action.CurPkg.CustSN?.ITEM_CODE; |
| | | var weight = action.CurPkg.WeightInfo.Weight; |
| | | var unit = action.CurPkg.WeightInfo.Unit.ToUpper(); |
| | | var model = WorkBatch.Product.ExtInfo?.Model; |
| | | var Input = WorkBatch.Product.ExtInfo?.Input; |
| | | var OutPut = WorkBatch.Product.ExtInfo?.OutPut; |