¶Ô±ÈÐÂÎļþ |
| | |
| | | using Rhea.Common; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Tiger.IBusiness; |
| | | using Tiger.IBusiness.MES.WorkAction; |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | |
| | | namespace Tiger.Business.MES.WorkAction |
| | | { |
| | | public class ThreeInOne : IThreeInOne |
| | | { |
| | | #region Propertys & Variables |
| | | #region åºå®åæ³ï¼å·¥åºä¸çå¿
è¦ä¿¡æ¯ |
| | | public bool IsFinished { get; set; } = false; |
| | | public IWorkStep CurStep { get; set; } |
| | | public IPosition CurPosition { get; set; } |
| | | public MES_WO_NODE_ACT NodeAct { get; set; } |
| | | public MES_WO_ACTION Setting { get; set; } |
| | | #endregion |
| | | public MES_CUST_SN CurCSN { get; set; } |
| | | public BAS_LABEL_TEMP Label { get; set; } |
| | | public List<BAS_LABEL_PV> LabelPV { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | | /// <summary> |
| | | /// åå§åå·¥åºè¡ä¸º |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) |
| | | { |
| | | #region åºå®åæ³ï¼ç»é»è®¤åéèµå¼ |
| | | CurStep = curStep; |
| | | CurPosition = position; |
| | | NodeAct = nodeAct; |
| | | Setting = setting; |
| | | #endregion |
| | | |
| | | Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First(); |
| | | LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åè¡ä¸ºå¼å§çæç¤ºä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | var msg = new Locale("MES.WorkAction.ThreeInOne.BeginMsg", CurPosition.CurSN); |
| | | //var msg = new Locale($"å¼å§æ£æ¥æ¡ç [{CurPosition.CurSN}]çæ¯å¦å·²ç»å®å®¢æ·æ¡ç "); |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å°è¯å¼å§æ§è¡å·¥åºè¡ä¸º |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> TryBegin(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //åªå
许å个产åè¿è¡å®¢æ·æ¡ç ç»å® |
| | | if (CurPosition.CurWipSNs.Count > 1) |
| | | { |
| | | action.Data.ShortMsg = new("è¯·æ«æäº§å", ShortMessage.Types.Error); |
| | | //action.LocaleMsg = new($"æ¡ç [{0}]æ¯å
è£
/è½½å
·æ¡ç ï¼è¯·éæ°æ«æå个åå
æ¡ç è¿è¡å®¢æ·æ¡ç ç»å®"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotProductSN", CurPosition.CurSN); |
| | | //éç½®å·¥åºæä½ |
| | | CurPosition.ResetNode(); |
| | | |
| | | action.IsSuccessed = false; |
| | | return action; |
| | | } |
| | | |
| | | var wipSn = CurPosition.CurWipSNs.First(); |
| | | CurCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN).First(); |
| | | //åå
æ¡ç å·²ç»å®å®¢æ·æ¡ç ï¼ç´æ¥ç»æè¡ä¸º |
| | | if (!CurCSN.IsNullOrEmpty()) |
| | | { |
| | | CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | |
| | | End(); |
| | | } |
| | | //åå
æ¡ç æªç»å®å®¢æ·æ¡ç |
| | | else |
| | | { |
| | | //å¦æå®¢æ·æ¡ç æ ç¾æ¨¡æ¿ä¸ºç©ºåä¸éè¦æå°ï¼çå¾
æ«æå®¢æ·æ¡ç è¿è¡ç»å® |
| | | if (Label.IsNullOrEmpty()) |
| | | { |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = false, |
| | | Label = "", |
| | | }; |
| | | action.Data.ShortMsg = new("æ«æå®¢æ·æ ç¾", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"è¯·æ«æåå
æ¡ç [{0}]éè¦ç»å®å®¢æ·æ¡ç "); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginScan", wipSn.SN); |
| | | } |
| | | else |
| | | { |
| | | //设置æå°åéå¼ |
| | | Label = CurPosition.SetLabelVariables(LabelPV, Label); |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = true, |
| | | Label, |
| | | }; |
| | | action.Data.ShortMsg = new("æå°å®¢æ·æ ç¾", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"å¼å§æå°åå
æ¡ç [{0}]对åºçå®¢æ·æ¡ç "); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginPrint", wipSn.SN); |
| | | } |
| | | } |
| | | |
| | | //妿è¿åæåå认为å½åè¡ä¸ºå¯ä»¥å¼å§æ§è¡ï¼å¦åè¿å失败 |
| | | action.IsSuccessed = true; |
| | | |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å·¥åºè¡ä¸ºæäº¤æ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Submit(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | var csn = input.Data; |
| | | |
| | | CurCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.CUST_SN == input.Data).First() ?? new() |
| | | { |
| | | CUST_SN = input.Data, |
| | | }; |
| | | |
| | | //å®¢æ·æ¡ç å·²ç»å®å
¶ä»åå
æ¡ç |
| | | if (!CurCSN.FLOW_SN.IsNullOrEmpty() && CurCSN.FLOW_SN != CurPosition.CurWipSNs.First().SN) |
| | | { |
| | | action.Data.ShortMsg = new("ç»å®å¤±è´¥", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"åå
æ¡ç [{0}]ç»å®å®¢æ·æ¡ç [{1}]失败ï¼å®¢æ·æ¡ç å·²ç»å®åå
æ¡ç [{2}]"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingOtherSN", CurPosition.CurWipSNs.First().SN, CurCSN.CUST_SN, CurCSN.FLOW_SN); |
| | | //妿è¡ä¸ºè®¾ç½®ä¸ºåºééè¦éç½®å·¥åºæä½ |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | | } |
| | | //å®¢æ·æ¡ç ä¸å±äºå½åå·¥åçå®¢æ· |
| | | else if (CurCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) |
| | | { |
| | | action.Data.ShortMsg = new("ç»å®å¤±è´¥", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"å®¢æ·æ¡ç [{0}]å±äºå®¢æ·[{1}]ï¼ä¸å½åå·¥åç客æ·[{2}]ä¸ä¸è´"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CurCSN.CUST_SN, CurCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE); |
| | | //妿è¡ä¸ºè®¾ç½®ä¸ºåºééè¦éç½®å·¥åºæä½ |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | | } |
| | | //æäº¤æ°æ®æ§è¡å¤±è´¥ |
| | | else |
| | | { |
| | | CurCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; |
| | | CurCSN.FLOW_SN = CurPosition.CurWipSNs.First().SN; |
| | | CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | action = End(); |
| | | } |
| | | |
| | | return action; |
| | | } |
| | | /// <summary> |
| | | /// ç»ææ§è¡å·¥åºè¡ä¸º |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> End() |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //è®°å½è¡ä¸ºæä½è®°å½ |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, |
| | | WIP_ID = wipSn.ID, |
| | | SN = wipSn.SN, |
| | | STATUS = wipSn.STATUS, |
| | | ITEM_CODE = wipSn.ITEM_CODE, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | ROT_CODE = wipSn.ROT_CODE, |
| | | NODE_ID = wipSn.NODE_ID, |
| | | NODE_NAME = wipSn.NODE_NAME, |
| | | ACT_ID = NodeAct.ID, |
| | | ACT_NAME = NodeAct.ACT_NAME, |
| | | FTY_CODE = wipSn.FTY_CODE, |
| | | WS_CODE = wipSn.WS_CODE, |
| | | LINE_CODE = wipSn.LINE_CODE, |
| | | POST_CODE = wipSn.POST_CODE, |
| | | OPER_CODE = wipSn.OPER_CODE, |
| | | SEGMENT = wipSn.SEGMENT, |
| | | FLOW_SN = wipSn.FLOW_SN, |
| | | TRAY_SN = wipSn.TRAY_SN, |
| | | INNER_SN = wipSn.INNER_SN, |
| | | CARTON_SN = wipSn.CARTON_SN, |
| | | PALLET_SN = wipSn.PALLET_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = wipSn.SFTS_CODE, |
| | | SFT_CODE = wipSn.SFT_CODE, |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = wipSn.SN, |
| | | ACT_VALUE_1 = Label.LABEL_CODE, |
| | | ACT_VALUE_2 = Label.Variables.ToJson(), |
| | | ACT_RESULT = "Y", |
| | | TRACE_INFO = $"åå
æ¡ç [{0}]å·²ç»å®å®¢æ·æ¡ç [{1}]æå", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | } |
| | | |
| | | //å建åéå
é对象ç¨äºä¼ å
¥DBSubmitActionä¸ä¿åå½åéè¦æåçæ°æ®å¼ |
| | | var _wipActs = wipActs.Clone(); |
| | | var _CurCSN = CurCSN.Clone(); |
| | | //ä¿åæ°æ® |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_CurCSN, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | action.Data.ShortMsg = new("å®¢æ·æ¡ç å·²ç»å®", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"åå
æ¡ç [{0}]å·²ç»å®å®¢æ·æ¡ç [{1}]宿", Label.LABEL_NAME); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingComplete", CurCSN.FLOW_SN, CurCSN.CUST_SN); |
| | | return action; |
| | | } |
| | | |
| | | #endregion Functions |
| | | } |
| | | } |