From 349f2f66fdac1a2d64e0c99201b7f09579470714 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期四, 16 十月 2025 14:26:31 +0800
Subject: [PATCH] SJ,XJ,RKJ检验项单独拍照+提交限制
---
StandardInterface/MES.Service/service/QC/RKJService.cs | 130 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 127 insertions(+), 3 deletions(-)
diff --git a/StandardInterface/MES.Service/service/QC/RKJService.cs b/StandardInterface/MES.Service/service/QC/RKJService.cs
index f7da3e0..83a7b51 100644
--- a/StandardInterface/MES.Service/service/QC/RKJService.cs
+++ b/StandardInterface/MES.Service/service/QC/RKJService.cs
@@ -608,6 +608,7 @@
if (StringUtil.IsNotNullOrEmpty(queryObj.createUser))
lineNo = _baseService.getUserLineNo(queryObj.createUser);
+
return db
.Queryable<QsItemOqcReq, Womdaa, MesItems>((a, da, b) =>
new JoinQueryInfos(
@@ -625,12 +626,12 @@
!"鏈畬鎴�".Equals(queryObj.result),
(a, da, b) => a.FcheckResu != null && a.FcheckResu != "")
.WhereIF(id > 0, (a, da, b) => a.Id == id)
- // 娣诲姞fsubmit瀛楁杩囨护閫昏緫
+ // 娣诲姞fsubmit瀛楁杩囨护閫昏緫 - 鍙湁鍦ㄦ槑纭寚瀹歠submit鍙傛暟鏃舵墠杩囨护锛屼笖娌℃湁浼犻�抜d鏃舵墠杩囨护
.WhereIF(
- StringUtil.IsNotNullOrEmpty(queryObj.fsubmit) && queryObj.fsubmit == "1",
+ id <= 0 && StringUtil.IsNotNullOrEmpty(queryObj.fsubmit) && queryObj.fsubmit == "1",
(a, da, b) => a.Fsubmit == 1)
.WhereIF(
- StringUtil.IsNullOrEmpty(queryObj.fsubmit) || queryObj.fsubmit == "0",
+ id <= 0 && StringUtil.IsNotNullOrEmpty(queryObj.fsubmit) && queryObj.fsubmit == "0",
(a, da, b) => a.Fsubmit == 0 || a.Fsubmit == null)
// 娣诲姞鎼滅储鏉′欢 - 鏍规嵁閫夋嫨鐨勬悳绱㈠瓧娈佃繘琛岀簿纭悳绱�
.WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && !string.IsNullOrEmpty(queryObj.searchField) && queryObj.searchField == "billNo", // 宸ュ崟
@@ -1217,4 +1218,127 @@
.ExecuteCommand();
});
}
+
+ /// <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<QsItemOqcItem>()
+ .Where(s => s.Id == id)
+ .Any();
+
+ if (!exists)
+ {
+ throw new Exception("妫�楠岄」鐩笉瀛樺湪");
+ }
+
+ // 鏇存柊PICTURE瀛楁锛圠ONG RAW绫诲瀷锛夊拰TPICTURENAME瀛楁锛堟椂闂存埑鏂囦欢鍚嶏級
+ var updateResult = db.Updateable<QsItemOqcItem>()
+ .SetColumns(s => s.Picture == imageBytes)
+ .SetColumns(s => s.TPicturename == 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<QsItemOqcItem>()
+ .Where(s => s.Id == id)
+ .Any();
+
+ if (!exists)
+ {
+ throw new Exception("妫�楠岄」鐩笉瀛樺湪");
+ }
+
+ // 娓呯┖PICTURE瀛楁鍜孴PICTURENAME瀛楁
+ var updateResult = db.Updateable<QsItemOqcItem>()
+ .SetColumns(s => s.Picture == null)
+ .SetColumns(s => s.TPicturename == 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