From b71144811c970ddb7296f5243f722ec6b00cf805 Mon Sep 17 00:00:00 2001
From: liudl <673013083@qq.com>
Date: 星期四, 13 三月 2025 18:52:52 +0800
Subject: [PATCH] 程序修改
---
Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs | 118 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 99 insertions(+), 19 deletions(-)
diff --git a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
index 8890284..ea89850 100644
--- a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
+++ b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
@@ -1,5 +1,6 @@
锘縰sing Dm.filter;
using DocumentFormat.OpenXml.Drawing.Charts;
+using DocumentFormat.OpenXml.Office.CustomUI;
using DocumentFormat.OpenXml.Presentation;
using Elastic.Clients.Elasticsearch;
using Furion.Logging;
@@ -373,24 +374,83 @@
//鑾峰彇鍖呰鏁伴噺
int Fqty = int.Parse(models.FinishQty);
+ int bzQty = 0;
var boxinfolog = _db.Queryable<WcsBoxInfoLog>().Where(m => m.SkuNo == models.SkuNo && m.LotNo == models.LotNo && m.BitBoxMark == "0").First();
if (boxinfolog == null)
{
var boxinfo = _db.Queryable<WcsBoxInfo>().Where(m => m.SkuNo == models.SkuNo && m.LotNo == models.LotNo && m.BitBoxMark == "0").First();
Fqty = (int)(Fqty /boxinfo.QtyCount);
+ bzQty = (int)boxinfo.QtyCount;
}
else
{
Fqty = (int)(Fqty / boxinfolog.QtyCount);
+ bzQty = (int)boxinfolog.QtyCount;
}
-
+ int Jpqty = 0;
//鍐欏叆璇ヤ换鍔″畬鎴愭暟閲�
foreach (var item in num)
{
item.FinishQty = Fqty;
+ //鍒ゆ柇褰撳墠鍗曟嵁鐮佸灈鏁伴噺鏄惁鍜屽畬宸ユ暟閲忕浉绛夛紝鏄垯缁撴壒璇ュ崟鎹�
+ var checkNum = _db.Queryable<WcsBoxInfoLog>().Where(m => m.SkuNo == models.SkuNo && m.LotNo == models.LotNo && m.OrderCode == item.OrderNo).ToList();//缁勭洏琛ㄧ鐮佷俊鎭�
+ if (checkNum.Count>0)
+ {
+ if (checkNum.First().Qty != 0)//鏈夋敮鐮�
+ {
+ foreach (var item2 in checkNum)
+ {
+ Jpqty = (int)(Jpqty + item2.Qty);
+ }
+ }
+ else//鏃犳敮鐮�
+ {
+ foreach (var item2 in checkNum)
+ {
+ Jpqty = (int)(Jpqty + item2.QtyCount);
+ }
+ }
+ }
+ var checkNum2 = _db.Queryable<WcsBoxInfo>().Where(m => m.SkuNo == models.SkuNo && m.LotNo == models.LotNo && m.OrderCode == item.OrderNo).ToList();//绠辩爜琛ㄥ凡鐮佸灈绠辩爜淇℃伅
+ if (checkNum2.Count>0)
+ {
+ if (checkNum2.First().Qty != 0)//鏈夋敮鐮�
+ {
+ foreach (var item2 in checkNum)
+ {
+ Jpqty = (int)(Jpqty + item2.Qty);
+ }
+ }
+ else//鏃犳敮鐮�
+ {
+ foreach (var item2 in checkNum)
+ {
+ Jpqty = (int)(Jpqty + item2.QtyCount);
+ }
+ }
+ }
+ if (Jpqty/bzQty == Fqty)
+ {
+ //棰勭粨鎵逛俊鍙蜂笅鍙�
+ var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == ("2灞傛墭鐩樿緭閫佺嚎")).First();
+ if (modPlc == null)
+ throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+ PLCUtil plcConn = new PLCUtil(modPlc);
+ //鑾峰彇宸ヤ綅鐐逛綅淇℃伅
+ var portno = item.Port;
+ var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno).First();
+ var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.StationNum == portno && s.Text.Contains("2妤�")).First();
+ var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "1");//鍐欏叆寮�濮嬬粨鎵逛俊鍙�
+ if (ret.IsSucceed)
+ {
+ item.Status = "2";//缁撴壒涓�
+ }
+ else { throw new Exception("瀹屽伐缁撴壒淇″彿涓嬪彂缁橮LC閿欒"); }
+ }
+ _db.Updateable(item).ExecuteCommand();
+ return new ResponseFuMaModel() { Success = "0", Message = "鎺ュ彈瀹屽伐缁撴壒鏁伴噺鎴愬姛" };
}
- _db.Updateable(num).ExecuteCommand();
-
+
return new ResponseFuMaModel() { Success = "0", Message = "鎺ュ彈瀹屽伐缁撴壒鏁伴噺鎴愬姛" };
}
catch (Exception ex)
@@ -415,36 +475,42 @@
string str = JsonConvert.SerializeObject(models);
Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port+"鍏ュ簱鍙�");
- var portno = "";
+ var portno = models.Port;
+ var layer = "3";
switch (models.Port)
{
case "033":
portno = "33";
+ layer = "1";
break;
case "039":
portno = "39";
+ layer = "1";
break;
case "044":
portno = "44";
+ layer = "1";
break;
case "051":
portno = "51";
+ layer = "1";
break;
}
//妫�娴嬪叆搴撳彛鐘舵�侊紝120涓哄彲鏀撅紝鍗犵敤鍒欎慨鏀逛负130
-
- WcsDeviceDto mod = new WcsDeviceDto();
- var plcConn = mod.PLCUtil;
+ var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+ if (modPlc == null)
+ throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+ PLCUtil plcConn = new PLCUtil(modPlc);
//鑾峰彇宸ヤ綅鐐逛綅淇℃伅
var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First();
- var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "PLC娴佺▼瀛�").First();
+ var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "PLC").First();
var (res1, val) = plcConn.GetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos);
if (val.ToString() == "120")
{
//璇诲彇鎴愬姛鍚庡啓鍏�130
- modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First();
+ modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "130");//鍗犵敤姝ゅ伐浣�
if (ret.IsSucceed)
{
@@ -473,33 +539,40 @@
try
{
string str = JsonConvert.SerializeObject(models);
- Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
+ Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣璇锋眰锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
- var portno = "";
+ var portno = models.Port;
+ var layer = "3";
switch (models.Port)
{
case "033":
portno = "33";
+ layer = "1";
break;
case "039":
portno = "39";
+ layer = "1";
break;
case "044":
portno = "44";
+ layer = "1";
break;
case "051":
portno = "51";
+ layer = "1";
break;
}
- WcsDeviceDto mod = new WcsDeviceDto();
- var plcConn = mod.PLCUtil;
+ var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+ if (modPlc == null)
+ throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+ PLCUtil plcConn = new PLCUtil(modPlc);
//鑾峰彇宸ヤ綅鐐逛綅淇℃伅
var listPlcDevice = _db.Queryable<WcsDevice>().Where(s=>s.LedIP != null && s.StationNum == portno).First();
var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "浠诲姟鍙�").First();
plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, models.TaskNo);//鍐欏叆浠诲姟鍙�
//
- modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First();
+ modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "140");//鍐欏叆寮�濮嬫斁璐т俊鍙�
if (ret.IsSucceed)
{
@@ -529,30 +602,37 @@
try
{
string str = JsonConvert.SerializeObject(models);
- Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
+ Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣瀹屾垚锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
- var portno = "";
+ var portno = models.Port;
+ var layer = "3";
switch (models.Port)
{
case "033":
portno = "33";
+ layer = "1";
break;
case "039":
portno = "39";
+ layer = "1";
break;
case "044":
portno = "44";
+ layer = "1";
break;
case "051":
portno = "51";
+ layer = "1";
break;
}
- WcsDeviceDto mod = new WcsDeviceDto();
- var plcConn = mod.PLCUtil;
+ var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+ if (modPlc == null)
+ throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+ PLCUtil plcConn = new PLCUtil(modPlc);
//鑾峰彇宸ヤ綅鐐逛綅淇℃伅
var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First();
- var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First();
+ var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "160");//鏀惧畬鎴�
if (ret.IsSucceed)
--
Gitblit v1.8.0