Commit 860f29f7e45411f4636963638367b968664b5bde

Authored by liufu
1 parent 8227adb6

bug修改、出库拣选循环执行

HHWCS.Dao/Bll.cs
... ... @@ -18,7 +18,7 @@ namespace HHWCS.Bll
18 18 //string str = "";
19 19 //for (int i = 1; i < 3; i++)
20 20 //{
21   - // for (int j = 1; j < 17; j++)
  21 + // for (int j = 1; j < 33; j++)
22 22 // {
23 23 // for (int k = 1; k < 6; k++)
24 24 // {
... ... @@ -61,7 +61,7 @@ namespace HHWCS.Bll
61 61 {
62 62 try
63 63 {
64   - string sql = $"update task set isBoubleIn = {flag},secondDestinationLocation = '{location}' WHERE id = {taskId}";
  64 + string sql = $"update task set isDoubleIn = {flag},secondDestinationLocation = '{location}' WHERE id = {taskId}";
65 65 int i = MySqlHelper.ExecuteNonQuery(AppCommon.ConnectionString, sql);
66 66 if (i == 0)
67 67 {
... ... @@ -104,7 +104,7 @@ namespace HHWCS.Bll
104 104 {
105 105 sql += " and created<='" + endTime.ToString() + "'";
106 106 }
107   - sql += " ORDER BY lastUpdated desc";
  107 + sql += " ORDER BY lastUpdated ";
108 108  
109 109 DataSet ds = MySqlHelper.ExecuteDataset(AppCommon.ConnectionString, sql);
110 110 if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
... ... @@ -464,7 +464,7 @@ namespace HHWCS.Bll
464 464 Bll.SetLocationPallet(location.Code, task.ContainerCode);
465 465 }
466 466 //更新任务状态
467   - Bll.SetTaskStatus(task.Id, 40);
  467 + Bll.SetTaskStatus(task.Id, 10);
468 468 }
469 469 if (task.Type == 300 || task.Type == 600)
470 470 {
... ... @@ -623,7 +623,8 @@ namespace HHWCS.Bll
623 623 Enable = Convert.ToBoolean(t["enable"]),
624 624 DeviceTypeId = (int)t["deviceTypeId"],
625 625 Roadway = t["roadway"] is DBNull ? -1 : Convert.ToInt32(t["roadway"]),
626   - SelfAddress = t["selfAddress"] is DBNull ? -1 : Convert.ToInt32(t["selfAddress"])
  626 + SelfAddress = t["selfAddress"] is DBNull ? -1 : Convert.ToInt32(t["selfAddress"]),
  627 + BackAddress = t["backAddress"] is DBNull ? null: t["backAddress"].ToString()
627 628 }).ToList();
628 629 return BllResultFactory.Sucess<List<DeviceEntity>>(list, "成功");
629 630  
... ... @@ -1061,11 +1062,11 @@ namespace HHWCS.Bll
1061 1062 /// <param name="v"></param>
1062 1063 /// <param name="task"></param>
1063 1064 /// <returns></returns>
1064   - public static BllResult EmptyOutHandle(string v, TaskEntity task)
  1065 + public static BllResult EmptyOutHandle(string v,string status, TaskEntity task)
