|
@@ -110,10 +110,10 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
conditions.keySet().forEach(item -> {
|
|
|
Object value = conditions.get(item);
|
|
|
// 判断value是否为String类型且非JSON数组格式
|
|
|
- if (((String) value).startsWith("[")) {
|
|
|
+ if (!String.valueOf(value) .startsWith("[")) {
|
|
|
// 将单个值转换成JSON数组
|
|
|
- JSONArray jsonArray = new JSONArray(Arrays.asList((String) value));
|
|
|
- endConditions.put(toUnderScoreCase(item), jsonArray.toJSONString());
|
|
|
+ JSONArray jsonArray = new JSONArray(Arrays.asList(String.valueOf(value)));
|
|
|
+ endConditions.put(toUnderScoreCase(item), jsonArray);
|
|
|
} else {
|
|
|
endConditions.put(toUnderScoreCase(item), value);
|
|
|
}
|
|
@@ -325,6 +325,72 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
return commonEntities;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<CommonEntity> queryGroupTableList1(CommonEntity commonEntity, TableSql tableSql, String tableFormat) {
|
|
|
+ //前端传递过来的参数
|
|
|
+ Map<String, Object> queryMap = commonEntity.getQueryMap();
|
|
|
+ //是否存在
|
|
|
+ AtomicReference<Boolean> isExist = new AtomicReference<>(true);
|
|
|
+ //循环前端传过来的参数 跳过 sqlkey
|
|
|
+ AtomicReference<String> replaceSql = new AtomicReference<>(tableSql.getTableCondition());
|
|
|
+ queryMap.forEach((k, v) -> {
|
|
|
+ if (!k.equals("sqlkey") && !k.equals("queryCriteriaValue")) { //查询第一个表的数据是不会进行任何替换的
|
|
|
+ int isExistIndex = tableSql.getTableCondition().indexOf(k);
|
|
|
+ replaceSql.set(tableSql.getTableCondition().replace(k, v.toString()));
|
|
|
+ if (isExistIndex < 0) {
|
|
|
+ isExist.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //证明条件不对应不能让他进行查询
|
|
|
+ if (!isExist.get()) {
|
|
|
+ List<CommonEntity> commonEntityList = new ArrayList<>();
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ HashMap<String, Object> hashMap = new HashMap();
|
|
|
+ hashMap.put("err", "查询条件不匹配查询失败");
|
|
|
+ common.setResultMap(hashMap);
|
|
|
+ commonEntityList.add(common);
|
|
|
+ return commonEntityList;
|
|
|
+ }
|
|
|
+ Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(commonEntity.getQueryMap()));
|
|
|
+ //正常的查询
|
|
|
+ String queryCriteriaValue =
|
|
|
+ conditions.containsKey("queryCriteriaValue") == true
|
|
|
+ ? conditions.get("queryCriteriaValue").toString() : "";
|
|
|
+ String endSQL = replaceSql.get().replace("#{val}", queryCriteriaValue);
|
|
|
+
|
|
|
+ String columnName = commonEntity.getConditionMap().get("columnName").toString();
|
|
|
+ String columnValue = commonEntity.getConditionMap().get("columnValue").toString();
|
|
|
+ String sqlString = tableSql.getTableSql() + " where " + endSQL + " and sale_order." + columnName + " in (" + columnValue + ")";
|
|
|
+
|
|
|
+ List<CommonEntity> commonEntities = commonMapper.queryTableList(sqlString);
|
|
|
+ //根据sqlKey查询表格数据
|
|
|
+ commonEntities.forEach(item -> {
|
|
|
+ Map<String, Object> resultMap = item.getResultMap();
|
|
|
+ resultMap.forEach((k, v) -> {
|
|
|
+ if (StringUtils.isNotNull(v) && !v.toString().isEmpty()) {
|
|
|
+ //正则匹配成功
|
|
|
+ boolean validDateTimeFormat = isValidDateTimeFormat(v.toString());
|
|
|
+ if (validDateTimeFormat) {
|
|
|
+ if (v.toString().indexOf("T") > 0) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; // 默认支持这种格式
|
|
|
+ LocalDateTime dateTime = LocalDateTime.parse(v.toString(), formatter);
|
|
|
+ DateTimeFormatter fmt = DateTimeFormatter.ofPattern(tableFormat);
|
|
|
+ String dateStr = dateTime.format(fmt);
|
|
|
+ resultMap.put(k, dateStr);
|
|
|
+ } else {
|
|
|
+ LocalDateTime localDateTime = DateUtils.toLocalDateTime(v.toString(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ DateTimeFormatter fmt = DateTimeFormatter.ofPattern(tableFormat);
|
|
|
+ String dateStr = localDateTime.format(fmt);
|
|
|
+ resultMap.put(k, dateStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return commonEntities;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public CommonEntity queryDropDownBoxData(List<CommonEntity> commonEntityList) {
|
|
|
Map<String, Object> retMap = new HashMap<>();
|