From 52169a0d87f14f922b1865212b20ce89f68d33df Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期三, 03 十二月 2025 10:00:04 +0800
Subject: [PATCH] 委外领料不能更新
---
StandardInterface/MES.Service/service/QC/XJService.cs | 192 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 173 insertions(+), 19 deletions(-)
diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs
index de5a9a7..05212da 100644
--- a/StandardInterface/MES.Service/service/QC/XJService.cs
+++ b/StandardInterface/MES.Service/service/QC/XJService.cs
@@ -153,10 +153,23 @@
)
);
- // 娣诲姞绾夸綋绛涢�夋潯浠�
+ // 娣诲姞绾夸綋绛涢�夋潯浠讹紙鍩轰簬鐢ㄦ埛鏉冮檺锛�
if (lineNo != null && lineNo.Length > 0)
{
query = query.Where((s, a, c, b) => lineNo.Contains(c.LineNo));
+ }
+
+ // 娣诲姞QC绛涢�夋潯浠讹細杞﹂棿鍜岀嚎浣�
+ if (!string.IsNullOrEmpty(queryObj.departmentId))
+ {
+ // 濡傛灉鎸囧畾浜嗚溅闂达紝绛涢�夎杞﹂棿涓嬬殑绾夸綋
+ query = query.Where((s, a, c, b) => c.DepotId.ToString() == queryObj.departmentId);
+ }
+
+ if (!string.IsNullOrEmpty(queryObj.lineId))
+ {
+ // 濡傛灉鎸囧畾浜嗙嚎浣擄紝鐩存帴绛涢�夌嚎浣�
+ query = query.Where((s, a, c, b) => c.LineNo == queryObj.lineId);
}
// 娣诲姞鐘舵�佺瓫閫夋潯浠� - 鏄庣‘鍖归厤鍓嶇浼犻�掔殑鍊�
@@ -287,6 +300,7 @@
var qsQaItemXj01s = db.Queryable<QsQaItemXj01>()
.WhereIF(pid > 0, a => a.Pid == pid)
.WhereIF(id > 0, a => a.Id == id)
+ .OrderBy(a => a.Forder ?? 0)
.ToList();
var array = qsQaItemXj01s.Select(s => s.Id).ToArray();
@@ -323,8 +337,10 @@
s.imageData = Convert.ToBase64String(s.Picture);
});
- //鎺掑簭锛屾湭瀹屾垚鐨勬帓鍦ㄥ墠闈�
- qsQaItemXj01s = qsQaItemXj01s.OrderBy(s => s.isCheck).ToList();
+ //鎺掑簭锛氬彧鎸塅ORDER椤哄簭鎺掑簭
+ qsQaItemXj01s = qsQaItemXj01s
+ .OrderBy(s => s.Forder ?? 0)
+ .ToList();
return qsQaItemXj01s;
}
@@ -678,24 +694,39 @@
{
try
{
- var db = SqlSugarHelper.GetInstance();
-
- // 鐩存帴鏇存柊Fsubmit瀛楁涓�1锛堝凡鎻愪氦鐘舵�侊級
- var result = db.Updateable<QsQaItemXj>()
- .SetColumns(s => s.Fsubmit == 1)
- .SetColumns(s => s.FsubmitBy == dto.userNo)
- .SetColumns(s => s.FsubmitDate == DateTime.Now)
- .Where(s => s.Id == dto.id)
- .ExecuteCommand();
+ // 瀹氫箟杈撳嚭鍙傛暟
+ var outputResult = new SugarParameter("c_res", null,
+ System.Data.DbType.Int32, ParameterDirection.Output,
+ 4000);
- if (result > 0)
+ var outputMessage = new SugarParameter("c_msg", null,
+ System.Data.DbType.String,
+ ParameterDirection.Output, 4000);
+
+ // 瀹氫箟杈撳叆鍙傛暟锛屽浐瀹欶LAG涓�1锛堝鏍革級
+ var parameters = new List<SugarParameter>
{
- return true;
- }
- else
- {
- throw new Exception("鎻愪氦澶辫触锛氭湭鎵惧埌瀵瑰簲鐨勬楠屽崟");
- }
+ 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)
{
@@ -1001,5 +1032,128 @@
};
}
+ /// <summary>
+ /// 涓婁紶鍥剧墖鍒版楠岄」鐩殑PICTURE瀛楁
+ /// </summary>
+ /// <param name="id">妫�楠岄」鐩甀D</param>
+ /// <param name="imageBytes">鍥剧墖瀛楄妭鏁扮粍</param>
+ /// <param name="fileName">鍘熷鏂囦欢鍚�</param>
+ /// <param name="createBy">鍒涘缓浜�</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ public (int status, string message) UploadImageToPicture(decimal id, byte[] imageBytes, string fileName, string createBy)
+ {
+ try
+ {
+ if (imageBytes == null || imageBytes.Length == 0)
+ {
+ return (1, "鍥剧墖鏁版嵁涓虹┖");
+ }
+
+ if (string.IsNullOrEmpty(fileName))
+ {
+ return (1, "鏂囦欢鍚嶄负绌�");
+ }
+
+ // 楠岃瘉鍥剧墖鏍煎紡
+ var allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp" };
+ var extension = System.IO.Path.GetExtension(fileName).ToLower();
+ if (!allowedExtensions.Contains(extension))
+ {
+ return (1, "涓嶆敮鎸佺殑鍥剧墖鏍煎紡锛屼粎鏀寔锛歫pg, jpeg, png, gif, bmp, webp");
+ }
+
+ // 楠岃瘉鍥剧墖澶у皬锛堥檺鍒朵负5MB锛�
+ if (imageBytes.Length > 5 * 1024 * 1024)
+ {
+ return (1, "鍥剧墖澶у皬涓嶈兘瓒呰繃5MB");
+ }
+
+ // 鐢熸垚鏃堕棿鎴虫枃浠跺悕锛屾牸寮忥細1746945271304.jpg
+ var timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
+ var timestampFileName = $"{timestamp}{extension}";
+
+ var result = SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ // 妫�鏌ユ楠岄」鐩槸鍚﹀瓨鍦�
+ var exists = db.Queryable<QsQaItemXj01>()
+ .Where(s => s.Id == id)
+ .Any();
+
+ if (!exists)
+ {
+ throw new Exception("妫�楠岄」鐩笉瀛樺湪");
+ }
+
+ // 鏇存柊PICTURE瀛楁锛圠ONG RAW绫诲瀷锛夊拰PICTURENAME瀛楁锛堟椂闂存埑鏂囦欢鍚嶏級
+ var updateResult = db.Updateable<QsQaItemXj01>()
+ .SetColumns(s => s.Picture == imageBytes)
+ .SetColumns(s => s.Picturename == timestampFileName)
+ .Where(s => s.Id == id)
+ .ExecuteCommand();
+
+ return updateResult;
+ });
+
+ if (result > 0)
+ {
+ return (0, "鍥剧墖淇濆瓨鎴愬姛");
+ }
+ else
+ {
+ return (1, "鍥剧墖淇濆瓨澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勬楠岄」鐩�");
+ }
+ }
+ catch (Exception ex)
+ {
+ return (1, $"鍥剧墖淇濆瓨澶辫触锛歿ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鍒犻櫎妫�楠岄」鐩殑鍥剧墖
+ /// </summary>
+ /// <param name="id">妫�楠岄」鐩甀D</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ public (int status, string message) DeleteImageFromPicture(decimal id)
+ {
+ try
+ {
+ var result = SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ // 妫�鏌ユ楠岄」鐩槸鍚﹀瓨鍦�
+ var exists = db.Queryable<QsQaItemXj01>()
+ .Where(s => s.Id == id)
+ .Any();
+
+ if (!exists)
+ {
+ throw new Exception("妫�楠岄」鐩笉瀛樺湪");
+ }
+
+ // 娓呯┖PICTURE瀛楁鍜孭ICTURENAME瀛楁
+ var updateResult = db.Updateable<QsQaItemXj01>()
+ .SetColumns(s => s.Picture == null)
+ .SetColumns(s => s.Picturename == null)
+ .Where(s => s.Id == id)
+ .ExecuteCommand();
+
+ return updateResult;
+ });
+
+ if (result > 0)
+ {
+ return (0, "鍥剧墖鍒犻櫎鎴愬姛");
+ }
+ else
+ {
+ return (1, "鍥剧墖鍒犻櫎澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勬楠岄」鐩�");
+ }
+ }
+ catch (Exception ex)
+ {
+ return (1, $"鍥剧墖鍒犻櫎澶辫触锛歿ex.Message}");
+ }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.3