优化配置文件读取逻辑,将ERP反馈接口写入配置文件中配置
| | |
| | | <Compile Include="models\TN_Record_Table.cs" /> |
| | | <Compile Include="models\TN_RelocationList_Detail.cs" /> |
| | | <Compile Include="models\TN_Relocation_List.cs" /> |
| | | <Compile Include="models\TN_Shipping_Order.cs" /> |
| | | <Compile Include="models\TN_SpotCheck_Detail.cs" /> |
| | | <Compile Include="models\TN_Spot_Check.cs" /> |
| | | <Compile Include="process\TaskProcess.cs" /> |
| | |
| | | <Compile Include="dispatch\HostToAGV.cs" /> |
| | | <Compile Include="util\LogHelper.cs" /> |
| | | <Compile Include="wms\ContainerHelper.cs" /> |
| | | <Compile Include="wms\InfoBuilder.cs" /> |
| | | <Compile Include="wms\LocationHelper.cs" /> |
| | | <Compile Include="wms\SYSHelper.cs" /> |
| | | <Compile Include="Program.cs" /> |
| | |
| | | /// </summary> |
| | | private static void StartTcp() |
| | | { |
| | | var tcpServerIP = Settings.TcpServerIp; |
| | | var tcpServerPort = Settings.TcpServerPort; |
| | | new TcpServer(tcpServerIP, tcpServerPort); |
| | | //var tcpServerIP = Settings.TcpServerIp; |
| | | //var tcpServerPort = Settings.TcpServerPort; |
| | | //new TcpServer(tcpServerIP, tcpServerPort); |
| | | |
| | | //var res = TcpClientHelper.Init(tcpServerIP, tcpServerPort); |
| | | //var res = TcpClientHelper.Init(tcpServerIP, 8550); |
| | | //LogHelper.Info($"TcpClient连接" + (res ? "成功" : "失败")); |
| | |
| | | var startAreas = taskInfo.StartAreas; |
| | | var endAreas = taskInfo.EndAreas; |
| | | |
| | | var log = $"API:{taskName}:"; |
| | | |
| | | try { |
| | | if (model.Num <= 0) { |
| | | info = $"物料数量'{model.Num}'不合法:物料数量应该大于0"; |
| | |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | |
| | | var startLoc = LocationHelper.GetLocQuery(db, 0, startAreas, model.StartLoc).First(); |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(l => l.S_CODE == model.StartLoc) |
| | | .Where(l => startAreas.Contains(l.S_AREA_CODE)) |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") |
| | | .Where(l => l.N_CURRENT_NUM == 0) |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | info = $":没有找到起点货位'{model.StartLoc}'!要求:未上锁、数量=0、货区属于[{string.Join(", ", startAreas)}]"; |
| | |
| | | S_CNTR_TYPE = "好运箱", |
| | | }; |
| | | |
| | | var endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).OrderBy(l => new { l.N_LAYER }).First(); |
| | | var endLoc = db.Queryable<TN_Location>() |
| | | .Where(l => startAreas.Contains(l.S_AREA_CODE)) |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") |
| | | .Where(l => l.N_CURRENT_NUM == 0) |
| | | .OrderBy(l => new { l.N_LAYER }).First(); |
| | | |
| | | if (endLoc == null) { |
| | | info = $"没有找到合适的终点货位,需要满足:未上锁、当前容器数量=0"; |
| | |
| | | TN_Location endLoc = null; |
| | | if (locCntrRel.S_CNTR_TYPE == "托盘") { |
| | | endAreas = taskInfo.EndAreas_Pallet; |
| | | endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).First(); |
| | | endLoc = db.Queryable<TN_Location>() |
| | | .Where(l => startAreas.Contains(l.S_AREA_CODE)) |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") |
| | | .Where(l => l.N_CURRENT_NUM == 0).First(); |
| | | } |
| | | else if (locCntrRel.S_CNTR_TYPE == "好运箱") { |
| | | endAreas = taskInfo.EndAreas_Goodpack; |
| | | endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).First(); |
| | | endLoc = db.Queryable<TN_Location>().Where(l => startAreas.Contains(l.S_AREA_CODE)).Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y").Where(l => l.N_CURRENT_NUM == 0).First(); |
| | | } |
| | | else { |
| | | return NewSimpleResult(-1, $"托盘类型{locCntrRel.S_CNTR_TYPE}不合法:托盘号{locCntrRel.S_CNTR_CODE}"); |
| | |
| | | |
| | | return ApiHelper.ErpSendOutboundPlan(model); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | "WebApiUrl": "http://127.0.0.1:8901", // 后台接口访问地址 |
| | | "NdcApiUrl": "http://127.0.0.1:5201/api/order/", // NDC接口地址 |
| | | "WebApiUrl": "http://127.0.0.1:8901", // 后台服务接口地址 |
| | | "NdcApiUrl": "http://127.0.0.1:5201/api/order/", // NDC AGV接口地址 |
| | | "ErpApiUrl": "http://127.0.0.1:8901/api/", // ERP接口地址 |
| | | "SqlServer": "Data Source=192.168.1.87;Initial Catalog=AMS_OIMobox;User ID=sa;Password=123456;", // 数据库配置地址 |
| | | "TcpServerIp": "127.0.0.1", |
| | | "TcpServerPort": 8085, |
| | | "TaskInfo": [ // 任务起点终点配置(不能改变任务的相对位置) |
| | | "ErpRoute": { |
| | | "CreateTaskReturn": "CreateTaskReturn", // 根据ERP下发出库计划,创建任务后反馈ERP的接口 |
| | | "PickUpReturn": "PickUpReturn" // 根据ERP下发出库计划,AGV取货后反馈ERP的接口 |
| | | }, |
| | | "SqlServer": "Data Source=192.168.1.87;Initial Catalog=AMS_OIMobox;User ID=sa;Password=123456;", // 数据库配置 |
| | | "TaskInfos": [ // 任务信息(名称、起点货区、终点货区) |
| | | { |
| | | "TaskName": "好运箱-满箱下线入库", // 任务名称 |
| | | "StartAreas": [ "MXCZQ" ], // 起点货区:满箱存放区 |
| | | "EndAreas": [ "MXHJQ" ] // 终点货区:满箱货架区 |
| | | "TaskName": "满托下线入库", // 任务名称(可以更改,但各任务相对位置不能更改) |
| | | "StartAreas": [ "BZQ" ], // 起点货区编号:包装区 |
| | | "EndAreas": [ "MTHJQ" ] // 终点货区编号:满托货架区 |
| | | }, |
| | | { |
| | | "TaskName": "好运箱-空箱上线", |
| | | "StartAreas": [ "KXHJQ" ], // 空箱货架区 |
| | | "EndAreas": [ "KXCZQ" ] // 空箱操作区 |
| | | }, |
| | | { |
| | | "TaskName": "好运箱-空箱入库", |
| | | "StartAreas": [ "KXJBQ1", "KXJBQ2" ], // 空箱入库接驳区1/2 |
| | | "EndAreas": [ "KXHJQ" ] // 空箱货架区 |
| | | "TaskName": "满箱下线入库", |
| | | "StartAreas": [ "MXCZQ" ], // 满箱操作区 |
| | | "EndAreas": [ "MXHJQ" ] // 满箱货架区 |
| | | }, |
| | | { |
| | | "TaskName": "成品胶出库", |
| | | "StartAreas": [ "MTHJQ", "MXHJQ", "HCBHQ", "QCBHQ" ], |
| | | "EndAreas": [ "HCCKQ", "QCCKQ" ] |
| | | "StartAreas": [ "MTHJQ", "MXHJQ", "HCBHQ", "QCBHQ" ], // 满托货架区、满箱货架区、火车备货区、汽车备货区 |
| | | "EndAreas": [ "HCCKQ", "QCCKQ" ] // 火车出库区、汽车出库区 |
| | | }, |
| | | { |
| | | "TaskName": "托盘-满托下线入库", |
| | | "StartAreas": [], |
| | | "EndAreas": [ "MTHJQ" ] |
| | | "TaskName": "空托上线出库", |
| | | "StartAreas": [ "KTCFQ" ], // 空托存放区 |
| | | "EndAreas": [ "BZQ" ] // 包装区 |
| | | }, |
| | | { |
| | | "TaskName": "托盘-空托上线", |
| | | "StartAreas": [], |
| | | "EndAreas": [] |
| | | "TaskName": "空箱上线出库", |
| | | "StartAreas": [ "KXHJQ" ], // 满箱货架区 |
| | | "EndAreas": [ "KXCZQ" ] // 空箱操作区 |
| | | }, |
| | | { |
| | | "TaskName": "托盘-空托入库", |
| | | "StartAreas": [ "KTJBQ" ], // 空托接驳区 |
| | | "TaskName": "空托入库", |
| | | "StartAreas": [ "KTJBQ" ], // 空托入库接驳区 |
| | | "EndAreas": [ "KTCFQ" ] // 空托存放区 |
| | | }, |
| | | { |
| | | "TaskName": "抽检-出库", |
| | | "TaskName": "空箱入库", |
| | | "StartAreas": [ "KXJBQ1", "KXJBQ2" ], // 空箱入库接驳区1、2 |
| | | "EndAreas": [ "KXHJQ" ] // 空箱货架区 |
| | | }, |
| | | { |
| | | "TaskName": "抽检出库", |
| | | "StartAreas": [ "MTHJQ", "MXHJQ" ], // 满托货架区、满箱货架区 |
| | | "EndAreas": [ "CJQ" ] // 抽检区 |
| | | }, |
| | | { |
| | | "TaskName": "抽检-合格回库", |
| | | "TaskName": "抽检合格回库", |
| | | "StartAreas": [ "CJQ" ], // 抽检区 |
| | | "EndAreas": [] |
| | | "EndAreas_Pallet": [ "MTHJQ" ], // 终点货区(托盘):满托货架区 |
| | | "EndAreas_Goodpack": [ "MXHJQ" ] // 终点货区(好运箱):满箱货架区 |
| | | }, |
| | | { |
| | | "TaskName": "抽检-不合格移库", |
| | | "StartAreas": [ "CJQ" ], |
| | | "EndAreas": [] |
| | | "TaskName": "抽检不合格移库", |
| | | "StartAreas": [ "CJQ" ], // 抽检区 |
| | | "EndAreas": [ "CJYCQ" ] // 抽检异常区 |
| | | }, |
| | | { |
| | | "TaskName": "移库", |
| | | "StartAreas": [], |
| | | "EndAreas": [] |
| | | "TaskName": "尾料回库", |
| | | "StartAreas": [ "HCCKQ", "QCCKQ" ], // 火车出库区 |
| | | "EndAreas_Pallet": [ "MTHJQ" ], // 满托货架区 |
| | | "EndAreas_Goodpack": [ "MXHJQ" ] // 满箱货架区 |
| | | }, |
| | | { |
| | | "TaskName": "尾箱回库", |
| | | "StartAreas": [ "HCCKQ", "QCCKQ" ], // 火车出库区、汽车出库区 |
| | | "EndAreas": [] |
| | | "TaskName": "移库" |
| | | } |
| | | ], |
| | | "ProductionLines": [ |
| | | "ProductionLines": [ // 产线信息(待定,根据后面需求再更改) |
| | | { |
| | | "Id": "1", |
| | | "Name": "托盘产线1", |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 502, |
| | | "SlaveId": 1, |
| | | "OnLoc": [ "CX11" ], |
| | | "OffLoc": [ "CX12" ] |
| | | "Id": "1", // 产线编号 |
| | | "Name": "托盘产线1", // 产线名称 |
| | | "PlcIp": "127.0.0.1", // 产线IP |
| | | "PlcPort": 502, // 产线端口 |
| | | "SlaveId": 1, // 产线modbus slave id(根据实际情况) |
| | | "OnLoc": [ "BZQ-1-1" ], // 上线货位 |
| | | "OffLoc": [ "BZQ-1-2" ] // 下线货位 |
| | | }, |
| | | { |
| | | "Id": "2", |
| | |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 503, |
| | | "SlaveId": 2, |
| | | "OnLoc": [ "CX21" ], |
| | | "OffLoc": [ "CX22" ] |
| | | "OnLoc": [ "BZQ-2-1" ], |
| | | "OffLoc": [ "BZQ-2-2" ] |
| | | }, |
| | | { |
| | | "Id": "3", |
| | | "Name": "好运箱产线1", |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 504, |
| | | "SlaveId": 3, |
| | | "OnLoc": [ "CX31" ], |
| | | "OffLoc": [ "CX32" ] |
| | | "SlaveId": 3 |
| | | }, |
| | | { |
| | | "Id": "4", |
| | | "Name": "好运箱产线2", |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 505, |
| | | "SlaveId": 4, |
| | | "OnLoc": [ "CX41" ], |
| | | "OffLoc": [ "CX42" ] |
| | | "SlaveId": 4 |
| | | } |
| | | ] |
| | | } |
| | |
| | | "WebApiUrl": "http://127.0.0.1:8901", |
| | | "NdcApiUrl": "http://127.0.0.1:5201/api/order/", |
| | | "ErpApiUrl": "http://127.0.0.1:8901/api/", |
| | | "TcpServerPort": 6000, |
| | | "ErpRoute": { |
| | | "CreateTaskReturn": "CreateTaskReturn", |
| | | "PickUpReturn": "PickUpReturn" |
| | | }, |
| | | "SqlServer": "Data Source=192.168.1.87;Initial Catalog=AMS_OIMobox;User ID=sa;Password=123456;", |
| | | "TcpServerIp": "127.0.0.1", |
| | | "TcpServerPort": 8085, |
| | | "TaskInfos": [ |
| | | { |
| | | "TaskName": "满托下线入库(托盘)", |
| | | "TaskName": "满托下线入库", |
| | | "StartAreas": [ "BZQ" ], |
| | | "EndAreas": [ "MTHJQ" ] |
| | | }, |
| | | { |
| | | "TaskName": "满箱下线入库(好运箱)", |
| | | "TaskName": "满箱下线入库", |
| | | "StartAreas": [ "MXCZQ" ], |
| | | "EndAreas": [ "MXHJQ" ] |
| | | }, |
| | |
| | | "PlcPort": 502, |
| | | "SlaveId": 1, |
| | | "OnLoc": [ "BZQ-1-1" ], |
| | | "OffLoc": [ "BZQ12" ] |
| | | "OffLoc": [ "BZQ-1-2" ] |
| | | }, |
| | | { |
| | | "Id": "2", |
| | |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 503, |
| | | "SlaveId": 2, |
| | | "OnLoc": [ "CX21" ], |
| | | "OffLoc": [ "CX22" ] |
| | | "OnLoc": [ "BZQ-2-1" ], |
| | | "OffLoc": [ "BZQ-2-2" ] |
| | | }, |
| | | { |
| | | "Id": "3", |
| | | "Name": "好运箱产线1", |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 504, |
| | | "SlaveId": 3, |
| | | "OnLoc": [], |
| | | "OffLoc": [ "CX32" ] |
| | | "SlaveId": 3 |
| | | }, |
| | | { |
| | | "Id": "4", |
| | | "Name": "好运箱产线2", |
| | | "PlcIp": "127.0.0.1", |
| | | "PlcPort": 505, |
| | | "SlaveId": 4, |
| | | "OnLoc": [], |
| | | "OffLoc": [ "CX42" ] |
| | | "SlaveId": 4 |
| | | } |
| | | ] |
| | | } |
| | |
| | | model.ph = cgDetail.S_BATCH_NO; |
| | | |
| | | var jsonInfo = JsonConvert.SerializeObject(model); |
| | | var result = httpH.WebPost(Settings.ErpApiUrl + "CreateTaskReturn", jsonInfo); |
| | | var result = httpH.WebPost(Settings.ErpApiUrl + Settings.ErpRoute.CreateTaskReturn, jsonInfo); |
| | | |
| | | LogHelper.InfoApi($"创建任务完成反馈ERP接口,结果={result},调用参数:", model); |
| | | |
| | |
| | | model.hwzt = "已出库"; |
| | | |
| | | var jsonInfo = JsonConvert.SerializeObject(model); |
| | | var result = httpH.WebPost(Settings.ErpApiUrl + "PickUpReturn", jsonInfo); |
| | | var result = httpH.WebPost(Settings.ErpApiUrl + Settings.ErpRoute.PickUpReturn, jsonInfo); |
| | | |
| | | LogHelper.InfoApi($"取货完成反馈ERP接口,结果={result},调用参数:", model); |
| | | |
| | |
| | | // TCP 非轮询方式 模拟产线下线的尝试 |
| | | |
| | | public static void StartServer() { |
| | | var ListenPort = 6000; |
| | | var ListenPort = Settings.TcpServerPort; |
| | | TcpListener listener = new TcpListener(IPAddress.Any, ListenPort); |
| | | listener.Start(); |
| | | Console.WriteLine($"后台服务已启动,监听端口 {ListenPort}..."); |
| | |
| | | public static string WebApiUrl { get; set; } |
| | | public static string NdcApiUrl { get; set; } |
| | | public static string ErpApiUrl { get; set; } // ERP 反馈接口URL |
| | | public static string SqlServer { get; set; } |
| | | public static string TcpServerIp { get; set; } |
| | | |
| | | public static int TcpServerPort { get; set; } |
| | | public static Config.ErpRoute ErpRoute { get; set; } |
| | | |
| | | public static string SqlServer { get; set; } |
| | | //public static string TcpServerIp { get; set; } |
| | | //public static int TcpServerPort { get; set; } |
| | | public static List<Config.ProductionLine> ProductionLines { get; set; } = new List<Config.ProductionLine>(); |
| | | |
| | | public static List<Config.TaskInfo> TaskInfos { get; set; } = new List<Config.TaskInfo> { }; |
| | |
| | | WebApiUrl = root.WebApiUrl; |
| | | NdcApiUrl = root.NdcApiUrl; |
| | | ErpApiUrl = root.ErpApiUrl; |
| | | ErpRoute = root.ErpRoute; |
| | | TcpServerPort= root.TcpServerPort; |
| | | SqlServer = root.SqlServer; |
| | | TcpServerIp = root.TcpServerIp; |
| | | TcpServerPort = root.TcpServerPort; |
| | | //TcpServerIp = root.TcpServerIp; |
| | | //TcpServerPort = root.TcpServerPort; |
| | | ProductionLines = root.ProductionLines; |
| | | TaskInfos = root.TaskInfos; |
| | | |
| | | for (var i = 0; i < ProductionLines.Count; i++) { |
| | | if (ProductionLines[i].OnLoc == null) continue; |
| | | foreach (var onLoc in ProductionLines[i].OnLoc) { |
| | | LocProdIdMap.Add(onLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | |
| | | // [Convert JSON to C# Classes Online - Json2CSharp Toolkit](https://json2csharp.com/) |
| | | |
| | | public class Config { |
| | | |
| | | // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse); |
| | | public class ErpRoute { |
| | | public string CreateTaskReturn { get; set; } |
| | | public string PickUpReturn { get; set; } |
| | | } |
| | | |
| | | public class ProductionLine { |
| | | public string Id { get; set; } |
| | | public string Name { get; set; } |
| | |
| | | public string WebApiUrl { get; set; } |
| | | public string NdcApiUrl { get; set; } |
| | | public string ErpApiUrl { get; set; } |
| | | public string SqlServer { get; set; } |
| | | public string TcpServerIp { get; set; } |
| | | public int TcpServerPort { get; set; } |
| | | public ErpRoute ErpRoute { get; set; } |
| | | public string SqlServer { get; set; } |
| | | public List<TaskInfo> TaskInfos { get; set; } |
| | | public List<ProductionLine> ProductionLines { get; set; } |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 构建货位查询表达式:当前数量、货区、名称 |
| | | /// </summary> |
| | | /// <param name="db"></param> |
| | | /// <param name="nCurrentNum"></param> |