¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 VerifyItem : IVerifyItem |
| | | { |
| | | #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 |
| | | |
| | | #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 |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åè¡ä¸ºå¼å§çæç¤ºä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | var msg = new Locale("MES.WorkAction.VerifyItem.BeginMsg"); |
| | | //var msg = new Locale($"å¼å§éªè¯äº§å[{CurPosition.CurWipSN.SN}]"); |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å°è¯å¼å§æ§è¡å·¥åºè¡ä¸º |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> TryBegin(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | action = Submit(input); |
| | | |
| | | //妿è¿åæåå认为å½åè¡ä¸ºå¯ä»¥å¼å§æ§è¡ï¼å¦åè¿å失败 |
| | | //action.IsSuccessed = true; |
| | | //action.Data.ShortMsg = new("éªè¯å¼å§", ShortMessage.Types.Success); |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å·¥åºè¡ä¸ºæäº¤æ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Submit(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | action = Verify(input, action); |
| | | //ä¸ææ°æ®ä¿å失败 |
| | | if (!action.IsSuccessed) |
| | | { |
| | | //妿è¡ä¸ºè®¾ç½®ä¸ºåºééè¦éç½®å·¥åºæä½ |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | | } |
| | | return action; |
| | | } |
| | | |
| | | public ApiAction<SubmitOutput> Verify(SubmitInput input, ApiAction<SubmitOutput> action) |
| | | { |
| | | try |
| | | { |
| | | var isOK = true; |
| | | //éªè¯é»è¾ |
| | | //if (input.SN.IsNullOrEmpty()) |
| | | { |
| | | action.Data.ShortMsg = new("éªè¯å¤±è´¥", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = isOK = false; |
| | | //action.LocaleMsg = new Locale($"é误ï¼[{ExtInfo.FIELD_NAME}]æ ç¾æ¡ç ä¸è½ä¸ºç©ºï¼è¯·éæ°æ«æ"); |
| | | //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.SnEmptyError", ExtInfo.FIELD_NAME); |
| | | } |
| | | //if (CurPosition.CurWipSNs.Any(w => w.SN == input.SN)) |
| | | { |
| | | action.Data.ShortMsg = new("éªè¯å¤±è´¥", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = isOK = false; |
| | | //action.LocaleMsg = new Locale($"éè¯¯ï¼æ«æå°äº§åæ¡ç [{input.SN}]ï¼è¯·éæ°æ«æ[{ExtInfo.FIELD_NAME}]æ ç¾æ¡ç "); |
| | | //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.ScanProdSnError", input.SN, ExtInfo.FIELD_NAME); |
| | | } |
| | | |
| | | //éªè¯éè¿åä¿å |
| | | if (isOK) |
| | | { |
| | | action = End(); |
| | | } |
| | | |
| | | //齿²¡æç©æéªè¯éè¿ï¼åè¿åéè¯¯ä¿¡æ¯ |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | action.Data.ShortMsg = new("éªè¯å¼å¸¸", ShortMessage.Types.Exception); |
| | | action.CatchExceptionWithLog(ex, $"éªè¯å¼å¸¸"); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"产å[{CurPosition.CurSN}]éªè¯å¼å¸¸ï¼å·¥åºå·²éç½®ï¼è¯·éæ°æ«æè¿ç«äº§åæ¡ç "); |
| | | //action.LocaleMsg = new("MES.WorkAction.VerifyItem.SaveExtInfoException", CurPosition.CurSN); |
| | | CurPosition.ResetNode(); |
| | | } |
| | | 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, |
| | | WIP_ID = wipSn.ID, |
| | | HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).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_RESULT = "Y", |
| | | TRACE_INFO = $"产å[{CurPosition.CurSN}]éªè¯éè¿", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | } |
| | | |
| | | //å建åéå
é对象ç¨äºä¼ å
¥DBSubmitActionä¸ä¿åå½åéè¦æåçæ°æ®å¼ |
| | | var _wipActs = wipActs.Clone(); |
| | | //ä¿åæ°æ® |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | action.Data.ShortMsg = new("éªè¯éè¿", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"产å[{CurPosition.CurSN}]éªè¯éè¿"); |
| | | action.LocaleMsg = new("MES.WorkAction.VerifyItem.VerifySuccess", CurPosition.CurSN); |
| | | return action; |
| | | } |
| | | |
| | | #endregion Functions |
| | | } |
| | | } |