From e4690fca932b352927af3d186ed2a4767f017e79 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 17 八月 2025 15:02:37 +0800
Subject: [PATCH] 修改问题
---
Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 213 insertions(+), 10 deletions(-)
diff --git a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
index bc403f1..ee7fe90 100644
--- a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
+++ b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
@@ -1,4 +1,10 @@
-锘縰sing Elastic.Clients.Elasticsearch;
+锘縰sing AngleSharp.Io;
+using COSXML.Network;
+using Elastic.Clients.Elasticsearch;
+using Elastic.Clients.Elasticsearch.Inference;
+using Furion.Logging;
+using NewLife.Http;
+using Newtonsoft.Json;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
@@ -30,7 +36,7 @@
//}
// <summary>
- /// WCS鎺ュ彈WMS涓嬪彂鐨勪换鍔�(鍗曟潯浠诲姟)
+ /// WCS鎺ュ彈WMS涓嬪彂鐨勪换鍔�
/// </summary>
/// <param name="models">浠诲姟淇℃伅</param>
/// <returns>鍙嶉淇℃伅</returns>
@@ -89,19 +95,21 @@
{
models.Order = 2;
}
- //鏂板浠诲姟
+
+ int aaa = int.Parse(models.TaskType);
var taskAdd = new WcsTask()
{
TaskNo = models.TaskNo,
- TaskType = TaskTypeEnum.Out,
+ TaskType = (TaskTypeEnum)aaa,
Status = TaskStatusEnum.Wait,
//IsSuccess =TaskSuccessEnum.Success,
Origin = "WMS",
- StartRoadway= models.StartRoadway,
+ StartRoadway = models.StartRoadway,
StartLocate = models.StartLocate,
EndLocate = models.EndLocate,
- EndRoadway= models.EndRoadway,
+ EndRoadway = models.EndRoadway,
PalletNo = models.PalletNo,
+ Levels = 999
//LotNo =models.LotNo,
//SkuNo=models.SkuNo,
@@ -137,14 +145,15 @@
//{
var orderAdd = new WcsOderTask()
{
- OrderNo = item.OrderNo,
+ OrderNo = item.OrderNo.Trim(),
TaskNo = "",
- LotNo = item.LotNo,
- SkuNo = item.SkuNo,
- SkuName = item.SkuName,
+ LotNo = item.LotNo.Trim(),
+ SkuNo = item.SkuNo.Trim(),
+ SkuName = item.SkuName.Trim(),
BoxType = item.BoxType,
Qty = item.Qty,
TaskType = (TaskTypeEnum)item.TaskType,
+ Status=TaskStatusEnum.Wait
};
_db.Insertable(orderAdd).ExecuteCommand();
//}
@@ -157,4 +166,198 @@
}
}
+ /// <summary>
+ /// 鑾峰彇绌烘墭鐩樺灈鐢宠鍏ュ簱宸ヤ綅
+ /// </summary>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public ResponseModel GetNullPalletRukuStation()
+ {
+ try
+ {
+ string rukuAdress = "";
+ var conveyList4 = new List<string>() { "266", "265" };//鍥涙ゼ鍏ュ簱宸ヤ綅
+ foreach (var item in conveyList4)
+ {
+ // 鏍规嵁鐩爣宸ヤ綅鍙疯幏鍙栬緭閫佺嚎閾炬帴
+ var plcCconn = PLCCommon.GetPlcIp(item);
+ // 璇诲彇鐩爣宸ヤ綅褰撳墠鐘舵��
+ var ConveyorMod = PLCTaskAction.plcDevices.First(m => m.StationNum == item && m.DeviceType == DeviceTypeEnum.Business);
+ var (result, value) = plcCconn.GetPlcDBValue(ConveyorMod.PosType, ConveyorMod.DbNumber, ConveyorMod.PlcPos);
+ if (result.IsSucceed)
+ {
+ if (value.ToString() == "120")//绌洪棽鐘舵��
+ {
+ // 鍒ゆ柇璇ュ伐浣嶆槸鍚﹀瓨鍦ㄦ湭瀹屾垚鐨勫嚭搴撲换鍔�
+ var modInTask = _db.Queryable<WcsTask>().OrderBy(m => m.Levels, OrderByType.Asc).OrderBy(m => m.CreateTime, OrderByType.Asc)
+ .First(s => (s.Status == TaskStatusEnum.Wait || s.Status == TaskStatusEnum.Doing) && s.TaskType == TaskTypeEnum.Out && s.EndLocate == item);
+
+ if (modInTask == null)
+ {
+ // 鑻ョ┖闂插苟娌℃湁鏈畬鎴愮殑鍑哄簱浠诲姟鎻愬墠鍗犵敤姝ゅ伐浣�
+ var ret = plcCconn.SetPlcDBValue(ConveyorMod.PosType, ConveyorMod.DbNumber, ConveyorMod.WcsPos, "130");
+ if (ret.IsSucceed)
+ {
+ rukuAdress = item;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!string.IsNullOrEmpty(rukuAdress))
+ {
+ return new ResponseModel() { StatusCode = 0, Msg = rukuAdress };
+ }
+ else
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = "鏃犵┖闂插叆搴撳伐浣�" };
+ }
+ }
+ catch (Exception ex)
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = ex.Message };
+ }
+ }
+ /// <summary>
+ /// 灏忚溅鍏ュ簱鍙f斁璐у畬鎴愶紝WMS璋冪敤WCS鏇存敼PLC
+ /// </summary>
+ /// <param name="StationNum"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public ResponseModel UpdatePlcPosAgvTaskFinsh(AgvTaskFinshModel model)
+ {
+ try
+ {
+ var conveyList4 = new List<string>() { "266", "265" };//鍥涙ゼ鍏ュ簱宸ヤ綅
+ if (!conveyList4.Contains(model.StationNum))
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = "宸ヤ綅鍙锋棤鏁�" };
+ }
+ // 鏍规嵁鐩爣宸ヤ綅鍙疯幏鍙栬緭閫佺嚎閾炬帴
+ var plcCconn = PLCCommon.GetPlcIp(model.StationNum);
+ // 璇诲彇鐩爣宸ヤ綅褰撳墠鐘舵��
+ var ConveyorMod = PLCTaskAction.plcDevices.First(m => m.StationNum == model.StationNum && m.DeviceType == DeviceTypeEnum.Business);
+ var (result, value) = plcCconn.GetPlcDBValue(ConveyorMod.PosType, ConveyorMod.DbNumber, ConveyorMod.PlcPos);
+ if (result.IsSucceed)
+ {
+ if (value.ToString() != "150")//绌洪棽鐘舵��
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = "宸ヤ綅鍙稰LC鐘舵�佸紓甯�" };
+ }
+ // 鍐欏叆160锛屾斁璐у畬鎴�
+ var ret = plcCconn.SetPlcDBValue(ConveyorMod.PosType, ConveyorMod.DbNumber, ConveyorMod.WcsPos, "160");
+ if (ret.IsSucceed)
+ {
+ return new ResponseModel() { StatusCode = 0, Msg = "鎴愬姛" };
+ }
+ else
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = "鍐欏叆PLC澶辫触" };
+ }
+ }
+ else
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = "杩炴帴PLC澶辫触" };
+ }
+ }
+ catch (Exception ex)
+ {
+ return new ResponseModel() { StatusCode = -1, Msg = ex.Message };
+ }
+ }
+
+ /// <summary>
+ /// WCS鎺ュ彈璧嬬爜绯荤粺鎺ㄩ�佺殑绠辩爜淇℃伅
+ /// </summary>
+ /// <param name="models">绠辩爜淇℃伅</param>
+ /// <returns>鍙嶉淇℃伅</returns>
+ [HttpPost("AddHttpBoxInfo")]
+ [AllowAnonymous]
+ public ResponseFuMaModel AddHttpBoxInfo(FumaBoxModel models)
+ {
+ try
+ {
+ string str = JsonConvert.SerializeObject(models);
+ Log.Information("鎺ユ敹璧嬬爜鎺ㄩ�佺殑绠辩爜淇℃伅锛�" + str);
+
+ var num = _db.Queryable<WcsBoxInfo>().Where(m => m.BoxNo == models.Product.BoxNo && m.IsDelete == false).ToList();
+ var type = "add";
+ if (num.Count > 0)
+ {
+ //WCS瀛樺湪绠辩爜淇℃伅锛屾洿鏂扮鐮佷俊鎭�(闇�鍒ゆ柇绠辩爜鏄惁宸茬粍鐩樺叆搴�)
+ var num2 = num.Count(m => m.Status != "0" || !string.IsNullOrWhiteSpace(m.PalletNo));
+ if (num2 > 0)
+ {
+ throw new Exception("璇ョ宸插叆鐩樺叆搴擄紝涓嶅彲鏇存柊淇℃伅");
+ }
+ type = "edit";
+ }
+
+ if (models.Product.Barcodes.Count == 0)
+ {
+ throw new Exception("鐩掔爜闆嗗悎涓嶈兘涓虹┖");
+ }
+
+ var listBox = new List<WcsBoxInfo>();
+ foreach (var item in models.Product.Barcodes)
+ {
+ if (string.IsNullOrWhiteSpace(models.Product.ProductionTime) || string.IsNullOrWhiteSpace(models.Product.ExpirationTime))
+ {
+ throw new Exception("鐢熶骇鏃ユ湡鎴栬繃鏈熸棩鏈熶笉鑳戒负绌�");
+ }
+ DateTime proTime;
+ DateTime expTime;
+ var isValid = DateTime.TryParse(models.Product.ProductionTime, out proTime);
+ var isValid2 = DateTime.TryParse(models.Product.ExpirationTime, out expTime);
+ if (!isValid || !isValid2)
+ {
+ throw new Exception("鐢熶骇鏃ユ湡鎴栧け鏁堟棩鏈熸牸寮忛敊璇�");
+ };
+
+ var boxAdd = new WcsBoxInfo()
+ {
+ SkuNo = models.Product.SkuNo,
+ SkuName = models.Product.SkuName,
+ LotNo = models.Product.LotNo,
+ LotText = models.Product.LotText,
+ Custom = models.Product.Custom,
+ CustomName = models.Product.CustomName,
+ ProductionTime = proTime,
+ ExpirationTime = expTime,
+ LineNo=models.Product.Line_No,
+ Standard = models.Product.Standard,
+ PackageStandard = models.Product.PackageStandard,
+ PackUnit = models.Product.PackUnit,
+ StoreTime = DateTime.Parse(models.Product.StoreTime),
+ BitBoxMark = models.Product.BitBoxMark,
+ BoxNo = models.Product.BoxNo,
+ Qty = 1,//鏁伴噺
+ FullQty = 0,//鏁寸鏁伴噺
+ InsPectMark = models.Product.InsPectMark,//鎶芥鏍囪
+ BoxNo2 = item.BoxNo2,
+ BoxNo3 = "",
+ Level = item.Level,
+ EndLotFlag = string.IsNullOrWhiteSpace(models.Product.BitBoxMark) ? "0" : models.Product.BitBoxMark,//缁撴壒鏍囪瘑
+ QtyCount = 0,//鎬讳欢鏁�
+ QtyOrd = 0,//绗嚑浠�
+ Status = "0",
+ IsDelete = false
+ };
+ listBox.Add(boxAdd);
+ }
+ _db.Insertable(listBox).ExecuteCommand();
+ if (type == "edit")
+ {
+ _db.Deleteable(num).ExecuteCommand();
+ }
+ return new ResponseFuMaModel() { Success = true, Message = "ok" };
+ }
+ catch (Exception ex)
+ {
+ return new ResponseFuMaModel() { Success = false, Message = ex.Message };
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0