From 2d07ecf4a434a9d68d3ba82997916c5eade88d35 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 06 五月 2026 17:12:02 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/WebAPIController.cs | 142 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 126 insertions(+), 16 deletions(-)
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 0bba5be..6c68f9e 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -23569,7 +23569,7 @@
{
objjson.code = "0";
objjson.count = 0;
- objjson.Message = "鑾峰彇澶辫触, 鍗曟嵁鏃犺繑鍥炲��!";
+ objjson.Message = "鏃犲緟涓婃ā鍗曟嵁!";
objjson.data = null;
return objjson;
}else
@@ -23624,7 +23624,7 @@
{
objjson.code = "0";
objjson.count = 0;
- objjson.Message = "鑾峰彇澶辫触, 鍗曟嵁鏃犺繑鍥炲��!";
+ objjson.Message = "鏃犲緟寮�宸ュ崟鎹�!";
objjson.data = null;
return objjson;
}
@@ -23681,7 +23681,7 @@
{
objjson.code = "0";
objjson.count = 0;
- objjson.Message = "鑾峰彇澶辫触, 鍗曟嵁鏃犺繑鍥炲��!";
+ objjson.Message = "鏃犲緟涓嬫ā鍗曟嵁!";
objjson.data = null;
return objjson;
}
@@ -24129,6 +24129,11 @@
// 鍖归厤 {{ 瀛楁鍚� }} 鎵�闇�姝e垯琛ㄨ揪寮� 鏀寔涓枃
var regex = new Regex(@"{{\s*([\u4e00-\u9fa5a-zA-Z0-9_\s]+?)\s*}}", RegexOptions.Compiled);
+ // 鍖归厤 鐭╁舰妗� 浣嶇疆 瀹介珮 鎵�闇�姝e垯琛ㄨ揪寮�
+ var RectRegex = new Regex(@"^\^FO(\d+),(\d+)\^GB(\d+),(\d+)", RegexOptions.Compiled);
+ // 鍖归厤 妯℃澘瀛楃涓� 鎵�鍦ㄨ 浣嶇疆 瀹介珮 鎵�闇�姝e垯琛ㄨ揪寮� 鏀寔涓枃
+ var fieldRegex = new Regex(@"\^FO(\d+),(\d+)\^A[A-Z]+,(\d+),(\d+).*\{\{\s*([\u4e00-\u9fa5a-zA-Z0-9_\s]+?)\s*}\}", RegexOptions.Compiled);
+
if (ptMode == "ZPL")
{
suffix = ".zpl";
@@ -24168,9 +24173,45 @@
{
if(JOneKVP is JObject item)
{
- foreach (var line in lines)
+ //foreach (var line in lines)
+ //{
+ //string currentLine = line;
+
+ //// 璺宠繃娉ㄩ噴琛� //
+ //if (currentLine.TrimStart().StartsWith("//"))
+ //{
+ //continue;
+ //}
+
+
+ //// 姝e垯琛ㄨ揪寮忓尮閰� {{ 瀛楁鍚� }} 鎵�鍦ㄨ鐨勫瓧娈碉紝濡傛灉鏈夛紝鍒欒繘琛屾浛鎹紝娌℃湁锛屽垯榛樿涓虹┖瀛楃涓�
+ //currentLine = regex.Replace(currentLine, match =>
+ //{
+ ////鍒ゆ柇涓婁竴琛屾槸鍚︿负鐭╁舰琛岋紝濡傛灉鏄煩褰㈣锛屽垯鏍规嵁鐭╁舰琛岀殑瀹介珮鍒ゆ柇瀛楃鏄惁闇�瑕佹崲琛�
+
+ //string fieldName = match.Groups[1].Value.Trim();
+ //if (msg != null && item.ContainsKey(fieldName))
+ //{
+ //return item[fieldName]?.ToString() ?? "";
+ //}
+ //return "";
+ //});
+ //// 灏嗘墍鏈� \n 鐨勬崲琛岀 鏇挎崲涓� \r\n
+
+ //sb.Append(currentLine);
+ //sb.Append("\r\n"); // 鏍囧噯鎹㈣
+ //}
+
+ for(int i = 0; i<lines.Length; i++)
{
- string currentLine = line;
+ string currentLine = lines[i];
+ string preLine = "";
+ string concatStr = "";
+ if(i>0)
+ {
+ // 鑾峰彇褰撳墠琛岀殑涓婁竴琛岋紝鐢ㄤ簬鍒ゆ柇鏄惁鏄煩褰㈡
+ preLine = lines[i - 1];
+ }
// 璺宠繃娉ㄩ噴琛� //
if (currentLine.TrimStart().StartsWith("//"))
@@ -24178,19 +24219,26 @@
continue;
}
- // 姝e垯琛ㄨ揪寮忓尮閰� {{ 瀛楁鍚� }} 鎵�鍦ㄨ鐨勫瓧娈碉紝濡傛灉鏈夛紝鍒欒繘琛屾浛鎹紝娌℃湁锛屽垯榛樿涓虹┖瀛楃涓�
- currentLine = regex.Replace(currentLine, match =>
+ // 鍒ゆ柇鐭╁舰妗嗭紝濡傛灉鍓嶄竴琛屾槸鐭╁舰妗嗭紝鍒欓渶鍒ゆ柇璇ヨ瀛楃涓查暱搴︽槸鍚﹁秴闀�
+ if(!getConcatStr(rectRegex: RectRegex, fieldRegex: fieldRegex,
+ PreLine: preLine, CurrLine: currentLine, fieldObject: item, ref concatStr))
{
- string fieldName = match.Groups[1].Value.Trim();
- if (msg != null && item.ContainsKey(fieldName))
+ // 姝e垯琛ㄨ揪寮忓尮閰� {{ 瀛楁鍚� }} 鎵�鍦ㄨ鐨勫瓧娈碉紝濡傛灉鏈夛紝鍒欒繘琛屾浛鎹紝娌℃湁锛屽垯榛樿涓虹┖瀛楃涓�
+ concatStr = regex.Replace(currentLine, match =>
{
- return item[fieldName]?.ToString() ?? "";
- }
- return "";
- });
- // 灏嗘墍鏈� \n 鐨勬崲琛岀 鏇挎崲涓� \r\n
+ string fieldName = match.Groups[1].Value.Trim();
+ if (msg != null && item.ContainsKey(fieldName))
+ {
+ return item[fieldName]?.ToString() ?? "";
+ }
+ return "";
+ });
+ }
- sb.Append(currentLine);
+
+
+ // 灏嗘墍鏈� \n 鐨勬崲琛岀 鏇挎崲涓� \r\n
+ sb.Append(concatStr);
sb.Append("\r\n"); // 鏍囧噯鎹㈣
}
}
@@ -24215,6 +24263,69 @@
}
}
+
+ private bool getConcatStr(Regex rectRegex, Regex fieldRegex,
+ string PreLine, string CurrLine, JObject fieldObject, ref string concatStr)
+ {
+ var rectRegexResult = rectRegex.Match(PreLine);
+ var fieldRegexResult = fieldRegex.Match(CurrLine);
+ if (!rectRegexResult.Success)
+ {
+ return false;
+ }
+
+ if(!fieldRegexResult.Success)
+ {
+ return false;
+ }
+
+ // 鐭╁舰 浣嶇疆 瀹介珮
+ int rectLocationX = int.Parse(rectRegexResult.Groups[1].Value);
+ int rectLocationY = int.Parse(rectRegexResult.Groups[2].Value);
+ int rectWidth = int.Parse(rectRegexResult.Groups[3].Value);
+ int rectHeight = int.Parse(rectRegexResult.Groups[4].Value);
+
+ // 妯℃澘瀛楃涓� 浣嶇疆 瀛楃瀹介珮
+ int fieldLocationX = int.Parse(fieldRegexResult.Groups[1].Value);
+ int fieldLocationY = int.Parse(fieldRegexResult.Groups[2].Value);
+ int fieldWidth = int.Parse(fieldRegexResult.Groups[3].Value);
+ int fieldHeight = int.Parse(fieldRegexResult.Groups[4].Value);
+ string fieldName = fieldRegexResult.Groups[5].Value;
+
+ string fieldValue = fieldObject[fieldName].ToString() ?? "";
+ if(string.IsNullOrWhiteSpace(fieldValue))
+ {
+ return false;
+ }
+
+ if(fieldValue.Length * fieldWidth > rectWidth)
+ {
+ // 瀛楃涓查暱搴﹀ぇ浜庣煩褰㈢殑鏈�澶ч暱搴� 鍒欐枃鏈渶瑕佷粠鐭╁舰鐨刌浣嶇疆寮�濮嬫覆鏌�
+ fieldLocationY = rectLocationY;
+ // 鑾峰彇鎹㈣鎵�闇�鐨勮鏁�
+ int lineCount = int.Parse(Math.Ceiling((float)fieldValue.Length / fieldWidth).ToString());
+
+ // 璁$畻鎹㈣鍚庣殑鏈�澶ц鏁� * 瀛楃楂樺害 鏄惁澶т簬鐭╁舰鏈�澶ч珮搴�
+ if(lineCount * fieldHeight > rectHeight)
+ {
+ fieldWidth = int.Parse(Math.Floor((float)fieldHeight / lineCount).ToString());
+ fieldHeight = int.Parse(Math.Floor((float)fieldHeight / lineCount).ToString());
+ }
+
+ for(uint i=0;i<lineCount; i++)
+ {
+ concatStr += fieldRegex.Replace(CurrLine, match =>
+ {
+ return "";
+ });
+ }
+
+ }
+
+ return true;
+
+ }
+ #endregion
[HttpGet]
[Route("Web/getSysParameter")]
public object getSysParameter(string HClientID)
@@ -24260,4 +24371,3 @@
}
}
}
-#endregion
\ No newline at end of file
--
Gitblit v1.9.1