From d151ad916449dd1b081ce515daf893e54ef5511c Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周五, 20 12月 2024 18:08:17 +0800
Subject: [PATCH] 22
---
CC/iWareCC_ASRS/ThreadService/04_BZ21(搬运整垛机器人)/1、DataProcess_BZ21.cs | 197 ++++++++++++++++++++++++++++++++----------------
1 files changed, 131 insertions(+), 66 deletions(-)
diff --git "a/CC/iWareCC_ASRS/ThreadService/04_BZ21\357\274\210\346\220\254\350\277\220\346\225\264\345\236\233\346\234\272\345\231\250\344\272\272\357\274\211/1\343\200\201DataProcess_BZ21.cs" "b/CC/iWareCC_ASRS/ThreadService/04_BZ21\357\274\210\346\220\254\350\277\220\346\225\264\345\236\233\346\234\272\345\231\250\344\272\272\357\274\211/1\343\200\201DataProcess_BZ21.cs"
index ca1fd9b..17ad69b 100644
--- "a/CC/iWareCC_ASRS/ThreadService/04_BZ21\357\274\210\346\220\254\350\277\220\346\225\264\345\236\233\346\234\272\345\231\250\344\272\272\357\274\211/1\343\200\201DataProcess_BZ21.cs"
+++ "b/CC/iWareCC_ASRS/ThreadService/04_BZ21\357\274\210\346\220\254\350\277\220\346\225\264\345\236\233\346\234\272\345\231\250\344\272\272\357\274\211/1\343\200\201DataProcess_BZ21.cs"
@@ -10,8 +10,10 @@
using iWareSql.WmsDBModel;
using Newtonsoft.Json.Linq;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading;
@@ -21,7 +23,7 @@
{
public class DataProcess_BZ21
{
- public static void Hander()
+ public static async void Hander()
{
var alertMsg = "";
LogType logType = LogType.DataProcess_BZ21;
@@ -78,69 +80,114 @@
using (WmsDBModel wmsDB = new WmsDBModel())
{
//瑕佹槸鏈夊凡涓嬪彂鐨勪换鍔★紝灏变笉瑕佹墽琛�
- var isValidate = TaskHandler.ValidateIssueTaskForBZ21(wmsDB, result);
+ var isValidate = TaskHandler.ValidateIssueTaskForNoFinishTaskByUpi(wmsDB, result);
if (!isValidate)
{
SystemWarningMsg._lbl_alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-鏈夆�樺凡涓嬪彂鈥欑殑浠诲姟锛屼笉鑳藉鐞�,姝ゆ寰幆缁撴潫";
continue;
}
+
+ //澧炲姞鏍¢獙锛屽鏋滀笂涓�涓换鍔pi璺熸湰娆pi涓�鑷达紝灏辨姤閿� 銆怑ditby shaocx,2024-12-03銆�
+ var lastTask = wmsDB.wms_rbline_task.Where(x => x.RbTaskType == (int)RbTaskTypeEnum.鍚堝寘浠诲姟).OrderByDescending(x => x.Id).FirstOrDefault();
+ if (lastTask != null && lastTask.Upi == result)
+ {
+ SystemWarningMsg._lbl_alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-PLC閲嶅彂姝や换鍔★紝upi锛歿result}锛岀郴缁熶笉鑳介噸澶嶅鐞�,姝ゆ寰幆缁撴潫";
+ continue;
+ }
+
var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == result).FirstOrDefault();
if (upiObj == null)
{
+ //鍐欏叆鎶ヨ淇℃伅
+ await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ21_1);
+
SystemWarningMsg._lbl_alert_DataProcess_BZ21 = $"{rgvLocation.ToString()},鏍规嵁UPI:{result}娌℃湁鎵惧埌瀵硅薄 ";
continue;
}
+
+ //楠岃瘉鏄惁鍏佽鍒囩焊
+ var validteReslt = ValidateIsAllowCut();
+ if (validteReslt == false)
+ {
+ //鍐欏叆鎶ヨ淇℃伅
+ await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ21_2);
+
+ continue;
+ }
+
//string upi = "LS070700101B0001GS";
//璋冪敤鍑虹焊鏈烘帴鍙�
var papercut = ClassHelper.RotationMapping<mes_push_papercut, mes_batchOrderUPI_new>(upiObj);
papercut.Id = Yitter.IdGenerator.YitIdHelper.NextId();
papercut.ApiMessage = "";
- papercut.PushNum = 1;
+ papercut.PushNum = 0;
papercut.PushStatus = (int)PushStatusEnum.NotPush;
+ papercut.CreateUserName = papercut.UpdateUserName = SysGloble.WCSSystem;
papercut.CreateTime = papercut.UpdateTime = DateTime.Now;
wmsDB.mes_push_papercut.Add(papercut);
+
+
+ AreaCodeEnum setAreaCode = AreaCodeEnum.鍚堝寘瑁佸垏鍖�;
+ UpiStatusEnum setUpiStatus = UpiStatusEnum.宸插悎鍖�;
+
+ var ngFlag = false;
+ var queryFlag = (int)UpiFlagEnum.NG;
+ var upilist = wmsDB.mes_batchOrderUPI_new.Where(x => x.PackageCode == upiObj.PackageCode).ToList();
+ var ngCount = upilist.Count(x => x.UpiFlag == queryFlag);
+ if (ngCount > 0)
+ {
+ ngFlag = true;
+ setUpiStatus = UpiStatusEnum.宸蹭笅绾�;
+ setAreaCode = AreaCodeEnum.涓嬬嚎鍖哄煙;
+ }
+ else
+ {//涓嶆槸NG
+ //鏂板mes鎺ㄩ�佽〃
+ var putpakegecodeid = Yitter.IdGenerator.YitIdHelper.NextId();
+ var putpakegecode = new mes_push_packagecode()
+ {
+ Id = putpakegecodeid,
+ PackageCode = upiObj.PackageCode,
+ PushStatus = 0,
+ PushNum = 0,
+ ApiMessage = "",
+ CreateTime = DateTime.Now,
+ CreateUserName = SysGloble.WCSSystem,
+ UpdateTime = DateTime.Now,
+ UpdateUserName = SysGloble.WCSSystem
+
+ };
+ wmsDB.mes_push_packagecode.Add(putpakegecode);
+
+ //鏂板琛�
+ var mesinequeue = ClassHelper.RotationMapping<mes_package_linequeue, mes_batchOrderUPI_new>(upiObj);
+ mesinequeue.Id = Yitter.IdGenerator.YitIdHelper.NextId();
+ mesinequeue.CreateTime = mesinequeue.UpdateTime = DateTime.Now;
+ wmsDB.mes_package_linequeue.Add(mesinequeue);
+ }
//鏇存柊琛�
var mesgather = wmsDB.mes_package_gather.Where(x => x.PackageCode == upiObj.PackageCode).FirstOrDefault();
if (mesgather != null)
{
- mesgather.AreaCode = (int)AreaCodeEnum.鍚堝寘瑁佸垏鍖�;
- mesgather.UpiStatus = (int)UpiStatusEnum.宸插悎鍖�;
+ mesgather.AreaCode = (int)setAreaCode;
+ mesgather.UpiStatus = (int)setUpiStatus;
}
- //var upilist = wmsDB.mes_batchOrderUPI_new.Where(x => x.PackageCode == upiObj.PackageCode).ToList();
- //var upilength = upilist.Max(x => x.Length);
- //var upiwidth = upilist.Max(x => x.Width);
- //cartonhigh = (short)upiObj.Info3;
- //cartonwidth = (short)upiObj.Info2;
- upiObj.UpiStatus = (int)UpiStatusEnum.宸插悎鍖�;
- upiObj.AreaCode = (int)AreaCodeEnum.鍚堝寘瑁佸垏鍖�;
+
+ upiObj.UpiStatus = (int)setUpiStatus;
+ upiObj.AreaCode = (int)setAreaCode;
//璁板綍浠诲姟
var _id = Yitter.IdGenerator.YitIdHelper.NextId();
- var putpakegecodeid = Yitter.IdGenerator.YitIdHelper.NextId();
- var plcTaskNo = BusinessHelper.CreatePlcTaskIdForSrmTask();
- //鏂板琛�
- var mesinequeue = ClassHelper.RotationMapping<mes_package_linequeue, mes_batchOrderUPI_new>(upiObj);
- mesinequeue.Id = Yitter.IdGenerator.YitIdHelper.NextId();
- //鏂板mes鎺ㄩ�佽〃
- var putpakegecode = new mes_push_packagecode()
- {
- Id = putpakegecodeid,
- PackageCode = upiObj.PackageCode,
- PushStatus = 0,
- PushNum = 0,
- ApiMessage = "寰呮帹閫�",
- CreateTime = DateTime.Now,
- CreateUserName = "CC",
- UpdateTime = DateTime.Now,
- UpdateUserName = "CC",
- CreateOrgName = "11"
- };
+
+ var plcTaskNo = BusinessHelper.CreatePlcTaskId();
+ plcTaskNo = MyExtendHelper.GetNewTaskNo(wmsDB, RbTaskTypeEnum.鍚堝寘浠诲姟, plcTaskNo);
+
//鏂板浠诲姟琛�
var task = new wms_rbline_task()
{
Id = _id,
TaskNo = plcTaskNo,
- UPI = upiObj.UPI,
+ Upi = upiObj.UPI,
Length = upiObj.Length,
Width = upiObj.Width,
Thk = upiObj.Thk,
@@ -149,14 +196,12 @@
OrderId = upiObj.OrderId,
PackageCode = upiObj.PackageCode,
RbTaskType = (int)RbTaskTypeEnum.鍚堝寘浠诲姟,
- RbTaskTypeEnumName = RbTaskTypeEnum.鍚堝寘浠诲姟.ToString(),
TaskStatus = (int)TaskStatusEnum.鏂板缓,
- TaskStatusName = TaskStatusEnum.鏂板缓.ToString(),
TaskMsg = "澶规澘",
CreateTime = DateTime.Now,
- CreateUserName = "CC",
+ CreateUserName = SysGloble.WCSSystem,
UpdateTime = DateTime.Now,
- UpdateUserName = "CC",
+ UpdateUserName = SysGloble.WCSSystem,
PlaceCode = place
};
//鏂板鎵撳嵃琛�
@@ -171,20 +216,20 @@
print.IsAllowPrint = true;
print.CreateTime = print.UpdateTime = DateTime.Now;
wmsDB.wms_record_print.Add(print);
- var printtwo = ClassHelper.RotationMapping<wms_record_print, mes_batchOrderUPI_new>(upiObj);
- printtwo.PrintType = (int)PrintTypeEnum.鍖呰鏉$爜;
- printtwo.PrintSource = (int)PrintSourceEnum.鍖呰鏉$爜鎵撳嵃;
- printtwo.PrintSheetNum = 1;
- printtwo.PrintNum = 0;
- printtwo.PrintStatus = (int)PrintStatuEnum.鏈墦鍗�;
- printtwo.IsAllowPrint = true;
- printtwo.CreateTime = print.UpdateTime = DateTime.Now;
- printtwo.Id = Yitter.IdGenerator.YitIdHelper.NextId();
- wmsDB.wms_record_print.Add(printtwo);
+ //var printtwo = ClassHelper.RotationMapping<wms_record_print, mes_batchOrderUPI_new>(upiObj);
+ //printtwo.PrintType = (int)PrintTypeEnum.鍖呰鏉$爜;
+ //printtwo.PrintSource = (int)PrintSourceEnum.鍖呰鏉$爜鎵撳嵃;
+ //printtwo.PrintSheetNum = 1;
+ //printtwo.PrintNum = 0;
+ //printtwo.PrintStatus = (int)PrintStatuEnum.鏈墦鍗�;
+ //printtwo.IsAllowPrint = true;
+ //printtwo.CreateTime = print.UpdateTime = DateTime.Now;
+ //printtwo.Id = Yitter.IdGenerator.YitIdHelper.NextId();
+ //wmsDB.wms_record_print.Add(printtwo);
- wmsDB.mes_package_linequeue.Add(mesinequeue);
+
wmsDB.wms_rbline_task.Add(task);
- wmsDB.mes_push_packagecode.Add(putpakegecode);
+
//澶勭悊琛� mes_order_gather
var errmsg = "";
@@ -196,30 +241,16 @@
continue;
}
- /*
- using (StationServiceClient client = new StationServiceClient())
- {
-
- var plcres = client.WriteSurroundTaskInfo((int)EDevice.Station, rgvLocation, short.Parse(task.TaskNo),
- (short)upilength, (short)upiwidth, cartonhigh, cartonwidth, 0, 0);
- if (!plcres.result)
- {
- SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,WriteInStoreTaskInfoAsync 杩斿洖:{plcres.resMsg}";
- continue;
- }
- else
- {
- Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 鎴愬姛,WriteInStoreTaskInfoAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
- }
- }
- //*/
-
WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, "BZ21", "鍚堝寘");
WmsRecordUpiProcessHandler.SaveWmsRecordPackageProcess(wmsDB, upiObj, "BZ21", "鍚堝寘");
wmsDB.SaveChanges();
}
+ }
+ else
+ {
+ SystemWarningMsg._lbl_Alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-娌℃湁瑕佸鐞嗙殑鏁版嵁";
}
}
}
@@ -232,5 +263,39 @@
}
+ /// <summary>
+ /// 楠岃瘉鏄惁鍏佽鍒囩焊
+ /// </summary>
+ /// <returns></returns>
+ public static bool ValidateIsAllowCut()
+ {
+ var rgvLocation = StationLocationEnum.BZ3007.ToString();
+
+ if (FormCC.stationView == null)
+ {
+ SystemWarningMsg._lbl_Alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-鑾峰彇PLC瀵硅薄涓簄ull";
+ return false;
+ }
+ var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
+ if (obj != null)
+ {
+ if (obj.R_AllowCut)
+ {
+ return true;
+ }
+ else
+ {
+ SystemWarningMsg._lbl_Alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-PLC涓嶅厑璁稿垏绾�";
+ return false;
+ }
+ }
+ else
+ {
+ SystemWarningMsg._lbl_Alert_DataProcess_BZ21 = $"{rgvLocation.ToString()}-鑾峰彇PLC瀵硅薄涓簄ull";
+ return false;
+ }
+
+ }
+
}
}
--
Gitblit v1.9.3