Commit d47d214a authored by 黄伟铭's avatar 黄伟铭

综合查询增加分页,增加结束时间

parent 87419fef
package net.wanji.opt.controllerv2.comprehensivequery;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
......@@ -55,18 +57,20 @@ public class ComprehensiveQueryController {
@ApiImplicitParam(name = "endTime", value = "日期 格式:yyyy-MM-dd h:i:s", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "objectType", value = "范围 0:路口级指标 1:方向级指标 2:转向级指标", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "groupType", value = "时间粒度 0--5分钟 1--15分钟 2--30分钟 3--60分钟", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "pageNum", value = "分页页码", required = true, dataType = "Integer", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "分页数据条数", required = true, dataType = "Integer", paramType = "query"),
})
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = String.class),
})
public JsonViewObject getComprehensiveQuery(String crossId , String startTime ,String endTime ,String objectType ,String groupType) {
List<CrossLaneDataHistPoExtendName> list = new ArrayList<>();
public JsonViewObject getComprehensiveQuery(String crossId , String startTime ,String endTime ,String objectType ,String groupType,Integer pageNum,Integer pageSize) {
try {
list = comprehensiveQueryService.getCrossStatusDistribution(crossId, startTime , endTime , objectType , groupType);
JSONObject list = comprehensiveQueryService.getCrossStatusDistribution(crossId, startTime , endTime , objectType , groupType,pageNum,pageSize);
return JsonViewObject.newInstance().success(list);
} catch (Exception e) {
log.error("综合查询-综合查询数据-查询失败:{}", e);
JsonViewObject.newInstance().success(list);
return JsonViewObject.newInstance().success("");
}
return JsonViewObject.newInstance().success(list);
}
}
......@@ -74,4 +74,9 @@ public class CrossLaneDataHistPoExtend {
@ApiModelProperty(value = "空间占有率", notes = "")
double vehicleLengthRatioMean;
@ApiModelProperty(value = "结束时间:yyyy-MM-dd HH:mm:ss", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
public Date endTime;
}
package net.wanji.opt.servicev2.comprehensivequery;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import net.wanji.opt.entity.comprehensivequery.CrossLaneDataHistPoExtendName;
import net.wanji.opt.entity.comprehensivequery.GreenTreeEntity;
......@@ -8,5 +10,5 @@ import java.util.Map;
public interface ComprehensiveQueryService {
List<GreenTreeEntity> getGreenAndCross();
List<CrossLaneDataHistPoExtendName> getCrossStatusDistribution(String crossId , String startTime , String endTime , String objectType , String groupType);
JSONObject getCrossStatusDistribution(String crossId , String startTime , String endTime , String objectType , String groupType, Integer pageNum, Integer pageSize);
}
package net.wanji.opt.servicev2.comprehensivequery.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.wanji.common.enums.BaseEnum;
import net.wanji.opt.dao.mapper.comprehensivequery.ComprehensiveQueryMapper;
import net.wanji.opt.entity.comprehensivequery.CrossEntity;
......@@ -8,7 +11,9 @@ import net.wanji.opt.entity.comprehensivequery.CrossLaneDataHistPoExtendName;
import net.wanji.opt.entity.comprehensivequery.GreenAndCrossEntity;
import net.wanji.opt.entity.comprehensivequery.GreenTreeEntity;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.po.strategy.StrategyPO;
import net.wanji.opt.servicev2.comprehensivequery.ComprehensiveQueryService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
......@@ -84,7 +89,7 @@ public class ComprehensiveQueryServiceImpl implements ComprehensiveQueryService
}
@Override
public List<CrossLaneDataHistPoExtendName> getCrossStatusDistribution(String crossId , String startTime ,String endTime ,String objectType ,String groupType) {
public JSONObject getCrossStatusDistribution(String crossId , String startTime ,String endTime ,String objectType ,String groupType,Integer pageNum,Integer pageSize) {
List<CrossLaneDataHistPoExtendName> resultList = new ArrayList<>();
List<GreenAndCrossEntity> CrossList = comprehensiveQueryMapper.getCross();
String[] crossIdArray = crossId.split(",");
......@@ -117,6 +122,7 @@ public class ComprehensiveQueryServiceImpl implements ComprehensiveQueryService
temp.setDelayTime(c.getDelayTime());
temp.setTrafficIndex(c.getTrafficIndex());
temp.setCrossName(crossName);
temp.setEndTime(c.getEndTime());
if(c.getDirType() != null && c.getDirType() > 0 ){
temp.setDirTypeName(BaseEnum.SignalDirectionEnum.getNameByCode(c.getDirType()));
}
......@@ -128,7 +134,16 @@ public class ComprehensiveQueryServiceImpl implements ComprehensiveQueryService
resultList.add(temp);
}
}
return resultList;
List<CrossLaneDataHistPoExtendName> collect = new ArrayList<>();
if(CollectionUtils.isNotEmpty(resultList)){
collect = resultList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
}
JSONObject result = new JSONObject();
result.put("fullDataList",resultList);
result.put("pageList",collect);
result.put("totalPage",Math.ceil((double) resultList.size() / pageSize));
result.put("totalSize",resultList.size());
return result;
}
}
......@@ -26,6 +26,13 @@
<select id="findCrossObjectIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
(case
when #{groupType}=0 then DATE_FORMAT(DATE_ADD(t.unit_time,INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:00')
when #{groupType}=1 then DATE_FORMAT(DATE_ADD(t.unit_time,INTERVAL 15 MINUTE),'%Y-%m-%d %H:%i:00')
when #{groupType}=2 then DATE_FORMAT(DATE_ADD(t.unit_time,INTERVAL 30 MINUTE),'%Y-%m-%d %H:%i:00')
when #{groupType}=3 then DATE_FORMAT(DATE_ADD(t.unit_time,INTERVAL 60 MINUTE),'%Y-%m-%d %H:00:00')
end
) end_time,
cross_id ,
lane_no ,
dir_type ,
......
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