From 89b4e034c1c6157a71c5bf323055e989f420b588 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期四, 19 六月 2025 13:46:27 +0800
Subject: [PATCH] 维护检验人

---
 StandardInterface/MES.Service/Dto/service/XJPageResult.cs        |    3 
 StandardInterface/MES.Service/service/QC/LljService.cs           |  134 ++++++++++++++++++++++++++++++--
 StandardInterface/MES.Service/util/ResponseResult.cs             |    1 
 StandardInterface/MES.Service/Modes/LtsLlj.cs                    |    3 
 StandardInterface/MES.Service/Modes/MesQaItemsDetect01.cs        |    5 +
 StandardInterface/MESApplication/Controllers/QC/LljController.cs |   43 ++++++++++
 StandardInterface/MESApplication/appsettings.json                |    2 
 7 files changed, 179 insertions(+), 12 deletions(-)

diff --git a/StandardInterface/MES.Service/Dto/service/XJPageResult.cs b/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
index 09cc6c5..4acaf9d 100644
--- a/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
+++ b/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
@@ -10,4 +10,7 @@
     public string? id { get; set; }
 
     public string? SearchValue { get; set; }
+
+    public string? UserIndex { get; set; }
+
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/Modes/LtsLlj.cs b/StandardInterface/MES.Service/Modes/LtsLlj.cs
index 2aecc8a..8450691 100644
--- a/StandardInterface/MES.Service/Modes/LtsLlj.cs
+++ b/StandardInterface/MES.Service/Modes/LtsLlj.cs
@@ -201,4 +201,7 @@
     /// </summary>
     [SugarColumn(IsIgnore = true)]
     public string? NewFngDesc { get; set; }
+    [SugarColumn(IsIgnore = true)]
+    //绱ф�ユ斁琛屾爣璇�
+    public int EMERGENCY { get; set; }
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/Modes/MesQaItemsDetect01.cs b/StandardInterface/MES.Service/Modes/MesQaItemsDetect01.cs
index cebf04e..1ca3523 100644
--- a/StandardInterface/MES.Service/Modes/MesQaItemsDetect01.cs
+++ b/StandardInterface/MES.Service/Modes/MesQaItemsDetect01.cs
@@ -459,4 +459,9 @@
     /// </summary>
     [SugarColumn(ColumnName = "MANAGER_USER")]
     public string? ManagerUser { get; set; }
+    /// <summary>
+    ///     绱ф�ユ斁琛�
+    /// </summary>
+    [SugarColumn(ColumnName = "MANAGER_USER")]
+    public int EMERGENCY { get; set; }
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/service/QC/LljService.cs b/StandardInterface/MES.Service/service/QC/LljService.cs
index e07051c..fe7b172 100644
--- a/StandardInterface/MES.Service/service/QC/LljService.cs
+++ b/StandardInterface/MES.Service/service/QC/LljService.cs
@@ -1,10 +1,12 @@
 锘縰sing System.Data;
+using System.Xml;
 using Masuit.Tools;
 using MES.Service.DB;
 using MES.Service.Dto.service;
 using MES.Service.Modes;
 using MES.Service.util;
 using SqlSugar;
+using Tea.Utils;
 using DbType = System.Data.DbType;
 
 
@@ -22,23 +24,36 @@
 
         var totalCount = 0;
 
