|
@@ -1,13 +1,8 @@
|
|
|
-using System;
|
|
|
|
|
-using System.Collections.Generic;
|
|
|
|
|
-using System.IO;
|
|
|
|
|
-using System.Text;
|
|
|
|
|
-using System.Threading;
|
|
|
|
|
|
|
+using System.Collections;
|
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using Common;
|
|
using Common;
|
|
|
-using Infrastructure;
|
|
|
|
|
-using Services;
|
|
|
|
|
-using Model;
|
|
|
|
|
using LitJson;
|
|
using LitJson;
|
|
|
|
|
+using Microsoft.CodeAnalysis.CSharp.Scripting;
|
|
|
|
|
|
|
|
//营业额日汇总统计
|
|
//营业额日汇总统计
|
|
|
public class MakeSqlHelper
|
|
public class MakeSqlHelper
|
|
@@ -37,8 +32,108 @@ public class MakeSqlHelper
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void DoQueue(string content)
|
|
public void DoQueue(string content)
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ JsonData jsonObj = JsonMapper.ToObject(content);
|
|
|
|
|
+ string templateString = Function.ReadInstance("Template/Sql/db.sql");
|
|
|
|
|
+ string resultString = StartMake(jsonObj, templateString);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public string StartMake(JsonData jsonObj, string templateString)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach(string key in jsonObj.Keys)
|
|
|
|
|
+ {
|
|
|
|
|
+ JsonData obj = jsonObj[key];
|
|
|
|
|
+ if(obj.IsArray)
|
|
|
|
|
+ {
|
|
|
|
|
+ MatchCollection mc = Regex.Matches(templateString, "<<ym-loop:" + key + ".*?>>[\\s\\S]*?<</ym-loop:" + key + ">>");
|
|
|
|
|
+ foreach(Match m in mc)
|
|
|
|
|
+ {
|
|
|
|
|
+ string listString = "";
|
|
|
|
|
+ string matchValue = m.Value;
|
|
|
|
|
+ Match head = Regex.Match(matchValue, "<<ym-loop:" + key + ".*>>");
|
|
|
|
|
+ if(head.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ string headValue = head.Value;
|
|
|
|
|
+ string itemTemplate = matchValue.Replace(headValue, "").Replace("<</ym-loop:" + key + ">>", "");
|
|
|
|
|
+ foreach(JsonData item in obj)
|
|
|
|
|
+ {
|
|
|
|
|
+ string itemString = itemTemplate;
|
|
|
|
|
+ IDictionary<string, JsonData> itemData = item as IDictionary<string, JsonData>;
|
|
|
|
|
+ foreach(string itemKey in itemData.Keys)
|
|
|
|
|
+ {
|
|
|
|
|
+ JsonData itemObj = itemData[itemKey];
|
|
|
|
|
+ if(itemObj.IsArray || itemObj.IsObject)
|
|
|
|
|
+ {
|
|
|
|
|
+ itemString = StartMake(itemObj, itemTemplate);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ itemString = itemString.Replace("<<" + itemKey + ">>", itemObj[itemKey].ToString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ listString += itemString;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ templateString.Replace(matchValue, listString);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(obj.IsObject)
|
|
|
|
|
+ {
|
|
|
|
|
+ MatchCollection mc = Regex.Matches(templateString, "<<ym-item:" + key + ".*?>>[\\s\\S]*?<</ym-item:" + key + ">>");
|
|
|
|
|
+ foreach(Match m in mc)
|
|
|
|
|
+ {
|
|
|
|
|
+ string listString = "";
|
|
|
|
|
+ string matchValue = m.Value;
|
|
|
|
|
+ Match head = Regex.Match(matchValue, "<<ym-item:" + key + ".*>>");
|
|
|
|
|
+ if(head.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ string headValue = head.Value;
|
|
|
|
|
+ string itemTemplate = matchValue.Replace(headValue, "").Replace("<</ym-item:" + key + ">>", "");
|
|
|
|
|
+ string itemString = itemTemplate;
|
|
|
|
|
+ IDictionary<string, JsonData> itemData = obj as IDictionary<string, JsonData>;
|
|
|
|
|
+ foreach(string itemKey in itemData.Keys)
|
|
|
|
|
+ {
|
|
|
|
|
+ JsonData itemObj = itemData[itemKey];
|
|
|
|
|
+ if(itemObj.IsArray || itemObj.IsObject)
|
|
|
|
|
+ {
|
|
|
|
|
+ itemString = StartMake(itemObj, itemTemplate);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ itemString = itemString.Replace("<<" + itemKey + ">>", itemObj[itemKey].ToString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ listString += itemString;
|
|
|
|
|
+ }
|
|
|
|
|
+ templateString.Replace(matchValue, listString);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ templateString = templateString.Replace("<<ym:" + key + ">>", jsonObj[key].ToString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return templateString;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public async Task<string> PublicMakeAsync(string content)
|
|
|
|
|
+ {
|
|
|
|
|
+ MatchCollection mc = Regex.Matches(content, "<<ym-if:.*?>>.*?<</ym-if>>");
|
|
|
|
|
+ foreach(Match m in mc)
|
|
|
|
|
+ {
|
|
|
|
|
+ string matchValue = m.Value;
|
|
|
|
|
+ Match head = Regex.Match(matchValue, "<<ym-if:.*>>");
|
|
|
|
|
+ if(head.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ string headValue = head.Value;
|
|
|
|
|
+ string resultValue = matchValue.Replace(headValue, "").Replace("<</ym-if>>", "");
|
|
|
|
|
+ string condition = headValue.Substring(8, headValue.Length - 10);
|
|
|
|
|
+ condition = condition.Replace("isEmpty", "string.IsNullOrEmpty");
|
|
|
|
|
+ bool result = await CSharpScript.EvaluateAsync<bool>(condition);
|
|
|
|
|
+ content = content.Replace(matchValue, result ? resultValue : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return content;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|