| | |
| | | using System; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.WMSInfo; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_Tasks.ProductionLineJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | public partial class CommonProductionLineJob |
| | | { |
| | | /// <summary> |
| | | /// 产线 |
| | | /// å
¥åºäº§çº¿ |
| | | /// </summary> |
| | | /// <param name="conveyorLine"></param> |
| | | /// <returns></returns> |
| | | public List<Task> ProductionLineExtend(OtherDevice ProductionLine) |
| | | public void ProductionLineIn(OtherDevice ProductionLine) |
| | | { |
| | | foreach (var item in ProductionLine.DeviceProDTOs.GroupBy(x => x.DeviceChildCode)) |
| | | { |
| | | var request = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.request, item.Key); |
| | | if (request == 1) |
| | | { |
| | | var traytype = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.trayType, item.Key); |
| | | var content = Request(ProductionLine, traytype, item.Key); |
| | | |
| | | var traytype = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.trayType); |
| | | ProductionLine.SetValue(ProductionLineDBName.trayType, traytype); |
| | | List<Task> tasks = new List<Task>(); |
| | | return tasks; |
| | | if (content.Status) ProductionLine.SetValue(ProductionLineDBName.Wrequest, 1, item.Key); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// åºåºäº§çº¿ |
| | | /// </summary> |
| | | /// <param name="ProductionLine"></param> |
| | | public void ProductionLineOut(OtherDevice ProductionLine) |
| | | { |
| | | foreach (var item in ProductionLine.DeviceProDTOs.GroupBy(x => x.DeviceChildCode)) |
| | | { |
| | | var request = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.request, item.Key); |
| | | if (request == 1) |
| | | { |
| | | bool ok = false; |
| | | var traytype = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.trayType, item.Key); |
| | | if (traytype == 2 || traytype == 4 || traytype == 6) |
| | | ok = Request(ProductionLine, traytype, item.Key).Status; |
| | | else |
| | | { |
| | | var task = _taskService.QuertOutProductionLineTask(true); |
| | | if (task != null) |
| | | { |
| | | //if (task.Remark.ObjToInt() == traytype) |
| | | if (!string.IsNullOrEmpty(task.Remark) && traytype == 5) |
| | | { |
| | | task.TargetAddress = item.Key; |
| | | task.NextAddress = item.Key; |
| | | ok = _taskService.UpdateData(task).Status; |
| | | } |
| | | } |
| | | } |
| | | if (ok) ProductionLine.SetValue(ProductionLineDBName.Wrequest, 1, item.Key); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// ç³è¯· |
| | | /// </summary> |
| | | /// <param name="ProductionLine">产线</param> |
| | | /// <param name="traytype">æçç±»å</param> |
| | | /// <param name="station">ç«å°å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent Request(OtherDevice ProductionLine, short traytype, string station) |
| | | { |
| | | WebResponseContent response = new WebResponseContent(); |
| | | ProductionLineDTO MaterielGroupDTO = new ProductionLineDTO(); |
| | | try |
| | | { |
| | | switch (traytype) |
| | | { |
| | | case 1://æ¾ç©ºæ |
| | | case 3://æ¾ç©ºç |
| | | //case 5://æ¾æ»¡ç |
| | | { |
| | | MaterielGroupDTO.stationCode = station; |
| | | MaterielGroupDTO.traytype = traytype; |
| | | } |
| | | break; |
| | | case 2://å空æ |
| | | case 4://åæ»¡ç |
| | | case 6://å空ç |
| | | { |
| | | MaterielGroupDTO.Barcode = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.trayBarcode, station); |
| | | MaterielGroupDTO.stationCode = station; |
| | | MaterielGroupDTO.traytype = traytype; |
| | | if (traytype == 4) |
| | | { |
| | | #region è¯»åæ°é |
| | | //var productQtyadd = ProductionLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == ProductionLineDBName.productQty.ToString() && x.DeviceChildCode == station); |
| | | //var productQty = ProductionLine.Communicator.Read<short>(productQtyadd.DeviceProAddress, (ushort)productQtyadd.DeviceProDataLength); |
| | | //#endregion |
| | | |
| | | //#region åå
¥æ°é |
| | | //var WproductQtyadd = ProductionLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == ProductionLineDBName.WproductQty.ToString() && x.DeviceChildCode == station); |
| | | //ProductionLine.Communicator.Write(WproductQtyadd.DeviceProAddress, productQty); |
| | | #endregion |
| | | |
| | | MaterielGroupDTO.batchNo = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.batchNo, station); |
| | | //MaterielGroupDTO.productQty = string.Join(",", productQty); |
| | | } |
| | | } |
| | | break; |
| | | #region MyRegion |
| | | //case 3://æ¾ç©ºç |
| | | // { |
| | | // MaterielGroupDTO.stationCode = station; |
| | | // MaterielGroupDTO.traytype = traytype; |
| | | // } |
| | | // break; |
| | | //case 4://åæ»¡ç |
| | | // { |
| | | // //var productQty = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.productQty, station); |
| | | // #region è¯»åæ°é |
| | | // var productQtyadd = ProductionLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == ProductionLineDBName.productQty.ToString() && x.DeviceChildCode == station); |
| | | // var productQty = ProductionLine.Communicator.Read<short>(productQtyadd.DeviceProAddress, (ushort)productQtyadd.DeviceProDataLength); |
| | | // #endregion |
| | | |
| | | // #region åå
¥æ°é |
| | | // var WproductQtyadd = ProductionLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == ProductionLineDBName.WproductQty.ToString() && x.DeviceChildCode == station); |
| | | // ProductionLine.Communicator.Write(WproductQtyadd.DeviceProAddress, productQty); |
| | | // #endregion |
| | | |
| | | // var batchNo = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.batchNo, station); |
| | | // var trayBarcode = ProductionLine.GetValue<ProductionLineDBName, string>(ProductionLineDBName.trayBarcode, station); |
| | | |
| | | // MaterielGroupDTO.batchNo = batchNo; |
| | | // MaterielGroupDTO.Barcode = trayBarcode; |
| | | // MaterielGroupDTO.stationCode = station; |
| | | // MaterielGroupDTO.traytype = traytype; |
| | | // MaterielGroupDTO.productQty = string.Join(",", productQty); |
| | | // } |
| | | // break; |
| | | //case 5://æ¾æ»¡ç |
| | | // { |
| | | // MaterielGroupDTO.stationCode = station; |
| | | // MaterielGroupDTO.traytype = traytype; |
| | | // } |
| | | // break; |
| | | //case 6://å空ç |
| | | // { |
| | | |
| | | // } |
| | | // break; |
| | | #endregion |
| | | default: |
| | | throw new Exception("æªå®ä¹æçç±»å"); |
| | | } |
| | | |
| | | response = ProductionLineToWMSRequest(MaterielGroupDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | response.Error(ex.Message); |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | public WebResponseContent ProductionLineToWMSRequest(ProductionLineDTO MaterielGroupDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.ProductionlineRequest, MaterielGroupDTO.ToJson(), headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result == null) throw new Exception($"产线åWMS请æ±è¶
æ¶"); |
| | | |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | |
| | | #region 产线ç³è¯·å
¥åºä»»å¡ |
| | | if (content != null && content.Status)//ä»»å¡è½¬æ¢ |
| | | { |
| | | var task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToJson()); |
| | | if (task != null) |
| | | { |
| | | List<int> TaskNums = new List<int>(); |
| | | List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.TargetAddress); |
| | | if (routers.Count > 0) |
| | | { |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | task.WMSId = task.TaskId; |
| | | task.Creater = "WMS"; |
| | | task.Dispatchertime = null; |
| | | task.CreateDate = DateTime.Now; |
| | | content = _taskService.AddData(task); |
| | | TaskNums.Add(task.TaskNum); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(TaskNums, "æ¥æ¶WMSä»»å¡"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |