|
...
|
...
|
@@ -6,7 +6,11 @@ import com.google.gson.JsonObject; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.utils.FeishuUtil;
|
|
|
|
import com.ruoyi.common.utils.GsonConstructor;
|
|
|
|
import com.ruoyi.system.domain.log.LogExcelSub;
|
|
|
|
import com.zhonglai.luhui.api.controller.test.dto.ClueData;
|
|
|
|
import com.zhonglai.luhui.api.controller.test.dto.FindExcelDataDto;
|
|
|
|
import com.zhonglai.luhui.dao.dto.SqlResult;
|
|
|
|
import com.zhonglai.luhui.dao.service.PublicService;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.apache.batik.transcoder.Transcoder;
|
|
...
|
...
|
@@ -15,6 +19,7 @@ import org.apache.batik.transcoder.TranscoderInput; |
|
|
|
import org.apache.batik.transcoder.TranscoderOutput;
|
|
|
|
import org.apache.batik.transcoder.image.JPEGTranscoder;
|
|
|
|
import org.apache.batik.transcoder.image.PNGTranscoder;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.util.StreamUtils;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
...
|
...
|
@@ -24,14 +29,14 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
import java.io.StringReader;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@Api(tags = "测试")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/test")
|
|
|
|
public class TestController {
|
|
|
|
@Autowired
|
|
|
|
private PublicService publicService;
|
|
|
|
@ApiOperation("账号密码登陆")
|
|
|
|
@GetMapping("/t1")
|
|
|
|
public AjaxResult t1()
|
|
...
|
...
|
@@ -109,6 +114,43 @@ public class TestController { |
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("新增多维表格数据")
|
|
|
|
@RequestMapping(value = "addExcelData")
|
|
|
|
public AjaxResult addExcelData(Integer system_type,String log_id,String excel_id,String sheet_id,@RequestBody String sub_data) throws IOException {
|
|
|
|
LogExcelSub logExcelSub = new LogExcelSub();
|
|
|
|
logExcelSub.setExcel_id(excel_id);
|
|
|
|
logExcelSub.setSheet_id(sheet_id);
|
|
|
|
logExcelSub.setSub_data(sub_data);
|
|
|
|
logExcelSub.setSystem_type(system_type);
|
|
|
|
logExcelSub.setLog_id(log_id);
|
|
|
|
return AjaxResult.success(publicService.insert(logExcelSub));
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("修改多维表格数据")
|
|
|
|
@RequestMapping(value = "upExcelData")
|
|
|
|
public AjaxResult upExcelData(Integer system_type,String log_id,String excel_id,String sheet_id,@RequestBody String sub_data) throws IOException {
|
|
|
|
LogExcelSub logExcelSub = new LogExcelSub();
|
|
|
|
logExcelSub.setExcel_id(excel_id);
|
|
|
|
logExcelSub.setSheet_id(sheet_id);
|
|
|
|
logExcelSub.setSystem_type(system_type);
|
|
|
|
logExcelSub.setLog_id(log_id);
|
|
|
|
Long nub = publicService.getObjectListTotle(logExcelSub,null);
|
|
|
|
|
|
|
|
logExcelSub.setSub_data(sub_data);
|
|
|
|
if(0==nub)
|
|
|
|
{
|
|
|
|
return AjaxResult.success(publicService.insert(logExcelSub));
|
|
|
|
}
|
|
|
|
return AjaxResult.success(publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("查询多维表格数据")
|
|
|
|
@RequestMapping(value = "findExcelData")
|
|
|
|
public AjaxResult findExcelData(@RequestBody FindExcelDataDto findExcelDataDto) throws IOException {
|
|
|
|
List<Map<String,Object>> list =publicService.getDynamicList(buildDynamicSqlSecure(findExcelDataDto.getSelectFields(),findExcelDataDto.getEqualConditions(),findExcelDataDto.getRangeConditions(),findExcelDataDto.getSystemType(),findExcelDataDto.getExcelId(),findExcelDataDto.getSheetId(),findExcelDataDto.getOrderFields(),findExcelDataDto.getOrderDirections()));
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("重写Highcharts导出")
|
|
|
|
@RequestMapping(value = "getFeishuTable")
|
|
|
|
public void getFeishuTable(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
...
|
...
|
@@ -202,4 +244,113 @@ public class TestController { |
|
|
|
FeishuUtil.subFeishuTables(FeishuUtil.gettenant_access_token("cli_a77e560b9475100c","7E80HFwgkmHjngFWDNsz6Pe1aqtKLC3m"),"YY58bkeMjahX5Uskh4WcnYOCnZc","tbldo1VjlU9jY51Y",field);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SqlResult buildDynamicSqlSecure(
|
|
|
|
List<String> selectFields, // 需要返回的字段
|
|
|
|
Map<String, Object> equalConditions, // JSON 等值条件
|
|
|
|
Map<String, Object[]> rangeConditions, // JSON 范围条件 [start, end]
|
|
|
|
Integer systemType, // system_type
|
|
|
|
String excel_id,
|
|
|
|
String sheetId, // sheet_id
|
|
|
|
List<String> orderFields, // 排序字段
|
|
|
|
List<String> orderDirections // 排序方向 ASC/DESC
|
|
|
|
) {
|
|
|
|
SqlResult result = new SqlResult();
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
List<Object> params = new ArrayList<>();
|
|
|
|
|
|
|
|
sql.append("SELECT id, log_id, ");
|
|
|
|
|
|
|
|
// SELECT JSON 字段
|
|
|
|
for (int i = 0; i < selectFields.size(); i++) {
|
|
|
|
String field = selectFields.get(i);
|
|
|
|
sql.append("JSON_UNQUOTE(JSON_EXTRACT(sub_data, '$.\"")
|
|
|
|
.append(field)
|
|
|
|
.append("\"')) AS `")
|
|
|
|
.append(field)
|
|
|
|
.append("`");
|
|
|
|
if (i < selectFields.size() - 1) sql.append(", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
sql.append(" FROM log_excel_sub WHERE 1=1 ");
|
|
|
|
|
|
|
|
// system_type
|
|
|
|
if (systemType != null) {
|
|
|
|
sql.append(" AND system_type = ? ");
|
|
|
|
params.add(systemType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// sheet_id
|
|
|
|
if (excel_id != null) {
|
|
|
|
sql.append(" AND excel_id = ? ");
|
|
|
|
params.add(excel_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// sheet_id
|
|
|
|
if (sheetId != null) {
|
|
|
|
sql.append(" AND sheet_id = ? ");
|
|
|
|
params.add(sheetId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 等值查询
|
|
|
|
if (equalConditions != null) {
|
|
|
|
for (Map.Entry<String, Object> entry : equalConditions.entrySet()) {
|
|
|
|
sql.append(" AND JSON_UNQUOTE(JSON_EXTRACT(sub_data, '$.\"")
|
|
|
|
.append(entry.getKey())
|
|
|
|
.append("\"')) = ? ");
|
|
|
|
params.add(entry.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 范围查询
|
|
|
|
if (rangeConditions != null) {
|
|
|
|
for (Map.Entry<String, Object[]> entry : rangeConditions.entrySet()) {
|
|
|
|
String field = entry.getKey();
|
|
|
|
Object[] range = entry.getValue();
|
|
|
|
|
|
|
|
sql.append(" AND STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(sub_data, '$.\"")
|
|
|
|
.append(field)
|
|
|
|
.append("\"')), '%Y/%m/%d %H:%i:%s') ");
|
|
|
|
|
|
|
|
if (range[0] != null && range[1] != null) {
|
|
|
|
sql.append("BETWEEN ? AND ? ");
|
|
|
|
params.add(range[0]);
|
|
|
|
params.add(range[1]);
|
|
|
|
} else if (range[0] != null) {
|
|
|
|
sql.append(">= ? ");
|
|
|
|
params.add(range[0]);
|
|
|
|
} else if (range[1] != null) {
|
|
|
|
sql.append("<= ? ");
|
|
|
|
params.add(range[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 排序
|
|
|
|
if (orderFields != null && !orderFields.isEmpty()) {
|
|
|
|
sql.append(" ORDER BY ");
|
|
|
|
|
|
|
|
for (int i = 0; i < orderFields.size(); i++) {
|
|
|
|
String field = orderFields.get(i);
|
|
|
|
String direction = (orderDirections != null && orderDirections.size() > i)
|
|
|
|
? orderDirections.get(i)
|
|
|
|
: "ASC";
|
|
|
|
|
|
|
|
sql.append("JSON_UNQUOTE(JSON_EXTRACT(sub_data, '$.\"")
|
|
|
|
.append(field)
|
|
|
|
.append("\"')) ")
|
|
|
|
.append(direction);
|
|
|
|
|
|
|
|
if (i < orderFields.size() - 1) {
|
|
|
|
sql.append(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result.setSql(sql.toString());
|
|
|
|
result.setParams(params);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|