From e2778527b8db64879a5080a64669e5dd9ab016d2 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期五, 05 十二月 2025 13:32:04 +0800
Subject: [PATCH] 111
---
StandardPda/MES.Service/Dto/service/GetTransferListResponse.cs | 25 +++
StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs | 113 ++++++++++++++++
StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs | 166 +++++++++++++++++++++++
StandardPda/MES.Service/Modes/MesPalletBinding1.cs | 96 +++++++++++++
4 files changed, 400 insertions(+), 0 deletions(-)
diff --git a/StandardPda/MES.Service/Dto/service/GetTransferListResponse.cs b/StandardPda/MES.Service/Dto/service/GetTransferListResponse.cs
new file mode 100644
index 0000000..737cedf
--- /dev/null
+++ b/StandardPda/MES.Service/Dto/service/GetTransferListResponse.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+
+namespace MES.Service.Dto.service
+{
+ public class GetTransferListResponse
+ {
+ public int Code { get; set; }
+ public string Msg { get; set; }
+ public TransferListData Data { get; set; }
+ }
+
+ public class TransferListData
+ {
+ public string StackCode { get; set; }
+ public List<SnItem> SnList { get; set; }
+ }
+
+ public class SnItem
+ {
+ public string SnNo { get; set; }
+ public string TickeNo { get; set; }
+ public string SnStatus { get; set; }
+ public string MediumBoxCode { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/StandardPda/MES.Service/Modes/MesPalletBinding1.cs b/StandardPda/MES.Service/Modes/MesPalletBinding1.cs
new file mode 100644
index 0000000..c256891
--- /dev/null
+++ b/StandardPda/MES.Service/Modes/MesPalletBinding1.cs
@@ -0,0 +1,96 @@
+using SqlSugar;
+
+namespace MES.Service.Modes;
+
+/// <summary>
+/// 鏍堟澘缁戝畾淇℃伅琛�
+/// </summary>
+[SugarTable("MES_PALLET_BINDING")]
+public class MesPalletBinding1
+{
+ /// <summary>
+ /// 涓婚敭ID
+ /// </summary>
+ [SugarColumn(ColumnName = "ID",
+ OracleSequenceName = "SEQ_MES_PALLET_BINDING_ID",
+ IsPrimaryKey = true)]
+ public decimal Id { get; set; }
+
+ /// <summary>
+ /// 鏍堟澘鐮�
+ /// </summary>
+ [SugarColumn(ColumnName = "STACKCODE")]
+ public string Stackcode { get; set; }
+
+ /// <summary>
+ /// 鐧诲綍鍙�
+ /// </summary>
+ [SugarColumn(ColumnName = "LOGIN_ID")]
+ public string LoginId { get; set; }
+
+ /// <summary>
+ /// SN鍙�
+ /// </summary>
+ [SugarColumn(ColumnName = "SN_NO")]
+ public string SnNo { get; set; }
+
+ /// <summary>
+ /// 宸ュ崟鍗曞彿
+ /// </summary>
+ [SugarColumn(ColumnName = "TICKET_NO")]
+ public string TicketNo { get; set; }
+
+ /// <summary>
+ /// 涓鐮�
+ /// </summary>
+ [SugarColumn(ColumnName = "MEDIUMBOXCODE")]
+ public string Mediumboxcode { get; set; }
+
+ /// <summary>
+ /// 鍒涘缓鏃堕棿(瑙g粦鏃堕棿)
+ /// </summary>
+ [SugarColumn(ColumnName = "CREATE_DATE")]
+ public DateTime? CreateDate { get; set; }
+
+ /// <summary>
+ /// 鍒涘缓浜�
+ /// </summary>
+ [SugarColumn(ColumnName = "CREATED_BY")]
+ public string CreatedBy { get; set; }
+
+ /// <summary>
+ /// 鍏ュ簱鏍囪瘑锛�0-鏈叆搴擄紝1-宸插叆搴擄紝2-宸查攢鍞嚭搴擄紝榛樿0
+ /// </summary>
+ [SugarColumn(ColumnName = "IS_INBOUND")]
+ public decimal IsInbound { get; set; }
+
+ /// <summary>
+ /// 鍏ュ簱鏃堕棿
+ /// </summary>
+ [SugarColumn(ColumnName = "INBOUND_TIME")]
+ public DateTime? InboundTime { get; set; }
+
+ /// <summary>
+ /// 浜ф祴鏍堟澘缁戝畾鏃堕棿(鎺ュ彛TransitTime)
+ /// </summary>
+ [SugarColumn(ColumnName = "BIND_TRANSIT_TIME")]
+ public DateTime? BindTransitTime { get; set; }
+
+ /// <summary>
+ /// 绾夸綋缂栫爜
+ /// </summary>
+ [SugarColumn(ColumnName = "LINE_NO")]
+ public string LineNo { get; set; }
+
+ /// <summary>
+ /// 鍏ュ簱鍗曞彿
+ /// </summary>
+ [SugarColumn(ColumnName = "RK_NO")]
+ public string RkNo { get; set; }
+
+ /// <summary>
+ /// 鍏ュ簱鏉$爜
+ /// </summary>
+ [SugarColumn(ColumnName ="RK_CODE")]
+ public string RkCode { get; set; }
+}
diff --git a/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs b/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs
new file mode 100644
index 0000000..75ef3a3
--- /dev/null
+++ b/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs
@@ -0,0 +1,166 @@
+using MES.Service.DB;
+using MES.Service.Dto.service;
+using MES.Service.Modes;
+using Newtonsoft.Json;
+using System.Text;
+
+namespace MES.Service.service.Warehouse;
+
+public class MesPalletBinding1Manager : Repository<MesPalletBinding1>
+{
+ /// <summary>
+ /// 璋冪敤鎺ュ彛鑾峰彇鏍堟澘缁戝畾淇℃伅
+ /// </summary>
+ /// <param name="stackCode">鏍堟澘鐮�</param>
+ /// <returns>鎺ュ彛杩斿洖缁撴灉</returns>
+ public async Task<GetTransferListResponse> GetTransferListByStackCodeAsync(
+ MesPalletBinding palletBinding)
+ {
+ try
+ {
+ // API URL
+ string apiUrl =
+ "http://no2api.dream-maker.com/bu/storage/pallet/getTransferList";
+
+ // 鏋勫缓璇锋眰浣�
+ var requestData = new { stackCode = palletBinding.StackCode };
+ var jsonContent = JsonConvert.SerializeObject(requestData);
+ var content = new StringContent(jsonContent, Encoding.UTF8,
+ "application/json");
+
+ // 鍙戦�丠TTP璇锋眰
+ using (var httpClient = new HttpClient())
+ {
+ var response = await httpClient.PostAsync(apiUrl, content);
+ var responseContent =
+ await response.Content.ReadAsStringAsync();
+
+ // 鍙嶅簭鍒楀寲鍝嶅簲
+ var result =
+ JsonConvert.DeserializeObject<GetTransferListResponse>(
+ responseContent);
+ return result;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"璋冪敤鎺ュ彛鑾峰彇鏍堟澘缁戝畾淇℃伅澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓�
+ /// </summary>
+ /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+ /// <returns>鎻掑叆璁板綍鏁�</returns>
+ public int InsertPalletBindingData(MesPalletBinding palletBinding)
+ {
+ var response = GetTransferListByStackCodeAsync(palletBinding).Result;
+
+ if (response?.Data?.SnList == null || string.IsNullOrEmpty(response.Data.StackCode))
+ {
+ return 0;
+ }
+
+ int insertedCount = 0;
+
+ try
+ {
+ // 鍑嗗瑕佹彃鍏ョ殑鏁版嵁鍒楄〃
+ var bindingList = new List<MesPalletBinding1>();
+
+ foreach (var snItem in response.Data.SnList)
+ {
+ var binding = new MesPalletBinding1
+ {
+ Stackcode = response.Data.StackCode,
+ SnNo = snItem.SnNo,
+ TicketNo = snItem.TickeNo,
+ Mediumboxcode = snItem.MediumBoxCode,
+ CreateDate = DateTime.Now,
+ IsInbound = 0 // 榛樿鏈叆搴�
+ };
+
+ bindingList.Add(binding);
+ }
+
+ // 鎵归噺鎻掑叆鏁版嵁鍒版暟鎹簱
+ if (bindingList.Any())
+ {
+ // 鎵归噺鎻掑叆鏂版暟鎹�
+ var insertedIds = Db.Insertable(bindingList).PageSize(1)
+ .IgnoreColumnsNull()
+ .ExecuteCommand();
+ insertedCount = insertedIds;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"鎻掑叆鏍堟澘缁戝畾鏁版嵁澶辫触: {ex.Message}");
+ }
+
+ return insertedCount;
+ }
+
+ /// <summary>
+ /// 妫�鏌ユ爤鏉跨爜鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦�
+ /// </summary>
+ /// <param name="stackCode">鏍堟澘鐮�</param>
+ /// <returns>瀛樺湪杩斿洖true锛屽惁鍒欒繑鍥瀎alse</returns>
+ public bool CheckStackCodeExists(string stackCode)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(stackCode))
+ {
+ return false;
+ }
+
+ // 鏌ヨMES_PALLET_BINDING琛ㄤ腑鏄惁瀛樺湪璇ユ爤鏉跨爜鐨勬暟鎹�
+ var exists = Db.Queryable<MesPalletBinding1>()
+ .Any(x => x.Stackcode == stackCode);
+
+ return exists;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"妫�鏌ユ爤鏉跨爜鏄惁瀛樺湪鏃跺嚭閿�: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓紙甯﹀瓨鍦ㄦ�ф鏌ワ級
+ /// </summary>
+ /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ public async Task<int> InsertPalletBindingDataWithCheckAsync(MesPalletBinding palletBinding)
+ {
+ // 鍏堟鏌ユ爤鏉跨爜鏄惁瀛樺湪
+ bool exists = CheckStackCodeExists(palletBinding.StackCode);
+ return exists ? 1 :
+ // 璋冪敤鍘熸潵鐨勬彃鍏ユ柟娉�
+ InsertPalletBindingData(palletBinding);
+ }
+
+ /// <summary>
+ /// 鏍规嵁鏍堟澘鐮佸垹闄ゆ棫鏁版嵁
+ /// </summary>
+ /// <param name="stackCode">鏍堟澘鐮�</param>
+ /// <returns>鍒犻櫎璁板綍鏁�</returns>
+ private async Task<int> DeleteByStackCodeAsync(string stackCode)
+ {
+ try
+ {
+ var deleteResult = await Db.Deleteable<MesPalletBinding1>()
+ .Where(x => x.Stackcode == stackCode)
+ .ExecuteCommandAsync();
+ return deleteResult;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍閿欒浣嗕笉鎶涘嚭寮傚父锛屽厑璁告彃鍏ユ搷浣滅户缁�
+ Console.WriteLine($"鍒犻櫎鏃ф暟鎹椂鍑洪敊: {ex.Message}");
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs b/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs
new file mode 100644
index 0000000..801c57a
--- /dev/null
+++ b/StandardPda/MESApplication/Controllers/Warehouse/MesPalletBinding1Controller.cs
@@ -0,0 +1,113 @@
+using MES.Service.Dto.service;
+using MES.Service.Modes;
+using MES.Service.service;
+using MES.Service.service.Warehouse;
+using MES.Service.util;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+
+namespace MESApplication.Controllers.Warehouse
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class MesPalletBinding1Controller : ControllerBase
+ {
+ private readonly MessageCenterManager _manager = new();
+ private readonly MesPalletBinding1Manager m = new();
+ private readonly string METHOD = "POST";
+ private readonly string TableName = "mespalletbinding1";
+
+ private readonly string URL =
+ "http://localhost:10054/api/mespalletbinding1/";
+
+ /// <summary>
+ /// 浠庡閮ㄦ帴鍙h幏鍙栨爤鏉跨粦瀹氫俊鎭苟淇濆瓨鍒版暟鎹簱
+ /// </summary>
+ /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+ /// <returns></returns>
+ [HttpPost("SavePalletBindingData")]
+ public ResponseResult SavePalletBindingData([FromBody] MesPalletBinding palletBinding)
+ {
+ try
+ {
+ // 璋冪敤涓氬姟閫昏緫灞傛柟娉曞皢鏁版嵁淇濆瓨鍒版暟鎹簱
+ int insertedCount = m.InsertPalletBindingData(palletBinding);
+
+ if (insertedCount > 0)
+ {
+ return new ResponseResult
+ {
+ status = 0,
+ message = $"鎴愬姛鎻掑叆 {insertedCount} 鏉℃爤鏉跨粦瀹氭暟鎹�",
+ data = insertedCount
+ };
+ }
+ else
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "鏈彃鍏ヤ换浣曟暟鎹紝鍙兘鏄洜涓烘帴鍙h繑鍥炵殑鏁版嵁涓虹┖",
+ data = null
+ };
+ }
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 妫�鏌ユ爤鏉跨爜鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦�
+ /// </summary>
+ /// <param name="stackCode">鏍堟澘鐮�</param>
+ /// <returns></returns>
+ [HttpPost("CheckStackCodeExists")]
+ public ResponseResult CheckStackCodeExists([FromBody] dynamic request)
+ {
+ try
+ {
+ string stackCode = request.stackCode;
+ bool exists = m.CheckStackCodeExists(stackCode);
+
+ return new ResponseResult
+ {
+ status = 0,
+ message = exists ? "鏍堟澘鐮佸凡瀛樺湪" : "鏍堟澘鐮佷笉瀛樺湪",
+ data = exists
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 浠庡閮ㄦ帴鍙h幏鍙栨爤鏉跨粦瀹氫俊鎭苟淇濆瓨鍒版暟鎹簱锛堝甫瀛樺湪鎬ф鏌ワ級
+ /// </summary>
+ /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+ /// <returns></returns>
+ [HttpPost("SavePalletBindingDataWithCheck")]
+ public async Task<ResponseResult> SavePalletBindingDataWithCheck([FromBody] MesPalletBinding palletBinding)
+ {
+ try
+ {
+ // 璋冪敤涓氬姟閫昏緫灞傛柟娉曞皢鏁版嵁淇濆瓨鍒版暟鎹簱锛堝甫瀛樺湪鎬ф鏌ワ級
+ int result = await m.InsertPalletBindingDataWithCheckAsync(palletBinding);
+
+ return new ResponseResult
+ {
+ status = 0,
+ message = result > 0 ? $"鎴愬姛澶勭悊 {result} 鏉℃爤鏉跨粦瀹氭暟鎹�" : "鏈鐞嗕换浣曟暟鎹紝鍙兘鏄洜涓烘帴鍙h繑鍥炵殑鏁版嵁涓虹┖",
+ data = result
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3