From 6738bfc4d55d8948e87cd78a2341cf4f988431f8 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 20 五月 2024 15:13:14 +0800 Subject: [PATCH] Smt上料一些更新 --- Tiger.Business/MES/Transaction/LoadingMaterial.cs | 254 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 248 insertions(+), 6 deletions(-) diff --git a/Tiger.Business/MES/Transaction/LoadingMaterial.cs b/Tiger.Business/MES/Transaction/LoadingMaterial.cs index 7d83e1a..1eeda4b 100644 --- a/Tiger.Business/MES/Transaction/LoadingMaterial.cs +++ b/Tiger.Business/MES/Transaction/LoadingMaterial.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Tiger.Model; using Tiger.Model.Sharetronic.Shelf; +using System.ComponentModel; namespace Tiger.Business.MES.Transaction { @@ -33,9 +34,71 @@ public string UserCode { get; set; } public long UserId { get; set; } public string OrgCode { get; set; } - public bool his_isComplete { get; set; } - public bool isManual { get; set; } - public decimal cutQty { get; set; } + public string CurrSmtCode { get; set; } + public string CurrSlotNo { get; set; } + /// <summary> + /// 姝ラ绫诲瀷 + /// </summary> + public enum Step_Types + { + /// <summary> + /// 鎵弿鏈哄櫒缂栫爜 + /// </summary> + [Description("鏈哄櫒缂栫爜")] + SmtCode, + /// <summary> + /// 鎵弿妲戒綅 + /// </summary> + [Description("妲戒綅")] + SlotNo, + /// <summary> + /// 鎵弿椋炶揪 + /// </summary> + [Description("Feeder")] + Feeder, + /// <summary> + /// 鎵弿鏂欑洏SN + /// </summary> + [Description("鏂欑洏鐮�")] + SN, + } + + /// <summary> + /// 瀹屾垚鐘舵�� + /// </summary> + public enum Statuss + { + /// <summary> + /// 鎵弿鏈哄櫒缂栫爜瀹屾垚 + /// </summary> + [Description("鏈哄櫒缂栫爜瀹屾垚")] + SmtCodeOK, + /// <summary> + /// 鎵弿妲戒綅瀹屾垚 + /// </summary> + [Description("妲戒綅瀹屾垚")] + SlotNoOK, + /// <summary> + /// 鎵弿椋炶揪瀹屾垚 + /// </summary> + [Description("Feeder瀹屾垚")] + FeederOK, + /// <summary> + /// 鎵弿鏂欑洏SN瀹屾垚 + /// </summary> + [Description("鏂欑洏鐮佸畬鎴�")] + SnOK, + /// <summary> + /// 褰撳墠鏈哄櫒瀹屾垚 + /// </summary> + [Description("褰撳墠鏈哄櫒瀹屾垚")] + CurrCompleted, + /// <summary> + /// 鍏ㄩ儴瀹屾垚 + /// </summary> + [Description("鍏ㄩ儴瀹屾垚")] + Completed, + } #endregion Propertys & Variables @@ -46,16 +109,69 @@ /// </summary> /// <param name="input"></param> /// <returns></returns> - public async Task<ApiAction<ProdReqOutput>> ScanItem(BaseCodeInput input) + public async Task<ApiAction<SmtLoadingReturn>> ScanItem(SmtLoadingInput input) { - var action = new ApiAction<ProdReqOutput>(); + var action = new ApiAction<SmtLoadingReturn>(); try { if (input.Code.IsNullOrEmpty()) { action.IsSuccessed = false; - action.LocaleMsg = Biz.L("鏉$爜涓嶈兘涓虹┖"); + action.LocaleMsg = Biz.L($"{EnumHelper.GetEnum<Step_Types>(input.Step).GetDesc()}涓嶈兘涓虹┖"); return action; + } + + //01鏍规嵁涓婃枡姝ラ鎵ц鐩稿簲鏂规硶 + switch (EnumHelper.GetEnum<Step_Types>(input.Step)) + { + case Step_Types.SmtCode: + action = ExecuteSmtCode(input); + break; + case Step_Types.SlotNo: + action = ExecuteSlotNo(input); + break; + case Step_Types.Feeder: + action = ExecuteFeeder(input); + break; + case Step_Types.SN: + action = ExecuteSN(input); + break; + } + if (!action.IsSuccessed) { return action; } + + //02淇濆瓨涓婃枡鏁版嵁 + + //03鏌ョ湅鏈笂鏂欏垪琛� + Biz.SmtTool smtTool = new(); + var actionSmtTool = await smtTool.GetNotLoadingMaterial(input); + if (actionSmtTool.IsSuccessed) + { + //甯﹀叆鏈哄櫒缂栫爜鏌ヨ锛屽鏋滄病鏈夋湭涓婃枡鐨勯」锛岃鏄庡綋鍓嶆満鍣ㄦ墍鏈夋Ы浣嶅潎宸插畬鎴愪笂鏂欙紒 + if (actionSmtTool.Data.Count == 0) + { + var _input = input.Clone(); + _input.machineCode = ""; + action.LocaleMsg = Biz.L($"褰撳墠鏈哄櫒鎵�鏈夋Ы浣嶅潎宸插畬鎴愪笂鏂欙紒"); + var _actionSmtTool = await smtTool.GetNotLoadingMaterial(_input); + if (_actionSmtTool.IsSuccessed) + { + //涓嶅甫鍏ユ満鍣ㄧ紪鐮佹煡璇紝濡傛灉娌℃湁鏈笂鏂欑殑椤癸紝璇存槑褰撳墠绾垮埆鎵�鏈夋満鍣ㄥ潎宸插畬鎴愪笂鏂欙紒 + if (_actionSmtTool.Data.Count == 0) + { + action.LocaleMsg = Biz.L($"褰撳墠绾垮埆鎵�鏈夋満鍣ㄥ潎宸插畬鎴愪笂鏂�"); + } + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"鑾峰彇鏈笂鏂欏垪琛ㄥけ璐ワ紒"); + } + } + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"鑾峰彇鏈笂鏂欏垪琛ㄥけ璐ワ紒"); } //action.Data = new ProdReqOutput() @@ -79,6 +195,132 @@ } /// <summary> + /// 鎵弿鏈哄櫒缂栫爜鎿嶄綔 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + private ApiAction<SmtLoadingReturn> ExecuteSmtCode(SmtLoadingInput input) { + var action = new ApiAction<SmtLoadingReturn>(); + SmtLoadingReturn loadingReturn = new(); + try + { + if (Biz.Db.Queryable<SMT_WO_TABLE>().Where(x => x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == input.Code).Any()) + { + CurrSmtCode = input.Code; + action.IsSuccessed = true; + action.LocaleMsg = Biz.L($"鏈哄櫒缂栫爜楠岃瘉閫氳繃锛�"); + loadingReturn.SmtCode = CurrSmtCode; + loadingReturn.Step = (int)Step_Types.SmtCode; + loadingReturn.Status = (int)Statuss.SmtCodeOK; + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"鏂欑珯琛ㄤ腑涓嶅瓨鍦ㄦ鏈哄櫒缂栫爜锛岃纭鏂欑珯琛ㄦ槸鍚︽纭笂浼狅紒"); + } + action.Data = loadingReturn; + } + catch (Exception ex) + { + action.CatchExceptionWithLog(ex, $"鎵弿鏈哄櫒缂栫爜寮傚父"); + } + return action; + } + + /// <summary> + /// 鎵弿妲戒綅鎿嶄綔 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + private ApiAction<SmtLoadingReturn> ExecuteSlotNo(SmtLoadingInput input) + { + var action = new ApiAction<SmtLoadingReturn>(); + SmtLoadingReturn loadingReturn = new(); + try + { + if (Biz.Db.Queryable<SMT_WO_TABLE>().Where(x => x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == CurrSmtCode && x.SLOT_NO == input.Code).Any()) + { + CurrSlotNo = input.Code; + action.IsSuccessed = true; + action.LocaleMsg = Biz.L($"妲戒綅楠岃瘉閫氳繃锛�"); + loadingReturn.SmtCode = CurrSmtCode; + loadingReturn.SlotNo = CurrSlotNo; + loadingReturn.Step = (int)Step_Types.SlotNo; + loadingReturn.Status = (int)Statuss.SlotNoOK; + loadingReturn.LoadingCount = Biz.Db.Queryable<SMT_LOADING>().Where(x=> x.WORK_ORDER == input.moCode && x.LINE_CODE == input.lineCode && x.PROD_CODE == input.prodCode && x.SMT_CODE == CurrSmtCode && x.SLOT_NO == input.Code).Count(); + } + else + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"姝ゆЫ浣峓{input.Code}]涓嶅瓨鍦ㄦ垨鏂欑珯琛ㄦ湭涓婁紶锛�"); + } + action.Data = loadingReturn; + } + catch (Exception ex) + { + action.CatchExceptionWithLog(ex, $"鎵弿妲戒綅寮傚父"); + } + return action; + } + + /// <summary> + /// 鎵弿椋炶揪鎿嶄綔 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + private ApiAction<SmtLoadingReturn> ExecuteFeeder(SmtLoadingInput input) + { + var action = new ApiAction<SmtLoadingReturn>(); + try + { + var _feeder = Biz.Db.Queryable<SMT_FEEDER>().Where(x => x.FEEDER_CODE == input.Code).First(); + //妫�鏌ラ杈句繚鍏荤淮鎶ゆ儏鍐� + if (_feeder.FEEDER_TYPE.IsNullOrEmpty()) + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]鏈淮鎶ょ被鍨嬩俊鎭紒"); + return action; + } + if (_feeder.FEEDER_TYPE != input.feederType) + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]Feeder绫诲瀷涓嶄竴鑷达紒瑕佹眰鐨勭被鍨嬶細[{_feeder.FEEDER_TYPE}]锛涘綋鍓岶eeder鐨勭被鍨嬶細[{input.feederType}]"); + return action; + } + if (_feeder.USED_COUNT >= _feeder.MAX_COUNT) + { + action.IsSuccessed = false; + action.LocaleMsg = Biz.L($"姝ら杈綶{input.Code}]宸茶揪鏈�澶т娇鐢ㄦ鏁帮紝璇蜂繚鍏诲悗鍐嶄娇鐢紒"); + return action; + } + } + catch (Exception ex) + { + action.CatchExceptionWithLog(ex, $"鎵弿Feeder寮傚父"); + } + return action; + } + + /// <summary> + /// 鎵弿鐗╂枡鏉$爜鎿嶄綔 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + private ApiAction<SmtLoadingReturn> ExecuteSN(SmtLoadingInput input) + { + var action = new ApiAction<SmtLoadingReturn>(); + try + { + + } + catch (Exception ex) + { + action.CatchExceptionWithLog(ex, $"鎵弿鏂欑洏鐮佸紓甯�"); + } + return action; + } + + /// <summary> /// 娣诲姞涓�涓狝piAction鐨勫巻鍙茶褰� /// </summary> /// <param name="action"></param> -- Gitblit v1.9.3