Commit e3bcc68a authored by wujiang's avatar wujiang

添加筛选项级联过滤

parent 78aac8fe
...@@ -5,6 +5,9 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController; ...@@ -5,6 +5,9 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanPointProcessVariableClassificationServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanPointProcessVariableClassificationServiceImpl;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,6 +18,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -15,6 +18,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -124,13 +129,24 @@ public class IdxBizFanPointProcessVariableClassificationController extends BaseC ...@@ -124,13 +129,24 @@ public class IdxBizFanPointProcessVariableClassificationController extends BaseC
* 列表全部数据查询 * 列表全部数据查询
* *
* @return * @return
* @throws UnsupportedEncodingException
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询", notes = "列表全部数据查询") @ApiOperation(httpMethod = "GET",value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/selectParams") @GetMapping(value = "/selectParams")
public ResponseModel<List<Map<String,Object>>> selectParams(String tableName,String column,@RequestParam(required = false) String isFx) { public ResponseModel<List<Map<String,Object>>> selectParams() throws UnsupportedEncodingException {
String queryString = request.getQueryString();
String[] paramPairs = queryString.split("&");
Map<String, String> params = new HashMap<>();
for (String paramPair : paramPairs) {
String[] keyValue = paramPair.split("=");
String key = keyValue[0];
String value = keyValue[1];
value= URLDecoder.decode(value, "utf-8");
params.put(key, value);
}
// return ResponseHelper.buildResponse(idxBizFanPointProcessVariableClassificationServiceImpl.selectParams(column,tableName,isFx)); // return ResponseHelper.buildResponse(idxBizFanPointProcessVariableClassificationServiceImpl.selectParams(column,tableName,isFx));
List<Map<String, Object>> selectOptions = idxBizTableService.getSelectOptions(tableName, column, null,null, null, isFx); List<Map<String, Object>> selectOptions = idxBizTableService.getSelectOptions(params);
return ResponseHelper.buildResponse(selectOptions); return ResponseHelper.buildResponse(selectOptions);
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -14,43 +15,49 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -14,43 +15,49 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
@Api(tags = "idx业务前置接口") @Api(tags = "idx业务前置接口")
@RequestMapping(value = "/idx") @RequestMapping(value = "/idx")
public class IdxBizTableController { public class IdxBizTableController extends BaseController{
@Autowired @Autowired
IIdxBizTableService idxBizTableService; IIdxBizTableService idxBizTableService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "分页查询业务事实表的数据", notes = "分页查询业务事实表的数据-IDX前置接口") @ApiOperation(httpMethod = "GET", value = "分页查询业务事实表的数据", notes = "分页查询业务事实表的数据-IDX前置接口")
@GetMapping(value = "/table/getPage") @GetMapping(value = "/table/getPage")
public ResponseModel<Page<Map<String, Object>>> getTablePage(@RequestParam Map<String, Object> map) { public ResponseModel<Page<Map<String, Object>>> getTablePage(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(idxBizTableService.getPage(map)); return ResponseHelper.buildResponse(idxBizTableService.getPage(map));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "分页查询业务事实表的数据", notes = "分页查询业务事实表的数据-IDX前置接口")
@GetMapping(value = "/table/getPageO")
public ResponseModel<Page<Map<String, Object>>> getPageO(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(idxBizTableService.getPageO(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表下拉框选项数据", notes = "列表下拉框选项数据") @ApiOperation(httpMethod = "GET", value = "分页查询业务事实表的数据", notes = "分页查询业务事实表的数据-IDX前置接口")
@GetMapping(value = "/select-options") @GetMapping(value = "/table/getPageO")
public ResponseModel<List<Map<String, Object>>> getSelectOptions( public ResponseModel<Page<Map<String, Object>>> getPageO(@RequestParam Map<String, Object> map) {
@RequestParam(value = "tableName") String tableName, return ResponseHelper.buildResponse(idxBizTableService.getPageO(map));
@RequestParam(value = "column") String column, }
@RequestParam(value = "valueColumn", required = false) String valueColumn,
@RequestParam(value = "conditionColumn", required = false) String conditionColumn, @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestParam(value = "conditionValue", required = false) String conditionValue, @ApiOperation(httpMethod = "GET", value = "列表下拉框选项数据", notes = "列表下拉框选项数据")
@RequestParam(value = "isFx", required = false) String isFx @GetMapping(value = "/select-options")
) { public ResponseModel<List<Map<String, Object>>> getSelectOptions() throws UnsupportedEncodingException {
List<Map<String, Object>> selectOptions = idxBizTableService.getSelectOptions(tableName, column, valueColumn, conditionColumn, conditionValue, isFx); String queryString = request.getQueryString();
return ResponseHelper.buildResponse(selectOptions); String[] paramPairs = queryString.split("&");
} Map<String, String> params = new HashMap<>();
for (String paramPair : paramPairs) {
String[] keyValue = paramPair.split("=");
String key = keyValue[0];
String value = keyValue[1];
value = URLDecoder.decode(value, "utf-8");
params.put(key, value);
}
List<Map<String, Object>> selectOptions = idxBizTableService.getSelectOptions(params);
return ResponseHelper.buildResponse(selectOptions);
}
} }
...@@ -14,6 +14,7 @@ public interface IdxBizTableMapper extends BaseMapper { ...@@ -14,6 +14,7 @@ public interface IdxBizTableMapper extends BaseMapper {
@Param("conditionColumn") String conditionColumn, @Param("conditionColumn") String conditionColumn,
@Param("conditionValue") String conditionValue, @Param("conditionValue") String conditionValue,
@Param("isFx") String isFx, @Param("isFx") String isFx,
@Param("gatewayIds") List<String> gatewayIds @Param("gatewayIds") List<String> gatewayIds,
@Param("filters") List<Map<String, String>> filters
); );
} }
...@@ -30,5 +30,5 @@ public interface IIdxBizTableService { ...@@ -30,5 +30,5 @@ public interface IIdxBizTableService {
* @param conditionValue 条件值 * @param conditionValue 条件值
* @param isFx 是否是"分析变量" * @param isFx 是否是"分析变量"
*/ */
List<Map<String, Object>> getSelectOptions(String tableName, String column, String valueColumn, String conditionColumn, String conditionValue, String isFx); List<Map<String, Object>> getSelectOptions(Map<String,String> map);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.feign.IdxFeign; import com.yeejoin.amos.boot.module.jxiop.api.feign.IdxFeign;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizTableMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizTableMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizTableService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList; import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service @Service
@Slf4j @Slf4j
public class IdxBizTableServiceImpl implements IIdxBizTableService { public class IdxBizTableServiceImpl implements IIdxBizTableService {
@Autowired @Autowired
private IPermissionService permissionService; private IPermissionService permissionService;
@Autowired
private IdxBizTableMapper idxBizTableMapper;
@Autowired
private IdxFeign idxFeign;
@Autowired private static Map<String, String> cmap = new HashMap<>();
private IdxBizTableMapper idxBizTableMapper;
private static String[] tableNames = {"idx_biz_fan_point_process_variable_classification","idx_biz_pv_point_process_variable_classification"};
@Autowired //初始化表列对应map
private IdxFeign idxFeign; static {
cmap.put("area", "ARAE");
cmap.put("station", "STATION");
cmap.put("number", "NUMBER");
cmap.put("equipmentName", "EQUIPMENT_NAME");
cmap.put("subSystem", "SUB_SYSTEM");
cmap.put("pointName", "ANALYSIS_POINT_NAME");
cmap.put("subarray", "SUBARRAY");
}
/** /**
* 分页查询业务事实表的数据-IDX(/idx/table/getPage)前置接口, 增加权限控制 * 分页查询业务事实表的数据-IDX(/idx/table/getPage)前置接口, 增加权限控制
* *
* @param map 查询参数 * @param map 查询参数
*/ */
public Page<Map<String, Object>> getPage(Map<String, Object> map) { public Page<Map<String, Object>> getPage(Map<String, Object> map) {
List<String> currentUserPermissions = permissionService.getCurrentUserPermissions(); List<String> currentUserPermissions = permissionService.getCurrentUserPermissions();
if (Objects.isNull(currentUserPermissions)) { if (Objects.isNull(currentUserPermissions)) {
currentUserPermissions = new ArrayList<>(); currentUserPermissions = new ArrayList<>();
} }
String gatewayIds = String.join(",", currentUserPermissions); String gatewayIds = String.join(",", currentUserPermissions);
if (!gatewayIds.isEmpty()) { if (!gatewayIds.isEmpty()) {
map.put("GATEWAY_ID", String.format("[%s]", gatewayIds)); map.put("GATEWAY_ID", String.format("[%s]", gatewayIds));
} } else {
else { map.put("GATEWAY_ID", "[NULL]");
map.put("GATEWAY_ID", "[NULL]"); }
} FeignClientResult<Page<Map<String, Object>>> page = idxFeign.getPage(map);
FeignClientResult<Page<Map<String, Object>>> page = idxFeign.getPage(map); return page.getResult();
return page.getResult(); }
}
/**
* 分页查询业务事实表的数据-IDX(/idx/table/getPage)前置接口, 增加权限控制
*
* @param map 查询参数
*/
public Page<Map<String, Object>> getPageO(Map<String, Object> map) {
List<String> currentUserPermissions = permissionService.getCurrentUserProjectOrgCodes();
if (Objects.isNull(currentUserPermissions)) {
currentUserPermissions = new ArrayList<>();
}
String orgcodes = String.join(",", currentUserPermissions);
if (!orgcodes.isEmpty()) {
map.put("ORG_CODE", String.format("[%s]", orgcodes));
} else {
map.put("ORG_CODE", "[NULL]");
}
FeignClientResult<Page<Map<String, Object>>> page = idxFeign.getPage(map);
return page.getResult();
}
/** /**
* 分页查询业务事实表的数据-IDX(/idx/table/getPage)前置接口, 增加权限控制 * 获取下拉列表参数
* *
* @param map 查询参数 * @param tableName 表名
*/ * @param column 列名
public Page<Map<String, Object>> getPageO(Map<String, Object> map) { * @param valueColumn 数据值列
List<String> currentUserPermissions = permissionService.getCurrentUserProjectOrgCodes(); * @param conditionColumn 条件列名
if (Objects.isNull(currentUserPermissions)) { * @param conditionValue 条件值
currentUserPermissions = new ArrayList<>(); * @param isFx 是否是"分析变量"
} */
String orgcodes = String.join(",", currentUserPermissions); @Override
if (!orgcodes.isEmpty()) { public List<Map<String, Object>> getSelectOptions(Map<String, String> map) {
map.put("ORG_CODE", String.format("[%s]", orgcodes)); // List<String> permissions = permissionService.getCurrentUserPermissions();
}else { String tableName = map.get("tableName");
map.put("ORG_CODE", "[NULL]"); map.remove("tableName");
} String column = map.get("column");
FeignClientResult<Page<Map<String, Object>>> page = idxFeign.getPage(map); map.remove("column");
return page.getResult(); String valueColumn = map.get("valueColumn");
} map.remove("valueColumn");
String conditionColumn = map.get("conditionColumn");
/** map.remove("conditionColumn");
* 获取下拉列表参数 String conditionValue = map.get("conditionValue");
* map.remove("conditionValue");
* @param tableName 表名 String isFx = map.get("isFx");
* @param column 列名 map.remove("isFx");
* @param valueColumn 数据值列 List<String> permissions = permissionService.getCurrentUserProjectOrgCodes();
* @param conditionColumn 条件列名 List<Map<String, String>> filters = new ArrayList<>();
* @param conditionValue 条件值 map.forEach((key, value) -> {
* @param isFx 是否是"分析变量" Map<String, String> smap = new HashMap<>();
*/ if (Arrays.asList(tableNames).contains(tableName)&&cmap.containsKey(key)) {
@Override key = cmap.get(key);
public List<Map<String, Object>> getSelectOptions(String tableName, String column, String valueColumn, String conditionColumn, String conditionValue, String isFx) { }
// List<String> permissions = permissionService.getCurrentUserPermissions(); smap.put("column", key);
List<String> permissions = permissionService.getCurrentUserProjectOrgCodes(); smap.put("value", value);
if (Objects.isNull(permissions)) { filters.add(smap);
permissions = new ArrayList<>(); });
permissions.add("NULL"); if (Objects.isNull(permissions)) {
} permissions = new ArrayList<>();
return idxBizTableMapper.getSelectOptions(tableName, column, valueColumn, conditionColumn, conditionValue, isFx, permissions); permissions.add("NULL");
} }
return idxBizTableMapper.getSelectOptions(tableName, column, valueColumn, conditionColumn, conditionValue, isFx,
permissions, filters);
}
} }
...@@ -31,6 +31,13 @@ ...@@ -31,6 +31,13 @@
AND 1 = 2 AND 1 = 2
</if> </if>
</if> </if>
<if test="filters != null">
<if test="filters.size() > 0">
<foreach collection="filters" item="item">
AND ${item.column} = #{item.value}
</foreach>
</if>
</if>
GROUP BY GROUP BY
${column} ${column}
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment