From 3f7693504fdb48ab76fd41029859d84774b42a28 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期日, 03 八月 2025 13:38:42 +0800
Subject: [PATCH] 首检巡检修改

---
 StandardInterface/MESApplication/Controllers/QC/SJController.cs |   50 ++++++
 StandardInterface/MES.Service/service/QC/XJService.cs           |  150 ++++++++++++++++++
 StandardInterface/MES.Service/Modes/MesLine.cs                  |    6 
 StandardInterface/MES.Service/Modes/QsQaItemXj.cs               |   12 +
 StandardInterface/MES.Service/Dto/service/SJPageResult.cs       |    3 
 StandardInterface/MESApplication/Controllers/QC/XJController.cs |  129 ++++++++++++++++
 StandardInterface/MES.Service/service/QC/SJService.cs           |   76 +++++++++
 StandardInterface/MESApplication/appsettings.json               |    2 
 8 files changed, 419 insertions(+), 9 deletions(-)

diff --git a/StandardInterface/MES.Service/Dto/service/SJPageResult.cs b/StandardInterface/MES.Service/Dto/service/SJPageResult.cs
index f662c90..819d93a 100644
--- a/StandardInterface/MES.Service/Dto/service/SJPageResult.cs
+++ b/StandardInterface/MES.Service/Dto/service/SJPageResult.cs
@@ -83,6 +83,9 @@
     [SugarColumn(ColumnName = "DAA008")]
     public decimal? Daa008 { get; set; }
 
+    [SugarColumn(ColumnName = "FSUBMIT")]
+    public decimal? Fsubmit { get; set; }
+
     /// <summary>
     ///     鐗╂枡ID
     /// </summary>
diff --git a/StandardInterface/MES.Service/Modes/MesLine.cs b/StandardInterface/MES.Service/Modes/MesLine.cs
index b1d8449..5facfe9 100644
--- a/StandardInterface/MES.Service/Modes/MesLine.cs
+++ b/StandardInterface/MES.Service/Modes/MesLine.cs
@@ -149,6 +149,12 @@
     public string Departmentcode { get; set; }
 
     /// <summary>
+    ///     閮ㄩ棬ID
+    /// </summary>
+    [SugarColumn(ColumnName = "DEPOT_ID")]
+    public decimal? DepotId { get; set; }
+
+    /// <summary>
     ///     鎵�灞炲伐搴�
     /// </summary>
     [SugarColumn(ColumnName = "PROC_NO")]
diff --git a/StandardInterface/MES.Service/Modes/QsQaItemXj.cs b/StandardInterface/MES.Service/Modes/QsQaItemXj.cs
index 28c435a..8a1e420 100644
--- a/StandardInterface/MES.Service/Modes/QsQaItemXj.cs
+++ b/StandardInterface/MES.Service/Modes/QsQaItemXj.cs
@@ -80,6 +80,18 @@
     public string? Modify1By { get; set; }
 
     /// <summary>
+    ///     杞﹂棿
+    /// </summary>
+    [SugarColumn(ColumnName = "WORKSHOP")]
+    public string? WorkShop { get; set; }
+
+    /// <summary>
+    ///     閮ㄩ棬ID
+    /// </summary>
+    [SugarColumn(ColumnName = "DEPARTMENT_ID")]
+    public string? DepartmentId { get; set; }
+
+    /// <summary>
     ///     鍗曚綅
     /// </summary>
     [SugarColumn(ColumnName = "ITEM_UNIT")]
diff --git a/StandardInterface/MES.Service/service/QC/SJService.cs b/StandardInterface/MES.Service/service/QC/SJService.cs
index cdd8865..dcc7beb 100644
--- a/StandardInterface/MES.Service/service/QC/SJService.cs
+++ b/StandardInterface/MES.Service/service/QC/SJService.cs
@@ -3,6 +3,7 @@
 using MES.Service.Modes;
 using MES.Service.util;
 using SqlSugar;
+using System.Data;
 
 namespace MES.Service.service.QC;
 
@@ -30,7 +31,7 @@
             number = no.ToString().PadLeft(4, '0');
         }
 
-        return "SJN" + date.Replace("-", "") + number;
+        return "SJ" + date.Replace("-", "") + number;
     }
 
     //鑾峰彇鎵�鏈夋暟鎹垎椤�
@@ -52,11 +53,11 @@
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 "鏈畬鎴�".Equals(queryObj.Result),
-                a => a.Result == queryObj.Result)
+                a => a.Fsubmit == 0)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 !"鏈畬鎴�".Equals(queryObj.Result),
-                a => a.Result != "鏈畬鎴�");
+                a => a.Fsubmit == 1);
 
         // 鏂板鐨勫姩鎬佹悳绱㈤�昏緫
         if (!string.IsNullOrEmpty(queryObj.SearchValue) && !string.IsNullOrEmpty(queryObj.searchField))
@@ -501,4 +502,73 @@
 
         return withOracle;
     }
+    //鍒锋柊妫�楠岄」鐩�
+    public (int result, string message) GenUpdate(decimal? id, string? no, string? user)
+    {
+        var outputResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, ParameterDirection.Output, 4000);
+        var outputMessage = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, System.Data.DbType.Decimal, ParameterDirection.Input),
+        new("P_NO", no, System.Data.DbType.String, ParameterDirection.Input),
+        new("P_USER", user, System.Data.DbType.String, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        var db = SqlSugarHelper.GetInstance();
+        db.Ado.ExecuteCommand(
+            "BEGIN PRC_GEN_UPDATE(:P_ID, :P_NO, :P_USER, :PO_RESULT, :PO_TEXT); END;",
+            parameters.ToArray());
+
+        int result = outputResult.Value == null ? -1 : Convert.ToInt32(outputResult.Value);
+        string message = outputMessage.Value?.ToString() ?? "";
+
+        return (result, message);
+    }
+
+    public bool SjSubmit(SJDto dto)
+    {
+        try
+        {
+            // 瀹氫箟杈撳嚭鍙傛暟
+            var outputResult = new SugarParameter("c_res", null,
+                System.Data.DbType.Int32, ParameterDirection.Output,
+                4000);
+
+            var outputMessage = new SugarParameter("c_msg", null,
+                System.Data.DbType.String,
+                ParameterDirection.Output, 4000);
+
+            // 瀹氫箟杈撳叆鍙傛暟锛屽浐瀹欶LAG涓�1锛堝鏍革級
+            var parameters = new List<SugarParameter>
+            {
+                new("P_ID", dto.id, System.Data.DbType.Decimal, ParameterDirection.Input),
+                new("P_FLAG", 1, System.Data.DbType.Int32, ParameterDirection.Input),
+                new("P_USER", dto.userNo, System.Data.DbType.String, ParameterDirection.Input),
+                outputResult,
+                outputMessage
+            };
+
+            var db = SqlSugarHelper.GetInstance();
+
+            // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+            db.Ado.ExecuteCommand(
+                "BEGIN PRC_WOMDAA_SJ_UPDATE_RES(:P_ID, :P_FLAG, :P_USER, :c_res, :c_msg); END;",
+                parameters.ToArray());
+
+            // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+            var resultValue = outputResult.Value?.ToString();
+            var messageValue = outputMessage.Value?.ToString();
+
+            if ("1".Equals(resultValue)) throw new Exception(messageValue);
+
+            return true;
+        }
+        catch (Exception ex)
+        {
+            throw new Exception(ex.Message);
+        }
+    }
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs
index b94657d..efcf669 100644
--- a/StandardInterface/MES.Service/service/QC/XJService.cs
+++ b/StandardInterface/MES.Service/service/QC/XJService.cs
@@ -1,4 +1,5 @@
-锘縰sing MES.Service.DB;
+锘縰sing System.Data;
+using MES.Service.DB;
 using MES.Service.Dto.service;
 using MES.Service.Modes;
 using MES.Service.util;
@@ -28,14 +29,14 @@
         var number = "0001";
         var olReleaseNo = executeScalar.ToString();
         //鍒ゆ柇浠婂ぉ鏄惁鐢熸垚浜嗗贰妫�鍗�
-        if (string.IsNullOrEmpty(olReleaseNo)) return "XJN" + date + number;
+        if (string.IsNullOrEmpty(olReleaseNo)) return "XJ" + date + number;
         //鎴彇鍚庡洓浣嶇殑娴佹按鍙风疮鍔�
         var substring = Convert.ToInt32(olReleaseNo.Substring(10));
         substring += 1;
         number = substring.ToString("D4");
 
         //濡傛灉涓虹┖鐩存帴杩斿洖0001
-        return "XJN" + date + number;
+        return "XJ" + date + number;
     }
 
     public List<Womdaa> getItem(string daa001)
@@ -132,11 +133,11 @@
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                (s, a, c, b) => s.FcheckResu == null)
+                (s, a, c, b) => s.Fsubmit == 0)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                (s, a, c, b) => s.FcheckResu != null)
+                (s, a, c, b) => s.Fsubmit != 1)
             .WhereIF(id > 0, (s, a, c, b) => s.Id == id)
             .Select((s, a, c, b) => new QsQaItemXj
             {
@@ -532,4 +533,143 @@
         });
     }
 
+    //鍒锋柊妫�楠岄」鐩�
+    public (int result, string message) GenUpdate(decimal? id, string? no, string? user)
+    {
+        var outputResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, ParameterDirection.Output, 4000);
+        var outputMessage = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, System.Data.DbType.Decimal, ParameterDirection.Input),
+        new("P_NO", no, System.Data.DbType.String, ParameterDirection.Input),
+        new("P_USER", user, System.Data.DbType.String, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        var db = SqlSugarHelper.GetInstance();
+        db.Ado.ExecuteCommand(
+            "BEGIN PRC_GEN_UPDATE_XJ(:P_ID, :P_NO, :P_USER, :PO_RESULT, :PO_TEXT); END;",
+            parameters.ToArray());
+
+        int result = outputResult.Value == null ? -1 : Convert.ToInt32(outputResult.Value);
+        string message = outputMessage.Value?.ToString() ?? "";
+
+        return (result, message);
+    }
+
+    public bool SjSubmit(SJDto dto)
+    {
+        try
+        {
+            // 瀹氫箟杈撳嚭鍙傛暟
+            var outputResult = new SugarParameter("c_res", null,
+                System.Data.DbType.Int32, ParameterDirection.Output,
+                4000);
+
+            var outputMessage = new SugarParameter("c_msg", null,
+                System.Data.DbType.String,
+                ParameterDirection.Output, 4000);
+
+            // 瀹氫箟杈撳叆鍙傛暟锛屽浐瀹欶LAG涓�1锛堝鏍革級
+            var parameters = new List<SugarParameter>
+            {
+                new("P_ID", dto.id, System.Data.DbType.Decimal, ParameterDirection.Input),
+                new("P_FLAG", 1, System.Data.DbType.Int32, ParameterDirection.Input),
+                new("P_USER", dto.userNo, System.Data.DbType.String, ParameterDirection.Input),
+                outputResult,
+                outputMessage
+            };
+
+            var db = SqlSugarHelper.GetInstance();
+
+            // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+            db.Ado.ExecuteCommand(
+                "BEGIN PRC_WOMDAA_XJ_UPDATE_RES(:P_ID, :P_FLAG, :P_USER, :c_res, :c_msg); END;",
+                parameters.ToArray());
+
+            // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+            var resultValue = outputResult.Value?.ToString();
+            var messageValue = outputMessage.Value?.ToString();
+
+            if ("1".Equals(resultValue)) throw new Exception(messageValue);
+
+            return true;
+        }
+        catch (Exception ex)
+        {
+            throw new Exception(ex.Message);
+        }
+    }
+
+    /// <summary>
+    /// 鑾峰彇鏈夌嚎浣撶殑閮ㄩ棬鍒楄〃
+    /// </summary>
+    /// <returns>閮ㄩ棬鍒楄〃</returns>
+    public List<SysDepartment> GetDepartmentsWithLines()
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+        // 鏌ヨ鏈夌嚎浣撶殑閮ㄩ棬锛岄摼鎺ユ潯浠舵槸绾夸綋鐨凞EPOT_ID绛変簬閮ㄩ棬鐨凞epartmentid
+        var departments = db.Queryable<SysDepartment, MesLine>((dept, line) =>
+                new JoinQueryInfos(JoinType.Inner, line.DepotId == dept.Departmentid))
+            .Where((dept, line) => line.LineNo != null && line.LineName != null)
+            .GroupBy((dept, line) => new
+            {
+                dept.Departmentid,
+                dept.Departmentname
+            })
+            .Select((dept, line) => new SysDepartment
+            {
+                Departmentid = dept.Departmentid,
+                Departmentname = dept.Departmentname
+            })
+            .OrderBy(dept => dept.Departmentname)
+            .ToList();
+
+        return departments;
+    }
+
+    /// <summary>
+    /// 淇濆瓨閮ㄩ棬閫夋嫨
+    /// </summary>
+    /// <param name="id">宸℃鍗旾D</param>
+    /// <param name="departmentId">閮ㄩ棬ID</param>
+    /// <param name="departmentName">閮ㄩ棬鍚嶇О</param>
+    /// <returns>淇濆瓨缁撴灉</returns>
+    public int SaveDepartmentSelection(decimal id, string departmentId, string departmentName)
+    {
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<QsQaItemXj>()
+                .SetColumns(it => it.WorkShop == departmentName)
+                .SetColumns(it => it.DepartmentId == departmentId)
+                .Where(it => it.Id == id)
+                .ExecuteCommand();
+        });
+    }
+
+    /// <summary>
+    /// 鏍规嵁閮ㄩ棬ID鑾峰彇璇ラ儴闂ㄤ笅鐨勭嚎浣撳垪琛�
+    /// </summary>
+    /// <param name="departmentId">閮ㄩ棬ID</param>
+    /// <returns>绾夸綋鍒楄〃</returns>
+    public List<MesLine> GetLinesByDepartment(string departmentId)
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+        // 灏嗗瓧绗︿覆杞崲涓篸ecimal杩涜姣旇緝
+        if (!decimal.TryParse(departmentId, out var deptId))
+        {
+            return new List<MesLine>();
+        }
+
+        return db.Queryable<MesLine>()
+            .Where(line => line.DepotId == deptId && 
+                          line.LineNo != null && 
+                          line.LineName != null)
+            .OrderBy(line => line.LineNo)
+            .ToList();
+    }
 }
