| | |
| | | using static Tiger.Business.Biz; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using System.Globalization; |
| | | using Tiger.Business.MES.WorkAction; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | { |
| | | OperInfoDic.Add(CurBatch.Batch.BATCH_NO, new()); |
| | | } |
| | | |
| | | |
| | | action.Data = new { WorkOrder = CurBatch.WO, Bacth = CurBatch.Batch }; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | OperInfo info = new(); |
| | | if (CurBatch?.Batch?.BATCH_NO != null) |
| | | { |
| | | info = OperInfoDic[CurBatch.Batch.BATCH_NO ]; |
| | | info = OperInfoDic[CurBatch.Batch.BATCH_NO]; |
| | | info.StepsInfo = Steps.Select(q => q.GetInfo(locale)).ToList(); |
| | | } |
| | | return info; |
| | |
| | | if (CurStep.IsFinished && NextSteps.Any()) |
| | | { |
| | | result = BeginNextActionStep(input); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //返回结果到客户端 |
| | | result = canBegin; |
| | | result.Data.SetValue(CurBatch, CurStep, CurStep?.ID, IsFinishAllSteps); |
| | | //返回结果到客户端 |
| | | result = canBegin; |
| | | result.Data.SetValue(CurBatch, CurStep, CurStep?.ID, IsFinishAllSteps); |
| | | } |
| | | return result; |
| | | } |
| | | //工序被重置 |
| | | else if(Steps.IsNullOrEmpty()) |
| | | else if (Steps.IsNullOrEmpty()) |
| | | { |
| | | return canBegin; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public BAS_LABEL_TEMP SetLabelVariables(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_TEMP label, IWorkAction action) |
| | | { |
| | | foreach (var item in label.Variables) |
| | | 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, action); |
| | | item.Value = GetPrintProcessValue(labelPVs, item, label.Variables, action); |
| | | 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, IWorkAction action) |
| | | public string GetPrintProcessValue(List<BAS_LABEL_PV> labelPVs, BAS_LABEL_VAR lv, List<BAS_LABEL_VAR> lvars, IWorkAction action) |
| | | { |
| | | var pv = labelPVs.FirstOrDefault(q => q.VAR_CODE == lv.VAR_VALUE); |
| | | if (!pv.IsNullOrEmpty()) |
| | |
| | | case "GetSN": |
| | | return CurSN; |
| | | case "GetBAS_ITEM": |
| | | return WorkBatch.Product.ToJson(); |
| | | return WorkBatch.Product.ITEM_CODE; |
| | | case "GetCustomer": |
| | | return WorkBatch.Batch.ToJson(); |
| | | case "GetBoxQR": |
| | | return action is PackingAction ? GetBoxCode(lvars, action as PackingAction) : ""; |
| | | case "GetCardQR": |
| | | return action is PackingAction? GetCardCode(lvars, action as PackingAction) : ""; |
| | | case "GetDescription": |
| | | return WorkBatch.Product.ITEM_DESC; |
| | | case "GetPAndO": |
| | | return WorkBatch.WO.SALES_CONTRACT; |
| | | case "GetLTD": |
| | | return WorkBatch.Batch.Customer.SHORT_NAME; |
| | | case "GetHWDate": |
| | | return WorkBatch.Batch.ToJson(); |
| | | case "GetModel": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo.Model); |
| | | case "GetInput": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo.Input); |
| | | case "GetOutput": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo.OutPut); |
| | | case "GetPower": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo.Power); |
| | | case "GetAccuracy": |
| | | return GetLabelVarWo(lv, WorkBatch.Product.ExtInfo.Accuracy); |
| | | case "GetVarByWo": |
| | | return GetLabelVarWo(lv); |
| | | return GetLabelVarWo(lv, ""); |
| | | default: |
| | | return ""; |
| | | } |
| | |
| | | case "GetCartonGenerate": |
| | | return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate($"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | case "GetHW21SNGenerate": |
| | | return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:","05").Data.ToString() ?? ""; |
| | | return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate("SN:", "05").Data.ToString() ?? ""; |
| | | default: |
| | | return ""; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="labelId"></param> |
| | | /// <returns></returns> |
| | | private string GetLabelVarWo(BAS_LABEL_VAR lv) |
| | | private string GetLabelVarWo(BAS_LABEL_VAR lv, string value) |
| | | { |
| | | string result = ""; |
| | | var labelVarwos = Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == lv.LABEL_ID && x.VAR_NAME == lv.VAR_NAME).ToList(); |
| | |
| | | } |
| | | else |
| | | { |
| | | result = labelVarwos.Count > 0 ? labelVarwos[0].DEFAULT_VALUE : ""; |
| | | result = value.IsNullOrEmpty() ? (labelVarwos.Count > 0 ? labelVarwos.First().DEFAULT_VALUE : "") : value; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取白盒条码 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetBoxCode(List<BAS_LABEL_VAR> lvars, PackingAction action) |
| | | { |
| | | return GetCardOrBoxQR(CurSN, lvars, action); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取箱条码 |
| | | /// </summary> |
| | | /// <param name="lvars"></param> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetCardCode(List<BAS_LABEL_VAR> lvars, PackingAction action) |
| | | { |
| | | var cardCode = lvars.First(q=>q.VAR_NAME == "CardQR").Value; |
| | | return GetCardOrBoxQR(cardCode, lvars, action); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取白盒或者箱二维码 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <param name="lvars"></param> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | private string GetCardOrBoxQR(string code, List<BAS_LABEL_VAR> lvars, PackingAction action) |
| | | { |
| | | var itemCode = WorkBatch.Product.ITEM_CODE; |
| | | var wo = WorkBatch.Batch.ORDER_NO; |
| | | var snList = string.Join("\r\n", action.GetMinPackageList(action.CurPkg.Item).Select(q => q.SN)); |
| | | 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; |
| | | var Power = WorkBatch.Product.ExtInfo.Power; |
| | | var Accuracy = WorkBatch.Product.ExtInfo.Accuracy; |
| | | var Remark = WorkBatch.Product.ExtInfo.Remark; |
| | | |
| | | return $"{code}|{itemCode}|{wo}|{snList}|{weight}|型号:{model},输入:{Input},输出:{OutPut},电源:{Power},精度:{Accuracy},备注:{Remark}"; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0); |
| | | int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday); |
| | | dic.Add(sn, $"{year.ToString().Substring(2, 2)}{week:00}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | dic.Add(sn, ""); |