| | |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using System.Drawing.Printing; |
| | | using System.Net.NetworkInformation; |
| | | using Tiger.Model.MES.Yada; |
| | | using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; |
| | | using Tiger.Model.Minsun; |
| | | |
| | | namespace Tiger.Business.MES |
| | | { |
| | |
| | | result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经存在工单批次[{_batch.BATCH_NO}]在线体[{input.WoBatch.ACT_LINE}]中状态为[{_batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!"); |
| | | return result; |
| | | } |
| | | WoContext.RemoveBatch(input.WoBatch.BATCH_NO); |
| | | //WoContext.RemoveBatch(input.WoBatch.BATCH_NO); |
| | | input.Wo.ACT_LINE = input.WoBatch.ACT_LINE; |
| | | input.Wo.RELEASE_TIME = DateTime.Now; |
| | | input.Wo.RELEASE_USER = input.WoBatch.UPDATE_USER; |
| | |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"保存批次工单异常"); |
| | | } |
| | | //如果成功,根据条件异步保存工艺路线到产品的客户 |
| | | if (result.IsSuccessed && input.IfToCust) |
| | | { |
| | | Work.DoAsync(() => |
| | | { |
| | | try |
| | | { |
| | | SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { WO = input.Wo.ORDER_NO, ERR_CODE = 0, ERR_MSG = "" }); |
| | | pars[1].Direction = System.Data.ParameterDirection.Output; |
| | | pars[2].Direction = System.Data.ParameterDirection.Output; |
| | | Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_WO2CUST", pars); |
| | | //response.LocaleMsg = new(pars[2].Value.ToString()); |
| | | if (pars[1].Value.ToInt32() == 0) |
| | | { |
| | | Logger.Default.Info($"工单[{input.Wo.ORDER_NO}]下发完成后保存工艺路线数据到产品[{input.Wo.ITEM_CODE}]的客户[{input.Wo.CUST_CODE ?? ""}]的工艺路线中,{pars[2].Value.ToString()}"); |
| | | } |
| | | else |
| | | { |
| | | Logger.Default.Error($"工单[{input.Wo.ORDER_NO}]下发完成后保存工艺路线数据到产品[{input.Wo.ITEM_CODE}]的客户[{input.Wo.CUST_CODE ?? ""}]的工艺路线出错,{pars[2].Value.ToString()}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "保存批次工单异常"); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.ROUTE_STATUS }).ExecuteCommand(); |
| | | db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.ROUTE_STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | |
| | | _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status; |
| | | if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) |
| | | { |
| | | WoContext.RemoveBatch(input.WoBatch); |
| | | //WoContext.RemoveBatch(input.WoBatch); |
| | | } |
| | | //如果是下发 |
| | | if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue()) |
| | |
| | | //如果是下发 |
| | | if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue()) |
| | | { |
| | | db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE }).ExecuteCommand(); |
| | | db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand(); |
| | | db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); |
| | | } |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | |
| | | try |
| | | { |
| | | //保存前的判断 |
| | | if (input.WORK_ORDER.IsNullOrEmpty()) |
| | | if (input.WORK_ORDER.IsNullOrEmpty() && input.PROD_CODE.IsNullOrEmpty()) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单号不能为空!"); |
| | | result.LocaleMsg = new($"工单号或者产品编码不能为空!"); |
| | | return result; |
| | | } |
| | | List<BAS_LABEL_VAR_WO> varWoList = new(); |
| | | if (File.Exists(input.LABEL_VIEW_PATH)) |
| | | string imageFileName = Path.GetFileNameWithoutExtension(input.LABEL_VIEW_PATH); |
| | | string path = @$"{BizConfig.Configuration["UploadAddress"]}//Upload/Template//Temp//{imageFileName}.png"; |
| | | if (File.Exists(path)) |
| | | { |
| | | string imageFileName = Path.GetFileNameWithoutExtension(input.LABEL_VIEW_PATH); |
| | | string? path = Path.GetDirectoryName(input.LABEL_VIEW_PATH); |
| | | input.LABEL_VIEW_PATH = $"{path}//Temp//{imageFileName}.png"; |
| | | varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == input.LABEL_ID && x.WORK_ORDER == input.WORK_ORDER).ToListAsync(); |
| | | varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>() |
| | | .Where(x => x.LABEL_ID == input.LABEL_ID) |
| | | .WhereIF(!input.WORK_ORDER.IsNullOrEmpty(), x => x.WORK_ORDER == input.WORK_ORDER) |
| | | .WhereIF(!input.PROD_CODE.IsNullOrEmpty(), x => x.PROD_CODE == input.PROD_CODE) |
| | | .ToListAsync(); |
| | | foreach (var item in varWoList) |
| | | { |
| | | item.LABEL_VIEW_PATH = $"{BizConfig.Configuration["DownloadAddress"]}//Template//Temp//{imageFileName}.png"; |
| | | } |
| | | } |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | Expression<Func<BAS_LABEL_VAR_WO, object>> predicate = !input.WORK_ORDER.IsNullOrEmpty() ? t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW } : |
| | | !input.PROD_CODE.IsNullOrEmpty() ? t => new { t.LABEL_ID, t.PROD_CODE, t.VAR_NAME, t.GHOST_ROW } : t => new { t.LABEL_ID, t.VAR_NAME, t.GHOST_ROW }; |
| | | var y = db.Storageable(input) |
| | | .WhereColumns(t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW }) |
| | | .WhereColumns(predicate) |
| | | .ToStorage(); |
| | | y.AsInsertable.ExecuteCommand(); |
| | | y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | |
| | | try |
| | | { |
| | | QueryAble<BAS_LABEL_VAR_WO> query = new(); |
| | | if (input.WorkOrder.IsNullOrEmpty()) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单号不能为空!"); |
| | | return result; |
| | | } |
| | | //if (input.WorkOrder.IsNullOrEmpty()) |
| | | //{ |
| | | // result.IsSuccessed = false; |
| | | // result.LocaleMsg = new($"工单号不能为空!"); |
| | | // return result; |
| | | //} |
| | | var labeltemp = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE.Equals(input.LabelId) || q.ID.Equals(input.LabelId)).First(); |
| | | if (labeltemp == null) |
| | | { |
| | |
| | | result.LocaleMsg = new($"模板不存在!"); |
| | | return result; |
| | | } |
| | | var lableVars = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) && q.LABEL_ID.Equals(labeltemp.ID)).ToListAsync(); |
| | | var queryable = Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => q.WORK_ORDER.Equals(input.WorkOrder) && q.LABEL_ID.Equals(labeltemp.ID)); |
| | | query.page = await queryable.ToPageAsync(input.pageIndex, input.pageSize); |
| | | var lableVars = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) |
| | | && SqlFunc.IsNullOrEmpty(q.PROD_CODE) |
| | | && SqlFunc.IsNullOrEmpty(q.CUST_CODE) |
| | | && q.LABEL_ID.Equals(labeltemp.ID)).ToListAsync(); |
| | | var queryable = Biz.Db.Queryable<BAS_LABEL_VAR_WO>() |
| | | .Where(q => q.LABEL_ID.Equals(labeltemp.ID)) |
| | | .WhereIF(!input.WorkOrder.IsNullOrEmpty(), q => q.WORK_ORDER.Equals(input.WorkOrder)) |
| | | .WhereIF(!input.ProdCode.IsNullOrEmpty(), q => q.PROD_CODE.Equals(input.ProdCode)) |
| | | .WhereIF(!input.CustCode.IsNullOrEmpty(), q => q.PROD_CODE.Equals(input.CustCode)); |
| | | query.page = await queryable.ToPageAsync(input.page, input.pageSize); |
| | | //如果不存在,则返回初始数据 |
| | | if (query.page.totals == 0) |
| | | { |
| | | query.page = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) && q.LABEL_ID.Equals(labeltemp.ID)).ToPageAsync(input.pageIndex, input.pageSize); |
| | | query.page = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(q => SqlFunc.IsNullOrEmpty(q.WORK_ORDER) |
| | | && SqlFunc.IsNullOrEmpty(q.PROD_CODE) |
| | | && SqlFunc.IsNullOrEmpty(q.CUST_CODE) |
| | | && q.LABEL_ID.Equals(labeltemp.ID)) |
| | | .ToPageAsync(input.page, input.pageSize); |
| | | query.Items = query.page.data; |
| | | } |
| | | //如果初始变量数大于工单设置的变量数 |
| | |
| | | { |
| | | if (queryable.ToList().Any(q => q.VAR_NAME == item.VAR_NAME)) |
| | | { |
| | | var list = queryable.ToList().Where(q => q.VAR_NAME == item.VAR_NAME).First(); |
| | | item.ID = list?.ID; |
| | | item.WORK_ORDER = input.WorkOrder; |
| | | item.VAR_VALUE = queryable.ToList().Where(q => q.VAR_NAME == item.VAR_NAME).First()?.VAR_VALUE; |
| | | item.PROD_CODE = input.ProdCode; |
| | | item.VAR_VALUE = list?.VAR_VALUE; |
| | | item.LABEL_VIEW_PATH = list?.LABEL_VIEW_PATH; |
| | | } |
| | | } |
| | | query.Items = lableVars.Skip((input.pageIndex - 1) * input.pageSize).Take(input.pageSize).ToList(); |
| | | query.Items = lableVars.Skip((input.page - 1) * input.pageSize).Take(input.pageSize).ToList(); |
| | | query.page.totals = lableVars.Count; |
| | | query.page.data = query.Items; |
| | | } |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新行为中的箱号 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> SavePrintLabelInAct(string code) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | var woSn = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q=>q.SN == code || q.FLOW_SN == code || q.OUTER_SN == code).FirstAsync(); |
| | | if (woSn == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码不存在!"); |
| | | return result; |
| | | } |
| | | //取得包装列表 |
| | | var pkgList = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.PARENT_SN == woSn.OUTER_SN && q.OPER_CODE == "SpecPackingNode").ToList(); |
| | | if (pkgList.Count == 0) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码不存在!"); |
| | | return result; |
| | | } |
| | | List<MES_WIP_ACT> actlist = new List<MES_WIP_ACT>(); |
| | | //客户标签 |
| | | var wipAct = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.CARTON_SN == woSn.OUTER_SN && q.NODE_ID == pkgList[0].NODE_ID && !SqlFunc.IsNullOrEmpty(q.ACT_VALUE_3)).First(); |
| | | if (!wipAct.IsNullOrEmpty()) |
| | | { |
| | | var label = JsonConvert.DeserializeObject<BAS_LABEL_TEMP>(wipAct.ACT_VALUE_3); |
| | | var cardNo = label.Variables.Where(q => q.VAR_NAME == "CardQR").FirstOrDefault(); |
| | | if (!woSn.OUTER_SN.IsNullOrEmpty() && !cardNo.IsNullOrEmpty() && !cardNo.Value.StartsWith(woSn.OUTER_SN)) |
| | | { |
| | | cardNo.Value = $"{woSn.OUTER_SN}{cardNo.Value}"; |
| | | } |
| | | string ACT_VALUE_3 = JsonConvert.SerializeObject(label); |
| | | foreach (var pkg in pkgList) |
| | | { |
| | | var actSn = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.WIP_ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_VALUE_4 == "Customer").First(); |
| | | if (!actSn.IsNullOrEmpty()) |
| | | { |
| | | actSn.ACT_VALUE_3 = ACT_VALUE_3; |
| | | actlist.Add(actSn); |
| | | } |
| | | } |
| | | } |
| | | //入库标签 |
| | | var wipActInStore = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.SN == woSn.SN && q.NODE_ID == pkgList[0].NODE_ID && !SqlFunc.IsNullOrEmpty(q.ACT_VALUE_3) && q.ACT_VALUE_4 == "InStore").First(); |
| | | if (!wipActInStore.IsNullOrEmpty()) |
| | | { |
| | | var label = JsonConvert.DeserializeObject<BAS_LABEL_TEMP>(wipActInStore.ACT_VALUE_3); |
| | | var cardNo = label.Variables.Where(q => q.VAR_NAME == "CardQR").FirstOrDefault(); |
| | | if (!woSn.OUTER_SN.IsNullOrEmpty() && !cardNo.IsNullOrEmpty() && !cardNo.Value.StartsWith(woSn.OUTER_SN)) |
| | | { |
| | | cardNo.Value = $"{woSn.OUTER_SN}{cardNo.Value}"; |
| | | } |
| | | var xh = label.Variables.Where(q => q.VAR_NAME == "XH").FirstOrDefault(); |
| | | if (!woSn.OUTER_SN.IsNullOrEmpty() && !xh.IsNullOrEmpty()) |
| | | { |
| | | xh.Value = $"{woSn.OUTER_SN}"; |
| | | } |
| | | string ACT_VALUE_3 = JsonConvert.SerializeObject(label); |
| | | foreach (var pkg in pkgList) |
| | | { |
| | | var actSn = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.WIP_ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_VALUE_4 == "InStore").First(); |
| | | if (!actSn.IsNullOrEmpty()) |
| | | { |
| | | actSn.ACT_VALUE_3 = ACT_VALUE_3; |
| | | actlist.Add(actSn); |
| | | } |
| | | } |
| | | } |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | db.Updateable(actlist).UpdateColumns(q => new { q.ACT_VALUE_3 }).ExecuteCommand(); |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"更新行为日志中的箱号异常"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "更新行为日志中的箱号异常"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取重打标签信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> GetRePrintInfo(RePrintInput input) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | //先查出工单条码中是否存在 |
| | | var outerSn = input.Code.Split('|')[0]; |
| | | var woSn = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.SN.Equals(input.Code) || q.FLOW_SN.Equals(input.Code) || q.OUTER_SN == outerSn).FirstAsync(); |
| | | if (woSn == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码不存在!"); |
| | | return result; |
| | | } |
| | | var woNode = await Biz.Db.Queryable<MES_WO_NODE>().Where(q => q.WORK_ORDER.Equals(woSn.WORK_ORDER) && q.OPER_CODE== "SpecPackingNode").FirstAsync(); |
| | | if (woNode == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工艺路线节点[SpecPackingNode-装箱]不存在"); |
| | | return result; |
| | | } |
| | | string printParam = ""; |
| | | var labelPrint = await Biz.Db.Queryable<LOG_LABEL_PRINT>() |
| | | .WhereIF(input.ReqType == 0, q => q.SN.Equals(woSn.SN) || q.SN.Equals(woSn.FLOW_SN)) //白盒标签 |
| | | .WhereIF(input.ReqType == 1, q => q.SN.Equals(woSn.OUTER_SN) && q.PRINT_LABEL != "InStoreLabel") //箱标签-客户 |
| | | .WhereIF(input.ReqType == 2, q => q.SN.Equals(woSn.OUTER_SN) && q.PRINT_LABEL == "InStoreLabel") //箱标签-入库 |
| | | .FirstAsync(); |
| | | //如果查不到就去行为日志查 |
| | | if (labelPrint.IsNullOrEmpty() && input.ReqType == 1) |
| | | { |
| | | printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.CARTON_SN.Equals(woSn.OUTER_SN) && q.ACT_VALUE_4 == "Customer").First()?.ACT_VALUE_3 ?? ""; |
| | | } |
| | | else if (labelPrint.IsNullOrEmpty() && input.ReqType == 2) |
| | | { |
| | | printParam = Biz.Db.Queryable<MES_WIP_ACT>().Where(q => q.SN.Equals(woSn.SN) && q.ACT_VALUE_4 == "InStore").First()?.ACT_VALUE_3 ?? ""; |
| | | } |
| | | else |
| | | { |
| | | printParam = labelPrint?.PRINT_PARAM ?? ""; |
| | | } |
| | | result.Data = printParam; |
| | | result.LocaleMsg = new($"重打条码[{input.Code}]的标签成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "获取重打标签信息异常"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取出货信息 |
| | | /// </summary> |
| | | /// <param name="wo"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> GetShipList(string wo, string orgCode) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | DbClient db = Biz.DataSource["YadaU9C"].Client; |
| | | var org = await Biz.Db.Queryable<SYS_ORGANIZATION>().Where(q=>q.ORG_CODE == orgCode).FirstAsync(); |
| | | var shipList = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now) && q.Status == 2 && q.Org == org.ID.ToInt64()).ToList(); |
| | | if (shipList.Any()) |
| | | { |
| | | result.Data = shipList[0].ShipQty; |
| | | result.LocaleMsg = new($"出货信息存在!"); |
| | | } |
| | | else |
| | | { |
| | | result.Data = "InStoreLabel"; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "获取出货信息异常"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="SN"></param> |
| | | /// <param name="user"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> UnbindWipSnFromWO(UnbindWipSnInput input) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | var cartonSn = input.SN.Split('|')[0]; |
| | | var wipList = await Biz.Db.Queryable<MES_WIP_DATA>().Where(q => q.SN.Equals(input.SN) || q.FLOW_SN.Equals(input.SN) || q.CARTON_SN == cartonSn).ToListAsync(); |
| | | if (wipList.Count == 0) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"解绑的条码不存在当前操作表中!"); |
| | | return result; |
| | | } |
| | | var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == wipList[0].WORK_ORDER).FirstAsync(); |
| | | result = WorkBatch.UnbindWipSnFromWO(wo, wipList, input.user); |
| | | if (result.IsSuccessed) |
| | | { |
| | | var newList = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.WORK_ORDER == wo.ORDER_NO && q.BATCH_NO == wipList[0].BATCH_NO && SqlFunc.IsNullOrEmpty(q.PARENT_SN) && q.QTY > 0).ToListAsync(); |
| | | result.Data = newList; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "解绑条码异常"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成入库获取条码工单信息及包装信息 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<InStoreInfo>> GetErpProdInBth(string code) |
| | | { |
| | | var result = new ApiAction<InStoreInfo>(); |
| | | try |
| | | { |
| | | //得到工单条码记录 |
| | | var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == code).ToListAsync(); |
| | | if (woSns.Count == 0) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码不存在!"); |
| | | return result; |
| | | } |
| | | var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == woSns[0].WORK_ORDER ).IncludesAllFirstLayer().FirstAsync(); |
| | | if (wo == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码对应的工单不存在"); |
| | | return result; |
| | | } |
| | | InStoreInfo inStoreInfo = new() { |
| | | ErpProdInBth= new() { |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | ITEM_CODE = wo.ITEM_CODE, |
| | | ITEM_NAME = wo.ItemInfo?.ITEM_NAME, |
| | | SCAN_QTY = woSns.Count |
| | | }, |
| | | ProdInBatch = new() |
| | | { |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | ITEM_CODE = wo.ITEM_CODE, |
| | | ITEM_NAME = wo.ItemInfo?.ITEM_NAME, |
| | | PLAN_QTY = wo.PLAN_QTY, |
| | | SCAN_QTY = woSns.Count |
| | | }, |
| | | InStoreScanInfo = new() { |
| | | SN = code, |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | SCAN_QTY = woSns.Count |
| | | } |
| | | }; |
| | | result.Data = inStoreInfo; |
| | | result.LocaleMsg = new($"获取条码[{code}]工单信息及包装信息成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, $"获取条码[{code}]工单信息及包装信息异常"); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | } |