From 38339731265cb8ffef7954fb90874036fd46f09d Mon Sep 17 00:00:00 2001
From: cdk <2441919651@qq.com>
Date: 星期一, 22 十二月 2025 09:46:11 +0800
Subject: [PATCH] 供应商分数获取调整
---
service/Warehouse/MesCgthSqManager.cs | 319 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 296 insertions(+), 23 deletions(-)
diff --git a/service/Warehouse/MesCgthSqManager.cs b/service/Warehouse/MesCgthSqManager.cs
index 97ad55d..3640c3b 100644
--- a/service/Warehouse/MesCgthSqManager.cs
+++ b/service/Warehouse/MesCgthSqManager.cs
@@ -4,39 +4,87 @@
using NewPdaSqlServer.DB;
using NewPdaSqlServer.Dto.service;
using NewPdaSqlServer.entity;
+using NewPdaSqlServer.entity.Base;
using SqlSugar;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace NewPdaSqlServer.service.Warehouse;
public class MesCgthSqManager : Repository<MesCgthSq>
{
- public List<MesCgthSq> GetMesCgthSq()
+ public dynamic GetMesCgthSq(dynamic RequestInfo)
{
- return Db.Queryable<MesCgthSq>()
- .Where(s => s.Status == true)
- .ToList();
+ var orgId = RequestInfo.OrgId;
+
+ if (orgId == null)
+ throw new Exception("缁勭粐涓嶅瓨鍦紒");
+
+ // 鑾峰彇鏈畬鎴愮殑閫�鏂欏崟鍙峰垪琛�
+ var parameters = new[]
+ {
+ new SugarParameter("@pi_orgId", orgId),
+ new SugarParameter("@inP1", null),
+ new SugarParameter("@inP2", null),
+ new SugarParameter("@inP3", null),
+ new SugarParameter("@inP4", null)
+ };
+ try
+ {
+ // 杩斿洖鍗曞彿瀛楃涓插垪琛�
+ var blDetails = Db.Ado.SqlQuery<string>(
+ "EXEC prc_pda_cgth_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
+ return blDetails;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"{ex.Message}");
+ }
}
- public OutItemDto GetSumItem(WarehouseQuery query)
+ public dynamic GetSumItem(WarehouseQuery query, dynamic RequestInfo)
{
- var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo);
- if (mesInvItemOuts == null) throw new Exception("閲囪喘閫�璐х敵璇峰崟涓嶅瓨鍦�");
+ if (string.IsNullOrEmpty(query.billNo))
+ throw new Exception("璇烽�夊崟鎹彿锛�");
- var dto = new OutItemDto();
- dto.SumItem = GetItems(query);
+ if (query == null)
+ throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓簄ull");
- var mesInvItemStocks = Db.Queryable<MesInvItemStocks>()
- .Where(a => a.ItemBarcode == query.barcode).Single();
+ if (string.IsNullOrEmpty(query.billNo?.ToString()))
+ throw new ArgumentException("鍗曟嵁鍙蜂笉鑳戒负绌�", nameof(query.billNo));
- if (mesInvItemStocks == null) return dto;
+ var orgId = RequestInfo.OrgId;
- var mesItems = Db.Queryable<MesItems>()
- .Where(s => s.Id == mesInvItemStocks.ItemId).Single();
+ if (orgId == null)
+ throw new Exception("缁勭粐涓嶅瓨鍦紒");
- dto.ItemNo = mesItems.ItemNo;
- dto.Quantity = mesInvItemStocks.Quantity;
-
- return dto;
+ // 鑾峰彇鏈畬鎴愮殑鍙戣揣閫氱煡鍗曟槑缁�
+ var parameters = new[]
+{
+ new SugarParameter("@billNo", query.billNo),
+ new SugarParameter("@pi_orgId",orgId),
+ new SugarParameter("@inP1", null),
+ new SugarParameter("@inP2", null),
+ new SugarParameter("@inP3", null),
+ new SugarParameter("@inP4", null)
+ };
+ try
+ {
+ List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>(
+ "EXEC prc_pda_cgth_detailList @billNo,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
+ var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 寰呮壂鐗╂枡
+ var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 宸叉壂鐗╂枡
+ return new
+ {
+ items = items,
+ ysitems = ysitems,
+ allList = blDetails
+ };
+ }
+ catch (Exception ex)
+ {
+ // 淇濈暀鍘熸湁寮傚父澶勭悊閫昏緫
+ throw new Exception($"{ex.Message}");
+ }
}
public List<MesCgthSqDetail> GetItems(WarehouseQuery query)
@@ -73,7 +121,7 @@
ItemNo = s.ItemNo, // 浠嶮esItems琛ㄤ腑鑾峰彇ItemNo
ItemName = s.ItemName, // 浠嶮esItems琛ㄤ腑鑾峰彇ItemName
ItemModel = s.ItemModel, // 浠嶮esItems琛ㄤ腑鑾峰彇ItemModel
- ItemId = c.ItemId,
+ ItemId = c.ItemId
}).ToList(); // 灏嗘煡璇㈢粨鏋滆浆鎹负鍒楄〃
return mesInvItemOutItemsList; // 杩斿洖澶勭悊鍚庣殑鍒楄〃
@@ -86,8 +134,7 @@
using (var conn = new SqlConnection(DbHelperSQL.strConn))
{
if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
- if (query.billNo.IsNullOrEmpty()) throw new Exception("棰嗘枡鍗曞彿涓嶅厑璁镐负绌�");
- if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+ if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�"); if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
using (var cmd = new SqlCommand("[prc_pda_CGTH]", conn))
{
@@ -123,10 +170,11 @@
var dto = new ProductionPickDto
{
- daa001 = query.daa001,
+ daa001 = query.billNo,
barcodeNum = barcodeNum,
splitNum = splitNum,
- barcode = query.barcode
+ barcode = query.barcode,
+ result = result.ToString()
};
return dto;
@@ -142,4 +190,229 @@
}
}
}
+
+
+ public ProductionPickDto ScanCodeCF(WarehouseQuery query)
+ {
+ if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+ if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�");
+ if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+
+ if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0");
+
+ var _strMsg = "";
+ var _intSum = "";
+ var _cfBar = "";//鎷嗗垎鍚庢潯鐮�
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("[prc_pda_CGTH_CF]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 2000),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@outCfBar", SqlDbType.NVarChar, 300),
+ new("@c_User", query.userName),
+ new("@p_biLL_no", query.billNo),
+ new("@p_item_barcode", query.barcode),
+ new("@num", query.Num)
+ };
+ 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();
+ _cfBar = parameters[2].Value.ToString();
+
+
+ var result = Convert.ToInt32(_intSum);
+ if (result <= 0) throw new Exception(_strMsg);
+
+ var dto = new ProductionPickDto
+ {
+ daa001 = query.billNo,
+ barcode = query.barcode,//鍘熸潯鐮�
+ cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮�
+ };
+
+ return dto;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// 閲囪喘鎵爜楠岄��
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ /// <exception cref="ArgumentNullException"></exception>
+ /// <exception cref="ArgumentException"></exception>
+ /// <exception cref="Exception"></exception>
+ public dynamic ScanCgyt(dynamic query)
+ {
+ if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+ // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛�
+ if (string.IsNullOrEmpty(query.userName?.ToString()))
+ throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+ if (string.IsNullOrEmpty(query.barcode?.ToString()))
+ throw new ArgumentException("閲囪喘鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(query.barcode));
+
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("prc_pda_scan_CGYT", conn))
+ {
+ cmd.CommandType = CommandType.StoredProcedure;
+ var parameters = new SqlParameter[]
+ {
+ new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+ new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = query.barcode },
+ new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+ new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output },
+ new("@po_ygdh", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }
+ };
+
+ cmd.Parameters.AddRange(parameters);
+ conn.Open();
+ cmd.ExecuteNonQuery();
+
+ var result = new
+ {
+ result = parameters[3].Value.ToString(),
+ barcode = query.barcode,
+ ytdh = parameters[4].Value.ToString(),
+ msg = parameters[2].Value.ToString()
+ };
+
+ if (result.result == "-1")
+ throw new Exception(parameters[2].Value.ToString());
+
+ return result;
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鍒犻櫎楠岄��鍗�
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ /// <exception cref="ArgumentNullException"></exception>
+ /// <exception cref="ArgumentException"></exception>
+ /// <exception cref="Exception"></exception>
+ public dynamic deleteCgyt(dynamic query)
+ {
+ if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+ // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛�
+ if (string.IsNullOrEmpty(query.userName?.ToString()))
+ throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+ if (string.IsNullOrEmpty(query.ytdh?.ToString()))
+ throw new ArgumentException("杩芥函鐮佷笉鍏佽涓虹┖", nameof(query.ytdh));
+
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("prc_pda_delete_CGYT", conn))
+ {
+ cmd.CommandType = CommandType.StoredProcedure;
+ var parameters = new SqlParameter[]
+ {
+ new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+ new("@pi_ytdh", SqlDbType.NVarChar, 100) { Value = query.ytdh },
+ new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+ new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+ };
+
+ cmd.Parameters.AddRange(parameters);
+ conn.Open();
+ cmd.ExecuteNonQuery();
+
+ var result = new
+ {
+ result = parameters[3].Value.ToString(),
+ msg = parameters[2].Value.ToString(),
+ };
+
+ if (result.result == "-1")
+ throw new Exception(parameters[2].Value.ToString());
+
+ return result;
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇楠岄��鍗曞凡鎵墿鏂欎俊鎭�
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ public dynamic getYtItem(string ytdh)
+ {
+ if (string.IsNullOrEmpty(ytdh?.ToString()))
+ throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh));
+
+ var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) };
+
+ var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity
+FROM MES_INV_ITEM_CGYT_ITEMS A
+ LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID
+ LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id
+WHERE B.item_cgyt_no = @ytdh";
+
+ var YtItem = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams);
+
+ //if (YtItem.Count < 1)
+ //{
+ // throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}鐗╂枡鏄庣粏涓嶅瓨鍦紒");
+ //}
+
+ return YtItem;
+ }
+
+ /// <summary>
+ /// 鑾峰彇楠岄��鍗曞凡鎵潯鐮佷俊鎭�
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ public dynamic getYtBarInfo(string ytdh)
+ {
+ if (string.IsNullOrEmpty(ytdh?.ToString()))
+ throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh));
+
+ var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) };
+
+ var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity,A.ITEM_BARCODE
+FROM MES_INV_ITEM_CGYT_C_DETAILS A
+ LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID
+ LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id
+WHERE B.item_cgyt_no = @ytdh";
+
+ var YtBarInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams);
+
+ //if (YtBarInfo.Count < 1)
+ //{
+ // throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}浠栦滑涓嶅瓨鍦紒");
+ //}
+
+ return YtBarInfo;
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3