Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Business.MES/Transaction/Position.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Business.MES/Transaction/YadaPacking.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Business.MES/iERP/MES_U9C.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.IBusiness.MES/Transaction/IYadaPacking.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.IBusiness.MES/iERP/IMES_U9C.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tiger.Model.Net/Entitys/WMS/BIZ_ERP_PROD_IN_BTH.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -703,7 +703,8 @@ try { //得到工单条码记录 var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == code).ToListAsync(); var cartonSn = code.Split('|')[0]; var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == cartonSn).ToListAsync(); if (woSns.Count == 0) { result.IsSuccessed = false; @@ -717,6 +718,9 @@ result.LocaleMsg = new($"条码对应的工单不存在"); return result; } //判断工单是否已经全部入库 InStoreInfo inStoreInfo = new() { ErpProdInBth= new() { WORK_ORDER = wo.ORDER_NO, @@ -733,10 +737,11 @@ ITEM_CODE = wo.ITEM_CODE, ITEM_NAME = wo.ItemInfo?.ITEM_DESC, PLAN_QTY = wo.PLAN_QTY, SCAN_QTY = woSns.Count SCAN_QTY = woSns.Count, STATUS = "N" //Y-已生成,N-未生成,F-失败 }, InStoreScanInfo = new() { SN = code, SN = cartonSn, SALES_ORDER = wo.SALES_ORDER, WORK_ORDER = wo.ORDER_NO, BATCH_NO = woSns[0].BATCH_NO, Tiger.Business.MES/Transaction/Position.cs
@@ -675,9 +675,14 @@ case "GetXH": return ""; case "GetCardNo": return ""; return $"{Context["CurWaitShipmentCarton"].ToInt32() + 1}"; case "GetCardTotal": return ""; var total = ""; var _curaction = curAction is PackingAction ? curAction as PackingAction : null; if (!_curaction.IsNullOrEmpty()) { total = $"{Math.Ceiling(Context["CurShipQty"].ToDecimal()/_curaction.PkgRule.GetTotalQty().ToDecimal())}"; } return total; case "GetModelSpec": //Model+空格+SPEC, return GetLabelVarWo(lv, $"{WorkBatch.Product.ExtInfo?.Model} {WorkBatch.Product.SPEC}"); case "GetDATE": Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -393,20 +393,44 @@ //设置当前指令为正常产品过站 NodeCmd = "NodeSubmit"; curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 11 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //获取出货状态 DbClient db = Biz.DataSource["YadaU9C"].Client; var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); int CurShipQty = 0; int WaitShipmentCarton = 0; if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; } else { CurShipQty = ship.ShipQty; SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { BATCH = CurBatch.Batch.BATCH_NO, NodeIdOrName = curNode.NODE_NAME }); var list = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList(); if (!list.IsNullOrEmpty()) { var batchCount = list.Where(q => q["ProdDate"].ToString() == "Whole").FirstOrDefault(); WaitShipmentCarton = batchCount["WaitShipment"].ToInt32(); IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? false : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true; } } ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : ""; //缓存出货数量 if (Context.ContainsKey("CurShipQty")) { Context["CurShipQty"] = CurShipQty; } else { Context.Add("CurShipQty", CurShipQty); } //缓存出货箱数 if (Context.ContainsKey("CurWaitShipmentCarton")) { Context["CurWaitShipmentCarton"] = WaitShipmentCarton; } else { Context.Add("CurWaitShipmentCarton", WaitShipmentCarton); } curtime = DateTime.Now; Logger.Console.Info($"{CurSN} : ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //绑定条码到工单 foreach (var wipSN in wipSNs) @@ -938,6 +962,24 @@ return action; } /// <summary> /// 获取是否打印客户标签还是入库标签 /// </summary> /// <returns></returns> public async Task<ApiAction<ShipingInfo>> GetIsCustomerLabelAndShipQty() { var action = new ApiAction<ShipingInfo>(); try { action.Data = new ShipingInfo() { IsPrintCustomerLabel= IsPrintCustomerLabel,ShipQty = Context["CurShipQty"].ToInt32() }; } catch (Exception ex) { action.CatchExceptionWithLog(ex, $"包装工序:获取是否打印客户标签还是入库标签异常"); } return action; } #endregion Functions /// <summary> Tiger.Business.MES/iERP/MES_U9C.cs
@@ -26,29 +26,25 @@ { public partial class MES_U9C : IMES_U9C { public static string U9CAuthLoginUrl { get; set; } = "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; public static string U9CAuthLoginUrl { get; set; } = Biz.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 测试 //public static string U9CAuthLoginUrl { get; set; } = Biz.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; //正式 public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20"; public static string RcvRptDocCreateUrl { get; set; } = "http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; { get; set; } = Biz.SysParam["RcvRptDocCreateUrl_Test", "U9CUrl"].PARAM_VALUE; //"http://172.16.80.20/u9C/webapi/RcvRptDoc/Create"; 测试 //public static string RcvRptDocCreateUrl //{ get; set; } = Biz.SysParam["RcvRptDocCreateUrl", "U9CUrl"].PARAM_VALUE; //正式 /// <summary> /// 入库单接口 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task<ApiAction<List<InStorePrintJson>>> RcvRptDocCreate(RcvRptDocCreateInput input) public async Task<ApiAction<RcvRptDocCreateInput>> RcvRptDocCreate(RcvRptDocCreateInput input) { Logger.Interface.Info($"/**\r\n *进入入库单接口....\r\n */\r\n"); //固定写法 var action = new ApiAction<List<InStorePrintJson>>(); var action = new ApiAction<RcvRptDocCreateInput>(); try { //List<RcvRptDocCreateParam> param = new List<RcvRptDocCreateParam>(); //List<CompleteList> CompleteLists = new List<CompleteList>(); //param.Add(new RcvRptDocCreateParam //{ // CompleteList = CompleteLists //}); //先保存数据 bool IsSuccessed = true; var db = Biz.Db; @@ -66,58 +62,17 @@ Logger.Interface.Error(action.Message); IsSuccessed = false; } //保存成功,调用U9C接口 //int i = 1; //foreach (var item in input.RcvRptDocBases) //{ // foreach (var p in input.PrintJsons) // { // var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); // if (!d.IsNullOrEmpty()) // { // d.ORDER_NO = $"XX001-{i}"; // } // i++; // } //} if (IsSuccessed) { var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}"); if (u9CLoginResult.Success) { var token = u9CLoginResult.Data; Logger.Interface.Info($"U9C登录token: {token}"); //保存成功,调用U9C接口-测试用 int i = 1; List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); foreach (var item in input.RcvRptDocBases) foreach (var item in input.RcvRptDocBases.Where(q => q.Status != "Y")) { List<RcvRptDocCreateParam> param = new() { new() { CompleteList = new(){ new CompleteList { MOKey = new MOKey { DocNo = item.WorkOrder }, Wh = new Wh { Code = item.WhCode }, DescFlexField = new DescFlexField { PrivateDescSeg1 = item.PkgQty.ToString() }, Item = new Item { Code = item.ItemCode }, CompleteQty = item.CompleteQty, OutputType = item.OutputType, StorageType = item.StorageType, DocState = item.DocState, } } } }; var response = await HttpHelper.PostAsync(RcvRptDocCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", token } }); var result = JsonConvert.DeserializeObject<U9CResult>(response.Message); if (result != null) { if (result.Success) { Logger.Interface.Info($"生成入库单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}"); var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q=> q.WORK_ORDER == item.WorkOrder).First(); item.Status = "Y"; if (!ErpProdInBth.IsNullOrEmpty()) { ErpProdInBth.ORDER_NO = result.Data[0].m_code; ErpProdInBth.ORDER_NO = $"XX001-{i}"; ErpProdInBth.IS_HANDLED = "Y"; ErpProdInBth.HANDLED_DATE = DateTime.Now; ErpProdInBths.Add(ErpProdInBth); @@ -127,23 +82,16 @@ var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); if (!d.IsNullOrEmpty()) { d.ORDER_NO = result.Data[0].m_code; d.ORDER_NO = $"XX001-{i}"; d.STATUS = "Y"; } } Logger.Interface.Info($"生成入库单成功"); } else { action.IsSuccessed = false; action.LocaleMsg = new($"{result.Data[0].m_errorMsg}"); Logger.Interface.Info($"生成入库单失败:{result.Data[0].m_errorMsg}"); } } i++; } var _db = Biz.Db; var _dbTran = _db.UseTran(() => { _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); }); if (!dbTran.IsSuccess) { @@ -151,9 +99,93 @@ Logger.Interface.Error(action.Message); IsSuccessed = false; } } } action.Data = input.PrintJsons; input.ErpProdInBths = ErpProdInBths; //保存成功,调用U9C接口 //if (IsSuccessed) //{ // var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode=admin{secret}"); // if (u9CLoginResult.Success) // { // var token = u9CLoginResult.Data; // Logger.Interface.Info($"U9C登录token: {token}"); // List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths = new List<BIZ_ERP_PROD_IN_BTH>(); // foreach (var item in input.RcvRptDocBases.Where(q=>q.Status != "Y")) // { // List<RcvRptDocCreateParam> param = new() { // new() { // CompleteList = new(){ // new CompleteList // { // MOKey = new MOKey { DocNo = item.WorkOrder }, // Wh = new Wh { Code = item.WhCode }, // DescFlexField = new DescFlexField { PrivateDescSeg1 = item.PkgQty.ToString() }, // Item = new Item { Code = item.ItemCode }, // CompleteQty = item.CompleteQty, // OutputType = item.OutputType, // StorageType = item.StorageType, // DocState = item.DocState, // } // } // } // }; // var response = await HttpHelper.PostAsync(RcvRptDocCreateUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", token } }); // var result = JsonConvert.DeserializeObject<U9CResult>(response.Message); // var ErpProdInBth = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>().Where(q => q.WORK_ORDER == item.WorkOrder).First(); // if (result != null) // { // if (result.Success && result.Data[0].m_isSucess) // { // Logger.Interface.Info($"生成入库单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}"); // item.Status = "Y"; // if (!ErpProdInBth.IsNullOrEmpty()) // { // ErpProdInBth.ORDER_NO = result.Data[0].m_code; // ErpProdInBth.IS_HANDLED = "Y"; // ErpProdInBth.HANDLED_DATE = DateTime.Now; // ErpProdInBths.Add(ErpProdInBth); // } // foreach (var p in input.PrintJsons) // { // var d = p.Items.Where(q => q.WORK_ORDER == item.WorkOrder).FirstOrDefault(); // if (!d.IsNullOrEmpty()) // { // d.ORDER_NO = result.Data[0].m_code; // } // } // Logger.Interface.Info($"生成入库单成功"); // } // else // { // action.IsSuccessed = false; // action.LocaleMsg = new($"{action.Message}; {result.Data[0].m_errorMsg}"); // item.Status = "F"; // if (!ErpProdInBth.IsNullOrEmpty()) // { // ErpProdInBth.REMARK = result.Data[0].m_errorMsg; // ErpProdInBth.IS_HANDLED = "F"; // ErpProdInBth.HANDLED_DATE = DateTime.Now; // ErpProdInBths.Add(ErpProdInBth); // } // Logger.Interface.Info($"生成入库单失败:{result.Data[0].m_errorMsg}"); // } // } // } // var _db = Biz.Db; // var _dbTran = _db.UseTran(() => // { // _db.Updateable(ErpProdInBths, "U9C_RcvRptDocCreate").UpdateColumns(x => new { x.ORDER_NO, x.REMARK, x.IS_HANDLED, x.HANDLED_DATE }).ExecuteCommand(); // }); // if (!dbTran.IsSuccess) // { // action.CatchExceptionWithLog(dbTran.ErrorException, $"数据处理失败"); // Logger.Interface.Error(action.Message); // IsSuccessed = false; // } // input.ErpProdInBths = ErpProdInBths; // } //} action.Data = input; } catch (System.Exception ex) { Tiger.Controllers.MES/Controllers/MESController.YadaPacking.cs
@@ -321,5 +321,50 @@ trans?.AddHistory(Request, action); return Ok(response); } /// <summary> /// 雅达装箱工序:打印测试标签 /// </summary> /// <param name="action"></param> /// <returns></returns> [HttpPost] [Route("api/[controller]/YadaPacking/GetIsCustomerLabelAndShipQty")] public async Task<IActionResult> YadaPacking_GetIsCustomerLabelAndShipQtyAsync([FromBody] ApiAction action) { ApiAction response; IYadaPacking trans = null; try { if (iBiz.MES.Context.GetTransDic().ContainsKey(action.ID)) { trans = iBiz.MES.Context.GetTransDic()[action.ID] as IYadaPacking; if (!trans.IsFinished) { if (action.IsAsync) { response = action.GetResponse(await trans.GetIsCustomerLabelAndShipQty()); } else { lock (trans.TransLock) { response = action.GetResponse(trans.GetIsCustomerLabelAndShipQty().Result); } } } else { response = action.GetResponse($"Transaction Error: 岗位[{trans.PostCode}]的雅达装箱工序事务[ID:{action.ID}]已经关闭", false); } } else { response = action.GetResponse($"Transaction Error: 岗位的雅达装箱工序事务[ID:{action.ID}]已经被关闭", false); } } catch (System.Exception ex) { response = action.GetResponse().CatchExceptionWithLog(ex); } trans?.AddHistory(Request, action); return Ok(response); } } } Tiger.IBusiness.MES/Transaction/IYadaPacking.cs
@@ -45,5 +45,6 @@ /// <param name="input"></param> /// <returns></returns> public Task<ApiAction<PackingActionOutput>> TestPrint(); public Task<ApiAction<ShipingInfo>> GetIsCustomerLabelAndShipQty(); } } Tiger.IBusiness.MES/iERP/IMES_U9C.cs
@@ -12,6 +12,6 @@ { public interface IMES_U9C { public Task<ApiAction<List<InStorePrintJson>>> RcvRptDocCreate(RcvRptDocCreateInput input); public Task<ApiAction<RcvRptDocCreateInput>> RcvRptDocCreate(RcvRptDocCreateInput input); } } Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
@@ -322,4 +322,13 @@ public string Message { get; set; } } /// <summary> /// 出货信息 /// </summary> public class ShipingInfo { public bool IsPrintCustomerLabel { get; set; } public int ShipQty { get; set; } } } Tiger.Model.Net/Entitys/MES/ParameterEntity/U9CParameter.cs
@@ -53,6 +53,7 @@ { public string ORDER_NO { get; set; } public string SALES_ORDER { get; set; } public string STATUS { get; set; } public string BATCH_NO { get; set; } public string WORK_ORDER { get; set; } public string ITEM_CODE { get; set; } @@ -71,6 +72,7 @@ public int OutputType { get; set; } = 0; public int StorageType { get; set; } = 4; public int DocState { get; set; } = 1; public string Status { get; set; } } public class RcvRptDocCreateParam Tiger.Model.Net/Entitys/WMS/BIZ_ERP_PROD_IN_BTH.cs
@@ -147,6 +147,7 @@ [DisplayName("入库单号")] public string ORDER_NO { get; set; } public string SALES_ORDER { get; set; } public string STATUS { get; set; } /// <summary> /// 工单批次号 /// </summary>