From cfb3f2c7e9cde8cc2eb2a19263d0802c0c5410a3 Mon Sep 17 00:00:00 2001
From: zhanghonglin <zhanghonglin@hnkhzn.com>
Date: 星期一, 06 四月 2026 15:41:04 +0800
Subject: [PATCH] mes接口
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs | 225 +++++++++++++++++++++++++++----------------------------
1 files changed, 111 insertions(+), 114 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
index 85698b5..90503dc 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
@@ -12,6 +12,7 @@
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.LogHelper;
using WIDESEAWCS_DTO.MES;
using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_ITaskInfoService;
@@ -55,6 +56,8 @@
public Task Execute(IJobExecutionContext context)
{
+ //鍫嗗灈鏈鸿澶囩姸鎬�
+ int sc = comm.GETR_TaskStatus();
//杩炴帴璁惧
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
if (flag && value != null)
@@ -62,29 +65,30 @@
OtherDevice device = (OtherDevice)value;
List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).Distinct().ToList();
List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
- //鍏蜂綋璁惧
- foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
+ try
{
- i++;
- //璇诲彇淇″彿
- DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
- //DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode ).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
- if (deviceProRead != null)
+ //鍏蜂綋璁惧
+ foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
{
- ConveyorLineCommand conveyorLineInfoRead = device.Communicator.ReadCustomer<ConveyorLineCommand>(deviceProRead.DeviceProAddress);
- //绌烘《鍏ュ簱浠诲姟
- if (item.StationName == "绌烘《鍏�")
+ i++;
+ //璇诲彇淇″彿
+ DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+ //DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode ).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+ if (deviceProRead != null)
{
- comm.R_StatusA((short)conveyorLineInfoRead.R_State);
- comm.R_PickA((short)conveyorLineInfoRead.R_Pick);
- if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+ ConveyorLineCommand conveyorLineInfoRead = device.Communicator.ReadCustomer<ConveyorLineCommand>(deviceProRead.DeviceProAddress);
+ //绌烘《鍏ュ簱浠诲姟
+ if (item.StationName == "绌烘《鍏�")
{
- try
+ comm.R_StatusA((short)conveyorLineInfoRead.R_State);
+ comm.R_PickA((short)conveyorLineInfoRead.R_Pick);
+ if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
{
//鍒ゆ柇浠诲姟鏄惁閲嶅
Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.InEmpty);
if (task == null)
{
+ LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"绌烘《鍏ュ簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
//WMS鐢熸垚浠诲姟
string address = AppSettings.Get("WMSApiAddress");
if (!string.IsNullOrEmpty(address))
@@ -93,21 +97,13 @@
}
}
}
- catch (Exception ex)
- {
- //鍐欏叆鏃ュ織
- WriteInfo(device.DeviceCode, $"{ex.Message}");
- }
}
- }
- //婊℃《鍏ュ簱浠诲姟
- if (item.StationName == "婊℃《鍏�")
- {
- comm.R_StatusC((short)conveyorLineInfoRead.R_State);
- comm.R_PickC((short)conveyorLineInfoRead.R_Pick);
- if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+ //婊℃《鍏ュ簱浠诲姟
+ if (item.StationName == "婊℃《鍏�")
{
- try
+ comm.R_StatusC((short)conveyorLineInfoRead.R_State);
+ comm.R_PickC((short)conveyorLineInfoRead.R_Pick);
+ if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
{
//娓呯┖鐗╂枡缂栧彿
if (k)
@@ -125,9 +121,10 @@
Stock.MaterialCode4 = conveyorLineInfoRead.R_NumberD;
//鍒ゆ柇浠诲姟鏄惁閲嶅
- Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.Infull);
+ Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.Infull || x.TaskType == (int)TaskTypeEnum.OutDirect);
if (task == null)
{
+ LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"婊℃《鍏ュ簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State + "//" + conveyorLineInfoRead.R_NumberA + "/" + conveyorLineInfoRead.R_NumberB + "/" + conveyorLineInfoRead.R_NumberC + "/" + conveyorLineInfoRead.R_NumberD}" });
Stock.location = item.location;
//WMS鐢熸垚浠诲姟
string address = AppSettings.Get("WMSApiAddress");
@@ -140,46 +137,40 @@
k = true;
//鍚慚ES鍙戦�佹姤宸ュ崟
- if (Stock.MaterialCode1 != null && !Stock.MaterialCode1.Equals(""))
- {
- MESReport(Stock.MaterialCode1);
- }
- if (Stock.MaterialCode2 != null && !Stock.MaterialCode2.Equals(""))
- {
- MESReport(Stock.MaterialCode2);
- }
- if (Stock.MaterialCode3 != null && !Stock.MaterialCode3.Equals(""))
- {
- MESReport(Stock.MaterialCode3);
- }
- if (Stock.MaterialCode4 != null && !Stock.MaterialCode4.Equals(""))
- {
- MESReport(Stock.MaterialCode4);
- }
+ //if (Stock.MaterialCode1 != null && !Stock.MaterialCode1.Equals(""))
+ //{
+ // MESReport(Stock.MaterialCode1);
+ //}
+ //if (Stock.MaterialCode2 != null && !Stock.MaterialCode2.Equals(""))
+ //{
+ // MESReport(Stock.MaterialCode2);
+ //}
+ //if (Stock.MaterialCode3 != null && !Stock.MaterialCode3.Equals(""))
+ //{
+ // MESReport(Stock.MaterialCode3);
+ //}
+ //if (Stock.MaterialCode4 != null && !Stock.MaterialCode4.Equals(""))
+ //{
+ // MESReport(Stock.MaterialCode4);
+ //}
}
}
}
- catch (Exception ex)
- {
- //鍐欏叆鏃ュ織
- WriteInfo(device.DeviceCode, $"{ex.Message}");
- }
}
- }
- //绌烘《鍑�
- if (item.StationName == "绌烘《鍑�")
- {
- comm.R_StatusB((short)conveyorLineInfoRead.R_State);
- comm.R_PickB((short)conveyorLineInfoRead.R_Pick);
- if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+ //绌烘《鍑�
+ if (item.StationName == "绌烘《鍑�")
{
- try
+ comm.R_StatusB((short)conveyorLineInfoRead.R_State);
+ comm.R_PickB((short)conveyorLineInfoRead.R_Pick);
+ if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
{
+
//鍒ゆ柇浠诲姟鏄惁閲嶅
Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.OutEmpty);
if (task == null)
{
+ LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"绌烘《鍑哄簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
//WMS鐢熸垚浠诲姟
string address = AppSettings.Get("WMSApiAddress");
if (!string.IsNullOrEmpty(address))
@@ -187,85 +178,91 @@
HttpHelper.Post($"{address}/api/Task/addOutEmptyTask/?location={item.location}", "");
}
}
- }
- catch (Exception ex)
- {
- //鍐欏叆鏃ュ織
- WriteInfo(device.DeviceCode, $"{ex.Message}");
+
}
}
- }
- //婊℃《鍑�
- if (item.StationName == "婊℃《鍑�")
- {
- comm.R_StatusD((short)conveyorLineInfoRead.R_State);
- comm.R_PickD((short)conveyorLineInfoRead.R_Pick);
- //鍛婅瘔WMS鍙互鍑哄簱
- if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+ //婊℃《鍑�
+ if (item.StationName == "婊℃《鍑�")
{
- if (m)
+ comm.R_StatusD((short)conveyorLineInfoRead.R_State);
+ comm.R_PickD((short)conveyorLineInfoRead.R_Pick);
+ //鍛婅瘔WMS鍙互鍑哄簱
+ if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
{
- //WMS鐢熸垚浠诲姟
- string address = AppSettings.Get("WMSApiAddress");
- if (!string.IsNullOrEmpty(address))
+ if (m)
{
- HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=1", "");
+ //WMS鐢熸垚浠诲姟
+ string address = AppSettings.Get("WMSApiAddress");
+ if (!string.IsNullOrEmpty(address))
+ {
+ HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=1", "");
+ }
+ m = false;
+ n = true;
+ //鍐欏叆鏃ュ織
+ LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"婊℃《鍑哄簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
}
- m = false;
- n = true;
}
- }
- //鍛婅瘔WMS涓嶅彲浠ュ嚭搴�
- else
- {
- if (n)
+ //鍛婅瘔WMS涓嶅彲浠ュ嚭搴�
+ else
{
- //WMS鐢熸垚浠诲姟
- string address = AppSettings.Get("WMSApiAddress");
- if (!string.IsNullOrEmpty(address))
+ if (n)
{
- HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=0", "");
+ //WMS鐢熸垚浠诲姟
+ string address = AppSettings.Get("WMSApiAddress");
+ if (!string.IsNullOrEmpty(address))
+ {
+ HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=0", "");
+ }
+ n = false;
+ m = true;
+ //鍐欏叆鏃ュ織
+ LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"婊℃《鍑哄簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
}
- n = false;
- m = true;
}
}
}
}
+ i = 0;
}
- i = 0;
+ catch (Exception ex)
+ {
+ //鍐欏叆鏃ュ織
+ WriteInfo(device.DeviceCode, $"{ex.Message}");
+ }
}
return Task.CompletedTask;
}
//MES鎶ュ伐
- public void MESReport(string MaterialCode)
- {
- try
- {
- Reports reports = new Reports();
+ //public void MESReport(string MaterialCode)
+ //{
+ // try
+ // {
+ // Reports reports = new Reports();
- //鏌ヨ浜岀淮鐮�
- Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x => x.BarCode == MaterialCode);
+ // //鏌ヨ浜岀淮鐮�
+ // Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x => x.BarCode == MaterialCode);
- reports.report.Qty = FillingOrder.BarNum;
- reports.report.DispatchID = FillingOrder.WorkID + "";
- reports.barcodeSN[0].Barcode = FillingOrder.BarCode;
- reports.barcodeSN[0].BatchNum = int.Parse(FillingOrder.batchNum);
- reports.barcodeSN[0].Id = FillingOrder.BarCodeID;
- reports.barcodeSN[0].MaterialId = FillingOrder.ArticleNumID;
- reports.barcodeSN[0].Quantity = (int)FillingOrder.BarNum;
- reports.barcodeSN[0].DispatchId = FillingOrder.WorkID;
+ // reports.report.Qty = FillingOrder.BarNum;
+ // reports.report.DispatchID = FillingOrder.WorkID + "";
+ // reports.barcodeSN[0].Barcode = FillingOrder.BarCode;
+ // reports.barcodeSN[0].BatchNum = int.Parse(FillingOrder.batchNum);
+ // reports.barcodeSN[0].Id = FillingOrder.BarCodeID;
+ // reports.barcodeSN[0].MaterialId = FillingOrder.ArticleNumID;
+ // reports.barcodeSN[0].Quantity = (int)FillingOrder.BarNum;
+ // reports.barcodeSN[0].DispatchId = FillingOrder.WorkID;
- string mes = AppSettings.Get("WMSApiAddress");
- if (!string.IsNullOrEmpty(mes))
- {
- HttpHelper.Post($"{mes}/Task/SaveReportRaw/", reports.Serialize());
- }
- }
- catch (Exception ex) {
- WriteInfo( "MES鎶ュ伐閿欒", $"{ex.Message}");
- }
- }
+ // string mes = AppSettings.Get("MSE");
+ // if (!string.IsNullOrEmpty(mes))
+ // {
+ // HttpHelper.Post($"{mes}/Task/SaveReportRaw/", reports.Serialize());
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // WriteInfo("MES鎶ュ伐閿欒", $"{ex.Message}");
+ // }
+ //}
}
}
--
Gitblit v1.9.3