Commit a38e9ea1 by 冯之健

接口修改

parent 74fa8830
Pipeline #1572 failed with stages
in 0 seconds
......@@ -8,12 +8,32 @@
package com.link;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.Quarter;
import cn.hutool.core.date.format.DateParser;
import com.alibaba.fastjson.JSON;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.DateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class BaseTest {
public static void main(String[] args) {
Quarter quarter = DateUtil.quarterEnum(new Date());
DateTime dateTime = DateUtil.beginOfQuarter(new Date());
String s = DateUtil.yearAndQuarter(new Date());
DateUtil.weekOfYear(DateUtil.parse("2019", "yyyy"));
System.out.println(s);
}
}
\ No newline at end of file
/**
* Copyright (c) 2018 开源 All rights reserved.
*
* <p>
* https://www.link.io
*
* <p>
* 版权所有,侵权必究!
*/
......@@ -10,6 +10,9 @@ package com.link.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
......@@ -22,6 +25,7 @@ import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.link.annotation.Login;
import com.link.annotation.LoginUser;
import com.link.common.constant.Constant;
import com.link.common.exception.RenException;
import com.link.common.page.PageData;
import com.link.common.utils.Result;
import com.link.dto.AgentnodeDTO;
......@@ -38,6 +42,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -45,10 +51,16 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 测试接口
......@@ -57,7 +69,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping("/api")
@Api(tags="数据接口")
@Api(tags = "数据接口")
public class ApiController {
@Autowired
......@@ -73,13 +85,13 @@ public class ApiController {
@GetMapping("getAgentnode")
@ApiOperation("获取节点")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "name", value = "节点名称", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "name", value = "节点名称", paramType = "query", dataType = "String")
})
public Result<PageData<AgentnodeDTO>> getAgentnode(@ApiIgnore @RequestParam Map<String,Object> params){
public Result<PageData<AgentnodeDTO>> getAgentnode(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<AgentnodeDTO> page = agentnodeService.page(params);
return new Result<PageData<AgentnodeDTO>>().ok(page);
}
......@@ -88,18 +100,18 @@ public class ApiController {
@GetMapping("getBdajob")
@ApiOperation("获取应用")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "jobName", value = "应用名称", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "jobName", value = "应用名称", paramType = "query", dataType = "String")
})
public Result<PageData<BdajobDTO>> getBdajob(@ApiIgnore @RequestParam Map<String,Object> params){
public Result<PageData<BdajobDTO>> getBdajob(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<BdajobDTO> page = bdajobService.page(params);
Map<String,Object> paramsMap = new HashMap<>();
for(BdajobDTO bdajobDto:page.getList()){
Map<String, Object> paramsMap = new HashMap<>();
for (BdajobDTO bdajobDto : page.getList()) {
paramsMap.clear();
paramsMap.put("jobId",bdajobDto.getJobId());
paramsMap.put("jobId", bdajobDto.getJobId());
List<BdajobConfigDTO> bdajobConfigDtoList = bdajobConfigService.list(paramsMap);
bdajobDto.setBdajobConfigDtoList(bdajobConfigDtoList);
}
......@@ -107,58 +119,213 @@ public class ApiController {
}
@Login
@GetMapping("getOoziejobresult")
@GetMapping("getBdajobConfig")
@ApiOperation("获取指标")
@ApiImplicitParams({
@ApiImplicitParam(name = "fieldType", value = "指标类型(0-草稿,1-正式)", paramType = "query", dataType = "String")
})
public Result<PageData<BdajobConfigDTO>> getBdajobConfig(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<BdajobConfigDTO> page = bdajobConfigService.page(params);
return new Result<PageData<BdajobConfigDTO>>().ok(page);
}
@Login
@GetMapping("getBusinessIndiceByCycle")
@ApiOperation("获取结果")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "nodeId", value = "节点id(节点信息的id)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "jobId", value = "应用id(应用信息的jobid)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "beginTime", value = "开始时间(yyyy-MM-dd HH:mm:ss)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "endTime", value = "结束时间(yyyy-MM-dd HH:mm:ss)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "fieldNames", value = "指标(多个逗号隔开)", paramType = "query", dataType="String")
/*@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),*/
@ApiImplicitParam(name = "node", value = "下沉节点编码,如果多个,须以“,”隔开,如果为空,则默认获取所有节点指标数据,下沉节点编码参见附件《各省下沉计算节点代码表》", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type", value = "周期类型:1-年,2-季度,3-月度,4-周,5-日,6-小时", paramType = "query", dataType = "int", required = true),
@ApiImplicitParam(name = "cycle", value = "周期值,根据周期类型,周期值格式也不同,具体要求如下:" +
"① 年,4位年度值,如2020;" +
"② 季度,4位年度值+2位季度序号(01-04),如202001;" +
"③ 月度,4位年度值+2位月度值(01-12),如202001;" +
"④ 周,4位年度值+2位周序号(01-52),如202016;" +
"⑤ 日,4位年度值+2位月度值+2位日数值,如20200101;" +
"⑥ 小时,4位年度值+2位月度值+2位日数值+2位小时数,如2020010112", paramType = "query", dataType = "String", required = true),
@ApiImplicitParam(name = "indice", value = "指标编码,如果有多个指标,须以“,”隔开,下沉计算项目组将定期发布《下沉计算指标编码表》", paramType = "query", dataType = "String", required = true)
})
public Result<PageData<Object>> getOoziejobresult(@ApiIgnore @RequestParam Map<String,Object> params){
PageData<OoziejobresultDTO> page = ooziejobresultService.getPage(params);
List<Object> resultList = new ArrayList<>();
String fieldNames = Convert.toStr(params.get("fieldNames"));
String[] fieldNameArr = StrUtil.split(fieldNames,",");
PageData<Object> resultPage = new PageData<>(new ArrayList<>(),0);
if(ArrayUtil.isNotEmpty(fieldNameArr)){
for(OoziejobresultDTO ooziejobresultDTO:page.getList()){
String result = ooziejobresultDTO.getResult();
if(StrUtil.isNotBlank(result)){
if(JSON.isValid(result)){
if(JSON.isValidObject(result)){
public Result<Map<String, Object>> getOoziejobresult(@ApiIgnore @RequestParam Map<String, Object> params) {
Integer type = Convert.toInt(params.get("type"));
if (type == null) {
throw new RenException("周期类型不能为空");
}
String cycle = Convert.toStr(params.get("cycle"));
if (StrUtil.isBlank(cycle)) {
throw new RenException("周期值不能为空");
}
String indice = Convert.toStr(params.get("indice"));
if (StrUtil.isBlank(indice)) {
throw new RenException("指标不能为空");
}
//处理时间
Date beginTime = null;
Date endTime = null;
if (Objects.equals(type, 1)) {
DateTime date = DateUtil.parse(cycle, "yyyy");
beginTime = DateUtil.beginOfYear(date);
endTime = DateUtil.endOfYear(date);
} else if (Objects.equals(type, 2)) {
if (StrUtil.length(cycle) >= 6) {
DateTime dateTime = DateUtil.parse(StrUtil.sub(cycle, 0, 4), "yyyy");
Integer quarter = Convert.toInt(StrUtil.sub(cycle, 4, 6));
if (dateTime != null && quarter != null) {
DateTime date = DateUtil.offsetMonth(dateTime, 3 * (quarter - 1));
beginTime = DateUtil.beginOfQuarter(date);
endTime = DateUtil.endOfQuarter(date);
}
}
} else if (Objects.equals(type, 3)) {
DateTime date = DateUtil.parse(cycle, "yyyyMM");
beginTime = DateUtil.beginOfMonth(date);
endTime = DateUtil.endOfMonth(date);
} else if (Objects.equals(type, 4)) {
if (StrUtil.length(cycle) >= 6) {
DateTime dateTime = DateUtil.parse(StrUtil.sub(cycle, 0, 4), "yyyy");
Integer week = Convert.toInt(StrUtil.sub(cycle, 4, 6));
if (dateTime != null && week != null) {
DateTime date = DateUtil.offsetWeek(dateTime, week - 1);
beginTime = DateUtil.beginOfWeek(date);
endTime = DateUtil.endOfWeek(date);
}
}
} else if (Objects.equals(type, 5)) {
DateTime date = DateUtil.parse(cycle, "yyyyMMdd");
beginTime = DateUtil.beginOfDay(date);
endTime = DateUtil.endOfDay(date);
} else if (Objects.equals(type, 6)) {
DateTime date = DateUtil.parse(cycle, "yyyyMMddHH");
beginTime = date;
endTime = DateUtil.offsetSecond(DateUtil.offsetHour(date, 1), -1);
}
if (beginTime == null || endTime == null) {
throw new RenException("时间解析失败");
}
Map<String, Object> paramsMap = new HashMap<>();
//获取所有节点
paramsMap.clear();
paramsMap.put("nodeIds", Convert.toStr(params.get("node")));
List<AgentnodeDTO> agentnodeDtoList = agentnodeService.list(paramsMap);
//根据指标获取应用id
paramsMap.clear();
String[] indiceArr = StrUtil.split(indice, ",");
paramsMap.put("fieldCodeArr", indiceArr);
List<BdajobConfigDTO> bdajobConfigDtoList = bdajobConfigService.list(paramsMap);
MultiValueMap<String, BdajobConfigDTO> jobIdMap = new LinkedMultiValueMap<>();
for (BdajobConfigDTO bdajobConfigDto : bdajobConfigDtoList) {
jobIdMap.add(bdajobConfigDto.getJobId(), bdajobConfigDto);
}
//获取结果
paramsMap.clear();
paramsMap.put("nodeIds", Convert.toStr(params.get("node")));
paramsMap.put("jobIdList", jobIdMap.keySet());
paramsMap.put("beginTime", DateUtil.format(beginTime, "yyyy-MM-dd HH:mm:ss"));
paramsMap.put("endTime", DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
paramsMap.put("orderBy", "t.createdTime asc");
List<OoziejobresultDTO> list = ooziejobresultService.getJoinList(paramsMap);
//按格式封装数据
Map<String, Object> resultMap = new HashMap<>();
LinkedHashMap<String, LinkedHashMap<String, ArrayList<Object>>> resultLinkedHashMap = new LinkedHashMap<>();
resultMap.put("type", params.get("type"));
resultMap.put("cycle", params.get("cycle"));
resultMap.put("total", indiceArr.length);
for (OoziejobresultDTO ooziejobresultDto : list) {
List<BdajobConfigDTO> indiceList = jobIdMap.get(ooziejobresultDto.getJobId());
if (CollUtil.isNotEmpty(indiceList)) {
String result = ooziejobresultDto.getResult();
if (StrUtil.isNotBlank(result)) {
if (JSON.isValid(result)) {
if (JSON.isValidObject(result)) {
JSONObject jsonObject = JSON.parseObject(result);
Map resultMap = (MapUtil.getAny(jsonObject,fieldNameArr));
resultList.add(resultMap);
}else{
for (BdajobConfigDTO bdajobConfigDto : indiceList) {
LinkedHashMap<String, ArrayList<Object>> stringArrayListLinkedHashMap = resultLinkedHashMap.get(bdajobConfigDto.getFieldCode());
if (stringArrayListLinkedHashMap == null) {
stringArrayListLinkedHashMap = new LinkedHashMap<>();
resultLinkedHashMap.put(bdajobConfigDto.getFieldCode(), stringArrayListLinkedHashMap);
}
for (AgentnodeDTO agentnodeDto : agentnodeDtoList) {
ArrayList<Object> objects = stringArrayListLinkedHashMap.get(agentnodeDto.getId());
if (objects == null) {
objects = new ArrayList<>();
stringArrayListLinkedHashMap.put(Convert.toStr(ooziejobresultDto.getNodeid()), objects);
}
objects.add(jsonObject.get(bdajobConfigDto.getFieldName()));
}
}
} else {
JSONArray jsonArray = JSON.parseArray(result);
List<Object> jsonArrayList = new ArrayList<>();
if(CollUtil.isNotEmpty(jsonArray)){
//只过滤第一层
for(Object o:jsonArray){
if(o instanceof JSONObject){
jsonArrayList.add(MapUtil.getAny((JSONObject)o,fieldNameArr));
}else{
jsonArrayList.add(o);
for (BdajobConfigDTO bdajobConfigDto : indiceList) {
LinkedHashMap<String, ArrayList<Object>> stringArrayListLinkedHashMap = resultLinkedHashMap.get(bdajobConfigDto.getFieldCode());
if (stringArrayListLinkedHashMap == null) {
stringArrayListLinkedHashMap = new LinkedHashMap<>();
resultLinkedHashMap.put(bdajobConfigDto.getFieldCode(), stringArrayListLinkedHashMap);
}
List<Object> jsonArrayList = new ArrayList<>();
if (CollUtil.isNotEmpty(jsonArray)) {
//只过滤第一层
for (Object o : jsonArray) {
if (o instanceof JSONObject) {
jsonArrayList.add(((JSONObject) o).get(bdajobConfigDto.getFieldName()));
} else {
jsonArrayList.add(o);
}
}
}
for (AgentnodeDTO agentnodeDto : agentnodeDtoList) {
ArrayList<Object> objects = stringArrayListLinkedHashMap.get(agentnodeDto.getId());
if (objects == null) {
objects = new ArrayList<>();
stringArrayListLinkedHashMap.put(Convert.toStr(ooziejobresultDto.getNodeid()), objects);
}
objects.add(jsonArrayList);
}
}
resultList.add(jsonArrayList);
}
}
}
}
}
resultPage = new PageData<>(resultList,page.getTotal());
List<Object> firstList = new ArrayList<>();
for (String indiceItem : indiceArr) {
Map<String, Object> firstMap = new LinkedHashMap<>();
firstList.add(firstMap);
firstMap.put("indice", indiceItem);
firstMap.put("total", agentnodeDtoList.size());
LinkedHashMap<String, ArrayList<Object>> stringArrayListLinkedHashMap = resultLinkedHashMap.get(indiceItem);
List<Object> secondList = new ArrayList<>();
firstMap.put("list", secondList);
for (AgentnodeDTO agentnodeDto : agentnodeDtoList) {
Map<String, Object> secondMap = new LinkedHashMap<>();
secondMap.put("node", agentnodeDto.getId());
secondMap.put("value", stringArrayListLinkedHashMap == null ? new ArrayList<>() : stringArrayListLinkedHashMap.get(Convert.toStr(agentnodeDto.getId())));
secondList.add(secondMap);
}
}
return new Result<PageData<Object>>().ok(resultPage);
resultMap.put("list", firstList);
return new Result<Map<String, Object>>().ok(resultMap);
}
}
\ No newline at end of file
......@@ -38,8 +38,8 @@ public class ApiLoginController {
private TokenService tokenService;
@PostMapping("login")
@ApiOperation("登录")
@PostMapping("authorize")
@ApiOperation("用于数据接口访问前的授权操作")
public Result<Map<String, Object>> login(@RequestBody LoginDTO dto){
//表单校验
ValidatorUtils.validateEntity(dto);
......
......@@ -6,6 +6,7 @@ import com.link.entity.OoziejobresultEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
......@@ -18,4 +19,6 @@ import java.util.Map;
public interface OoziejobresultDao extends BaseDao<OoziejobresultEntity> {
IPage<OoziejobresultEntity> getPage(IPage<OoziejobresultEntity> page,@Param("params") Map<String, Object> params);
List<OoziejobresultEntity> getJoinList(Map<String, Object> params);
}
\ No newline at end of file
......@@ -26,9 +26,15 @@ public class BdajobConfigDTO implements Serializable {
@ApiModelProperty("字段名")
private String fieldName;
@ApiModelProperty("字段编码")
private String fieldCode;
@ApiModelProperty("字段描述")
private String fieldDesc;
@ApiModelProperty("字段类型:0-草稿,1-正式")
private Integer fieldType;
@ApiModelProperty("创建时间")
private Date createTime;
}
\ No newline at end of file
......@@ -31,5 +31,8 @@ public class OoziejobresultDTO implements Serializable {
@ApiModelProperty(value = "创建时间")
private String createdtime;
@ApiModelProperty(value = "应用id")
private String jobId;
}
\ No newline at end of file
package com.link.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -29,10 +30,18 @@ public class BdajobConfigEntity {
*/
private String fieldName;
/**
* 字段编码
*/
private String fieldCode;
/**
* 字段描述
*/
private String fieldDesc;
/**
* 字段类型
*/
private Integer fieldType;
/**
* 创建时间
*/
private Date createTime;
......
......@@ -35,4 +35,9 @@ public class OoziejobresultEntity {
* 创建时间
*/
private String createdtime;
/**
* 应用id
*/
private String jobId;
}
\ No newline at end of file
......@@ -61,7 +61,11 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
//查询token信息
TokenEntity tokenEntity = tokenService.getByToken(token);
if(tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
// if(tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
// throw new RenException(ErrorCode.TOKEN_INVALID);
// }
//设置token不过期
if(tokenEntity == null){
throw new RenException(ErrorCode.TOKEN_INVALID);
}
......
......@@ -7,6 +7,7 @@ import com.link.entity.OoziejobresultEntity;
import com.link.dto.OoziejobresultDTO;
import com.link.entity.OoziejobresultEntity;
import java.util.List;
import java.util.Map;
/**
......@@ -24,4 +25,11 @@ public interface OoziejobresultService extends CrudService<OoziejobresultEntity,
*/
PageData<OoziejobresultDTO> getPage(Map<String,Object> params);
/**
* @author Mr.Feng
* @date 2020/4/17 11:30
* @description 连接查询
*/
List<OoziejobresultDTO> getJoinList(Map<String,Object> params);
}
\ No newline at end of file
......@@ -15,11 +15,10 @@ import com.link.service.AgentnodeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.swing.text.ComponentView;
import java.util.Map;
/**
*
*
* @author Mr.Feng zhijian.feng@hrtuoyu.com
* @since 1.0.0 2020-04-13
*/
......@@ -27,13 +26,15 @@ import java.util.Map;
public class AgentnodeServiceImpl extends CrudServiceImpl<AgentnodeDao, AgentnodeEntity, AgentnodeDTO> implements AgentnodeService {
@Override
public QueryWrapper<AgentnodeEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
public QueryWrapper<AgentnodeEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get("id");
String name = Convert.toStr(params.get("name"));
String nodeIds = Convert.toStr(params.get("nodeIds"));
QueryWrapper<AgentnodeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
wrapper.eq(StrUtil.isNotBlank(name),"name",name);
wrapper.eq(StrUtil.isNotBlank(name), "name", name);
wrapper.inSql(StrUtil.isNotBlank(nodeIds), "id", nodeIds);
return wrapper;
}
......
package com.link.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.link.common.service.impl.CrudServiceImpl;
......@@ -28,10 +29,16 @@ public class BdajobConfigServiceImpl extends CrudServiceImpl<BdajobConfigDao, Bd
public QueryWrapper<BdajobConfigEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get("id");
String jobId = Convert.toStr(params.get("jobId"));
String[] fieldCodeArr = (String[]) params.get("fieldCodeArr");
Integer fieldType = Convert.toInt(params.get("fieldType"));
QueryWrapper<BdajobConfigEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
wrapper.eq(StrUtil.isNotBlank(jobId), "job_id", jobId);
if (ArrayUtil.isNotEmpty(fieldCodeArr)) {
wrapper.in("field_code", fieldCodeArr);
}
wrapper.eq(fieldType != null, "field_type", fieldType);
return wrapper;
}
......
package com.link.service.impl;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.link.common.constant.Constant;
import com.link.common.page.PageData;
import com.link.common.service.impl.CrudServiceImpl;
import com.link.common.utils.ConvertUtils;
import com.link.dao.OoziejobresultDao;
import com.link.dto.OoziejobresultDTO;
import com.link.entity.OoziejobresultEntity;
......@@ -16,6 +18,7 @@ import com.link.service.OoziejobresultService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
......@@ -41,4 +44,10 @@ public class OoziejobresultServiceImpl extends CrudServiceImpl<OoziejobresultDao
IPage<OoziejobresultEntity> page = baseDao.getPage(getPage(params, "createdtime", false), params);
return getPageData(page, OoziejobresultDTO.class);
}
@Override
public List<OoziejobresultDTO> getJoinList(Map<String, Object> params) {
List<OoziejobresultEntity> entityList = baseDao.getJoinList(params);
return ConvertUtils.sourceToTarget(entityList,OoziejobresultDTO.class);
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ server:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
port: 8081
port: 8090
servlet:
context-path: /link-api
......
......@@ -6,7 +6,7 @@
<select id="getPage" resultType="com.link.entity.OoziejobresultEntity">
select t.*
from ooziejobresult t
left join ooziejob ooziejob on t.apppath = ooziejob.path and t.nodeid = ooziejob.id
left join ooziejob ooziejob on t.apppath = ooziejob.path and t.nodeid = ooziejob.nodeid
<where>
<if test="params != null and params.nodeId != null and params.nodeId != ''">
and t.nodeid = #{params.nodeId}
......@@ -23,5 +23,39 @@
</where>
</select>
<select id="getJoinList" resultType="com.link.entity.OoziejobresultEntity">
select t.*,
ooziejob.jobid jobId
from ooziejobresult t
left join ooziejob ooziejob on t.apppath = ooziejob.path and t.nodeid = ooziejob.nodeid
<where>
<if test="nodeId != null and nodeId != ''">
and t.nodeid = #{nodeId}
</if>
<if test="jobId != null and jobId != ''">
and ooziejob.jobid = #{jobId}
</if>
<if test="beginTime != null and beginTime != ''">
and t.createdtime &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
and t.createdtime &lt;= #{endTime}
</if>
<if test="nodeIds != null and nodeIds != ''">
and t.nodeid in (${nodeIds})
</if>
<if test="jobIdList != null and jobIdList.size > 0">
and ooziejob.jobid in
<foreach collection="jobIdList" item="jobId" open="(" close=")" separator=",">
#{jobId}
</foreach>
</if>
</where>
<if test="orderBy != null and orderBy != ''">
order by ${orderBy}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -45,7 +45,7 @@
<hutool.version>5.1.2</hutool.version>
<gson.version>2.8.6</gson.version>
<jsoup.version>1.11.3</jsoup.version>
<knife4j.version>2.0.1</knife4j.version>
<knife4j.version>2.0.2</knife4j.version>
<lombok.version>1.18.4</lombok.version>
<docker.plugin.version>1.1.1</docker.plugin.version>
</properties>
......
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