¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 Weighing : IWeighing |
| | | { |
| | | #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 |
| | | private MES_WIP_PKG CurPkg; |
| | | #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 |
| | | CurPkg = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == CurPosition.CurSN && q.AUTH_ORG == CurPosition.WorkBatch.WO.AUTH_ORG).First() ?? new() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | SN = CurPosition.CurSN, |
| | | PKG_TYPE = CurPosition.WorkBatch.WO.ItemInfo?.UNIT, |
| | | ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE, |
| | | QTY = CurPosition.CurWipSNs.Sum(q => q.QTY), |
| | | UNIT = CurPosition.WorkBatch.WO.ItemInfo?.UNIT, |
| | | WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSNs.First().NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSNs.First().WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSNs.First().POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSNs.First().SEGMENT, |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åè¡ä¸ºå¼å§çæç¤ºä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | var msg = new Locale("MES.WorkAction.Weighing.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()); |
| | | |
| | | action.LocaleMsg = GetBeginMsg(); |
| | | |
| | | //妿è¿åæåå认为å½åè¡ä¸ºå¯ä»¥å¼å§æ§è¡ï¼å¦åè¿å失败 |
| | | action.IsSuccessed = true; |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å·¥åºè¡ä¸ºæäº¤æ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Submit(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | action = SaveWeightInfo(input, action); |
| | | //ä¸ææ°æ®ä¿å失败 |
| | | if (!action.IsSuccessed) |
| | | { |
| | | //妿è¡ä¸ºè®¾ç½®ä¸ºåºééè¦éç½®å·¥åºæä½ |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | action = End(); |
| | | } |
| | | return action; |
| | | } |
| | | |
| | | public ApiAction<SubmitOutput> SaveWeightInfo(SubmitInput input, ApiAction<SubmitOutput> action) |
| | | { |
| | | try |
| | | { |
| | | var wInput = input?.Data?.JsonToObject<WeightInfo>(); |
| | | CurPkg.WEIGHT = wInput.Weight; |
| | | CurPkg.WEIGHT_UNIT = wInput.Unit; |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | action.CatchExceptionWithLog(ex, $"ç§°éè¡ä¸ºï¼æ¡ç [{CurPosition.CurSN}]ç§°éæ°æ®[{input?.Data.ToString()}]ä¿åå¼å¸¸"); |
| | | action.LocaleMsg = new("MES.WorkAction.Weighing.SaveWeightInfoException", CurPosition.CurSN, input?.Data.ToString()); |
| | | } |
| | | 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}]ç§°éæ°æ®[{CurPkg.WEIGHT} {CurPkg.WEIGHT_UNIT}]ä¿åæå", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | } |
| | | |
| | | //å建åéå
é对象ç¨äºä¼ å
¥DBSubmitActionä¸ä¿åå½åéè¦æåçæ°æ®å¼ |
| | | var _wipActs = wipActs.Clone(); |
| | | var _CurPkg = CurPkg.Clone(); |
| | | //ä¿åæ°æ® |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_CurPkg, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | //action.LocaleMsg = new($"æ¡ç [{CurPosition.CurSN}]ç§°éæ°æ®[{CurPkg.WEIGHT} {CurPkg.WEIGHT_UNIT}]ä¿åæå"); |
| | | action.LocaleMsg = new("MES.WorkAction.Weighing.SaveSuccess", CurPosition.CurSN, CurPkg.WEIGHT, CurPkg.WEIGHT_UNIT); |
| | | return action; |
| | | } |
| | | |
| | | #endregion Functions |
| | | } |
| | | } |