From 7105265a2199ad452aac42b1aab617621abb4d02 Mon Sep 17 00:00:00 2001
From: houzhongjian <houzhongyi@126.com>
Date: 星期三, 16 十月 2024 09:50:37 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java    |   13 +++++++++----
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/ApiIndItemController.java |   12 +++++++++++-
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/value/dto/QuerySourceValueDTO.java   |    3 +++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/ApiIndItemController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/ApiIndItemController.java
index 86b5abf..3fd5980 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/ApiIndItemController.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/ApiIndItemController.java
@@ -2,6 +2,7 @@
 
 import com.iailab.framework.common.pojo.CommonResult;
 import com.iailab.framework.common.util.object.ConvertUtils;
+import com.iailab.framework.tenant.core.context.TenantContextHolder;
 import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO;
 import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO;
 import com.iailab.module.data.ind.collection.IndItemCollector;
@@ -16,6 +17,7 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.security.PermitAll;
+import java.util.ArrayList;
 import java.util.List;
 
 import static com.iailab.framework.common.pojo.CommonResult.success;
@@ -38,8 +40,16 @@
     @GetMapping("/query-ind/default-value")
     @Operation(summary = "查询指标默认值")
     public CommonResult<List<ApiIndItemValueDTO>> queryIndItemDefaultValue(@RequestParam String itemNo) {
+        TenantContextHolder.setTenantId(161L);
         List<IndItemValueVO> list = indItemCollector.queryValue(itemNo);
-        return success(ConvertUtils.sourceToTarget(list, ApiIndItemValueDTO.class));
+        List<ApiIndItemValueDTO> dtoList = new ArrayList<>();
+        list.forEach(item -> {
+            ApiIndItemValueDTO dto = new ApiIndItemValueDTO();
+            dto.setDataTime(item.getDataTime());
+            dto.setDataValue(item.getDataValue().doubleValue());
+            dtoList.add(dto);
+        });
+        return success(dtoList);
 
     }
 
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
index c20dadd..4636904 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/collection/utils/IndSqlUtils.java
@@ -50,6 +50,7 @@
         if (indItem == null) {
             return result;
         }
+        result.setIndItemAtom(indItem);
         IndDataSetDTO dataSet = indDataSetService.getDet(indItem.getDataSet());
         if (dataSet == null) {
             return result;
@@ -94,11 +95,15 @@
 
         // 拼接SELECT
         StringBuilder selectSql = new StringBuilder();
-        if (StringUtils.isNotBlank(indItem.getDimension())){
+        if (StringUtils.isNotBlank(indItem.getDimension()) && StringUtils.isNotBlank(result.getIndItemAtom().getStatFunc())){
             selectSql.append(indItem.getDimension());
             selectSql.append(", ");
             selectSql.append(result.getSelectSql());
-        }else{
+        }
+        else if(StringUtils.isBlank(indItem.getDimension()) && StringUtils.isNotBlank(result.getIndItemAtom().getStatFunc())){
+            selectSql.append(result.getSelectSql());
+        }
+        else{
             selectSql.append(result.getSelectSql());
             selectSql.append(", ");
             selectSql.append(indItem.getTimeLabel());
@@ -188,9 +193,9 @@
                 whereSql.append(indItem.getTimeLabel());
                 whereSql.append(" <= '");
                 whereSql.append(DateUtils.format(indItem.getTimeEnd(), PATTERN_MON));
-                whereSql.append("' AND '");
+                whereSql.append("' AND ");
                 whereSql.append(indItem.getTimeLabel());
-                whereSql.append("' >= '");
+                whereSql.append(" >= '");
                 whereSql.append(DateUtils.format(indItem.getTimeStart(), PATTERN_MON));
                 whereSql.append("'");
                 break;
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/value/dto/QuerySourceValueDTO.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/value/dto/QuerySourceValueDTO.java
index 7a168f6..1b3ec27 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/value/dto/QuerySourceValueDTO.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/ind/value/dto/QuerySourceValueDTO.java
@@ -1,5 +1,6 @@
 package com.iailab.module.data.ind.value.dto;
 
+import com.iailab.module.data.ind.item.vo.IndItemAtomVO;
 import lombok.Data;
 
 /**
@@ -21,4 +22,6 @@
     private String groupSql;
 
     private String orderBySql;
+
+    private IndItemAtomVO indItemAtom;
 }
\ No newline at end of file

--
Gitblit v1.9.3