From 9440c4980e1f2415fdc0d61005b7d245fc16483e Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期五, 07 三月 2025 09:52:31 +0800
Subject: [PATCH] 1.受托入库,初步完成

---
 entity/MesShouTuo.cs                       |   94 +++++++++
 entity/MesShouTuoDetail.cs                 |   64 ++++++
 service/Warehouse/MesStrkManager.cs        |  130 +++++++++++++
 Controllers/Warehouse/MesStrkController.cs |  255 +++++++++++++++++++++++++
 4 files changed, 543 insertions(+), 0 deletions(-)

diff --git a/Controllers/Warehouse/MesStrkController.cs b/Controllers/Warehouse/MesStrkController.cs
new file mode 100644
index 0000000..fdb9a09
--- /dev/null
+++ b/Controllers/Warehouse/MesStrkController.cs
@@ -0,0 +1,255 @@
+锘縰sing System.Dynamic;
+using Microsoft.AspNetCore.Mvc;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.Warehouse;
+using NewPdaSqlServer.util;
+
+namespace NewPdaSqlServer.Controllers.Warehouse;
+
+/// <summary>
+///     鐢熶骇琛ユ枡鐩稿叧鎺ュ彛
+/// </summary>
+[Route("api/[controller]")]
+[ApiController]
+public class MesStrkController : ControllerBase
+{
+    private readonly MesStrkManager _manager = new();
+
+    #region 鍩虹
+    /***杩涘叆妯$増绠$悊鍙互淇敼妯$増***/
+
+    /// <summary>
+    ///     鑾峰彇鎵�鏈�
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("GetList")]
+    public ResponseResult GetList()
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.GetList();
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     鏍规嵁涓婚敭鑾峰彇
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("GetById")]
+    public ResponseResult GetById(int id)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.GetById(id);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     鏍规嵁涓婚敭鍒犻櫎
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("DeleteByIds")]
+    public ResponseResult DeleteByIds([FromBody] object[] ids)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.DeleteByIds(ids);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     娣诲姞
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("Insert")]
+    public ResponseResult Add([FromBody] MesItemBl data)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.Insert(data);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     娣诲姞杩斿洖鑷
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("InsertReturnIdentity")]
+    public ResponseResult InsertReturnIdentity([FromBody] MesItemBl data)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.InsertReturnIdentity(data);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     淇敼
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("Update")]
+    public ResponseResult Update([FromBody] MesItemBl data)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.Update(data);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    #endregion
+
+
+    /// <summary>
+    ///     鑾峰彇鍙楁墭鍏ュ簱鐢宠鍒楄〃
+    /// </summary>
+    /// <returns>鍙楁墭鍏ュ簱鐢宠鍒楄〃</returns>
+    [HttpPost("GetStrkBillNo")]
+    public ResponseResult GetStrkBillNo(WarehouseQuery query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.GetStrkBillNo(query);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     鏍规嵁鍗曞彿鑾峰彇鍙楁墭鍏ュ簱鍗曟槑缁�
+    /// </summary>
+    /// <param name="query">鏌ヨ鍙傛暟</param>
+    /// <returns>鍙楁墭鍏ュ簱鍗曟槑缁嗗垪琛�</returns>
+    [HttpPost("GetMesItemDetailByBillNo")]
+    public ResponseResult GetMesItemDetailByBillNo(
+        [FromBody] WarehouseQuery query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.GetMesItemDetailByBillNo(query);
+
+            if (resultInfos.tbBillList.Count < 1)
+            {
+                return new ResponseResult
+                {
+                    status = 1,
+                    message = "璇ョ敵璇峰崟鍙蜂笉瀛樺湪鎴栨湭瀹℃牳锛侊紒锛�",
+                    data = ""
+                };
+            }
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭�
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("XsthScanBarcode")]
+    public ResponseResult XsthScanBarcode(WarehouseQuery unity)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = _manager.XsthScanBarcode(unity);
+            return new ResponseResult
+            {
+                status = 0,
+                message = resultInfos.tbBillList,
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+
+}
\ No newline at end of file
diff --git a/entity/MesShouTuo.cs b/entity/MesShouTuo.cs
new file mode 100644
index 0000000..cea7f65
--- /dev/null
+++ b/entity/MesShouTuo.cs
@@ -0,0 +1,94 @@
+锘縰sing SqlSugar;
+
+namespace MES.Service.Modes;
+
+/// <summary>
+///     鍙楁墭鍏ュ簱鐢宠
+/// </summary>
+[SugarTable("Mes_SHOU_TUO")]
+public class MesShouTuo
+{
+    /// <summary>
+    ///     涓婚敭
+    /// </summary>
+    [SugarColumn(ColumnName = "guid", IsPrimaryKey = true)]
+    public Guid? Guid { get; set; }
+
+    /// <summary>
+    ///     鍗曟嵁缂栧彿
+    /// </summary>
+    [SugarColumn(ColumnName = "billNo")]
+    public string? BillNo { get; set; }
+
+    /// <summary>
+    ///     瀹㈡埛ID
+    /// </summary>
+    [SugarColumn(ColumnName = "FCustId")]
+    public string? FCustId { get; set; }
+
+    /// <summary>
+    ///     搴撳瓨缁勭粐ID
+    /// </summary>
+    [SugarColumn(ColumnName = "FStockOrgId")]
+    public string? FStockOrgId { get; set; }
+
+    /// <summary>
+    ///     寤虹珛鏃ユ湡
+    /// </summary>
+    [SugarColumn(ColumnName = "createDate")]
+    public DateTime? CreateDate { get; set; }
+
+    /// <summary>
+    ///     寤虹珛鑰�
+    /// </summary>
+    [SugarColumn(ColumnName = "createBy")]
+    public string? CreateBy { get; set; }
+
+    /// <summary>
+    ///     鏇存柊鑰�
+    /// </summary>
+    [SugarColumn(ColumnName = "lastupdateBy")]
+    public string? LastUpdateBy { get; set; }
+
+    /// <summary>
+    ///     鏇存柊鏃ユ湡
+    /// </summary>
+    [SugarColumn(ColumnName = "lastupdateDate")]
+    public DateTime? LastUpdateDate { get; set; }
+
+    /// <summary>
+    ///     澶囨敞
+    /// </summary>
+    [SugarColumn(ColumnName = "remark")]
+    public string? Remark { get; set; }
+
+    /// <summary>
+    ///     鏀惰揣浠撳簱
+    /// </summary>
+    [SugarColumn(ColumnName = "FStockId")]
+    public string? FStockId { get; set; }
+
+    /// <summary>
+    ///     瀹℃牳浜�
+    /// </summary>
+    [SugarColumn(ColumnName = "checkBy")]
+    public string? CheckBy { get; set; }
+
+    /// <summary>
+    ///     瀹℃牳鏃堕棿
+    /// </summary>
+    [SugarColumn(ColumnName = "checkDate")]
+    public DateTime? CheckDate { get; set; }
+
+    /// <summary>
+    ///     鏄惁瀹℃牳
+    /// </summary>
+    [SugarColumn(ColumnName = "isCheck")]
+    public bool? IsCheck { get; set; }
+
+    /// <summary>
+    ///     鏄惁瀹屾垚
+    /// </summary>
+    [SugarColumn(ColumnName = "isFinish")]
+    public bool? IsFinish { get; set; }
+}
\ No newline at end of file
diff --git a/entity/MesShouTuoDetail.cs b/entity/MesShouTuoDetail.cs
new file mode 100644
index 0000000..278c717
--- /dev/null
+++ b/entity/MesShouTuoDetail.cs
@@ -0,0 +1,64 @@
+锘縰sing SqlSugar;
+
+namespace MES.Service.Models;
+
+/// <summary>
+///     鍙楁墭鍏ュ簱鐢宠鏄庣粏
+/// </summary>
+[SugarTable("Mes_SHOU_TUO_DETAIL")]
+public class MesShouTuoDetail
+{
+    /// <summary>
+    ///     涓婚敭
+    /// </summary>
+    [SugarColumn(ColumnName = "guid", IsPrimaryKey = true)]
+    public Guid? Guid { get; set; }
+
+    /// <summary>
+    ///     澶栭敭
+    /// </summary>
+    [SugarColumn(ColumnName = "pGuid")]
+    public Guid? PGuid { get; set; }
+
+    /// <summary>
+    ///     鐗╂枡ID
+    /// </summary>
+    [SugarColumn(ColumnName = "FMaterialId")]
+    public string? FMaterialId { get; set; }
+
+    /// <summary>
+    ///     瀹炴敹鏁伴噺
+    /// </summary>
+    [SugarColumn(ColumnName = "FQty")]
+    public decimal? FQty { get; set; }
+
+    /// <summary>
+    ///     搴撳瓨鍗曚綅
+    /// </summary>
+    [SugarColumn(ColumnName = "FUintId")]
+    public string? FUintId { get; set; }
+
+    /// <summary>
+    ///     鎵瑰彿
+    /// </summary>
+    [SugarColumn(ColumnName = "FLot")]
+    public string? FLot { get; set; }
+
+    /// <summary>
+    ///     澶囨敞
+    /// </summary>
+    [SugarColumn(ColumnName = "Remark")]
+    public string? Remark { get; set; }
+
+    /// <summary>
+    ///     鎺掑簭
+    /// </summary>
+    [SugarColumn(ColumnName = "Fidx")]
+    public int? FIdx { get; set; }
+
+    /// <summary>
+    ///     宸叉壂鏁伴噺
+    /// </summary>
+    [SugarColumn(ColumnName = "SQty")]
+    public decimal? SQty { get; set; }
+}
\ No newline at end of file
diff --git a/service/Warehouse/MesStrkManager.cs b/service/Warehouse/MesStrkManager.cs
new file mode 100644
index 0000000..e0a12d0
--- /dev/null
+++ b/service/Warehouse/MesStrkManager.cs
@@ -0,0 +1,130 @@
+锘縰sing Masuit.Tools;
+using MES.Service.Models;
+using MES.Service.Modes;
+using NewPdaSqlServer.DB;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using NewPdaSqlServer.util;
+using OracleInternal.Sharding;
+using SqlSugar;
+using SqlSugar.Extensions;
+using System.Data;
+using System.Data.SqlClient;
+
+namespace NewPdaSqlServer.service.Warehouse;
+
+public class MesStrkManager : Repository<MesItemBl>
+{
+    /// <summary>
+    ///     鑾峰彇鍙楁墭鍏ュ簱鐢宠鍒楄〃
+    /// </summary>
+    /// <returns>鍙楁墭鍏ュ簱鐢宠鍒楄〃</returns>
+    public List<string> GetStrkBillNo(WarehouseQuery query)
+    {
+        var list = Db.Queryable<MesShouTuo>()
+            .Where(s => s.IsCheck == true && s.IsFinish == false)
+            .Select(s => s.BillNo).ToList();
+
+        return list;
+    }
+
+    /// <summary>
+    ///     鏍规嵁鍗曞彿鑾峰彇MES鐗╂枡琛ㄦ槑缁�
+    /// </summary>
+    /// <param name="query">浠撳簱鏌ヨ鍙傛暟</param>
+    /// <returns>鐗╂枡鏄庣粏鍒楄〃</returns>
+    public List<ItemDetailModel> GetMesItemDetailByBillNo(
+        WarehouseQuery query)
+    {
+        // 鍏宠仈鏌ヨ鐗╂枡琛ㄣ�佺墿鏂欐槑缁嗚〃鍜岀墿鏂欏熀纭�淇℃伅琛�
+        var mesItemTblDetails = Db
+            .Queryable<MesShouTuo, MesShouTuoDetail, MesItems>(
+                (a, b, c) => new JoinQueryInfos(
+                    JoinType.Left,
+                    a.Guid == b.PGuid,
+                    JoinType.Left,
+                    b.FMaterialId == c.Id.ToString())
+            ).Where((a, b, c) => a.BillNo == query.billNo && a.IsCheck == true)
+            .Select<ItemDetailModel>((a, b, c) => new ItemDetailModel
+            {
+                ItemNo = c.ItemNo,
+                ItemName = c.ItemName,
+                ItemModel = c.ItemModel,
+                FQty = b.FQty, // 鐢宠鏁伴噺
+                SQty = b.SQty, // 宸叉壂鏁伴噺
+                Pid = b.PGuid.ToString(),
+                FMaterialId = b.FMaterialId,
+                Id = b.Guid.ToString()
+            }).ToList();
+
+        // 绛涢�夊嚭寰呴��鏁伴噺澶т簬宸查��鏁伴噺鐨勮褰�
+        //var itemTblDetails = mesItemTblDetails
+        //    .Where(s => (s.Tld005 ?? 0) - (s.Tld006 ?? 0) > 0).ToList();
+
+        return mesItemTblDetails;
+    }
+
+    /// <summary>
+    /// 鍙楁墭鍏ュ簱鍏ュ簱
+    /// </summary>
+    /// <param name="unity"></param>
+    /// <returns></returns>
+    /// <exception cref="Exception"></exception>
+    public string XsthScanBarcode(WarehouseQuery unity)
+    {
+        var _strMsg = "";
+        var _intSum = "";
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            if (unity.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+            if (unity.sectionCode.IsNullOrEmpty()) throw new Exception("搴撲綅缂栧彿涓嶅厑璁镐负绌�");
+            if (unity.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+            if (unity.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�");
+
+            using (var cmd = new SqlCommand("[prc_pda_inv_strk]", conn))
+            {
+                try
+                {
+                    conn.Open();
+                    cmd.CommandType = CommandType.StoredProcedure;
+                    SqlParameter[] parameters =
+                    {
+                        new("@po_outMsg", SqlDbType.NVarChar, 300),
+                        new("@po_outSum", SqlDbType.NVarChar, 300),
+                        //new("@po_womInBarSum", SqlDbType.NVarChar, 300),
+                        new("@pi_user", unity.userName),
+                        new("@pi_barcode", unity.barcode),
+                        new("@pi_sectionCode", unity.sectionCode),
+                        new("@pi_billno", unity.billNo),
+
+                    };
+                    parameters[0].Direction = ParameterDirection.Output;
+                    parameters[1].Direction = ParameterDirection.Output;
+                   // parameters[2].Direction = ParameterDirection.Output;
+
+                    foreach (var parameter in parameters)
+                        cmd.Parameters.Add(parameter);
+                    cmd.ExecuteNonQuery();
+                    _strMsg = parameters[0].Value.ToString();
+                    _intSum = parameters[1].Value.ToString();
+
+                    var result = Convert.ToInt32(_intSum);
+                    if (result <= 0) throw new Exception(_strMsg);
+
+                    return _strMsg;
+
+                    //return 0;
+
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3