|
@@ -67,14 +67,14 @@ namespace Util
|
|
|
}
|
|
|
|
|
|
//查询条件匹配数据
|
|
|
- public static List<QueryCondition> condition(int listId, int projectId, List<int> ids, string content)
|
|
|
+ public static List<QueryCondition> condition(int listId, int projectId, List<int> ids, string content, Dictionary<string, string> startData)
|
|
|
{
|
|
|
List<QueryCondition> dic = new();
|
|
|
var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
var queryFieldService = App.GetService<IPriQueryFieldService>();
|
|
|
var returnFieldService = App.GetService<IPriReturnFieldService>();
|
|
|
//查询表
|
|
|
- var queryTables = queryTableService.GetList(m => ids.Contains(m.id));
|
|
|
+ var queryTables = queryTableService.GetList(m => ids.Contains(m.id) && m.startDataFlag == false);
|
|
|
foreach(var queryTable in queryTables)
|
|
|
{
|
|
|
//查询返回字段
|
|
@@ -339,6 +339,274 @@ namespace Util
|
|
|
return dic;
|
|
|
}
|
|
|
|
|
|
+ public static DataTable conditionList(int listId, int projectId, List<int> ids, string content, int skip = 0, int size = 1000)
|
|
|
+ {
|
|
|
+ List<QueryCondition> dic = new();
|
|
|
+ var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
+ var queryFieldService = App.GetService<IPriQueryFieldService>();
|
|
|
+ var returnFieldService = App.GetService<IPriReturnFieldService>();
|
|
|
+ //查询表
|
|
|
+ var queryTable = queryTableService.GetFirst(m => ids.Contains(m.id) && m.startDataFlag == true);
|
|
|
+ if (queryTable != null)
|
|
|
+ {
|
|
|
+ string groupBy = "";
|
|
|
+
|
|
|
+ //查询返回字段
|
|
|
+ string fields = "";
|
|
|
+ Dictionary<string, string> fieldDic = new();
|
|
|
+ var returnFields = returnFieldService.GetList(m => m.queryTableId == queryTable.id);
|
|
|
+ foreach(var returnField in returnFields)
|
|
|
+ {
|
|
|
+ if(returnField.fieldReturnKind == "2")
|
|
|
+ {
|
|
|
+ fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
|
|
|
+ }
|
|
|
+ else if(returnField.fieldReturnKind == "3")
|
|
|
+ {
|
|
|
+ fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
|
|
|
+ }
|
|
|
+ else if(returnField.fieldReturnKind == "4")
|
|
|
+ {
|
|
|
+ fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
|
|
|
+ }
|
|
|
+ fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
|
|
|
+ }
|
|
|
+ fields = fields.TrimEnd(',');
|
|
|
+
|
|
|
+ //查询匹配条件
|
|
|
+ string condi = "";
|
|
|
+ var queryFields = queryFieldService.GetList(m => m.queryTableId == queryTable.id);
|
|
|
+ foreach(var queryField in queryFields)
|
|
|
+ {
|
|
|
+ string fieldEnName = queryField.fieldEnName;
|
|
|
+ string fieldQueryKind = queryField.fieldQueryKind;
|
|
|
+ string fieldQueryModel = queryField.fieldQueryModel;
|
|
|
+ string fieldQueryValue = queryField.fieldQueryValue;
|
|
|
+ string fieldQueryValueType = queryField.fieldQueryValueType;
|
|
|
+ if(fieldQueryKind == "1") //模糊匹配
|
|
|
+ {
|
|
|
+ condi += " and " + fieldEnName + " like ";
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
|
|
|
+ condi += "'%" + val + "%'";
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ string val = GetQueryTableData(dic, fieldQueryValue);
|
|
|
+ condi += "'%" + val + "%'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "2") //精确匹配
|
|
|
+ {
|
|
|
+ if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is null";
|
|
|
+ else
|
|
|
+ {
|
|
|
+ condi += " and " + fieldEnName + "=";
|
|
|
+ string val = "";
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ val = GetExpressionVal(fieldQueryValue);
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ val = GetDbExpressionVal(fieldQueryValue);
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ val = GetQueryTableData(dic, fieldQueryValue);
|
|
|
+ }
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val = "'" + val + "'";
|
|
|
+ }
|
|
|
+ condi += val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
|
|
|
+ {
|
|
|
+ if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
|
|
|
+ else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
|
|
|
+ string val = "";
|
|
|
+ string[] valList = fieldQueryValue.Split(',');
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ foreach(string sub in valList)
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val += "'" + req[sub] + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ val += req[sub] + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ foreach(string sub in valList)
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val += "'" + GetExpressionVal(sub) + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ val += GetExpressionVal(sub) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ foreach(string sub in valList)
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val += "'" + GetDbExpressionVal(sub) + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ val += GetDbExpressionVal(sub) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ foreach(string sub in valList)
|
|
|
+ {
|
|
|
+ string dicVal = GetQueryTableData(dic, sub);
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val += "'" + dicVal + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ val += dicVal + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val = val.TrimEnd(',');
|
|
|
+ condi += val + ")";
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "3") //范围匹配
|
|
|
+ {
|
|
|
+ string[] val = fieldQueryValue.Split(':');
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
|
|
|
+ if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
|
|
|
+ if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
|
|
|
+ if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
|
|
|
+ if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + GetDbExpressionVal(val[0]);
|
|
|
+ if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + GetDbExpressionVal(val[1]);
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ string valLeft = val[0];
|
|
|
+ string valRight = val[1];
|
|
|
+ string dicValLeft = GetQueryTableData(dic, valLeft);
|
|
|
+ string dicValRight = GetQueryTableData(dic, valRight);
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
|
|
|
+ if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<=" + dicValRight;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">='" + GetExpressionVal(dicValLeft) + "'";
|
|
|
+ if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<='" + GetExpressionVal(dicValRight) + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "4") //取反匹配
|
|
|
+ {
|
|
|
+ if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is not null";
|
|
|
+ else
|
|
|
+ {
|
|
|
+ condi += " and " + fieldEnName + "!=";
|
|
|
+ string val = "";
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ val = GetExpressionVal(fieldQueryValue);
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ val = GetDbExpressionVal(fieldQueryValue);
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ val = GetQueryTableData(dic, fieldQueryValue);
|
|
|
+ }
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ val = "'" + val + "'";
|
|
|
+ }
|
|
|
+ condi += val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //拼装聚合字段
|
|
|
+ if(queryField.groupByFlag) groupBy += queryField.fieldEnName +",";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!string.IsNullOrEmpty(groupBy)) groupBy = " group by " + groupBy.TrimEnd(',');
|
|
|
+
|
|
|
+ var db = initDb(queryTable.databaseId);
|
|
|
+ string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi + groupBy + " limit " + skip + "," + size;
|
|
|
+ var items = db.Ado.GetDataTable(sql);
|
|
|
+ return items;
|
|
|
+ }
|
|
|
+ return new DataTable();
|
|
|
+ }
|
|
|
+
|
|
|
//奖励发放对象
|
|
|
public static string prizeObject(int listId, int prizeObjectTag, string content)
|
|
|
{
|
|
@@ -585,429 +853,470 @@ namespace Util
|
|
|
//奖励发放
|
|
|
public static void prizeSend(int projectId, int prizeInId, string prizeIds, string content, string queueName)
|
|
|
{
|
|
|
- var loopSetService = App.GetService<IPriLoopSetService>();
|
|
|
- var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
|
|
|
- var recursionStartConditionService = App.GetService<IPriRecursionStartConditionService>();
|
|
|
+ var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
var priList = prizeList(projectId, prizeIds);
|
|
|
foreach(var sub in priList)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- addLog(projectId, sub.id, prizeInId, content, queueName); //初始化日志
|
|
|
- string prizeObjectId = prizeObject(sub.id, sub.prizeObj, content);
|
|
|
- var recursionFlag = sub.recursionFlag; //是否递归
|
|
|
- setLogStep(sub.id, "是否递归", recursionFlag ? "是" : "否");
|
|
|
- if(recursionFlag)
|
|
|
- {
|
|
|
- List<QueryCondition> queryCondiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content);
|
|
|
- setLogStep(sub.id, "查询原始数据", queryCondiDic);
|
|
|
- var loopSet = loopSetService.GetFirst(m => m.listId == sub.id) ?? new PriLoopSet();
|
|
|
- var recursionStartTable = recursionStartTableService.GetFirst(m => m.listId == sub.id) ?? new PriRecursionStartTable();
|
|
|
- var tableEnName = loopSet.tableEnName; //递归查询表
|
|
|
- var parentField = loopSet.parentField; //父字段
|
|
|
- var sonField = loopSet.sonField; //子字段
|
|
|
- var afterPrizeFlag = loopSet.afterPrizeFlag; //发奖后是否继续
|
|
|
- var db = initDb(loopSet.databaseId);
|
|
|
- string objId = prizeObjectId;
|
|
|
+ List<int> ids = Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList();
|
|
|
+ var queryTable = queryTableService.GetFirst(m => ids.Contains(m.id) && m.startDataFlag == true);
|
|
|
+ if (queryTable != null)
|
|
|
+ {
|
|
|
+ int page = 0;
|
|
|
+ int size = queryTable.stepCount;
|
|
|
+ if(size == 0) size = 20;
|
|
|
bool op = true;
|
|
|
- int index = 0;
|
|
|
- loopAmount = 0;
|
|
|
- List<Dictionary<string, object>> loopLogDic = new();
|
|
|
- while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
|
|
|
- {
|
|
|
- Dictionary<string, object> loopLog = new();
|
|
|
- List<QueryCondition> condiDic = loopCondition(projectId, sub, objId, content);
|
|
|
- loopLog.Add("查询" + objId + "匹配数据", condiDic);
|
|
|
- if(condiDic.Count > 0)
|
|
|
- {
|
|
|
- bool prizeFlag = true;
|
|
|
- var conditions = recursionStartConditionService.GetList(m => m.loopSetId == loopSet.id);
|
|
|
- if(conditions.Count > 0)
|
|
|
+ while(op)
|
|
|
+ {
|
|
|
+ int skip = page * size;
|
|
|
+ DataTable query = conditionList(sub.id, projectId, ids, content, skip, size);
|
|
|
+ if(query.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ foreach(DataRow dr in query.Rows)
|
|
|
{
|
|
|
- int allCount = conditions.Count; //所有奖励条件数
|
|
|
- int passCount = 0; //通过条件数
|
|
|
- List<Dictionary<string, object>> logStepDics = new();
|
|
|
- foreach(var condition in conditions)
|
|
|
+ Dictionary<string, string> startData = new();
|
|
|
+ foreach(DataColumn dc in query.Columns)
|
|
|
{
|
|
|
- if(condition.startIndex <= index)
|
|
|
+ startData.Add(dc.ColumnName, dr[dc.ColumnName].ToString());
|
|
|
+ }
|
|
|
+ prizeSendSub(sub, projectId, prizeInId, prizeIds, content, queueName, startData);
|
|
|
+ }
|
|
|
+ page += 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ op = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ prizeSendSub(sub, projectId, prizeInId, prizeIds, content, queueName, new Dictionary<string, string>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
+ {
|
|
|
+ setLogFieldValue(sub.id, "errLog", ex.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行每个奖励发放逻辑
|
|
|
+ public static void prizeSendSub(PriList sub, int projectId, int prizeInId, string prizeIds, string content, string queueName, Dictionary<string, string> startData)
|
|
|
+ {
|
|
|
+ var loopSetService = App.GetService<IPriLoopSetService>();
|
|
|
+ var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
|
|
|
+ var recursionStartConditionService = App.GetService<IPriRecursionStartConditionService>();
|
|
|
+ addLog(projectId, sub.id, prizeInId, content, queueName); //初始化日志
|
|
|
+ string prizeObjectId = prizeObject(sub.id, sub.prizeObj, content);
|
|
|
+ var recursionFlag = sub.recursionFlag; //是否递归
|
|
|
+ setLogStep(sub.id, "是否递归", recursionFlag ? "是" : "否");
|
|
|
+ if(recursionFlag)
|
|
|
+ {
|
|
|
+ List<QueryCondition> queryCondiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content, startData);
|
|
|
+ setLogStep(sub.id, "查询原始数据", queryCondiDic);
|
|
|
+ var loopSet = loopSetService.GetFirst(m => m.listId == sub.id) ?? new PriLoopSet();
|
|
|
+ var recursionStartTable = recursionStartTableService.GetFirst(m => m.listId == sub.id) ?? new PriRecursionStartTable();
|
|
|
+ var tableEnName = loopSet.tableEnName; //递归查询表
|
|
|
+ var parentField = loopSet.parentField; //父字段
|
|
|
+ var sonField = loopSet.sonField; //子字段
|
|
|
+ var afterPrizeFlag = loopSet.afterPrizeFlag; //发奖后是否继续
|
|
|
+ var db = initDb(loopSet.databaseId);
|
|
|
+ string objId = prizeObjectId;
|
|
|
+ bool op = true;
|
|
|
+ int index = 0;
|
|
|
+ loopAmount = 0;
|
|
|
+ List<Dictionary<string, object>> loopLogDic = new();
|
|
|
+ while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> loopLog = new();
|
|
|
+ List<QueryCondition> condiDic = loopCondition(projectId, sub, objId, content);
|
|
|
+ loopLog.Add("查询" + objId + "匹配数据", condiDic);
|
|
|
+ if(condiDic.Count > 0)
|
|
|
+ {
|
|
|
+ bool prizeFlag = true;
|
|
|
+ var conditions = recursionStartConditionService.GetList(m => m.loopSetId == loopSet.id);
|
|
|
+ if(conditions.Count > 0)
|
|
|
+ {
|
|
|
+ int allCount = conditions.Count; //所有奖励条件数
|
|
|
+ int passCount = 0; //通过条件数
|
|
|
+ List<Dictionary<string, object>> logStepDics = new();
|
|
|
+ foreach(var condition in conditions)
|
|
|
+ {
|
|
|
+ if(condition.startIndex <= index)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> logStepDic = new();
|
|
|
+
|
|
|
+ var returnFieldId = condition.returnFieldId; //条件返回字段
|
|
|
+ var fieldQueryKind = condition.fieldQueryKind; //匹配条件
|
|
|
+ var fieldQueryModel = condition.fieldQueryModel; //匹配方式
|
|
|
+ var fieldQueryValue = condition.fieldQueryValue; //匹配值
|
|
|
+ var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
|
|
|
+
|
|
|
+ string checkObj = "";
|
|
|
+ string checkTitle = "";
|
|
|
+ if(returnFieldId.Contains(","))
|
|
|
+ {
|
|
|
+ string[] returnFieldIdList = returnFieldId.Split(',');
|
|
|
+ foreach(string subField in returnFieldIdList)
|
|
|
{
|
|
|
- Dictionary<string, object> logStepDic = new();
|
|
|
-
|
|
|
- var returnFieldId = condition.returnFieldId; //条件返回字段
|
|
|
- var fieldQueryKind = condition.fieldQueryKind; //匹配条件
|
|
|
- var fieldQueryModel = condition.fieldQueryModel; //匹配方式
|
|
|
- var fieldQueryValue = condition.fieldQueryValue; //匹配值
|
|
|
- var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
|
|
|
+ string val = GetQueryTableData(condiDic, subField);
|
|
|
+ checkObj += val + ",";
|
|
|
+ string title = GetQueryTableTitle(condiDic, subField);
|
|
|
+ checkTitle += title + ",";
|
|
|
+ }
|
|
|
+ checkObj = checkObj.TrimEnd(',');
|
|
|
+ checkTitle = checkTitle.TrimEnd(',');
|
|
|
+ }
|
|
|
+ else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
|
|
|
+ {
|
|
|
+ string expresssion = returnFieldId;
|
|
|
+ checkTitle = returnFieldId;
|
|
|
+ string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
|
|
|
+ foreach(string returnField in returnFields)
|
|
|
+ {
|
|
|
+ string val = GetQueryTableData(condiDic, returnField);
|
|
|
+ expresssion = expresssion.Replace(returnField, val);
|
|
|
|
|
|
- string checkObj = "";
|
|
|
- string checkTitle = "";
|
|
|
- if(returnFieldId.Contains(","))
|
|
|
+ string title = GetQueryTableTitle(condiDic, returnField);
|
|
|
+ checkTitle = checkTitle.Replace(returnField, title);
|
|
|
+ }
|
|
|
+ DataTable dt = new();
|
|
|
+ checkObj = dt.Compute(expresssion, "false").ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ checkObj = GetQueryTableData(condiDic, returnFieldId);
|
|
|
+ checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
|
|
|
+ }
|
|
|
+
|
|
|
+ logStepDic.Add("标题", checkTitle);
|
|
|
+ logStepDic.Add("匹配条件", getQueryKind(fieldQueryKind));
|
|
|
+ logStepDic.Add("匹配方式", getQueryModel(fieldQueryModel));
|
|
|
+ logStepDic.Add("匹配值", fieldQueryValue);
|
|
|
+ logStepDic.Add("实际值", checkObj);
|
|
|
+
|
|
|
+ var checkVal = fieldQueryValue;
|
|
|
+ bool passFlag = false;
|
|
|
+
|
|
|
+ if(fieldQueryKind == "1") //模糊匹配
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ if(checkObj.ToString().Contains(GetExpressionVal(checkVal)))
|
|
|
{
|
|
|
- string[] returnFieldIdList = returnFieldId.Split(',');
|
|
|
- foreach(string subField in returnFieldIdList)
|
|
|
- {
|
|
|
- string val = GetQueryTableData(condiDic, subField);
|
|
|
- checkObj += val + ",";
|
|
|
- string title = GetQueryTableTitle(condiDic, subField);
|
|
|
- checkTitle += title + ",";
|
|
|
- }
|
|
|
- checkObj = checkObj.TrimEnd(',');
|
|
|
- checkTitle = checkTitle.TrimEnd(',');
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "2") //精确匹配
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "int")
|
|
|
+ {
|
|
|
+ if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
|
|
|
+ }
|
|
|
+ else if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(checkObj.ToString() == GetExpressionVal(checkVal))
|
|
|
{
|
|
|
- string expresssion = returnFieldId;
|
|
|
- checkTitle = returnFieldId;
|
|
|
- string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
|
|
|
- foreach(string returnField in returnFields)
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "3") //范围匹配
|
|
|
+ {
|
|
|
+ string[] val = checkVal.Split(':');
|
|
|
+ string valLeft = val[0];
|
|
|
+ string valRight = val[1];
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
|
|
|
{
|
|
|
- string val = GetQueryTableData(condiDic, returnField);
|
|
|
- expresssion = expresssion.Replace(returnField, val);
|
|
|
-
|
|
|
- string title = GetQueryTableTitle(condiDic, returnField);
|
|
|
- checkTitle = checkTitle.Replace(returnField, title);
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- DataTable dt = new();
|
|
|
- checkObj = dt.Compute(expresssion, "false").ToString();
|
|
|
}
|
|
|
- else
|
|
|
+ else if(fieldQueryValueType == "int")
|
|
|
{
|
|
|
- checkObj = GetQueryTableData(condiDic, returnFieldId);
|
|
|
- checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
|
|
|
+ if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- logStepDic.Add("标题", checkTitle);
|
|
|
- logStepDic.Add("匹配条件", getQueryKind(fieldQueryKind));
|
|
|
- logStepDic.Add("匹配方式", getQueryModel(fieldQueryModel));
|
|
|
- logStepDic.Add("匹配值", fieldQueryValue);
|
|
|
- logStepDic.Add("实际值", checkObj);
|
|
|
-
|
|
|
- var checkVal = fieldQueryValue;
|
|
|
- bool passFlag = false;
|
|
|
-
|
|
|
- if(fieldQueryKind == "1") //模糊匹配
|
|
|
+ else if(fieldQueryValueType.StartsWith("date"))
|
|
|
{
|
|
|
- if(fieldQueryValueType == "text")
|
|
|
+ if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
|
|
|
{
|
|
|
- if(checkObj.ToString().Contains(GetExpressionVal(checkVal)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryKind == "2") //精确匹配
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ string checkValLeft = valLeft.Replace("#{", "").Replace("}#", "");
|
|
|
+ string checkValRight = valRight.Replace("#{", "").Replace("}#", "");
|
|
|
+ if(checkValLeft.Contains(",")) checkValLeft = checkValLeft.Split(',')[0];
|
|
|
+ if(checkValRight.Contains(",")) checkValRight = checkValRight.Split(',')[0];
|
|
|
+ valLeft = GetExpressionVal(valLeft);
|
|
|
+ valRight = GetExpressionVal(valRight);
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
{
|
|
|
- if(fieldQueryValueType == "int")
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
{
|
|
|
- if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if(fieldQueryValueType == "number")
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
|
|
|
{
|
|
|
- if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
{
|
|
|
- if(checkObj.ToString() == GetExpressionVal(checkVal))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryKind == "3") //范围匹配
|
|
|
+ else if(fieldQueryValueType == "int")
|
|
|
{
|
|
|
- string[] val = checkVal.Split(':');
|
|
|
- string valLeft = val[0];
|
|
|
- string valRight = val[1];
|
|
|
- if(fieldQueryModel == "request_param")
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
{
|
|
|
- Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
- if(fieldQueryValueType == "number")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "int")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType.StartsWith("date"))
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if(fieldQueryModel == "fixed_value")
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
|
|
|
{
|
|
|
- string checkValLeft = valLeft.Replace("#{", "").Replace("}#", "");
|
|
|
- string checkValRight = valRight.Replace("#{", "").Replace("}#", "");
|
|
|
- if(checkValLeft.Contains(",")) checkValLeft = checkValLeft.Split(',')[0];
|
|
|
- if(checkValRight.Contains(",")) checkValRight = checkValRight.Split(',')[0];
|
|
|
- valLeft = GetExpressionVal(valLeft);
|
|
|
- valRight = GetExpressionVal(valRight);
|
|
|
- if(fieldQueryValueType == "number")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "int")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType.StartsWith("date"))
|
|
|
- {
|
|
|
- if(valLeft == "0") valLeft = "";
|
|
|
- if(valRight == "0") valRight = "";
|
|
|
- if(checkObj != "0" && checkObj != "")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if(fieldQueryModel == "query_field")
|
|
|
- {
|
|
|
- valLeft = GetComputeVal(queryCondiDic, valLeft);
|
|
|
- valRight = GetComputeVal(queryCondiDic, valRight);
|
|
|
- if(fieldQueryValueType == "number")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "int")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryValueType.StartsWith("date"))
|
|
|
- {
|
|
|
- if(valLeft == "0") valLeft = "";
|
|
|
- if(valRight == "0") valRight = "";
|
|
|
- if(checkObj != "0" && checkObj != "")
|
|
|
- {
|
|
|
- if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
- {
|
|
|
- passCount += 1; passFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryKind == "4") //取反匹配
|
|
|
+ else if(fieldQueryValueType.StartsWith("date"))
|
|
|
{
|
|
|
- if(fieldQueryValueType == "int")
|
|
|
+ if(valLeft == "0") valLeft = "";
|
|
|
+ if(valRight == "0") valRight = "";
|
|
|
+ if(checkObj != "0" && checkObj != "")
|
|
|
{
|
|
|
- if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal)))
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
{
|
|
|
passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "number")
|
|
|
- {
|
|
|
- if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal)))
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
|
|
|
{
|
|
|
passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "text")
|
|
|
- {
|
|
|
- if(checkObj.ToString() != GetExpressionVal(checkVal))
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
{
|
|
|
passCount += 1; passFlag = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "query_field")
|
|
|
+ {
|
|
|
+ valLeft = GetComputeVal(queryCondiDic, valLeft);
|
|
|
+ valRight = GetComputeVal(queryCondiDic, valRight);
|
|
|
+ if(fieldQueryValueType == "number")
|
|
|
{
|
|
|
- string val = ",";
|
|
|
- string[] valList = checkVal.Split(',');
|
|
|
- if(fieldQueryModel == "request_param")
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
{
|
|
|
- Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
- foreach(string subVal in valList)
|
|
|
- {
|
|
|
- val += req[subVal] + ",";
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if(fieldQueryModel == "fixed_value")
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
|
|
|
{
|
|
|
- foreach(string subVal in valList)
|
|
|
- {
|
|
|
- val += GetExpressionVal(subVal) + ",";
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- else if(fieldQueryModel == "db_field")
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
|
|
|
{
|
|
|
- foreach(string subVal in valList)
|
|
|
- {
|
|
|
- val += GetDbExpressionVal(subVal) + ",";
|
|
|
- }
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryValueType == "int")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ","))
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
|
|
|
{
|
|
|
passCount += 1; passFlag = true;
|
|
|
}
|
|
|
- if(fieldQueryKind == "6" && !val.Contains("," + checkObj.ToString() + ","))
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
|
|
|
{
|
|
|
passCount += 1; passFlag = true;
|
|
|
}
|
|
|
}
|
|
|
- logStepDic.Add("状态", passFlag ? "通过" : "未通过");
|
|
|
- logStepDics.Add(logStepDic);
|
|
|
+ else if(fieldQueryValueType.StartsWith("date"))
|
|
|
+ {
|
|
|
+ if(valLeft == "0") valLeft = "";
|
|
|
+ if(valRight == "0") valRight = "";
|
|
|
+ if(checkObj != "0" && checkObj != "")
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- loopLog.Add(objId + "匹配情况", logStepDics);
|
|
|
- if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
|
|
|
- else if(loopSet.conditionMode == "one" && passCount >= 1) prizeFlag = true;
|
|
|
- else if(loopSet.conditionMode == "two" && passCount >= 2) prizeFlag = true;
|
|
|
- else if(loopSet.conditionMode == "three" && passCount >= 3) prizeFlag = true;
|
|
|
- else prizeFlag = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- prizeFlag = false;
|
|
|
- }
|
|
|
- loopLog.Add("匹配结果", prizeFlag);
|
|
|
- if(prizeFlag)
|
|
|
- {
|
|
|
- decimal prizeAmt = prizeSendDo(projectId, sub, objId, content, loopSet);
|
|
|
- op = afterPrizeFlag;
|
|
|
+ else if(fieldQueryKind == "4") //取反匹配
|
|
|
+ {
|
|
|
+ if(fieldQueryValueType == "int")
|
|
|
+ {
|
|
|
+ if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal)))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ if(checkObj.ToString() != GetExpressionVal(checkVal))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
|
|
|
+ {
|
|
|
+ string val = ",";
|
|
|
+ string[] valList = checkVal.Split(',');
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ val += req[subVal] + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ val += GetExpressionVal(subVal) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
+ {
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ val += GetDbExpressionVal(subVal) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ","))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ if(fieldQueryKind == "6" && !val.Contains("," + checkObj.ToString() + ","))
|
|
|
+ {
|
|
|
+ passCount += 1; passFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logStepDic.Add("状态", passFlag ? "通过" : "未通过");
|
|
|
+ logStepDics.Add(logStepDic);
|
|
|
}
|
|
|
}
|
|
|
- loopLogDic.Add(loopLog);
|
|
|
- var parent = db.Ado.GetScalar("select " + parentField + " from " + tableEnName + " where " + sonField + "=" + objId);
|
|
|
- if(parent != null)
|
|
|
- {
|
|
|
- objId = parent.ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- objId = "0";
|
|
|
- }
|
|
|
- index += 1;
|
|
|
+ loopLog.Add(objId + "匹配情况", logStepDics);
|
|
|
+ if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
|
|
|
+ else if(loopSet.conditionMode == "one" && passCount >= 1) prizeFlag = true;
|
|
|
+ else if(loopSet.conditionMode == "two" && passCount >= 2) prizeFlag = true;
|
|
|
+ else if(loopSet.conditionMode == "three" && passCount >= 3) prizeFlag = true;
|
|
|
+ else prizeFlag = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ prizeFlag = false;
|
|
|
}
|
|
|
- setLogStep(sub.id, "向上递归流程", loopLogDic);
|
|
|
+ loopLog.Add("匹配结果", prizeFlag);
|
|
|
+ if(prizeFlag)
|
|
|
+ {
|
|
|
+ decimal prizeAmt = prizeSendDo(projectId, sub, objId, content, loopSet, startData);
|
|
|
+ op = afterPrizeFlag;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loopLogDic.Add(loopLog);
|
|
|
+ var parent = db.Ado.GetScalar("select " + parentField + " from " + tableEnName + " where " + sonField + "=" + objId);
|
|
|
+ if(parent != null)
|
|
|
+ {
|
|
|
+ objId = parent.ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- prizeSendDo(projectId, sub, prizeObjectId, content, new PriLoopSet());
|
|
|
+ objId = "0";
|
|
|
}
|
|
|
+ index += 1;
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
- {
|
|
|
- setLogFieldValue(sub.id, "errLog", ex.ToString());
|
|
|
- }
|
|
|
+ setLogStep(sub.id, "向上递归流程", loopLogDic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ prizeSendDo(projectId, sub, prizeObjectId, content, new PriLoopSet(), startData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static decimal loopAmount = 0;
|
|
|
- public static decimal prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set)
|
|
|
+ public static decimal prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set, Dictionary<string, string> startData)
|
|
|
{
|
|
|
var projectService = App.GetService<IPriProjectService>();
|
|
|
var recordService = App.GetService<IPriRecordService>();
|
|
|
var conditionService = App.GetService<IPriConditionService>();
|
|
|
var returnFieldService = App.GetService<IPriReturnFieldService>();
|
|
|
- var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
+ // var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
var amountSetService = App.GetService<IPriListAmountSetService>();
|
|
|
|
|
|
var project = projectService.GetFirst(m => m.id == projectId) ?? new PriProject();
|
|
|
//查询匹配条件
|
|
|
- List<QueryCondition> condiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content);
|
|
|
+ List<QueryCondition> condiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content, startData);
|
|
|
if(sub.prizeSourceFieldType == "loop") MergeCondiDic(condiDic, loopCondition(projectId, sub, prizeObjectId, content));
|
|
|
setLogStep(sub.id, "发放奖励查询来源数据", condiDic);
|
|
|
|