1065 1066 {
1066 1067 try
1067 1068 {
1068   - string sql = $"UPDATE task set isEmptyOut ={v} where id = {task.Id}";
  1069 + string sql = $"UPDATE task set isEmptyOut ={v} ,status = {status} where id = {task.Id}";
1069 1070 int i = MySqlHelper.ExecuteNonQuery(AppCommon.ConnectionString, sql);
1070 1071 if (i == 0)
1071 1072 {
... ...
HHWCS.Model/DeviceEntity.cs
... ... @@ -34,5 +34,10 @@ namespace HHWCS.Model
34 34 {
35 35 return this.Code+" "+this.Name;
36 36 }
  37 +
  38 + /// <summary>
  39 + /// 托盘回退地址
  40 + /// </summary>
  41 + public string BackAddress { get; set; }
37 42 }
38 43 }
... ...
HHWCSHost/App.config
... ... @@ -4,7 +4,7 @@
4 4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5 5 </startup>
6 6 <connectionStrings>
7   - <add name="MySql" connectionString="server=172.16.29.40;user id=root;password=hhsoftware;persistsecurityinfo=True;database=hhwcs;SslMode=none"/>
  7 + <add name="MySql" connectionString="server=127.0.0.1;user id=root;password=123456;persistsecurityinfo=True;database=hhwcs;SslMode=none"/>
8 8 </connectionStrings>
9 9 <appSettings>
10 10 <add key="OPCServerIP" value="192.168.10.100"/>
... ...
HHWCSHost/Controls/StockerInfo.xaml
... ... @@ -48,7 +48,7 @@
48 48 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="1" Grid.Column="0" TextWrapping="Wrap" Text="任务校验" />
49 49 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="1" Grid.Column="2" TextWrapping="Wrap" Text="工作模式" />
50 50 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="1" Grid.Column="4" TextWrapping="Wrap" Text="操作模式" />
51   - <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="2" Grid.Column="0" TextWrapping="Wrap" Text="工作状态" />
  51 + <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="2" Grid.Column="0" TextWrapping="Wrap" Text="出入执行标记" />
52 52 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="2" Grid.Column="2" TextWrapping="Wrap" Text="任务标志" />
53 53 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="2" Grid.Column="4" TextWrapping="Wrap" Text="任务号1" />
54 54 <TextBlock Style="{DynamicResource txtBlockStyle}" Grid.Row="3" Grid.Column="0" TextWrapping="Wrap" Text="任务号2" />
... ...
HHWCSHost/Controls/StockerInfo.xaml.cs
... ... @@ -140,13 +140,13 @@ namespace HHWCSHost.Controls
140 140 lab_WorkStatus.Content = "出库";
141 141 break;
142 142 case "3":
143   - lab_WorkStatus.Content = "拣选";
  143 + lab_WorkStatus.Content = "转库"; //"拣选";
144 144 break;
145 145 case "4":
146 146 lab_WorkStatus.Content = "转库";
147 147 break;
148 148 case "5":
149   - lab_WorkStatus.Content = "双重入库";
  149 + lab_WorkStatus.Content = "不可用"; //"双重入库";
150 150 break;
151 151 case "6":
152 152 lab_WorkStatus.Content = "回库台位(入库准备)";
... ... @@ -253,7 +253,7 @@ namespace HHWCSHost.Controls
253 253 var a = (TextBlock)list_Alarm.Items[i];
254 254 if (a.Text.Contains(v))
255 255 {
256   - list_Alarm.Items.Remove(i);
  256 + list_Alarm.Items.Remove(list_Alarm.Items[i]);
257 257 }
258 258 }
259 259 }
... ...
HHWCSHost/SysData.txt
... ... @@ -58,3 +58,5 @@ disable 禁用
58 58 1.当条码不识别或外形检测不通过时,电气程序自动退回托盘到入库口;
59 59 2.当请求时的条码无对应任务或任务状态不对时,wcs给出回退的回复,即将去向地址写成入库口即可;
60 60  
  61 +货架1到2层可以承重,其他不能承重,需要区别;(没有实现)
  62 +