-        //var itemIds = GetQaItem(db, queryObj.createUser);
-
-        var pageList = db.Queryable<LtsLlj>()
+        var pageList = db.Queryable<LtsLlj, IqcBefore, SysUser,
+                IqcBeforeFrom, SysUser, SysUser>((a, b,
+                    e, f, g, i) =>
+                new JoinQueryInfos(JoinType.Left, a.ItemId == b.ItemId,
+                    JoinType.Left, a.CreateBy == e.Fcode,
+                    JoinType.Left, f.Id == b.Pid,
+                    JoinType.Left, f.Sid == Convert.ToDecimal(g.Fid),
+                    JoinType.Left, f.CheckUser == i.Fcode
+                ))
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu == null)
+                (a, b,
+                    e, f, g, i) => a.FcheckResu == null)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu != null)
-            .WhereIF(id > 0, a => a.Id == id)
+                (a, b,
+                    e, f, g, i) => a.FcheckResu != null)
+            .WhereIF(id > 0, (a, b,
+                    e, f, g, i) => a.Id == id)
+            .WhereIF(queryObj.createUser != "PL017" && queryObj.UserIndex == "0", (a, b,
+                    e, f, g, i) => (g.Fcode == queryObj.createUser || i.Fcode == queryObj.createUser || 
+                                   (g.Fcode == null && i.Fcode == null)))//鍒ゆ柇姝ゅ崟鐨勬楠屽憳锛屾垨鑰呮楠屼负绌哄氨鏄剧ず姝ゅ崟鎹�
 
             //鍔犵瓫閫夋潯浠�,鏍规嵁渚涘簲鍟嗭紝鐗╂枡缂栫爜锛岀墿鏂欏悕绉版悳绱�
             //.WhereIF(queryObj.SearchValue!=null && queryObj.SearchValue!="", (a) => a.SuppName == queryObj.SearchValue|| a.ItemName == queryObj.SearchValue || a.ItemNo == queryObj.SearchValue )
             .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
-                a => a.SuppName.ToLower()
+                (a, b,
+                    e, f, g, i) => a.SuppName.ToLower()
                          .Contains(queryObj.SearchValue.ToLower())
                      || a.ItemName.ToLower()
                          .Contains(queryObj.SearchValue.ToLower())
@@ -50,10 +65,20 @@
                         .Contains(queryObj.SearchValue.ToLower())
                      || a.ItemModel.ToLower()
                         .Contains(queryObj.SearchValue.ToLower()))
-            .OrderByDescending(a => a.Id)
+            .OrderByDescending((a, b,
+                    e, f, g, i) => a.Id)
+            //.Select((a, b,
+            //        e, f, g, i) => new LtsLlj
+            //        {
+            //            //UserName = g.Fname,
+            //            //UserName = (i.Fname!=null ||i.Fname!="") ? i.Fname : g.Fname,
+            //            UserName = i.Fname != null || i.Fname != "" ? i.Fname : g.Fname,
+            //            CreateUserName = e.Fname
+            //        }, true)
             .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
-
+        var emergencyValues = pageList.Select(item => item.EMERGENCY).ToList();
+        //return (pageList, totalCount);
         return (pageList, totalCount);
     }
 
@@ -101,6 +126,92 @@
         msg[1] = messageValue;
         return msg;
 
