From eea07b9c06f8a9070abe23816d02ae4fd73b4fa3 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期三, 25 六月 2025 14:48:18 +0800
Subject: [PATCH] 1.金蝶及时库存调用
---
service/QC/IpqcService.cs | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 215 insertions(+), 10 deletions(-)
diff --git a/service/QC/IpqcService.cs b/service/QC/IpqcService.cs
index 58c47fb..d6c87f0 100644
--- a/service/QC/IpqcService.cs
+++ b/service/QC/IpqcService.cs
@@ -5,6 +5,9 @@
using NewPdaSqlServer.entity;
using NewPdaSqlServer.util;
using SqlSugar;
+using System.Data;
+using System.Data.SqlClient;
+using System.Text;
using static Azure.Core.HttpHeader;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
@@ -85,7 +88,11 @@
a.Order,
a.Ybsl,
a.ISRZXX,
- a.IPQCRZXX
+ a.IPQCRZXX,
+ a.IPQCRZXXDate,
+ a.IPQCRZXXNum,
+ a.IPQCpscs,
+ a.FcheckType,
}).Select((a, b) => new MesQaItemsDetectDetail5
{
Guid = a.Guid,
@@ -110,7 +117,11 @@
Ybsl = a.Ybsl,
YbslIn = Ybsl_In,
ISRZXX = a.ISRZXX,
- IPQCRZXX = a.IPQCRZXX
+ IPQCRZXX = a.IPQCRZXX,
+ IPQCRZXXDate = a.IPQCRZXXDate.ToString(),
+ IPQCRZXXNum = a.IPQCRZXXNum,
+ IPQCpscs = a.IPQCpscs,
+ FcheckType =a.FcheckType,
}).OrderBy(a => a.Order)
.ToList();
}
@@ -142,6 +153,7 @@
a => a.Guid == parsedGuid.ToString())
.Where(a => (a.FSubmit ?? 0) == 0)
.OrderByDescending(a => a.CreateDate)
+ .OrderBy(a => a.checkTimeSlot)
.ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
return (pageList, totalCount);
@@ -149,19 +161,212 @@
//鏇存柊涓嶅悎鏍兼弿杩�
- public int updateIpqcRzxx(LLJDto dto)
+ public int updateIpqcRzxx(dynamic dto)
{
if (dto == null) throw new ArgumentNullException(nameof(dto), "鍙傛暟瀵硅薄涓嶈兘涓� null");
-
- // 鍙傛暟鏍¢獙锛堟牴鎹瓨鍌ㄨ繃绋嬫柊澧炲弬鏁帮級
if (string.IsNullOrEmpty(dto.pid?.ToString()))
throw new ArgumentException("椤圭洰鏄庣粏id瀛樺湪闂锛岃鑱旂郴绠$悊鍛橈紒", nameof(dto.pid));
- var withOracle = Db.Updateable<MesQaItemsDetectDetail5>()
- .SetColumns(s => s.IPQCRZXX == dto.inRzxxValue)
- .Where(s => s.Guid.ToString() == dto.pid)
- .ExecuteCommand();
+ var sqlParams = new List<SugarParameter> {
+ new("@inRzxxValue", dto.inRzxxValue),
+ new("@pid", dto.pid)
+ };
- return withOracle;
+ var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5
+ SET ipqc_rzxx = @inRzxxValue
+ WHERE guid = @pid";
+
+ return Db.Ado.ExecuteCommand(sql, sqlParams);
+ }
+
+
+ public dynamic CreateByWomdaa(dynamic query)
+ {
+ if (query == null) throw new ArgumentNullException(nameof(query));
+
+ if (string.IsNullOrEmpty(query.userAccount?.ToString()))
+ throw new ArgumentException("鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖", nameof(query.userAccount));
+
+ if (string.IsNullOrEmpty(query.inOrderGuid1?.ToString()))
+ throw new ArgumentException("妫�楠屽崟GUID涓嶈兘涓虹┖", nameof(query.inOrderGuid1));
+
+ if (string.IsNullOrEmpty(query.DAA001?.ToString()))
+ throw new ArgumentException("宸ュ崟鍙蜂笉鑳戒负绌�", nameof(query.inOrderGuid1));
+
+ var _strMsg = "";
+ var _status = -1;
+
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ using (var cmd = new SqlCommand("ipqc_createByWomdaa", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+
+ SqlParameter[] parameters =
+ {
+ new("@po_outMsg", SqlDbType.NVarChar, 150) { Direction = ParameterDirection.Output },
+ new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output },
+ new("@pi_user", SqlDbType.NVarChar, 150) { Value = query.userAccount },
+ new("@pi_OrderGuid1", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(query.inOrderGuid1.ToString()) },
+ new("@pi_DAA001", SqlDbType.NVarChar, 150) { Value = query.DAA001.ToString() },
+ new("@pi_inP1", SqlDbType.NVarChar, 20) { Value = query.pi_inP1 ?? DBNull.Value },
+ new("@pi_inP2", SqlDbType.NVarChar, 20) { Value = query.pi_inP2 ?? DBNull.Value }
+ };
+
+ cmd.Parameters.AddRange(parameters);
+ cmd.ExecuteNonQuery();
+
+ _strMsg = parameters[0].Value?.ToString() ?? "";
+ _status = Convert.ToInt32(parameters[1].Value ?? -1);
+
+ if (_status <= 0) throw new Exception(_strMsg);
+
+ return new
+ {
+ message = _strMsg,
+ status = _status
+ };
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"妫�楠屽崟鏇存柊澶辫触锛歿ex.Message}");
+ }
+ }
+ }
+
+ public int UpdateTableConfig(string selectedWater, string selectedFlow, string tableData, string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@selectedWater", selectedWater),
+ new("@selectedFlow", selectedFlow),
+ new("@tableData", tableData),
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5
+ SET ipqc_zrxn_sel1 = @selectedWater,
+ ipqc_zrxn_sel2 = @selectedFlow,
+ ipqc_zrxn_table = @tableData
+ WHERE guid = @mxguid";
+
+ return Db.Ado.ExecuteCommand(sql, sqlParams);
+ }
+
+ public dynamic GetTableConfig(string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"SELECT ipqc_zrxn_sel1,ipqc_zrxn_sel2,ipqc_zrxn_table
+ FROM MES_QA_ITEMS_DETECT_DETAIL5
+ WHERE guid = @mxguid";
+
+ var result = Db.Ado.SqlQuery<dynamic>(sql, sqlParams).FirstOrDefault();
+
+ if (result == null)
+ throw new Exception("閰嶇疆淇℃伅鏌ヨ缁撴灉涓虹┖");
+
+ return result;
+ }
+
+ public List<dynamic> GetRzxxList(string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"SELECT a.s_type, a.defect_name
+ FROM [dbo].[MES_DEFECT_CODE] a
+ WHERE a.s_type = '璁よ瘉淇℃伅'
+ AND a.pid = (
+ SELECT TOP 1 b.guid
+ FROM [dbo].[MES_DEFECT_CODE] b
+ INNER JOIN [dbo].[MES_QA_ITEMS_DETECT_DETAIL5] d
+ ON b.defect_name = d.fcheck_item
+ WHERE d.guid = @mxguid
+ ORDER BY b.guid
+ )";
+
+ var result = Db.Ado.SqlQuery<dynamic>(sql, sqlParams);
+
+ if (result == null || result.Count == 0)
+ throw new Exception("鏈壘鍒扮浉鍏宠璇佷俊鎭�");
+
+ return result;
+ }
+
+ public int UpdateScDate(string scDateValue, string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@scDateValue", scDateValue),
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5
+ SET ipqc_rzxx_date = @scDateValue
+ WHERE guid = @mxguid";
+
+ return Db.Ado.ExecuteCommand(sql, sqlParams);
+ }
+
+ public int UpdateRzxxNum(string ipqcrzxxNum, string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@ipqcrzxxNum", ipqcrzxxNum),
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5
+ SET ipqc_rzxx_num = @ipqcrzxxNum
+ WHERE guid = @mxguid";
+
+ return Db.Ado.ExecuteCommand(sql, sqlParams);
+ }
+
+ public int UpdateCpscs(string ipqCpscs, string mxguid)
+ {
+ var sqlParams = new List<SugarParameter> {
+ new("@ipqCpscs", ipqCpscs),
+ new("@mxguid", mxguid)
+ };
+
+ var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5
+ SET ipqc_pscs = @ipqCpscs
+ WHERE guid = @mxguid";
+
+ return Db.Ado.ExecuteCommand(sql, sqlParams);
+ }
+
+
+ public dynamic GetIpqcXjDaa(dynamic unity)
+ {
+
+ var sqlParams = new List<SugarParameter> { };
+ sqlParams.Add(new("@xt", unity.xt));
+
+ var sql2 = new StringBuilder(@"
+ SELECT '['+DAA001+']['+DAA021+']' AS daaInfo,DAA001,DAA021
+ FROM WOMDAA
+ WHERE DAA015 = @xt AND daa018 NOT IN ('W:瀹屽伐', 'D:寰呭紑宸�')");
+
+ if (!string.IsNullOrWhiteSpace(unity.selectKey?.ToString()))
+ {
+ sqlParams.Add(new("@selectKey", unity.selectKey));
+ sql2.Append(@"
+ AND (DAA001 LIKE '%' + @selectKey + '%'
+ OR DAA021 LIKE '%' + @selectKey + '%')");
+ }
+
+ var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2.ToString(), sqlParams);
+
+ if (XcslItem == null)
+ {
+ throw new Exception("璇ユ潯浠朵笅鏃犲搴斿伐鍗曚俊鎭紝璇烽噸鏂拌緭鍏ワ紒");
+ }
+
+ return XcslItem;
}
}
\ No newline at end of file
--
Gitblit v1.9.3