... ...
HHWCSHost/View/Frm_Main.xaml.cs
... ... @@ -125,7 +125,7 @@ namespace HHWCSHost.View
125 125 var stockers = FindDevByType("stocker").Data;
126 126 foreach (var item in stockers)
127 127 {
128   - StockerMonitor stockerMonitor = new StockerMonitor(16, false, false, 1200, 100)
  128 + StockerMonitor stockerMonitor = new StockerMonitor(32, false, false, 1200, 100)
129 129 {
130 130 ControlName = item.Name,
131 131 Name = item.Code
... ... @@ -138,6 +138,7 @@ namespace HHWCSHost.View
138 138 Name = item.Code
139 139 };
140 140 stockerInfo.DoubleInEvent += this.DoubleInHandle;
  141 + stockerInfo.EmptyOutEvent += this.EmptyOutHandle;
141 142 panel_Bottom.Children.Add(stockerInfo);
142 143 }
143 144  
... ... @@ -384,11 +385,6 @@ namespace HHWCSHost.View
384 385 }
385 386  
386 387 #endregion
387   - //AddLogToUI("线程" + Thread.CurrentThread.ManagedThreadId + "进入", 1);
388   - //Thread.Sleep(5000);
389   - //return;
390   -
391   - //todo:完善主控时钟
392 388  
393 389 #region 检查是否连接正常
394 390 if (PLC.GetConnStatus())
... ... @@ -428,35 +424,6 @@ namespace HHWCSHost.View
428 424 AddLogToUI("读取地址数据失败,请尝试关闭连接后重新连接;", 2);
429 425 return;
430 426 }
431   - //todo:测试值写入
432   - {
433   - //var tempds = DeviceAddressEntities.FindAll(t => t.DeviceId == 4);
434   - ////var temp23 = WriteWCSStationDataAddress(tempds, "1", "6", "1", "0", "1001", "0", tempds.Find(t=>t.DevicePropCode=="Barcode").value, "1003", "0");
435   -
436   -
437   - //var a = DeviceAddressEntities.FindAll(t => t.DeviceId == 5);
438   - //var b = a.Find(t => t.DevicePropCode == "RunningStatus");
439   - //b.value = "False";
440   - //var c = a.Find(t => t.DevicePropCode == "PalletExist");
441   - //c.value = "True";
442   - //var d = a.Find(t => t.DevicePropCode == "PalletDestinationAddress");
443   - //d.value = "1003";
444   - //var g = a.Find(t => t.DevicePropCode == "ConveyorNo");
445   - //g.value = "1001";
446   - //var f = a.Find(t => t.DevicePropCode == "PalletBarcode");
447   - //f.value = "TP001";
448   - //var rt = WriteAddress(a);
449   - //if (rt.Success)
450   - //{
451   - // //再读出来
452   - // var rt2 = ReadAddress(a);
453   - // AddLogToUI(rt2.Msg, 1);
454   - //}
455   - //else
456   - //{
457   - // AddLogToUI("写入地址错误:" + rt.Msg, 2);
458   - //}
459   - }
460 427  
461 428 //日志
462 429 DeviceEntities.ForEach(item => DeviceAddressEntities.FindAll(t => t.DeviceId == item.Id).Join(DevicePropEntities.FindAll(t => t.DeviceTypeId == item.DeviceTypeId && t.IsMonitor == 1), t => t.DevicePropCode, a => a.Code, (a, b) => new { a, b }).Where(t => t.a.value != t.b.MonitorCompareValue).Select(t => t.b).ToList().ForEach(t => AddLogToUI("报警:" + t.Name + " 信息:" + t.MonitorFailure, 2)));
... ... @@ -488,27 +455,6 @@ namespace HHWCSHost.View
488 455 var stockerMonitor = (StockerMonitor)panel_Stocker.FindName(item.Code);
489 456 stockerMonitor.SetProp(addressEntities);
490 457 }
491   - //foreach (var item in FindDevByType("stationForStockerIn").Data)
492   - //{
493   - // var s = this.FindName(item.Code);
494   - // var address = DeviceAddressEntities.FindAll(t => t.DeviceId == item.Id);
495   - // if (s is StationH stationH)
496   - // {
497   -
498   - // }
499   - // else if (s is StationV stationV)
500   - // {
501   -
502   - // }
503   - //}
504   - //foreach (var item in FindDevByType("stationForStockerOut").Data)
505   - //{
506   -
507   - //}
508   - //foreach (var item in FindDevByType("station").Data)
509   - //{
510   -
511   - //}
512 458 foreach (var item in FindDevByType("conveyor").Data)
513 459 {
514 460 var cv = this.FindName(item.Code);
... ... @@ -542,12 +488,6 @@ namespace HHWCSHost.View
542 488 //同巷道内的移库,当堆垛机状态为0,1,2时,均可以响应巷道内的移库
543 489 ExcuteTaskTransferInRoadway(stockers);
544 490  
545   -
546   - //响应任务校验为2时,重新写入任务
547   - //响应双重入库处理
548   - //响应高度不匹配
549   - //响应空出及发送地址错的处理
550   -
551 491 }
552 492  
553 493 #endregion
... ... @@ -860,8 +800,8 @@ namespace HHWCSHost.View
860 800 //表示地址请求,此时可能是分拣回库,也可能是新入库,也可能是空托入库,这里空托入库如果没有任务就自动生成任务(自动生成空托盘入库暂时不实现)
861 801 //获取目标库位
862 802 //hack:这里临时加个判断,如果任务状态不是31,则不响应
863   - if (taskEntity.Status == 31)
864   - {
  803 + //if (taskEntity.Status == 31)
  804 + //{
865 805 LocationEntity location;
866 806 if (taskEntity.Type == 100 || taskEntity.Type == 500)
867 807 {
... ... @@ -911,7 +851,7 @@ namespace HHWCSHost.View
911 851 AddLogToUI("写入" + station + "WCS区地址失败,任务:" + taskEntity.Id.ToString() + "消息:" + result.Msg, 2);
912 852 }
913 853 }
914   - }
  854 + //}
