| | |
| | | UserCode = userCode; |
| | | ApiHost = apiHost; |
| | | PostCode = postCode; |
| | | _MainDB = Biz.Db; |
| | | |
| | | CurPosition = Biz.Db.Queryable<MES_POSITION>().Where(q => q.POST_CODE == postCode).First(); |
| | | CurPosition = MainDB.Queryable<MES_POSITION>().Where(q => q.POST_CODE == postCode).First(); |
| | | //if (CurPosition.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.PositionNotExistsException", new Exception($"{postCode}|")); |
| | | if (CurPosition.IsNullOrEmpty()) throw new InvalidDataException($"岗位[{postCode}]不存在,请提交正确的岗位代码", new Exception($"{postCode}|")); |
| | | CurLine = Biz.Db.Queryable<MES_LINE>().Where(q => q.LINE_CODE == CurPosition.LINE_CODE).First(); |
| | | CurLine = MainDB.Queryable<MES_LINE>().Where(q => q.LINE_CODE == CurPosition.LINE_CODE).First(); |
| | | //if (CurLine.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.LineNotExistsException", new Exception($"{postCode}|{CurPosition.LINE_CODE}")); |
| | | if (CurLine.IsNullOrEmpty()) throw new InvalidDataException($"岗位[{postCode}]所属的产线[{CurPosition.LINE_CODE}]不存在,请先设置所属产线", new Exception($"{postCode}|{CurPosition.LINE_CODE}")); |
| | | CurWorkshop = Biz.Db.Queryable<MES_WORKSHOP>().Where(q => q.WS_CODE == CurLine.WS_CODE).First(); |
| | | CurWorkshop = MainDB.Queryable<MES_WORKSHOP>().Where(q => q.WS_CODE == CurLine.WS_CODE).First(); |
| | | //if (CurWorkshop.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.WorkshopNotExistsException", new Exception($"{postCode}|{CurLine.WS_CODE}")); |
| | | if (CurWorkshop.IsNullOrEmpty()) throw new InvalidDataException($"岗位[{postCode}]所属的车间[{CurLine.WS_CODE}]不存在,请先设置所属车间", new Exception($"{postCode}|{CurLine.WS_CODE}")); |
| | | CurFactory = Biz.Db.Queryable<MES_FACTORY>().Where(q => q.FTY_CODE == CurWorkshop.FTY_CODE).First(); |
| | | CurFactory = MainDB.Queryable<MES_FACTORY>().Where(q => q.FTY_CODE == CurWorkshop.FTY_CODE).First(); |
| | | //if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.FactoryNotExistsException", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}")); |
| | | if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"岗位[{postCode}]所属的工厂[{CurWorkshop.FTY_CODE}]不存在,请先设置所属工厂", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}")); |
| | | |
| | | //加载当前产线的班制 |
| | | CurShiftSys = Biz.Db.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First(); |
| | | CurShiftSys = MainDB.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First(); |
| | | |
| | | return this; |
| | | } |
| | |
| | | public bool IsFinishNodeSteps => !Steps.Any(q => q.NodeType == IWorkStep.NodeTypes.Node && !q.IsFinished); |
| | | public bool IsFinishAllSteps => Steps.Any() && !Steps.Any(q => !q.IsFinished); |
| | | //public int CurStep => Steps.Where(q => !q.IsFinished).OrderBy(q => q.Sequence).FirstOrDefault()?.Sequence ?? 0; |
| | | private DbClient _MainDB; |
| | | public DbClient MainDB => _MainDB; |
| | | private DbClient CommitDB; |
| | | /// <summary> |
| | | /// 是否需要临时存储数据库提交操作,待需要的时候再提交 |
| | |
| | | { |
| | | if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE, batchNo, true)) |
| | | { |
| | | var wo = await Biz.Db.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync(); |
| | | var wo = await MainDB.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync(); |
| | | //验证明细是否正确 |
| | | if (wo.IsNullOrEmpty()) |
| | | { |
| | |
| | | action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.StatusException", input.OrderNo, wo.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()); |
| | | return action; |
| | | } |
| | | var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption) |
| | | var batch = await MainDB.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption) |
| | | .Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE) |
| | | .WhereIF(!batchNo.IsNullOrEmpty(), q => q.BATCH_NO == batchNo) |
| | | .OrderBy(q => q.STATUS).FirstAsync(); |
| | |
| | | info.NextNode = " — "; |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置当前条码的工序信息 |
| | | /// </summary> |
| | | public ApiAction<SubmitOutput> SetOutPutMqttMsg(ApiAction<SubmitOutput> action, string locale = null) |
| | | { |
| | | MQTT.Message msg = new() |
| | | { |
| | | IsSuccessed = action.IsSuccessed, |
| | | Content = Biz.T(action.LocaleMsg, locale), |
| | | }; |
| | | switch (action.Status) |
| | | { |
| | | case ApiAction.StatusCodes.Success: |
| | | if (action.Data.IsFinished) |
| | | { |
| | | msg.Voice = MQTT.Voice.Pass; |
| | | msg.Color = "#FF228B22"; |
| | | } |
| | | else |
| | | { |
| | | msg.Voice = MQTT.Voice.Success; |
| | | msg.Color = "#FF1E90FF"; |
| | | } |
| | | break; |
| | | case ApiAction.StatusCodes.Warning: |
| | | msg.Voice = MQTT.Voice.Warning; |
| | | msg.Color = "#FFB8860B"; |
| | | break; |
| | | case ApiAction.StatusCodes.Error: |
| | | case ApiAction.StatusCodes.Failed: |
| | | msg.Voice = MQTT.Voice.Fail; |
| | | msg.Color = "#FFFF0000"; |
| | | break; |
| | | case ApiAction.StatusCodes.Exception: |
| | | msg.Voice = MQTT.Voice.Fail; |
| | | msg.Color = "#FF8B0000"; |
| | | break; |
| | | case ApiAction.StatusCodes.Normal: |
| | | case ApiAction.StatusCodes.NeedConfrim: |
| | | case ApiAction.StatusCodes.Confrimed: |
| | | default: |
| | | msg.Voice = MQTT.Voice.Silent; |
| | | msg.Color = "#FF000000"; |
| | | break; |
| | | } |
| | | action.Data.MqttMsg = msg; |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | snList.Add(_orderAction.CurPkg.CustSN?.FLOW_SN); |
| | | } |
| | | _lotnos = string.Join(",", Biz.Db.Queryable<MES_CUST_SN>() |
| | | _lotnos = string.Join(",", MainDB.Queryable<MES_CUST_SN>() |
| | | .Where((q) => snList.Contains(q.FLOW_SN)) |
| | | .Select((q) => q.WORK_ORDER).Distinct().ToList()); |
| | | return _lotnos; |
| | |
| | | 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(); |
| | | var labelVarwos = MainDB.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == lv.LABEL_ID && x.VAR_NAME == lv.VAR_NAME).ToList(); |
| | | if (labelVarwos.Any(q => q.WORK_ORDER == WorkBatch.Batch.ORDER_NO)) |
| | | { |
| | | result = labelVarwos.First(q => q.WORK_ORDER == WorkBatch.Batch.ORDER_NO).VAR_VALUE; |
| | |
| | | private string GetHuaWeiWeek(string pkgOrder, List<string> snList) |
| | | { |
| | | Dictionary<string, string> dic = new(); |
| | | var snOrder = Biz.Db.Queryable<MES_CUST_SN, BIZ_MES_WO>((q, w) => new JoinQueryInfos(JoinType.Left, q.WORK_ORDER == w.ORDER_NO)) |
| | | var snOrder = MainDB.Queryable<MES_CUST_SN, BIZ_MES_WO>((q, w) => new JoinQueryInfos(JoinType.Left, q.WORK_ORDER == w.ORDER_NO)) |
| | | .Where((q, w) => q.PKG_ORDER == pkgOrder && (snList.Contains(q.FLOW_SN) || snList.Contains(q.CUST_SN))) |
| | | .Select((q, w) => new { q.PKG_ORDER, q.WORK_ORDER, w.ACT_START_TIME, w.PLAN_START_TIME, q.FLOW_SN, q.CUST_SN }).ToList(); |
| | | foreach (var sn in snList) |