\ No newline at end of file
diff --git a/StandardInterface/MESApplication/Controllers/QC/SJController.cs b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
index 7ad79b1..87a2a52 100644
--- a/StandardInterface/MESApplication/Controllers/QC/SJController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
@@ -319,4 +319,54 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+
+    //鍒锋柊妫�楠岄」鐩�
+    [HttpPost("GenUpdate")]
+    public ResponseResult GenUpdate([FromBody] JObject data)
+    {
+        try
+        {
+            decimal? id = data["id"]?.ToObject<decimal>();
+            string? no = data["no"]?.ToString();
+            string? user = data["user"]?.ToString();
+
+            var (result, message) = new SJService().GenUpdate(id, no, user);
+
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.result = result;
+            resultInfos.message = message;
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+    //鎻愪氦妫�楠�
+    [HttpPost("SjSubmit")]
+    public ResponseResult SjSubmit([FromBody] SJDto sjDto)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new SJService().SjSubmit(sjDto);
+            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/Controllers/QC/XJController.cs b/StandardInterface/MESApplication/Controllers/QC/XJController.cs
index 40d2bdc..8068a2f 100644
--- a/StandardInterface/MESApplication/Controllers/QC/XJController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/XJController.cs
@@ -444,4 +444,133 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+
+    //鍒锋柊妫�楠岄」鐩�
+    [HttpPost("GenUpdate")]
+    public ResponseResult GenUpdate([FromBody] JObject data)
+    {
+        try
+        {
+            decimal? id = data["id"]?.ToObject<decimal>();
+            string? no = data["no"]?.ToString();
+            string? user = data["user"]?.ToString();
+
+            var (result, message) = new XJService().GenUpdate(id, no, user);
+
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.result = result;
+            resultInfos.message = message;
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+    
+    //鎻愪氦妫�楠�
+    [HttpPost("SjSubmit")]
+    public ResponseResult SjSubmit([FromBody] SJDto sjDto)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new XJService().SjSubmit(sjDto);
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    /// 鑾峰彇鏈夌嚎浣撶殑閮ㄩ棬鍒楄〃
+    /// </summary>
+    [HttpPost("getDepartmentsWithLines")]
+    public ResponseResult GetDepartmentsWithLines()
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new XJService().GetDepartmentsWithLines();
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    /// 淇濆瓨閮ㄩ棬閫夋嫨
+    /// </summary>
+    [HttpPost("saveDepartmentSelection")]
+    public ResponseResult SaveDepartmentSelection([FromBody] JObject data)
+    {
+        try
+        {
+            var id = Convert.ToDecimal(data["id"]);
+            var departmentId = data["departmentId"].ToString();
+            var departmentName = data["departmentName"].ToString();
+
+            dynamic resultInfos = new ExpandoObject();
+            var result = new XJService().SaveDepartmentSelection(id, departmentId, departmentName);
+            resultInfos.tbBillList = result;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    /// 鏍规嵁閮ㄩ棬ID鑾峰彇璇ラ儴闂ㄤ笅鐨勭嚎浣撳垪琛�
+    /// </summary>
+    [HttpPost("getLinesByDepartment")]
+    public ResponseResult GetLinesByDepartment([FromBody] JObject data)
+    {
+        try
+        {
+            var departmentId = data["departmentId"].ToString();
+
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new XJService().GetLinesByDepartment(departmentId);
+            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 28cfc2a..59a3601 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 = hm_prd; 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 = test_dev; Password=hmprd"
   }
 }

--
Gitblit v1.9.3