915 855 }
916 856  
917 857 if (addresses.Find(t => t.DevicePropCode == "Type").value == "2")
... ... @@ -1145,7 +1085,7 @@ namespace HHWCSHost.View
1145 1085 private void StationBack(List<DeviceAddressEntity> addresses,DeviceEntity device)
1146 1086 {
1147 1087 //获取地址
1148   - var result = WriteWCSStationDataAddress(addresses, "1", "06", addresses.Find(t => t.DevicePropCode == "PLCNo").value, "0", addresses.Find(t => t.DevicePropCode == "StationNo").value, addresses.Find(t => t.DevicePropCode == "TaskNo").value, addresses.Find(t => t.DevicePropCode == "Barcode").value, addresses.Find(t => t.DevicePropCode == "StationNo").value, "0");
  1088 + var result = WriteWCSStationDataAddress(addresses, "1", "06", addresses.Find(t => t.DevicePropCode == "PLCNo").value, "0", addresses.Find(t => t.DevicePropCode == "StationNo").value, addresses.Find(t => t.DevicePropCode == "TaskNo").value, addresses.Find(t => t.DevicePropCode == "Barcode").value,device.BackAddress, "0");
1149 1089 if (result.Success)
1150 1090 {
1151 1091 AddLogToUI($"{device}回退成功",1);
... ... @@ -1254,7 +1194,7 @@ namespace HHWCSHost.View
1254 1194 var task = taskResult.Data[0];
1255 1195 if (task.Status < 40)
1256 1196 {
1257   - BllResult temp = Bll.EmptyOutHandle("1",task);
  1197 + BllResult temp = Bll.EmptyOutHandle("1","40",task);
1258 1198 if (temp.Success)
1259 1199 {
1260 1200 //清空WCS交换区
... ... @@ -1266,7 +1206,7 @@ namespace HHWCSHost.View
1266 1206 else
1267 1207 {
1268 1208 //回滚
1269   - Bll.EmptyOutHandle("0", task);
  1209 + Bll.EmptyOutHandle("0",task.Status.ToString(), task);
1270 1210 return BllResultFactory.Error(null, "空出处理失败:" + sendResult.Msg);
1271 1211 }
1272 1212 }
... ... @@ -1552,7 +1492,7 @@ namespace HHWCSHost.View
1552 1492 case "DWORD": obj = Convert.ToUInt32(data); break;
1553 1493 case "BOOL": obj = Convert.ToBoolean(data); break;
1554 1494 case "WORD": obj = Convert.ToUInt16(data); break;
1555   - case "CHAR": obj = Bll.StringToASCII(data); break;
  1495 + case "CHAR": obj = Bll.StringToASCII(data+"\u0003"); break;
1556 1496 default:
1557 1497 obj = data;
1558 1498 break;
... ... @@ -1582,7 +1522,7 @@ namespace HHWCSHost.View
1582 1522 case "DWORD":
1583 1523 case "BOOL":
1584 1524 case "WORD": str = data.ToString(); break;
1585   - case "CHAR": str = Bll.ASCIIToString((short[])data).Trim(); break;
  1525 + case "CHAR": str = Bll.ASCIIToString((short[])data).Trim().Replace("\u0003",""); break;
1586 1526 default:
1587 1527 str = data.ToString();
1588 1528 break;
... ... @@ -1602,7 +1542,10 @@ namespace HHWCSHost.View
1602 1542 /// <returns></returns>
1603 1543 private bool ValidateStockerForCompleteTask(List<DeviceAddressEntity> addresses)
1604 1544 {
1605   - if (addresses.Find(t => t.DevicePropCode == "TaskExcuteStatus").value == "3")
  1545 + if (addresses.Find(t => t.DevicePropCode == "TaskExcuteStatus").value == "3"
  1546 + //这里加上WCS交换区检测,防止PLC来不及反应重复完成任务,交换区数据是会在完成任务后才会清除
  1547 + && addresses.First(t => t.DevicePropCode == "WCSTaskFlag").value != "0"
  1548 + )
1606 1549 {
1607 1550 return true;
1608 1551 }
... ... @@ -1621,6 +1564,7 @@ namespace HHWCSHost.View
1621 1564 private void ExcuteTaskOut(List<DeviceEntity> stockers)
1622 1565 {
1623 1566 List<TaskEntity> taskEntities = GetAllTaskOut();
  1567 + taskEntities = taskEntities.OrderBy(t => t.LastUpdated).ToList();
1624 1568 foreach (var task in taskEntities)
1625 1569 {
1626 1570 //获取任务所在巷道,即库位对应的巷道
... ... @@ -1919,11 +1863,12 @@ namespace HHWCSHost.View
1919 1863 {
1920 1864 if (deviceAddressEntities.First(t => t.DevicePropCode == "WorkModel").value == "2"
1921 1865 && deviceAddressEntities.First(t => t.DevicePropCode == "OperationModel").value == "5"
1922   - && (deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "0" || deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "2")
  1866 + && (deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "0" || deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "2" )
1923 1867 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskExcuteStatus").value == "1"
1924 1868 && deviceAddressEntities.First(t => t.DevicePropCode == "HasPallet").value == "1"
1925 1869 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskNo1").value == "0"
1926   - // &&
  1870 + //这里加上WCS交换区检测,防止PLC来不及反应重复写入任务
  1871 + && deviceAddressEntities.First(t => t.DevicePropCode == "WCSTaskFlag").value == "0"
1927 1872 )
1928 1873 {
1929 1874 return true;
... ... @@ -1951,11 +1896,12 @@ namespace HHWCSHost.View
1951 1896 {
1952 1897 if (deviceAddressEntities.First(t => t.DevicePropCode == "WorkModel").value == "2"
1953 1898 && deviceAddressEntities.First(t => t.DevicePropCode == "OperationModel").value == "5"
1954   - && (deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "0" || deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "2" || deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "1")
  1899 + && (deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "0" || deviceAddressEntities.First(t => t.DevicePropCode == "WorkStatus").value == "3")
1955 1900 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskExcuteStatus").value == "1"
1956 1901 && deviceAddressEntities.First(t => t.DevicePropCode == "HasPallet").value == "1"
1957 1902 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskNo1").value == "0"
1958   - // &&
  1903 + //这里加上WCS交换区检测,防止PLC来不及反应重复写入任务
  1904 + && deviceAddressEntities.First(t => t.DevicePropCode == "WCSTaskFlag").value == "0"
1959 1905 )
1960 1906 {
1961 1907 return true;
... ... @@ -1987,7 +1933,8 @@ namespace HHWCSHost.View
1987 1933 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskExcuteStatus").value == "1"
1988 1934 && deviceAddressEntities.First(t => t.DevicePropCode == "HasPallet").value == "1"
1989 1935 && deviceAddressEntities.First(t => t.DevicePropCode == "TaskNo1").value == "0"
1990   - // &&
  1936 + //这里加上WCS交换区检测,防止PLC来不及反应重复写入任务
  1937 + && deviceAddressEntities.First(t => t.DevicePropCode == "WCSTaskFlag").value == "0"
1991 1938 )
1992 1939 {
1993 1940 return true;
... ...