| | |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using XiGang.Core.Model; |
| | | |
| | | using LogType = iWareCommon.Utils.LogType; |
| | | |
| | | namespace iWareCC.Common.Helper |
| | | { |
| | |
| | | /// </summary> |
| | | public class MyExtendHelper |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 公共的控制请求对象字典 |
| | | /// </summary> |
| | | public static IDictionary<string, ControlRequest> controlRequestDicts = new Dictionary<string, ControlRequest>(); |
| | | |
| | | /// <summary> |
| | | /// 公共的控制请求对象字典赋值 |
| | | /// </summary> |
| | | /// <param name="placeNo"></param> |
| | | /// <param name="result"></param> |
| | | /// <param name="msg"></param> |
| | | public static void SetValueControlRequestDicts(string placeNo, bool result, string msg) |
| | | { |
| | | if (controlRequestDicts.ContainsKey(placeNo)) |
| | | { |
| | | controlRequestDicts[placeNo].IsSuccess = result; |
| | | controlRequestDicts[placeNo].LastTime = DateTime.Now; |
| | | controlRequestDicts[placeNo].PlaceNo = placeNo; |
| | | if (result) |
| | | { |
| | | controlRequestDicts[placeNo].Count = 0; |
| | | controlRequestDicts[placeNo].ErrMsg = ""; |
| | | } |
| | | else |
| | | { |
| | | controlRequestDicts[placeNo].Count++; |
| | | controlRequestDicts[placeNo].ErrMsg = msg; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (result) |
| | | { |
| | | controlRequestDicts.Add(placeNo, new ControlRequest() |
| | | { |
| | | PlaceNo = placeNo, |
| | | Count = 0, |
| | | LastTime = DateTime.Now, |
| | | ErrMsg = msg, |
| | | IsSuccess = result |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | controlRequestDicts.Add(placeNo, new ControlRequest() |
| | | { |
| | | PlaceNo = placeNo, |
| | | Count = 1, |
| | | LastTime = DateTime.Now, |
| | | ErrMsg = msg, |
| | | IsSuccess = result |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证是否允许给PLC发报警 |
| | | /// </summary> |
| | | /// <param name="placeNo"></param> |
| | | /// <returns></returns> |
| | | public static bool ValidateIsAllowRequest(string placeNo, LogType logType) |
| | | { |
| | | if (controlRequestDicts.ContainsKey(placeNo)) |
| | | { |
| | | if (controlRequestDicts[placeNo].IsSuccess == false) |
| | | { |
| | | //var diff = DateTime.Now - controlRequestDicts[placeNo].LastTime; |
| | | //if (diff.Seconds <= 10) |
| | | //{//如果连续请求在10秒内,则认为 不需要再次请求 |
| | | // WZ.Useful.Commons.LogTextHelper.WriteLine("CommonControl", "ValidateIsAllowRequest", "如果连续请求在10秒内,则认为 不需要再次请求,间隔" + diff.Seconds + "秒,placeNo:" + placeNo); |
| | | // return false; |
| | | //} |
| | | if (controlRequestDicts[placeNo].Count <= 5) |
| | | {//如果连续请求在5次内,则认为 不需要再次请求 |
| | | var msg = "如果连续请求在5次内,则认为 不需要再次请求,间隔" + controlRequestDicts[placeNo].Count + "个,placeNo:" + placeNo; |
| | | Log4NetHelper.WriteInfoLog(logType, msg); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成最新的任务号 |
| | |
| | | } |
| | | order.PackageNum = packageList.Count(); |
| | | order.UnLinePackageNum = packageList.Where(x => x.UpiStatus == (int)UpiStatusEnum.已下线).Count(); |
| | | if (order.UnLinePackageNum > order.PackageNum) |
| | | { |
| | | order.UnLinePackageNum = order.PackageNum; |
| | | } |
| | | |
| | | order.NgPackageNum = packageList.Where(x => x.UpiStatus == (int)UpiStatusEnum.已下线 && x.UpiFlag == (int)UpiFlagEnum.NG).Count(); |
| | | if (order.NgPackageNum > order.PackageNum) |
| | | { |
| | | order.NgPackageNum = order.PackageNum; |
| | | } |
| | | |
| | | order.NoUnLinePackageNum = order.PackageNum - order.UnLinePackageNum; |
| | | |
| | | order.AllPackageArea = packageList.Sum(x => Convert.ToDecimal(x.Info13)); |
| | | order.ScanPackageArea = packageList.Where(x => x.UpiStatus == (int)UpiStatusEnum.已下线 && x.UpiFlag == (int)UpiFlagEnum.正常).Sum(x => Convert.ToDecimal(x.Info13)); |
| | | order.NoScanPackageArea = order.AllPackageArea - order.ScanPackageArea; |
| | | order.IsKitting = qitaoValue == "齐套" ? true : false; |
| | | |
| | | |
| | | /* |
| | | var order_unLine = false; |
| | | //查询下一个包是不是属于该订单 |
| | | var newLineQueue = wmsDB.mes_package_linequeue.OrderBy(x => x.Id).FirstOrDefault(); |
| | |
| | | order.IsUnline = false; |
| | | } |
| | | |
| | | //*/ |
| | | |
| | | if (isAddOrder) |
| | | { |
| | | wmsDB.mes_order_gather.Add(order); |