+    }
+    //绱ф�ユ斁琛�
+    public string[] EmergencyRelease(int id)
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+        
+        int emergencyStatus = db.Queryable<MesQaItemsDetect01>() 
+                                .Where(t => t.Id == id)
+                                .Select(t => t.EMERGENCY) 
+                                .First();
+
+        if (emergencyStatus != 0)
+        {
+            return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犳硶鎵ц绱ф�ユ斁琛�" };
+        }
+
+        
+        var outputResult = new SugarParameter("PO_RESULT", null,
+            DbType.Int32, ParameterDirection.Output, 4000);
+
+        var outputMessage = new SugarParameter("PO_MSG", null,
+            DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        db.Ado.ExecuteCommand(
+            "BEGIN prc_MES_QA_ITEMS_update1(:P_ID, :PO_RESULT, :PO_MSG); END;",
+            parameters.ToArray());
+
+        var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+                   .Where(t => t.Id == id)
+                   .Select(t => t.LotNo1)
+                   .First();
+
+        var resultValue = outputResult.Value?.ToString();
+        var messageValue = outputMessage.Value?.ToString();
+        return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
+    }
+
+    public string[] WithdrawEmergencyRelease(int id)
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+      
+        int emergencyStatus = db.Queryable<MesQaItemsDetect01>() 
+                                .Where(t => t.Id == id)
+                                .Select(t => t.EMERGENCY) 
+                                .First();
+
+        if (emergencyStatus != 0)
+        {
+            return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犻渶鎾ゅ洖" };
+        }
+
+        var outputResult = new SugarParameter("PO_RESULT", null,
+            DbType.Int32, ParameterDirection.Output, 4000);
+
+        var outputMessage = new SugarParameter("PO_MSG", null,
+            DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        db.Ado.ExecuteCommand(
+            "BEGIN prc_MES_QA_ITEMS_update2(:P_ID, :PO_RESULT, :PO_MSG); END;",
+            parameters.ToArray());
+
+        var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+                   .Where(t => t.Id == id)
+                   .Select(t => t.LotNo1)
+                   .First();
+        
+
+        var resultValue = outputResult.Value?.ToString();
+        var messageValue = outputMessage.Value?.ToString();
+        return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
     }
 
     private string ExtractSubstring(string input, char startChar, char endChar)
@@ -194,7 +305,7 @@
                 a.FreQty,
                 a.CheckQyt,
                 a.FcheckResu,
-                a.FcheckItemDesc
+                a.FcheckItemDesc,a.Funit
             }).Select((a, b) => new MesQaItemsDetectDetail5
             {
                 Id = a.Id,
@@ -215,7 +326,8 @@
                 FenterQty = SqlFunc.AggregateCount(b.Id),
                 FcheckResu = a.FcheckResu,
                 // FcheckItemDesc = a.FcheckItemDesc
-                FcheckItemDesc = a.FspecRequ
+                FcheckItemDesc = a.FspecRequ,
+                Funit  =a.Funit
             }).ToList();
     }
 
diff --git a/StandardInterface/MES.Service/util/ResponseResult.cs b/StandardInterface/MES.Service/util/ResponseResult.cs
index cd81c43..3b9a098 100644
--- a/StandardInterface/MES.Service/util/ResponseResult.cs
+++ b/StandardInterface/MES.Service/util/ResponseResult.cs
@@ -17,6 +17,7 @@
 
     public int TotalCount { get; set; } = 0;
 
+
     //澶辫触鐨勮繑鍥炵粨鏋�
     public static ResponseResult ResponseError(Exception e)
     {
diff --git a/StandardInterface/MESApplication/Controllers/QC/LljController.cs b/StandardInterface/MESApplication/Controllers/QC/LljController.cs
index 2c242fe..8112f51 100644
--- a/StandardInterface/MESApplication/Controllers/QC/LljController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/LljController.cs
@@ -273,4 +273,47 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+    [HttpPost("EmergencyRelease")]
+    public ResponseResult EmergencyRelease([FromBody] JObject data)
+    {
+        var id = Convert.ToInt32(data["id"].ToString());
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new LljService().EmergencyRelease(id);
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    [HttpPost("WithdrawEmergencyRelease")]
+    public ResponseResult WithdrawEmergencyRelease([FromBody] JObject data)
+    {
+        var id = Convert.ToInt32(data["id"].ToString());
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new LljService().WithdrawEmergencyRelease(id);
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
 }
\ No newline at end of file
diff --git a/StandardInterface/MESApplication/appsettings.json b/StandardInterface/MESApplication/appsettings.json
index 59a3601..28cfc2a 100644
--- a/StandardInterface/MESApplication/appsettings.json
+++ b/StandardInterface/MESApplication/appsettings.json
@@ -10,6 +10,6 @@
   "AppSettings": {
     "TestErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfo",
     "ProductionErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfoFormal",
-    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = test_dev; Password=hmprd"
+    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = hm_prd; Password=hmprd"
   }
 }

--
Gitblit v1.9.3