Commit b0aaaf05 authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	signal-optimize-service/src/main/resources/bootstrap-dev.yaml
parents 9b741610 47017e84
...@@ -69,6 +69,38 @@ ...@@ -69,6 +69,38 @@
<elastic-data-version>2.6.3</elastic-data-version> <elastic-data-version>2.6.3</elastic-data-version>
</properties> </properties>
<!--部署私服配置-->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://106.120.201.126:14729/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://106.120.201.126:14729/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!--maven仓库配置-->
<repositories>
<repository>
<id>releases</id>
<url>http://106.120.201.126:14729/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<repository>
<id>snapshots</id>
<url>http://106.120.201.126:14729/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
<!-- 依赖声明 --> <!-- 依赖声明 -->
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
......
...@@ -2,3 +2,4 @@ utc.service.url=http://10.102.1.182:32000/utc ...@@ -2,3 +2,4 @@ utc.service.url=http://10.102.1.182:32000/utc
utc.dt.service.url=http://10.102.1.182:39002/utc-dt utc.dt.service.url=http://10.102.1.182:39002/utc-dt
utc.hisense.service.url=http://127.0.0.1:39003/utc-hisense utc.hisense.service.url=http://127.0.0.1:39003/utc-hisense
control.url=http://10.102.1.182:32001/web control.url=http://10.102.1.182:32001/web
ehualu.url=http://173.0.0.1:30015
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
package net.wanji.opt.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.wanji.common.utils.tool.StringUtils;
/**
* @author duanruiming
* @date 2024/12/03 19:14
*/
@Getter
@AllArgsConstructor
public enum GreenBeltDirEnum {
E2W("e2w", "东向西"),
W2E("w2e", "西向东"),
N2S("n2s", "北向南"),
S2N("s2n", "南向北");
private String code;
private String desc;
public static String getDesc(String code) {
for (GreenBeltDirEnum dirEnum : GreenBeltDirEnum.values()) {
if (StringUtils.equalsIgnoreCase(code, dirEnum.getCode())) {
return dirEnum.getDesc();
}
}
return "";
}
}
...@@ -6,10 +6,12 @@ import com.alibaba.fastjson.JSONObject; ...@@ -6,10 +6,12 @@ import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants;
import net.wanji.common.framework.i18n.I18nResourceBundle; import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.Page; import net.wanji.common.framework.rest.Page;
import net.wanji.common.framework.rest.ValidationGroups; import net.wanji.common.framework.rest.ValidationGroups;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.GreenwaveInfoPO; import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
...@@ -31,6 +33,7 @@ import javax.annotation.Resource; ...@@ -31,6 +33,7 @@ import javax.annotation.Resource;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -115,7 +118,17 @@ public class GreenwaveInducesController { ...@@ -115,7 +118,17 @@ public class GreenwaveInducesController {
greenwaveDTO.setStrategyId(m.getStrategyId()); greenwaveDTO.setStrategyId(m.getStrategyId());
greenwaveDTO.setStrategyName(m.getStrategyName()); greenwaveDTO.setStrategyName(m.getStrategyName());
greenwaveDTO.setDir(m.getDir()); greenwaveDTO.setDir(m.getDir());
if(Objects.nonNull(m.getControlOptTimes()) && m.getControlOptTimes().split("\\|").length>0) {
try {
String startTime = DateUtil.format(DateUtil.parse(m.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
String endTime = DateUtil.format(DateUtil.parse(m.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
greenwaveDTO.setControlOptTimes(startTime.substring(0,startTime.lastIndexOf(":00"))+"-"+endTime.substring(0,endTime.lastIndexOf(":00")));
}catch (ParseException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
}else {
greenwaveDTO.setControlOptTimes(m.getControlOptTimes()); greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
greenwaveList.add(greenwaveDTO); greenwaveList.add(greenwaveDTO);
}); });
induceDTO.setGreenwaveList(greenwaveList); induceDTO.setGreenwaveList(greenwaveList);
...@@ -185,7 +198,17 @@ public class GreenwaveInducesController { ...@@ -185,7 +198,17 @@ public class GreenwaveInducesController {
greenwaveDTO.setStrategyId(m.getStrategyId()); greenwaveDTO.setStrategyId(m.getStrategyId());
greenwaveDTO.setStrategyName(m.getStrategyName()); greenwaveDTO.setStrategyName(m.getStrategyName());
greenwaveDTO.setDir(m.getDir()); greenwaveDTO.setDir(m.getDir());
if(Objects.nonNull(m.getControlOptTimes()) && m.getControlOptTimes().split("\\|").length>0) {
try {
String startTime = DateUtil.format(DateUtil.parse(m.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
String endTime = DateUtil.format(DateUtil.parse(m.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
greenwaveDTO.setControlOptTimes(startTime.substring(0,startTime.lastIndexOf(":00"))+"-"+endTime.substring(0,endTime.lastIndexOf(":00")));
}catch (ParseException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
}else {
greenwaveDTO.setControlOptTimes(m.getControlOptTimes()); greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
greenwaveList.add(greenwaveDTO); greenwaveList.add(greenwaveDTO);
}); });
induceDTO.setGreenwaveList(greenwaveList); induceDTO.setGreenwaveList(greenwaveList);
......
...@@ -3,27 +3,25 @@ package net.wanji.opt.controller.induce; ...@@ -3,27 +3,25 @@ package net.wanji.opt.controller.induce;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants;
import net.wanji.common.framework.i18n.I18nResourceBundle; import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.Page;
import net.wanji.common.framework.rest.ValidationGroups; import net.wanji.common.framework.rest.ValidationGroups;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.dao.entity.GreenwaveInfoPO; import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.opt.dao.mapper.induce.GreenwaveInducesHistMapper; import net.wanji.opt.dao.mapper.induce.GreenwaveInducesHistMapper;
import net.wanji.opt.dto.induce.GreenwaveDirDTO;
import net.wanji.opt.dto.induce.GreenwaveInducesDTO; import net.wanji.opt.dto.induce.GreenwaveInducesDTO;
import net.wanji.opt.dto.induce.InduceDTO; import net.wanji.opt.dto.induce.InduceDTO;
import net.wanji.opt.entity.DeviceInduces; import net.wanji.opt.entity.DeviceInduces;
import net.wanji.opt.entity.GreenwaveInduces; import net.wanji.opt.entity.GreenwaveInduces;
import net.wanji.opt.entity.GreenwaveInducesHist; import net.wanji.opt.entity.GreenwaveInducesHist;
import net.wanji.opt.entity.InduceTemplate;
import net.wanji.opt.service.DeviceInducesService; import net.wanji.opt.service.DeviceInducesService;
import net.wanji.opt.service.induce.GreenwaveInducesHistService; import net.wanji.opt.service.induce.GreenwaveInducesHistService;
import net.wanji.opt.service.induce.GreenwaveInducesService; import net.wanji.opt.service.induce.GreenwaveInducesService;
import net.wanji.opt.service.induce.InduceTemplateService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -31,8 +29,9 @@ import javax.annotation.Resource; ...@@ -31,8 +29,9 @@ import javax.annotation.Resource;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.math.BigDecimal; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
...@@ -80,30 +79,45 @@ public class GreenwaveInducesHistController { ...@@ -80,30 +79,45 @@ public class GreenwaveInducesHistController {
JsonViewObject jsonView = JsonViewObject.newInstance(); JsonViewObject jsonView = JsonViewObject.newInstance();
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
try { try {
List<GreenwaveInducesDTO> list = new ArrayList<>();
List<GreenwaveInfoPO> greenwaveInfoPOList = greenwaveInfoMapper.selectAll(); List<GreenwaveInfoPO> greenwaveInfoPOList = greenwaveInfoMapper.selectAll();
List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(); List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list();
// List<InduceTemplate> induceTemplateList = induceTemplateService.list(); // List<InduceTemplate> induceTemplateList = induceTemplateService.list();
List<DeviceInduces> deviceInducesList = deviceInducesService.list(); List<DeviceInduces> deviceInducesList = deviceInducesService.list();
this.greenwaveInducesHistService.list().stream().forEach(o -> {
GreenwaveInducesDTO greenwaveInducesDTO = new GreenwaveInducesDTO();
greenwaveInducesDTO.setGreenId(o.getGreenId());
greenwaveInducesDTO.setDir(o.getDir());
//这里从绿波表里获取基本信息 //这里从绿波表里获取基本信息
List<GreenwaveInfoPO> greenwaveInfoByGreenId = greenwaveInfoPOList.stream().filter(n -> n.getId().equals(o.getGreenId())).collect(Collectors.toList());// 过滤条件// 收集结果 List<GreenwaveInducesDTO> greenwaveInfoList = new ArrayList<>();
if (Objects.nonNull(greenwaveInfoByGreenId) && greenwaveInfoByGreenId.size() > 0) { greenwaveInfoPOList.stream().forEach(x -> {
greenwaveInducesDTO.setGreenName(greenwaveInfoByGreenId.get(0).getName()); GreenwaveInducesDTO greenwaveInducesDTO = new GreenwaveInducesDTO();
greenwaveInducesDTO.setDesignSpeed(greenwaveInfoByGreenId.get(0).getDesignSpeed()); greenwaveInducesDTO.setGreenId(x.getId());
greenwaveInducesDTO.setGreenName(x.getName());
greenwaveInducesDTO.setDesignSpeed(x.getDesignSpeed());
greenwaveInducesDTO.setStatus(x.getStatus());
greenwaveInducesDTO.setWkt(x.getWkt());
AtomicReference<Integer> equipCount= new AtomicReference<>(0);
List<GreenwaveDirDTO> dirList = new ArrayList<>();
this.greenwaveInducesHistService.list().stream().filter(o->Objects.isNull(o.getGreenId()) || o.getGreenId().equals(x.getId())).forEach(o -> {
GreenwaveDirDTO greenwaveDirDTO=new GreenwaveDirDTO();
greenwaveDirDTO.setDir(o.getDir());
greenwaveDirDTO.setStrategyId(o.getStrategyId());
greenwaveDirDTO.setStrategyName(o.getStrategyName());
greenwaveDirDTO.setMinSpeed(o.getMinSpeed());
greenwaveDirDTO.setMinSpeed(o.getMaxSpeed());
if (Objects.nonNull(o.getControlOptTimes()) && o.getControlOptTimes().split("\\|").length > 0) {
try {
String startTime = DateUtil.format(DateUtil.parse(o.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
String endTime = DateUtil.format(DateUtil.parse(o.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
greenwaveDirDTO.setControlOptTimes(startTime.substring(0, startTime.lastIndexOf(":00")) + "-" + endTime.substring(0, endTime.lastIndexOf(":00")));
} catch (ParseException ex) {
ex.printStackTrace();
greenwaveDirDTO.setControlOptTimes(o.getControlOptTimes());
}
} else {
greenwaveDirDTO.setControlOptTimes(o.getControlOptTimes());
} }
greenwaveInducesDTO.setStatus(o.getStatus());
greenwaveInducesDTO.setStrategyId(o.getStrategyId());
greenwaveInducesDTO.setStrategyName(o.getStrategyName());
greenwaveInducesDTO.setMinSpeed(o.getMinSpeed());
greenwaveInducesDTO.setMinSpeed(o.getMaxSpeed());
greenwaveInducesDTO.setControlOptTimes(o.getControlOptTimes());
//获取诱导屏列表 //获取诱导屏列表
List<InduceDTO> induceDTOList = new ArrayList<>(); List<InduceDTO> induceDTOList = new ArrayList<>();
greenwaveInducesList.stream().filter(x -> Objects.nonNull(x.getGreenId()) && x.getGreenId().equals(o.getGreenId())).forEach(n -> { greenwaveInducesList.stream().filter(l -> Objects.nonNull(l.getGreenId()) && l.getGreenId().equals(o.getGreenId())).forEach(n -> {
InduceDTO induceDTO = new InduceDTO(); InduceDTO induceDTO = new InduceDTO();
induceDTO.setId(n.getId()); induceDTO.setId(n.getId());
induceDTO.setEquipCode(n.getEquipCode()); induceDTO.setEquipCode(n.getEquipCode());
...@@ -121,11 +135,15 @@ public class GreenwaveInducesHistController { ...@@ -121,11 +135,15 @@ public class GreenwaveInducesHistController {
//induceDTO.setInduceTemplateList(induceTemplateList.stream().filter(x->Objects.isNull(x.getEquipCode()) || x.getEquipCode().equals(n.getEquipCode())).collect(Collectors.toList())); //induceDTO.setInduceTemplateList(induceTemplateList.stream().filter(x->Objects.isNull(x.getEquipCode()) || x.getEquipCode().equals(n.getEquipCode())).collect(Collectors.toList()));
induceDTOList.add(induceDTO); induceDTOList.add(induceDTO);
}); });
greenwaveInducesDTO.setInduceList(induceDTOList); greenwaveDirDTO.setInduceList(induceDTOList);
greenwaveInducesDTO.setEquipCount(induceDTOList.size()); equipCount.updateAndGet(v -> v + induceDTOList.size());
list.add(greenwaveInducesDTO); dirList.add(greenwaveDirDTO);
});
greenwaveInducesDTO.setGreenwaveDirList(dirList);
greenwaveInducesDTO.setEquipCount(equipCount.get());
greenwaveInfoList.add(greenwaveInducesDTO);
}); });
jsonView.success(list); jsonView.success(greenwaveInfoList);
} catch (Exception e) { } catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG")); jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e); log.error("{} getAll error", this.getClass().getSimpleName(), e);
...@@ -142,9 +160,9 @@ public class GreenwaveInducesHistController { ...@@ -142,9 +160,9 @@ public class GreenwaveInducesHistController {
*/ */
@ApiOperation(value = "根据条件查询记录", notes = "根据条件查询记录", response = JsonViewObject.class, consumes = MediaType.APPLICATION_JSON) @ApiOperation(value = "根据条件查询记录", notes = "根据条件查询记录", response = JsonViewObject.class, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/byCondition", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) @PostMapping(value = "/byCondition", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject getByWhere(@ApiParam(value = "查询条件", required = true) @RequestBody @Validated({ValidationGroups.Query.class}) GreenwaveInducesHist GreenwaveInducesHist){ JsonViewObject getByWhere(@ApiParam(value = "查询条件", required = true) @RequestBody @Validated({ValidationGroups.Query.class}) GreenwaveInducesHist GreenwaveInducesHist) {
JsonViewObject jsonView = JsonViewObject.newInstance(); JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis(); long start = System.currentTimeMillis();
String jsonStr = JSON.toJSONString(GreenwaveInducesHist); String jsonStr = JSON.toJSONString(GreenwaveInducesHist);
try { try {
...@@ -152,32 +170,47 @@ public class GreenwaveInducesHistController { ...@@ -152,32 +170,47 @@ public class GreenwaveInducesHistController {
Map params = JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInducesHist), Map.class); Map params = JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInducesHist), Map.class);
// Map<String, Object> params = new HashMap<>(); // Map<String, Object> params = new HashMap<>();
// JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInducesHist), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v)); // JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInducesHist), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
List<GreenwaveInducesDTO> list = new ArrayList<>(); List<GreenwaveInducesHist> greenwaveInducesHistList = this.greenwaveInducesHistService.list();
List<GreenwaveInducesHist> greenwaveInducesHistList = this.greenwaveInducesHistMapper.findByMap(params); List<GreenwaveInfoPO> greenwaveInfoPOList = greenwaveInfoMapper.findByMap(params);
List<GreenwaveInfoPO> greenwaveInfoPOList = greenwaveInfoMapper.selectAll();
List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(); List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list();
// List<InduceTemplate> induceTemplateList = induceTemplateService.list(); // List<InduceTemplate> induceTemplateList = induceTemplateService.list();
List<DeviceInduces> deviceInducesList = deviceInducesService.list(); List<DeviceInduces> deviceInducesList = deviceInducesService.list();
greenwaveInducesHistList.stream().forEach(o -> { List<GreenwaveInducesDTO> greenwaveInfoList = new ArrayList<>();
greenwaveInfoPOList.stream().forEach(x -> {
GreenwaveInducesDTO greenwaveInducesDTO = new GreenwaveInducesDTO(); GreenwaveInducesDTO greenwaveInducesDTO = new GreenwaveInducesDTO();
greenwaveInducesDTO.setGreenId(o.getGreenId()); greenwaveInducesDTO.setGreenId(x.getId());
greenwaveInducesDTO.setDir(o.getDir()); greenwaveInducesDTO.setGreenName(x.getName());
greenwaveInducesDTO.setDesignSpeed(x.getDesignSpeed());
greenwaveInducesDTO.setWkt(x.getWkt());
greenwaveInducesDTO.setStatus(x.getStatus());
AtomicReference<Integer> equipCount = new AtomicReference<>(0);
List<GreenwaveDirDTO> dirList = new ArrayList<>();
greenwaveInducesHistList.stream().filter(o->Objects.isNull(o.getGreenId()) || o.getGreenId().equals(x.getId())).forEach(o -> {
GreenwaveDirDTO greenwaveDirDTO = new GreenwaveDirDTO();
//这里从绿波表里获取基本信息 //这里从绿波表里获取基本信息
List<GreenwaveInfoPO> greenwaveInfoByGreenId = greenwaveInfoPOList.stream().filter(n -> n.getId().equals(o.getGreenId())).collect(Collectors.toList());// 过滤条件// 收集结果 List<GreenwaveInfoPO> greenwaveInfoByGreenId = greenwaveInfoPOList.stream().filter(n -> n.getId().equals(o.getGreenId())).collect(Collectors.toList());// 过滤条件// 收集结果
if (Objects.nonNull(greenwaveInfoByGreenId) && greenwaveInfoByGreenId.size() > 0) {
greenwaveInducesDTO.setGreenName(greenwaveInfoByGreenId.get(0).getName()); greenwaveDirDTO.setDir(o.getDir());
greenwaveInducesDTO.setDesignSpeed(greenwaveInfoByGreenId.get(0).getDesignSpeed()); greenwaveDirDTO.setStrategyId(o.getStrategyId());
greenwaveInducesDTO.setWkt(greenwaveInfoByGreenId.get(0).getWkt()); greenwaveDirDTO.setStrategyName(o.getStrategyName());
greenwaveDirDTO.setMinSpeed(o.getMinSpeed());
greenwaveDirDTO.setMinSpeed(o.getMaxSpeed());
if (Objects.nonNull(o.getControlOptTimes()) && o.getControlOptTimes().split("\\|").length > 0) {
try {
String startTime = DateUtil.format(DateUtil.parse(o.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
String endTime = DateUtil.format(DateUtil.parse(o.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), Constants.DATE_FORMAT.E_DATE_FORMAT_TIME);
greenwaveDirDTO.setControlOptTimes(startTime.substring(0, startTime.lastIndexOf(":00")) + "-" + endTime.substring(0, endTime.lastIndexOf(":00")));
} catch (ParseException ex) {
ex.printStackTrace();
greenwaveDirDTO.setControlOptTimes(o.getControlOptTimes());
}
} else {
greenwaveDirDTO.setControlOptTimes(o.getControlOptTimes());
} }
greenwaveInducesDTO.setStatus(o.getStatus());
greenwaveInducesDTO.setStrategyId(o.getStrategyId());
greenwaveInducesDTO.setStrategyName(o.getStrategyName());
greenwaveInducesDTO.setMinSpeed(o.getMinSpeed());
greenwaveInducesDTO.setMinSpeed(o.getMaxSpeed());
greenwaveInducesDTO.setControlOptTimes(o.getControlOptTimes());
//获取诱导屏列表 //获取诱导屏列表
List<InduceDTO> induceDTOList = new ArrayList<>(); List<InduceDTO> induceDTOList = new ArrayList<>();
greenwaveInducesList.stream().filter(x -> Objects.nonNull(x.getGreenId()) && x.getGreenId().equals(o.getGreenId())).forEach(n -> { greenwaveInducesList.stream().filter(l -> Objects.nonNull(l.getGreenId()) && l.getGreenId().equals(o.getGreenId())).forEach(n -> {
InduceDTO induceDTO = new InduceDTO(); InduceDTO induceDTO = new InduceDTO();
induceDTO.setId(n.getId()); induceDTO.setId(n.getId());
induceDTO.setEquipCode(n.getEquipCode()); induceDTO.setEquipCode(n.getEquipCode());
...@@ -195,11 +228,15 @@ public class GreenwaveInducesHistController { ...@@ -195,11 +228,15 @@ public class GreenwaveInducesHistController {
//induceDTO.setInduceTemplateList(induceTemplateList.stream().filter(x -> Objects.isNull(x.getEquipCode()) || x.getEquipCode().equals(n.getEquipCode())).collect(Collectors.toList())); //induceDTO.setInduceTemplateList(induceTemplateList.stream().filter(x -> Objects.isNull(x.getEquipCode()) || x.getEquipCode().equals(n.getEquipCode())).collect(Collectors.toList()));
induceDTOList.add(induceDTO); induceDTOList.add(induceDTO);
}); });
greenwaveInducesDTO.setInduceList(induceDTOList); greenwaveDirDTO.setInduceList(induceDTOList);
greenwaveInducesDTO.setEquipCount(induceDTOList.size()); equipCount.updateAndGet(v -> v + induceDTOList.size());
list.add(greenwaveInducesDTO); dirList.add(greenwaveDirDTO);
});
greenwaveInducesDTO.setGreenwaveDirList(dirList);
greenwaveInducesDTO.setEquipCount(equipCount.get());
greenwaveInfoList.add(greenwaveInducesDTO);
}); });
jsonView.success(list); jsonView.success(greenwaveInfoList);
} catch (Exception e) { } catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG")); jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getByWhere error,jsonStr:{}", this.getClass().getSimpleName(), jsonStr, e); log.error("{} getByWhere error,jsonStr:{}", this.getClass().getSimpleName(), jsonStr, e);
......
...@@ -10,13 +10,11 @@ import net.wanji.common.framework.Constants; ...@@ -10,13 +10,11 @@ import net.wanji.common.framework.Constants;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.DateUtil; import net.wanji.common.utils.tool.DateUtil;
import net.wanji.opt.entity.GreenwaveInduces; import net.wanji.opt.entity.GreenwaveInduces;
import net.wanji.opt.entity.GreenwaveInducesHist;
import net.wanji.opt.entity.InduceHist; import net.wanji.opt.entity.InduceHist;
import net.wanji.opt.entity.InduceTemplate; import net.wanji.opt.entity.InduceTemplate;
import net.wanji.opt.dto.induce.MessageParam; import net.wanji.opt.dto.induce.MessageParam;
import net.wanji.opt.service.induce.GreenwaveInducesService; import net.wanji.opt.service.induce.*;
import net.wanji.opt.service.induce.InduceHistService;
import net.wanji.opt.service.induce.InduceSendService;
import net.wanji.opt.service.induce.InduceTemplateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -48,11 +46,26 @@ public class InduceSendController { ...@@ -48,11 +46,26 @@ public class InduceSendController {
@Autowired @Autowired
private GreenwaveInducesService greenwaveInducesService; private GreenwaveInducesService greenwaveInducesService;
@Autowired
private GreenwaveInducesHistService greenwaveInducesHistService;
@ApiOperation(value = "发送诱导信息", notes = "发送诱导信息", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON) @ApiOperation(value = "发送诱导信息", notes = "发送诱导信息", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON)
@PostMapping("/send") @PostMapping("/send")
public JsonViewObject send(@RequestBody MessageParam param) { public JsonViewObject send(@RequestBody MessageParam param) {
JsonViewObject jsonView = JsonViewObject.newInstance(); JsonViewObject jsonView = JsonViewObject.newInstance();
try { try {
if(Objects.nonNull(param.getGreenId())) {
LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, param.getGreenId());
List<GreenwaveInducesHist> greenwaveInducesHistList = greenwaveInducesHistService.list(greenwaveInducesHistQueryWrapper);
if (Objects.nonNull(greenwaveInducesHistList) && greenwaveInducesHistList.size() > 0 && Objects.nonNull(greenwaveInducesHistList.get(0).getControlOptTimes()) && greenwaveInducesHistList.get(0).getControlOptTimes().split("|").length > 0 && DateUtil.isBetween(new Date(), DateUtil.parse(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), DateUtil.parse(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND))) {
param.setStartTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[0]);
param.setEndTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1]);
} else {
param.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
param.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
}
}
induceSendService.send(param); induceSendService.send(param);
return jsonView.success(); return jsonView.success();
} catch (Exception e) { } catch (Exception e) {
...@@ -70,6 +83,11 @@ public class InduceSendController { ...@@ -70,6 +83,11 @@ public class InduceSendController {
LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, param.getGreenId()); greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, param.getGreenId());
List<GreenwaveInduces> greenwaveInducesList=greenwaveInducesService.list(greenwaveInducesQueryWrapper); List<GreenwaveInduces> greenwaveInducesList=greenwaveInducesService.list(greenwaveInducesQueryWrapper);
LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, param.getGreenId());
List<GreenwaveInducesHist> greenwaveInducesHistList=greenwaveInducesHistService.list(greenwaveInducesHistQueryWrapper);
for(GreenwaveInduces greenwaveInduces:greenwaveInducesList) for(GreenwaveInduces greenwaveInduces:greenwaveInducesList)
{ {
LambdaQueryWrapper<InduceTemplate> induceTemplateQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InduceTemplate> induceTemplateQueryWrapper = new LambdaQueryWrapper<>();
...@@ -81,8 +99,13 @@ public class InduceSendController { ...@@ -81,8 +99,13 @@ public class InduceSendController {
param.setEquipCode(greenwaveInduces.getEquipCode()); param.setEquipCode(greenwaveInduces.getEquipCode());
param.setPlayorder(induceTemplateList.size()); param.setPlayorder(induceTemplateList.size());
param.setDuration(greenwaveInduces.getDuration()); param.setDuration(greenwaveInduces.getDuration());
if (Objects.nonNull(greenwaveInducesHistList) && greenwaveInducesHistList.size() > 0 && Objects.nonNull(greenwaveInducesHistList.get(0).getControlOptTimes()) && greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|").length > 0 && DateUtil.isBetween(new Date(), DateUtil.parse(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), DateUtil.parse(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND))) {
param.setStartTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[0]);
param.setEndTime(greenwaveInducesHistList.get(0).getControlOptTimes().split("\\|")[1]);
} else {
param.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND)); param.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
param.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 30, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND)); param.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
}
induceSendService.send(param); induceSendService.send(param);
} }
} }
......
...@@ -8,16 +8,14 @@ import net.wanji.common.framework.rest.JsonViewObject; ...@@ -8,16 +8,14 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.po.CrossDataRealtimePO; import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataRealtimePO; import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO; import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.service.CrossIndexService; import net.wanji.opt.service.CrossIndexService;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Date; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -32,6 +30,17 @@ public class CrossIndexController { ...@@ -32,6 +30,17 @@ public class CrossIndexController {
@Resource @Resource
private CrossIndexService crossIndexService; private CrossIndexService crossIndexService;
@ApiOperation(value = "路口信息查询", notes = "路口信息查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossInfoList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = TBaseCrossInfo.class),
})
public JsonViewObject crossInfoList() {
List<TBaseCrossInfo> baseCrossInfoPOS = crossIndexService.crossInfoList();
return JsonViewObject.newInstance().success(baseCrossInfoPOS);
}
@ApiOperation(value = "路口方向指标", notes = "路口方向指标", response = JsonViewObject.class, @ApiOperation(value = "路口方向指标", notes = "路口方向指标", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossDirIndex", @PostMapping(value = "/crossDirIndex",
......
package net.wanji.opt.controller.signalopt; package net.wanji.opt.controller.signalopt;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.service.signalopt.GreenBeltInfoService;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
* @date 2024/11/28 16:03 * @date 2024/11/28 16:03
*/ */
@Api(value = "CrossIndexController", description = "路口指标控制器") @Api(value = "CrossIndexController", description = "路口指标控制器")
@RequestMapping("/crossIndex") @RequestMapping("/greenBelt")
@RestController @RestController
public class GreenBeltController { public class GreenBeltController {
@Resource
private GreenBeltInfoService greenBeltInfoService;
@ApiOperation(value = "绿波协调方向路口流量停车次数", notes = "绿波协调方向路口流量停车次数", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltCrossDetailHist")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
})
public JsonViewObject greenBeltCrossDetailHist(Integer greenId) {
List<GreenBeltFlowStopTimeVO> greenBeltFlowStopTimeVOS = greenBeltInfoService.greenBeltCrossDetailHist(greenId);
return JsonViewObject.newInstance().success(greenBeltFlowStopTimeVOS);
}
} }
package net.wanji.opt.dto.induce;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor
@Data
public class GreenwaveDirDTO {
@ApiModelProperty(name = "当前策略")
private Integer strategyId;
@ApiModelProperty(name = "策略名称")
private String strategyName;
@ApiModelProperty(name = "绿波方向:1 南向北 2 西向东 3 北向南 4 东向西")
private Integer dir;
@ApiModelProperty(name = "推荐最小速度")
private Double minSpeed;
@ApiModelProperty(name = "推荐最大速度")
private Double maxSpeed;
@ApiModelProperty(name = "执行时段")
private String controlOptTimes;
@ApiModelProperty(name = "诱导屏列表")
private List<InduceDTO> induceList;
}
...@@ -25,26 +25,8 @@ public class GreenwaveInducesDTO { ...@@ -25,26 +25,8 @@ public class GreenwaveInducesDTO {
@ApiModelProperty(name = "发布状态") @ApiModelProperty(name = "发布状态")
private Integer status ; private Integer status ;
@ApiModelProperty(name = "当前策略") @ApiModelProperty(name="绿波方向")
private Integer strategyId; private List<GreenwaveDirDTO> greenwaveDirList;
@ApiModelProperty(name = "策略名称")
private String strategyName;
@ApiModelProperty(name = "绿波方向:1 南向北 2 西向东 3 北向南 4 东向西")
private Integer dir;
@ApiModelProperty(name = "推荐最小速度")
private Double minSpeed;
@ApiModelProperty(name = "推荐最大速度")
private Double maxSpeed;
@ApiModelProperty(name = "执行时段")
private String controlOptTimes;
@ApiModelProperty(name = "诱导屏列表")
private List<InduceDTO> induceList;
@ApiModelProperty(name = "绿波带坐标") @ApiModelProperty(name = "绿波带坐标")
private String wkt; private String wkt;
......
...@@ -97,7 +97,7 @@ public class GreenwaveInducesHist implements Serializable { ...@@ -97,7 +97,7 @@ public class GreenwaveInducesHist implements Serializable {
* 0 未发布 1 已发布 * 0 未发布 1 已发布
*/ */
@TableField("status") @TableField("status")
private Integer status; private Integer status=0;
/** /**
* 执行时段 * 执行时段
......
...@@ -54,6 +54,12 @@ public class InduceHist implements Serializable { ...@@ -54,6 +54,12 @@ public class InduceHist implements Serializable {
@TableField("file_path") @TableField("file_path")
private String filePath; private String filePath;
/**
* 建议速度
*/
@TableField("induce_speed")
private String induceSpeed;
/** /**
* 创建时间 * 创建时间
*/ */
......
...@@ -3,7 +3,9 @@ package net.wanji.opt.service; ...@@ -3,7 +3,9 @@ package net.wanji.opt.service;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.po.CrossDataRealtimePO; import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataRealtimePO; import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.databus.po.TBaseCrossInfo;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -12,5 +14,8 @@ import java.util.Map; ...@@ -12,5 +14,8 @@ import java.util.Map;
*/ */
public interface CrossIndexService { public interface CrossIndexService {
Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO); Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO);
CrossDataRealtimePO crossIndex(CrossIdBO crossIdBO); CrossDataRealtimePO crossIndex(CrossIdBO crossIdBO);
List<TBaseCrossInfo> crossInfoList();
} }
package net.wanji.opt.service;
import net.wanji.opt.vo.GreenBeltInfoVO;
/**
* @author duanruiming
* @date 2024/11/19 18:07
*/
public interface GreenBeltInfoService {
/**
* 数据转换
* @param message
* @return
* @throws Exception
*/
GreenBeltInfoVO convertData(String message) throws Exception;
/**
* 存储
* @param infoVO
* @throws Exception
*/
void save(GreenBeltInfoVO infoVO) throws Exception;
}
package net.wanji.opt.service.impl; package net.wanji.opt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper; import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper; import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.po.CrossDataRealtimePO; import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataRealtimePO; import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.service.CrossIndexService; import net.wanji.opt.service.CrossIndexService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -27,6 +30,8 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -27,6 +30,8 @@ public class CrossIndexServiceImpl implements CrossIndexService {
private CrossDirDataRealtimeMapper crossDirDataRealtimeMapper; private CrossDirDataRealtimeMapper crossDirDataRealtimeMapper;
@Resource @Resource
private CrossDataRealtimeMapper crossDataRealtimeMapper; private CrossDataRealtimeMapper crossDataRealtimeMapper;
@Resource
private BaseCrossInfoMapper baseCrossInfoMapper;
@Override @Override
public Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO) { public Map<Integer, CrossDirDataRealtimePO> crossDirIndex(CrossIdBO crossIdBO) {
...@@ -46,4 +51,13 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -46,4 +51,13 @@ public class CrossIndexServiceImpl implements CrossIndexService {
CrossDataRealtimePO crossDataRealtimePO = crossDataRealtimeMapper.selectByCrossId(crossIdBO.getCrossId()); CrossDataRealtimePO crossDataRealtimePO = crossDataRealtimeMapper.selectByCrossId(crossIdBO.getCrossId());
return crossDataRealtimePO; return crossDataRealtimePO;
} }
@Override
public List<TBaseCrossInfo> crossInfoList() {
LambdaQueryWrapper<TBaseCrossInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TBaseCrossInfo::getIsSignal, 1);
List<TBaseCrossInfo> baseCrossInfoPOS = baseCrossInfoMapper.selectList(queryWrapper);
return baseCrossInfoPOS;
}
} }
package net.wanji.opt.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.opt.common.Constants;
import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper;
import net.wanji.opt.dto.GreenBeltKafkaDTO;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.service.GreenBeltInfoService;
import net.wanji.opt.vo.GreenBeltInfoVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author duanruiming
* @date 2024/11/19 19:04
*/
@Service
public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
@Resource
private StrategyGreenOptHistMapper strategyGreenOptHistMapper;
public static void main(String[] args) throws Exception {
String message = greenBeltInfoData;
ObjectMapper mapper = JacksonUtils.getInstance();
GreenBeltKafkaDTO kafkaDTO = mapper.readValue(message, GreenBeltKafkaDTO.class);
// 正反绿波容器
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = new ArrayList<>();
// 构建正向绿波
setForward(kafkaDTO, dirGreenDetails);
// 反向绿波
setBackward(kafkaDTO, dirGreenDetails);
// 返回绿波实体
GreenBeltInfoVO greenBeltInfoVO = new GreenBeltInfoVO();
greenBeltInfoVO.setGreenId(kafkaDTO.getGreenbeltId());
greenBeltInfoVO.setLength(kafkaDTO.getGreenbeltLength());
greenBeltInfoVO.setCycle(kafkaDTO.getMaxCycle());
greenBeltInfoVO.setControlTime(kafkaDTO.getControlTime());
greenBeltInfoVO.setControlDuration(kafkaDTO.getControlDuration());
greenBeltInfoVO.setType(kafkaDTO.getGreenbeltType());
greenBeltInfoVO.setDynamic(kafkaDTO.getDynamic());
greenBeltInfoVO.setControlMethod(kafkaDTO.getControlMethod());
greenBeltInfoVO.setDirGreenDetails(dirGreenDetails);
System.err.println(mapper.writeValueAsString(greenBeltInfoVO));
}
@Override
public GreenBeltInfoVO convertData(String message) throws Exception {
ObjectMapper mapper = JacksonUtils.getInstance();
GreenBeltKafkaDTO kafkaDTO = mapper.readValue(greenBeltInfoData, GreenBeltKafkaDTO.class);
// 正反绿波容器
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = new ArrayList<>();
// 构建正向绿波
setForward(kafkaDTO, dirGreenDetails);
// 反向绿波
setBackward(kafkaDTO, dirGreenDetails);
// 返回绿波实体
GreenBeltInfoVO greenBeltInfoVO = new GreenBeltInfoVO();
greenBeltInfoVO.setGreenId(kafkaDTO.getGreenbeltId());
greenBeltInfoVO.setLength(kafkaDTO.getGreenbeltLength());
greenBeltInfoVO.setCycle(kafkaDTO.getMaxCycle());
greenBeltInfoVO.setControlTime(kafkaDTO.getControlTime());
greenBeltInfoVO.setControlDuration(kafkaDTO.getControlDuration());
greenBeltInfoVO.setType(kafkaDTO.getGreenbeltType());
greenBeltInfoVO.setDynamic(kafkaDTO.getDynamic());
greenBeltInfoVO.setControlMethod(kafkaDTO.getControlMethod());
greenBeltInfoVO.setDirGreenDetails(dirGreenDetails);
return greenBeltInfoVO;
}
@Override
public void save(GreenBeltInfoVO infoVO) throws Exception {
if (Objects.nonNull(infoVO)) {
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = infoVO.getDirGreenDetails();
if (!CollectionUtils.isEmpty(dirGreenDetails)) {
for (GreenBeltInfoVO.DirGreenDetail dirGreenDetail : dirGreenDetails) {
StrategyGreenOptHistEntity entity = new StrategyGreenOptHistEntity();
entity.setGreenId(infoVO.getGreenId());
entity.setLength(infoVO.getLength());
entity.setCycle(infoVO.getCycle());
entity.setControlTime(infoVO.getControlTime());
entity.setControlDuration(infoVO.getControlDuration());
entity.setControlMethod(infoVO.getControlMethod());
entity.setType(infoVO.getType());
entity.setDynamic(infoVO.getDynamic());
entity.setDirType(dirGreenDetail.getDirType());
entity.setDir(dirGreenDetail.getDir());
entity.setMaxSpeed(dirGreenDetail.getMaxSpeed());
entity.setMinSpeed(dirGreenDetail.getMinSpeed());
entity.setGreenWidthTime(dirGreenDetail.getGreenWidthTime());
entity.setCrossGreenDetail(JacksonUtils.getInstance().writeValueAsString(dirGreenDetail.getCrossGreenDetailList()));
strategyGreenOptHistMapper.insert(entity);
String key = Constants.GREEN_ID_OPT_KEY.concat(String.valueOf(infoVO.getGreenId()));
}
}
}
}
private static void setBackward(GreenBeltKafkaDTO kafkaDTO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) {
// 反向绿波路口列表
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = new ArrayList<>();
Map<String, Double> phaseStartBackward = kafkaDTO.getPhaseStartBackward();
for (Map.Entry<String, Double> backEntry : phaseStartBackward.entrySet()) {
String crossId = backEntry.getKey();
Double phaseStartTime = backEntry.getValue();
GreenBeltInfoVO.CrossGreenDetail crossGreenDetail = new GreenBeltInfoVO.CrossGreenDetail();
crossGreenDetail.setCrossId(crossId);
crossGreenDetail.setPhaseStartTime(phaseStartTime);
Double phaseEndTime = kafkaDTO.getPhaseEndBackward().get(crossId);
crossGreenDetail.setPhaseEndTime(phaseEndTime);
Double greenStartTime = kafkaDTO.getBeltStartBackward().get(crossId);
crossGreenDetail.setGreenStartTime(greenStartTime);
Double speed = kafkaDTO.getSpeedBackward().get(crossId);
crossGreenDetail.setSpeed(speed);
Double offset = kafkaDTO.getOffset().get(crossId);
crossGreenDetail.setOffset(offset);
Double distance = kafkaDTO.getDistanceBackward().get(crossId);
crossGreenDetail.setDistance(distance);
Double travelTime = kafkaDTO.getTravelTimeBackward().get(crossId);
crossGreenDetail.setTravelTime(travelTime);
crossGreenDetails.add(crossGreenDetail);
}
// 反向绿波
// 反向绿波实体
GreenBeltInfoVO.DirGreenDetail dirGreenDetail = new GreenBeltInfoVO.DirGreenDetail();
dirGreenDetail.setDirType(0);
String forwardDirection = kafkaDTO.getBackwardDirection();
dirGreenDetail.setDir(forwardDirection);
double maxSpeedForward = kafkaDTO.getMaxSpeedBackward();
dirGreenDetail.setMaxSpeed(maxSpeedForward);
double minSpeedForward = kafkaDTO.getMinSpeedBackward();
dirGreenDetail.setMinSpeed(minSpeedForward);
double greenWidthForward = kafkaDTO.getGreenWidthBackward();
dirGreenDetail.setGreenWidthTime(greenWidthForward);
dirGreenDetail.setCrossGreenDetailList(crossGreenDetails);
dirGreenDetails.add(dirGreenDetail);
}
private static void setForward(GreenBeltKafkaDTO kafkaDTO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) {
// 正向绿波路口列表
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = new ArrayList<>();
Map<String, Double> phaseStartForward = kafkaDTO.getPhaseStartForward();
for (Map.Entry<String, Double> forwardEntry : phaseStartForward.entrySet()) {
String crossId = forwardEntry.getKey();
Double phaseStartTime = forwardEntry.getValue();
GreenBeltInfoVO.CrossGreenDetail crossGreenDetail = new GreenBeltInfoVO.CrossGreenDetail();
crossGreenDetail.setCrossId(crossId);
crossGreenDetail.setPhaseStartTime(phaseStartTime);
Double phaseEndTime = kafkaDTO.getPhaseEndForward().get(crossId);
crossGreenDetail.setPhaseEndTime(phaseEndTime);
Double greenStartTime = kafkaDTO.getBeltStartForward().get(crossId);
crossGreenDetail.setGreenStartTime(greenStartTime);
Double speed = kafkaDTO.getSpeedForward().get(crossId);
crossGreenDetail.setSpeed(speed);
Double offset = kafkaDTO.getOffset().get(crossId);
crossGreenDetail.setOffset(offset);
Double distance = kafkaDTO.getDistanceForward().get(crossId);
crossGreenDetail.setDistance(distance);
Double travelTime = kafkaDTO.getTravelTimeForward().get(crossId);
crossGreenDetail.setTravelTime(travelTime);
crossGreenDetails.add(crossGreenDetail);
}
// 正向绿波
// 正向绿波实体
GreenBeltInfoVO.DirGreenDetail dirGreenDetail = new GreenBeltInfoVO.DirGreenDetail();
dirGreenDetail.setDirType(1);
String forwardDirection = kafkaDTO.getForwardDirection();
dirGreenDetail.setDir(forwardDirection);
double maxSpeedForward = kafkaDTO.getMaxSpeedForward();
dirGreenDetail.setMaxSpeed(maxSpeedForward);
double minSpeedForward = kafkaDTO.getMinSpeedForward();
dirGreenDetail.setMinSpeed(minSpeedForward);
double greenWidthForward = kafkaDTO.getGreenWidthForward();
dirGreenDetail.setGreenWidthTime(greenWidthForward);
dirGreenDetail.setCrossGreenDetailList(crossGreenDetails);
dirGreenDetails.add(dirGreenDetail);
}
public static String greenBeltInfoData = "{\n" +
"\t\"backward_direction\": \"e2w\",\n" +
"\t\"belt_start_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": 0.0,\n" +
"\t\t\"13MQJ0B5SI0\": 91.0,\n" +
"\t\t\"13MS20B5SI0\": 25.0,\n" +
"\t\t\"13MUK0B5SH0\": 0.0,\n" +
"\t\t\"13N0F0B5SH0\": 45.0,\n" +
"\t\t\"13N200B5SH0\": 0.0\n" +
"\t},\n" +
"\t\"belt_start_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 0.0,\n" +
"\t\t\"13MQJ0B5SI0\": 91.0,\n" +
"\t\t\"13MS20B5SI0\": 25.0,\n" +
"\t\t\"13MUK0B5SH0\": 0.0,\n" +
"\t\t\"13N0F0B5SH0\": 45.0,\n" +
"\t\t\"13N200B5SH0\": 0.0\n" +
"\t},\n" +
"\t\"control_duration\": 10,\n" +
"\t\"control_method\": 1,\n" +
"\t\"control_time\": \"2024-11-20T18:15:31\",\n" +
"\t\"cycle\": {\n" +
"\t\t\"13MOD0B5SI0\": 220.0,\n" +
"\t\t\"13MQJ0B5SI0\": 220.0,\n" +
"\t\t\"13MS20B5SI0\": 220.0,\n" +
"\t\t\"13MUK0B5SH0\": 220.0,\n" +
"\t\t\"13N0F0B5SH0\": 220.0,\n" +
"\t\t\"13N200B5SH0\": 220.0\n" +
"\t},\n" +
"\t\"distance_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": -1.0,\n" +
"\t\t\"13MQJ0B5SI0\": 637.5,\n" +
"\t\t\"13MS20B5SI0\": 412.49999999999994,\n" +
"\t\t\"13MUK0B5SH0\": 725.0,\n" +
"\t\t\"13N0F0B5SH0\": 525.0,\n" +
"\t\t\"13N200B5SH0\": 450.0\n" +
"\t},\n" +
"\t\"distance_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 637.5,\n" +
"\t\t\"13MQJ0B5SI0\": 412.49999999999994,\n" +
"\t\t\"13MS20B5SI0\": 725.0,\n" +
"\t\t\"13MUK0B5SH0\": 525.0,\n" +
"\t\t\"13N0F0B5SH0\": 450.0,\n" +
"\t\t\"13N200B5SH0\": -1.0\n" +
"\t},\n" +
"\t\"dynamic\": 1,\n" +
"\t\"forward_direction\": \"w2e\",\n" +
"\t\"green_width_backward\": 42.0,\n" +
"\t\"green_width_forward\": 41.0,\n" +
"\t\"greenbelt_direction\": 2,\n" +
"\t\"greenbelt_id\": \"road1\",\n" +
"\t\"greenbelt_length\": 2757.0,\n" +
"\t\"greenbelt_type\": 2,\n" +
"\t\"max_cycle\": 220,\n" +
"\t\"max_speed_backward\": 50.0,\n" +
"\t\"max_speed_forward\": 50.0,\n" +
"\t\"min_speed_backward\": 40.0,\n" +
"\t\"min_speed_forward\": 40.0,\n" +
"\t\"offset\": {\n" +
"\t\t\"13MOD0B5SI0\": 0.0,\n" +
"\t\t\"13MQJ0B5SI0\": 87.0,\n" +
"\t\t\"13MS20B5SI0\": 117.0,\n" +
"\t\t\"13MUK0B5SH0\": 119.0,\n" +
"\t\t\"13N0F0B5SH0\": 0.0,\n" +
"\t\t\"13N200B5SH0\": 0.0\n" +
"\t},\n" +
"\t\"phase_end_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": 142.0,\n" +
"\t\t\"13MQJ0B5SI0\": 175.0,\n" +
"\t\t\"13MS20B5SI0\": 158.0,\n" +
"\t\t\"13MUK0B5SH0\": 125.0,\n" +
"\t\t\"13N0F0B5SH0\": 175.0,\n" +
"\t\t\"13N200B5SH0\": 145.0\n" +
"\t},\n" +
"\t\"phase_end_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 142.0,\n" +
"\t\t\"13MQJ0B5SI0\": 175.0,\n" +
"\t\t\"13MS20B5SI0\": 158.0,\n" +
"\t\t\"13MUK0B5SH0\": 125.0,\n" +
"\t\t\"13N0F0B5SH0\": 175.0,\n" +
"\t\t\"13N200B5SH0\": 145.0\n" +
"\t},\n" +
"\t\"phase_start_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": 39.0,\n" +
"\t\t\"13MQJ0B5SI0\": 42.0,\n" +
"\t\t\"13MS20B5SI0\": 45.0,\n" +
"\t\t\"13MUK0B5SH0\": 0.0,\n" +
"\t\t\"13N0F0B5SH0\": 42.0,\n" +
"\t\t\"13N200B5SH0\": 40.0\n" +
"\t},\n" +
"\t\"phase_start_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 39.0,\n" +
"\t\t\"13MQJ0B5SI0\": 42.0,\n" +
"\t\t\"13MS20B5SI0\": 45.0,\n" +
"\t\t\"13MUK0B5SH0\": 0.0,\n" +
"\t\t\"13N0F0B5SH0\": 42.0,\n" +
"\t\t\"13N200B5SH0\": 40.0\n" +
"\t},\n" +
"\t\"speed_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": -1.0,\n" +
"\t\t\"13MQJ0B5SI0\": 45.0,\n" +
"\t\t\"13MS20B5SI0\": 44.99999999999999,\n" +
"\t\t\"13MUK0B5SH0\": 45.0,\n" +
"\t\t\"13N0F0B5SH0\": 45.0,\n" +
"\t\t\"13N200B5SH0\": 45.0\n" +
"\t},\n" +
"\t\"speed_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 45.0,\n" +
"\t\t\"13MQJ0B5SI0\": 44.99999999999999,\n" +
"\t\t\"13MS20B5SI0\": 45.0,\n" +
"\t\t\"13MUK0B5SH0\": 45.0,\n" +
"\t\t\"13N0F0B5SH0\": 45.0,\n" +
"\t\t\"13N200B5SH0\": -1.0\n" +
"\t},\n" +
"\t\"travel_time_backward\": {\n" +
"\t\t\"13MOD0B5SI0\": -1.0,\n" +
"\t\t\"13MQJ0B5SI0\": 51.0,\n" +
"\t\t\"13MS20B5SI0\": 33.0,\n" +
"\t\t\"13MUK0B5SH0\": 58.0,\n" +
"\t\t\"13N0F0B5SH0\": 42.0,\n" +
"\t\t\"13N200B5SH0\": 36.0\n" +
"\t},\n" +
"\t\"travel_time_forward\": {\n" +
"\t\t\"13MOD0B5SI0\": 51.0,\n" +
"\t\t\"13MQJ0B5SI0\": 33.0,\n" +
"\t\t\"13MS20B5SI0\": 58.0,\n" +
"\t\t\"13MUK0B5SH0\": 42.0,\n" +
"\t\t\"13N0F0B5SH0\": 36.0,\n" +
"\t\t\"13N200B5SH0\": -1.0\n" +
"\t}\n" +
"}";
}
...@@ -490,7 +490,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService { ...@@ -490,7 +490,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
crossMetrics.setDelayTime(delayTimeSum / size); crossMetrics.setDelayTime(delayTimeSum / size);
crossMetrics.setEffusionRate(effusionRateSum / size); crossMetrics.setEffusionRate(effusionRateSum / size);
crossMetrics.setEmptyPhase(emptyPhaseSum); crossMetrics.setEmptyPhase(emptyPhaseSum);
Date currentDate = dtoList.get(0).getStartTime(); Date currentDate = dtoList.get(dtoList.size() - 1).getStartTime();
Calendar instance = Calendar.getInstance(); Calendar instance = Calendar.getInstance();
instance.setTime(currentDate); instance.setTime(currentDate);
instance.set(Calendar.HOUR_OF_DAY, Integer.parseInt(section.substring(0, 2))); instance.set(Calendar.HOUR_OF_DAY, Integer.parseInt(section.substring(0, 2)));
......
...@@ -208,11 +208,13 @@ public class TrendServiceImpl implements TrendService { ...@@ -208,11 +208,13 @@ public class TrendServiceImpl implements TrendService {
Double speed = 0.0; Double speed = 0.0;
Double trafficIndex = 1.0; Double trafficIndex = 1.0;
int travelTime = 0; int travelTime = 0;
Integer stopTimes = 0;
GreenwaveListVO wDirVo = new GreenwaveListVO(); GreenwaveListVO wDirVo = new GreenwaveListVO();
for (GreenwaveListVO greenwaveListVO : value) { for (GreenwaveListVO greenwaveListVO : value) {
speed += greenwaveListVO.getSpeed() == null ? 0.0 : greenwaveListVO.getSpeed(); speed += greenwaveListVO.getSpeed() == null ? 0.0 : greenwaveListVO.getSpeed();
trafficIndex += greenwaveListVO.getTrafficIndex() == null ? 0.0 : greenwaveListVO.getTrafficIndex(); trafficIndex += greenwaveListVO.getTrafficIndex() == null ? 0.0 : greenwaveListVO.getTrafficIndex();
travelTime += greenwaveListVO.getTravelTime(); travelTime += greenwaveListVO.getTravelTime();
stopTimes += greenwaveListVO.getStopTimes() == null ? 0 : greenwaveListVO.getStopTimes();
wDirVo.setId(greenId); wDirVo.setId(greenId);
wDirVo.setName(greenwaveListVO.getName()); wDirVo.setName(greenwaveListVO.getName());
wDirVo.setWkt(greenwaveListVO.getWkt()); wDirVo.setWkt(greenwaveListVO.getWkt());
...@@ -222,6 +224,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -222,6 +224,7 @@ public class TrendServiceImpl implements TrendService {
wDirVo.setInfoStatus(greenwaveListVO.getInfoStatus()); wDirVo.setInfoStatus(greenwaveListVO.getInfoStatus());
} }
wDirVo.setSpeed(speed / 2); wDirVo.setSpeed(speed / 2);
wDirVo.setStopTimes((int) (stopTimes / 2));
wDirVo.setTrafficIndex(trafficIndex / 2 < 1 ? 1 : trafficIndex / 2); wDirVo.setTrafficIndex(trafficIndex / 2 < 1 ? 1 : trafficIndex / 2);
wDirVo.setTravelTime(travelTime / 2); wDirVo.setTravelTime(travelTime / 2);
greenwaveListVOList.add(wDirVo); greenwaveListVOList.add(wDirVo);
...@@ -1756,7 +1759,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -1756,7 +1759,7 @@ public class TrendServiceImpl implements TrendService {
AbnormalCrossListVO abnormalCrossListVO = new AbnormalCrossListVO(); AbnormalCrossListVO abnormalCrossListVO = new AbnormalCrossListVO();
// 如果路口编号为空,态势监测页面默认展示拥堵指数第一的路口排队长度数据 // 如果路口编号为空,态势监测页面默认展示拥堵指数第一的路口排队长度数据
if (StringUtils.isBlank(crossId)) { if (StringUtils.isBlank(crossId)) {
Optional<AbnormalCrossListVO> max = signalCrossRealTimeList.stream().max(Comparator.comparingDouble(AbnormalCrossListVO::getCongestionIndex)); Optional<AbnormalCrossListVO> max = signalCrossRealTimeList.stream().max(Comparator.comparingDouble(AbnormalCrossListVO::getTrafficIndex));
if (max.isPresent()) { if (max.isPresent()) {
abnormalCrossListVO = max.get(); abnormalCrossListVO = max.get();
} }
...@@ -1769,7 +1772,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -1769,7 +1772,7 @@ public class TrendServiceImpl implements TrendService {
// 查询当前拥堵指数最大,历史表中一个小时以内数据 // 查询当前拥堵指数最大,历史表中一个小时以内数据
LambdaQueryWrapper<CrossDirDataHistPO> histQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CrossDirDataHistPO> histQuery = new LambdaQueryWrapper<>();
histQuery.eq(CrossDirDataHistPO::getCrossId, abnormalCrossListVO.getId()) histQuery.eq(CrossDirDataHistPO::getCrossId, abnormalCrossListVO.getId())
.between(CrossDirDataHistPO::getBatchTime, abnormalCrossListVO.getBatchTime() - 86400, abnormalCrossListVO.getBatchTime()); .between(CrossDirDataHistPO::getBatchTime, abnormalCrossListVO.getBatchTime() - 3600 * 2, abnormalCrossListVO.getBatchTime());
List<CrossDirDataHistPO> histPOS = crossDirDataHistMapper.selectList(histQuery); List<CrossDirDataHistPO> histPOS = crossDirDataHistMapper.selectList(histQuery);
if (!CollectionUtils.isEmpty(histPOS)) { if (!CollectionUtils.isEmpty(histPOS)) {
Map<Integer, List<CrossDirDataHistPO>> map = histPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getBatchTime)); Map<Integer, List<CrossDirDataHistPO>> map = histPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getBatchTime));
......
...@@ -113,6 +113,9 @@ public class InduceSendServiceImpl implements InduceSendService { ...@@ -113,6 +113,9 @@ public class InduceSendServiceImpl implements InduceSendService {
String filePath = uploadFile(image,dirName, fileName); String filePath = uploadFile(image,dirName, fileName);
param.setFtpPath(filePath); param.setFtpPath(filePath);
induceHist.setFilePath(PATH + dirName+"/"+fileName); induceHist.setFilePath(PATH + dirName+"/"+fileName);
if(Objects.nonNull(param.getContents()) && param.getContents().length>0) {
induceHist.setInduceSpeed(param.getContents()[0]);
}
if(Objects.nonNull(greenwaveinduces)) { if(Objects.nonNull(greenwaveinduces)) {
greenwaveinduces.setSourceId(PATH + dirName + "/" + fileName); greenwaveinduces.setSourceId(PATH + dirName + "/" + fileName);
} }
...@@ -146,7 +149,8 @@ public class InduceSendServiceImpl implements InduceSendService { ...@@ -146,7 +149,8 @@ public class InduceSendServiceImpl implements InduceSendService {
// messageProperties.setContentType("text/plain"); // 设置内容类型为text/plain // messageProperties.setContentType("text/plain"); // 设置内容类型为text/plain
// 创建Message并设置内容 // 创建Message并设置内容
// Message messageSend = new Message(message.getBytes(), messageProperties); // Message messageSend = new Message(message.getBytes(), messageProperties);
if(sending) { if(sending)
{
rabbitTemplate.convertAndSend("", queueName, message); rabbitTemplate.convertAndSend("", queueName, message);
} }
log.info("mqtt发送信息-topic:{},queueName:{},message:{}", queueName, message); log.info("mqtt发送信息-topic:{},queueName:{},message:{}", queueName, message);
...@@ -293,15 +297,23 @@ public class InduceSendServiceImpl implements InduceSendService { ...@@ -293,15 +297,23 @@ public class InduceSendServiceImpl implements InduceSendService {
g.drawString(text[0], x, y); g.drawString(text[0], x, y);
} else { // 纵向 } else { // 纵向
// 字体高度的70% // 字体高度的70%
int verticalSpacing = (int) (textHeight * 0.7); int verticalSpacing = (int) (textHeight * 0.95);
// 逐个字符绘制文字 // 逐个字符绘制文字
for (int i = 0; i < text.length; i++) { if(text[0].split("-").length==2) {
if (i == 0) { g.drawString(" "+text[0].split("-")[0], x, y);
g.drawString(text[i], x, y); g.drawString(" |", x, y + (1 * verticalSpacing));
} else { g.drawString(" "+text[0].split("-")[1].replace("km/h",""), x, y + (2 * verticalSpacing));
g.drawString(text[i], x, y + (i * verticalSpacing)); g.drawString("km/h", x, y + (3 * verticalSpacing));
} }else{
g.drawString(text[0], x, y);
} }
// for (int i = 0; i < text[0].split("-")[1]; i++) {
// if (i%2 == 0) {
// g.drawString(text[i], x, y);
// } else {
// g.drawString(text[i], x, y + (i * verticalSpacing));
// }
// }
} }
// 释放资源 // 释放资源
g.dispose(); g.dispose();
......
package net.wanji.opt.service.signalopt;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import java.util.List;
/**
* @author duanruiming
* @date 2024/11/19 18:07
*/
public interface GreenBeltInfoService {
List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId);
}
package net.wanji.opt.service.signalopt.impl;
import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.service.signalopt.GreenBeltInfoService;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author duanruiming
* @date 2024/12/02 13:42
*/
@Service
public class GreenBeltServiceImpl implements GreenBeltInfoService {
@Resource
private GreenwaveInfoMapper greenwaveInfoMapper;
@Resource
private CrossDataHistMapper crossDataHistMapper;
@Override
public List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) {
List<String> crossIds = greenwaveInfoMapper.selectCrossIdsById(greenId);
long currentTimeMillis = System.currentTimeMillis();
int startSecond = (int) (currentTimeMillis / 1000 - 3600);
int endSecond = (int) (currentTimeMillis / 1000);
List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectByCrossIdsAndTimestamp(crossIds, startSecond , endSecond);
if (!CollectionUtils.isEmpty(crossDataHistPOS)) {
List<GreenBeltFlowStopTimeVO> results = new ArrayList<>();
Map<Date, List<CrossDataHistPO>> startTimeMap = crossDataHistPOS.stream().collect(Collectors.groupingBy(CrossDataHistPO::getStartTime));
for (Map.Entry<Date, List<CrossDataHistPO>> entry : startTimeMap.entrySet()) {
GreenBeltFlowStopTimeVO greenBeltFlowStopTimeVO = new GreenBeltFlowStopTimeVO();
Date startDate = entry.getKey();
List<GreenBeltFlowStopTimeVO.FlowStopTimeDetail> crossList = new ArrayList<>();
greenBeltFlowStopTimeVO.setStartTime(startDate);
List<CrossDataHistPO> value = entry.getValue();
if (!CollectionUtils.isEmpty(value)) {
for (CrossDataHistPO crossDataHistPO : value) {
GreenBeltFlowStopTimeVO.FlowStopTimeDetail flowStopTimeDetail = new GreenBeltFlowStopTimeVO.FlowStopTimeDetail();
flowStopTimeDetail.setFlow(crossDataHistPO.getFlow());
flowStopTimeDetail.setStopTimes(crossDataHistPO.getStopTimes());
flowStopTimeDetail.setCrossId(crossDataHistPO.getCrossId());
// todo 先删除,后续通过路口距离/速度计算 距离通过卫博发送数据
flowStopTimeDetail.setTravelTime(0.0);
crossList.add(flowStopTimeDetail);
}
}
greenBeltFlowStopTimeVO.setDetailList(crossList);
results.add(greenBeltFlowStopTimeVO);
}
Collections.sort(results, Comparator.comparing(GreenBeltFlowStopTimeVO::getStartTime));
return results;
}
return Collections.EMPTY_LIST;
}
}
...@@ -5,12 +5,10 @@ import io.swagger.annotations.ApiOperation; ...@@ -5,12 +5,10 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dao.mapper.SynthesisOptimizeLogInfoMapper;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity; import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO; import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.request.StrategyHistReq;
import net.wanji.opt.synthesis.service.StrategyControlService; import net.wanji.opt.synthesis.service.StrategyControlService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -30,8 +28,6 @@ public class StrategyControlController { ...@@ -30,8 +28,6 @@ public class StrategyControlController {
@Resource @Resource
private StrategyControlService strategyControlService; private StrategyControlService strategyControlService;
@Resource
SynthesisOptimizeLogInfoMapper synthesisOptimizeLogInfoMapper;
@ApiOperation(value = "策略控制信息操作", notes = "策略控制信息操作", @ApiOperation(value = "策略控制信息操作", notes = "策略控制信息操作",
response = JsonViewObject.class, response = JsonViewObject.class,
...@@ -81,7 +77,18 @@ public class StrategyControlController { ...@@ -81,7 +77,18 @@ public class StrategyControlController {
} }
@ApiOperation(value = "路网优化监测", notes = "路网优化监测", @ApiOperation(value = "AI优化次数优化时长", notes = "路网优化检测-AI优化次数优化时长",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/strategyOptTimes")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyControlDataEntity.class),
})
public JsonViewObject strategyOptTimes() throws Exception {
return strategyControlService.strategyOptTimes();
}
@ApiOperation(value = "路网优化监测-接口干线列表", notes = "路网优化监测-AI路口-AI干线",
response = JsonViewObject.class, response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossOptInfoList") @GetMapping(value = "/crossOptInfoList")
......
...@@ -5,21 +5,26 @@ import io.swagger.annotations.ApiOperation; ...@@ -5,21 +5,26 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.synthesis.pojo.vo.GreenBeltAreaIndexVO;
import net.wanji.opt.synthesis.service.impl.StrategyGreenBeltServiceImpl; import net.wanji.opt.synthesis.service.impl.StrategyGreenBeltServiceImpl;
import net.wanji.opt.vo.GreenBeltChartVO; import net.wanji.opt.vo.GreenBeltChartVO;
import net.wanji.opt.vo.GreenBeltInfoVO; import net.wanji.opt.vo.GreenBeltInfoVO;
import org.springframework.web.bind.annotation.*; import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO;
import net.wanji.opt.vo.HotspotCrossVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Date; import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
* @date 2024/11/19 20:10 * @date 2024/11/19 20:10
* @description 神思推送绿波时序图 * @description 神思推送绿波时序图
*/ */
@Api(value = "StrategyGreenBeltController", description = "策略绿波带") @Api(value = "StrategyGreenBeltController", description = "策略绿波带弹窗")
@RequestMapping("/strategyBelt") @RequestMapping("/strategyBelt")
@RestController @RestController
public class StrategyGreenBeltController { public class StrategyGreenBeltController {
...@@ -38,4 +43,27 @@ public class StrategyGreenBeltController { ...@@ -38,4 +43,27 @@ public class StrategyGreenBeltController {
return JsonViewObject.newInstance().success(greenBeltChartVO); return JsonViewObject.newInstance().success(greenBeltChartVO);
} }
@ApiOperation(value = "绿波停车次数排队长度", notes = "绿波停车次数排队长度", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltStopTimeQueueLength")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HotspotCrossVO.class),
})
public JsonViewObject greenBeltStopTimeQueueLength(Integer greenId) throws Exception {
List<GreenBeltStopTimesQueueLengthVO> results = strategyGreenBeltService.greenBeltStopTimeQueueLength(greenId);
return JsonViewObject.newInstance().success(results);
}
@ApiOperation(value = "绿波子区指标", notes = "绿波子区指标", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltAreaIndex")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HotspotCrossVO.class),
})
public JsonViewObject greenBeltAreaIndex(Integer greenId) throws Exception {
GreenBeltAreaIndexVO result = strategyGreenBeltService.greenBeltAreaIndex(greenId);
return JsonViewObject.newInstance().success(result);
}
} }
package net.wanji.opt.synthesis.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2024/12/03 18:59
*/
@Data
@ApiModel("绿波干线子区返回参数")
public class GreenBeltAreaIndexVO {
@ApiModelProperty("子区状态")
private Integer status;
@ApiModelProperty("优化策略")
private String strategyName;
@ApiModelProperty("绿波方向详情")
private List<DirDetail> dirDetail;
@Data
public static class DirDetail {
@ApiModelProperty("绿波名称")
private String dirName;
@ApiModelProperty("行程时间")
private Integer travelTime;
@ApiModelProperty("停车次数")
private Double StopTimes;
}
}
package net.wanji.opt.synthesis.pojo; package net.wanji.opt.synthesis.pojo.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
package net.wanji.opt.synthesis.pojo; package net.wanji.opt.synthesis.pojo.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
package net.wanji.opt.synthesis.pojo; package net.wanji.opt.synthesis.pojo.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.Data; import lombok.Data;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlDataVO;
import java.util.List; import java.util.List;
......
package net.wanji.opt.synthesis.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author duanruiming
* @date 2024/12/04 13:58
*/
@Data
@ApiModel("AI优化次数优化时长返回实体")
public class StrategyOptTimesVO {
@ApiModelProperty("优化次数")
private Integer count;
@ApiModelProperty("优化时长")
private Integer times;
}
...@@ -3,9 +3,8 @@ package net.wanji.opt.synthesis.service; ...@@ -3,9 +3,8 @@ package net.wanji.opt.synthesis.service;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity; import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO; import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.request.StrategyHistReq;
/** /**
* @author duanruiming * @author duanruiming
...@@ -16,6 +15,7 @@ public interface StrategyControlService { ...@@ -16,6 +15,7 @@ public interface StrategyControlService {
JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception; JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception;
JsonViewObject crossStrategyInfoList(Integer type) throws Exception; JsonViewObject crossStrategyInfoList(Integer type) throws Exception;
JsonViewObject strategyOptTimes() throws Exception;
JsonViewObject crossStrategyHistList() throws Exception; JsonViewObject crossStrategyHistList() throws Exception;
JsonViewObject crossOptInfoList(Integer type) throws Exception; JsonViewObject crossOptInfoList(Integer type) throws Exception;
......
package net.wanji.opt.synthesis.service; package net.wanji.opt.synthesis.service;
import net.wanji.opt.synthesis.pojo.vo.GreenBeltAreaIndexVO;
import net.wanji.opt.vo.GreenBeltChartVO; import net.wanji.opt.vo.GreenBeltChartVO;
import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
...@@ -11,4 +14,6 @@ import java.util.Date; ...@@ -11,4 +14,6 @@ import java.util.Date;
public interface StrategyGreenBeltService { public interface StrategyGreenBeltService {
GreenBeltChartVO selectChart(Integer greenId, Date queryDate); GreenBeltChartVO selectChart(Integer greenId, Date queryDate);
List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId);
GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId);
} }
...@@ -16,12 +16,17 @@ import net.wanji.databus.dao.entity.GreenwaveInfoPO; ...@@ -16,12 +16,17 @@ import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper; import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.BaseCrossInfoPO; import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.cache.BaseCrossInfoCache; import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.cache.GreenWaveInfoCache; import net.wanji.opt.cache.GreenWaveInfoCache;
import net.wanji.opt.dao.mapper.*; import net.wanji.opt.dao.mapper.*;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum; import net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum;
import net.wanji.opt.synthesis.pojo.*; import net.wanji.opt.synthesis.pojo.*;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlDataVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlHistVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyOptTimesVO;
import net.wanji.opt.synthesis.service.PushStrategyControlService; import net.wanji.opt.synthesis.service.PushStrategyControlService;
import net.wanji.opt.synthesis.service.StrategyControlService; import net.wanji.opt.synthesis.service.StrategyControlService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -35,6 +40,7 @@ import java.text.ParseException; ...@@ -35,6 +40,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -174,7 +180,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -174,7 +180,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
// 查询当前绿波历史记录 // 查询当前绿波历史记录
setGreenOptHist(results, midnight, format); setGreenOptHist(results, midnight, format);
setCrossOptHist(results, midnight); setCrossOptHist(results, midnight);
return JsonViewObject.newInstance().success(results); List<StrategyControlHistVO> sorted = results.stream().sorted(Comparator.comparing(StrategyControlHistVO::getOptTime).reversed()).collect(Collectors.toList());
return JsonViewObject.newInstance().success(sorted);
} }
private void setCrossOptHist(List<StrategyControlHistVO> results, LocalDateTime midnight) { private void setCrossOptHist(List<StrategyControlHistVO> results, LocalDateTime midnight) {
...@@ -241,12 +248,15 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -241,12 +248,15 @@ public class StrategyControlServiceImpl implements StrategyControlService {
try { try {
List<StrategyControlDataEntity> results = new ArrayList<>(); List<StrategyControlDataEntity> results = new ArrayList<>();
List<StrategyControlDataEntity> entities = getCurrentStrateInfoList(type); List<StrategyControlDataEntity> entities = getCurrentStrateInfoList(type);
Map<String, StrategyControlDataEntity> map = entities.stream().collect(Collectors.toMap(StrategyControlDataEntity::getBizId, entity -> entity)); List<StrategyControlDataEntity> runList = entities.stream().filter(entity -> Objects.equals(1, entity.getStatus())).collect(Collectors.toList());
Map<String, StrategyControlDataEntity> map = runList.stream().collect(Collectors.toMap(StrategyControlDataEntity::getBizId, entity -> entity));
// 路口 // 路口
if (Objects.equals(0, type)) { if (Objects.equals(0, type)) {
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll(); LambdaQueryWrapper<TBaseCrossInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TBaseCrossInfo::getIsSignal, 1);
List<TBaseCrossInfo> baseCrossInfoPOS = baseCrossInfoMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) { if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) {
for (BaseCrossInfoPO baseCrossInfoPO : baseCrossInfoPOS) { for (TBaseCrossInfo baseCrossInfoPO : baseCrossInfoPOS) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity(); StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
String crossId = baseCrossInfoPO.getId(); String crossId = baseCrossInfoPO.getId();
strategyControlDataEntity.setBizType(0); strategyControlDataEntity.setBizType(0);
...@@ -254,13 +264,13 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -254,13 +264,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyControlDataEntity.setStrategy(null); strategyControlDataEntity.setStrategy(null);
strategyControlDataEntity.setTime(null); strategyControlDataEntity.setTime(null);
strategyControlDataEntity.setStatus(0); strategyControlDataEntity.setStatus(0);
if (map.containsKey(crossId)) {
strategyControlDataEntity = map.get(crossId);
}
strategyControlDataEntity.setCrossName(baseCrossInfoPO.getName()); strategyControlDataEntity.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation(); String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", ""); location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
strategyControlDataEntity.setWkt(location); strategyControlDataEntity.setWkt(location);
if (map.containsKey(crossId)) {
strategyControlDataEntity = map.get(crossId);
}
results.add(strategyControlDataEntity); results.add(strategyControlDataEntity);
} }
} }
...@@ -270,17 +280,17 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -270,17 +280,17 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if (!CollectionUtils.isEmpty(greenwaveInfoPOS)) { if (!CollectionUtils.isEmpty(greenwaveInfoPOS)) {
for (GreenwaveInfoPO greenwaveInfoPO : greenwaveInfoPOS) { for (GreenwaveInfoPO greenwaveInfoPO : greenwaveInfoPOS) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity(); StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
Integer greenId = greenwaveInfoPO.getId(); String greenId = String.valueOf(greenwaveInfoPO.getId());
strategyControlDataEntity.setBizType(1); strategyControlDataEntity.setBizType(1);
strategyControlDataEntity.setBizId(String.valueOf(greenId)); strategyControlDataEntity.setBizId(String.valueOf(greenId));
strategyControlDataEntity.setStrategy(null); strategyControlDataEntity.setStrategy(null);
strategyControlDataEntity.setTime(null); strategyControlDataEntity.setTime(null);
strategyControlDataEntity.setStatus(0); strategyControlDataEntity.setStatus(0);
strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName());
strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt());
if (map.containsKey(greenId)) { if (map.containsKey(greenId)) {
strategyControlDataEntity = map.get(greenId); strategyControlDataEntity = map.get(greenId);
} }
strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName());
strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt());
results.add(strategyControlDataEntity); results.add(strategyControlDataEntity);
} }
} }
...@@ -292,15 +302,50 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -292,15 +302,50 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
@Override
public JsonViewObject strategyOptTimes() throws Exception {
LocalDate currentDate = LocalDate.now();
LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime);
LambdaQueryWrapper<StrategyGreenOptHistEntity> greenQuery = new LambdaQueryWrapper<>();
greenQuery.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
List<StrategyGreenOptHistEntity> greenOptList = strategyGreenOptHistMapper.selectList(greenQuery);
int totalTime = 0;
int totalCount = 0;
if (!CollectionUtils.isEmpty(greenOptList)) {
for (StrategyGreenOptHistEntity entity : greenOptList) {
Integer controlDuration = entity.getControlDuration();
totalTime += controlDuration;
totalCount += 1;
}
}
LambdaQueryWrapper<StrategyCrossResultEntity> crossQuery = new LambdaQueryWrapper<>();
crossQuery.ge(StrategyCrossResultEntity::getIssueTime, startOfDay);
List<StrategyCrossResultEntity> crossList = strategyCrossResultMapper.selectList(crossQuery);
if (!CollectionUtils.isEmpty(crossList)) {
for (StrategyCrossResultEntity entity : crossList) {
Integer countDown = entity.getCountDown();
if (Math.abs(countDown) > 1) {
totalTime += countDown;
totalCount += 1;
}
}
}
StrategyOptTimesVO strategyOptTimesVO = new StrategyOptTimesVO();
strategyOptTimesVO.setCount(totalCount);
strategyOptTimesVO.setTimes(totalTime / 3600);
return JsonViewObject.newInstance().success(strategyOptTimesVO);
}
private List<StrategyControlDataEntity> getCurrentStrateInfoList(Integer type) throws Exception { private List<StrategyControlDataEntity> getCurrentStrateInfoList(Integer type) throws Exception {
ObjectMapper instance = JacksonUtils.getInstance(); ObjectMapper instance = JacksonUtils.getInstance();
LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
Date current = new Date();
queryWrapper.eq(StrategyControlDataEntity::getBizType, type); queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
queryWrapper.ge(StrategyControlDataEntity::getScheduleStart, new Date()); queryWrapper.le(StrategyControlDataEntity::getScheduleStart, current);
queryWrapper.le(StrategyControlDataEntity::getScheduleEnd, new Date()); queryWrapper.ge(StrategyControlDataEntity::getScheduleEnd, current);
List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper); List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
List<StrategyControlDataEntity> results = new ArrayList<>(entities.size()); List<StrategyControlDataEntity> results = new ArrayList<>(entities.size());
Date current = new Date();
for (StrategyControlDataEntity entity : entities) { for (StrategyControlDataEntity entity : entities) {
StrategyControlDataEntity result = new StrategyControlDataEntity(); StrategyControlDataEntity result = new StrategyControlDataEntity();
BeanUtils.copyProperties(entity, result); BeanUtils.copyProperties(entity, result);
...@@ -313,7 +358,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -313,7 +358,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() { List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() {
}); });
for (StrategyControlDataVO.TimeTable timeTable : timeTables) { for (StrategyControlDataVO.TimeTable timeTable : timeTables) {
int currentWeek = DateUtil.thisDayOfWeek(); int currentWeek = DateUtil.thisDayOfWeek() - 1;
if (currentWeek != timeTable.getWeek()) { if (currentWeek != timeTable.getWeek()) {
result.setTime(""); result.setTime("");
} else { } else {
...@@ -324,14 +369,17 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -324,14 +369,17 @@ public class StrategyControlServiceImpl implements StrategyControlService {
String[] currentHour = hour.split("-"); String[] currentHour = hour.split("-");
String startHour = currentHour[0]; String startHour = currentHour[0];
String entHour = currentHour[1]; String entHour = currentHour[1];
if (StringUtils.equals("24:00", entHour)) {
entHour = "23:59";
}
String format = DateUtil.format(current, "HH:mm"); String format = DateUtil.format(current, "HH:mm");
DateTime currentTime = DateUtil.parse(format, "HH:mm"); DateTime currentTime = DateUtil.parse(format, "HH:mm");
DateTime startHourDate = DateUtil.parse(startHour, "HH:mm"); DateTime startHourDate = DateUtil.parse(startHour, "HH:mm");
DateTime endHourDate = DateUtil.parse(entHour, "HH:mm"); DateTime endHourDate = DateUtil.parse(entHour, "HH:mm");
if (currentTime.before(startHourDate) || currentTime.after(endHourDate)) { if (currentTime.after(startHourDate) && currentTime.before(endHourDate)) {
result.setTime(hour); result.setTime(hour);
result.setStatus(1); result.setStatus(1);
} } else {
// 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置 // 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置
result.setStatus(0); result.setStatus(0);
} }
...@@ -339,6 +387,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -339,6 +387,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
} }
}
if (type == 0) { if (type == 0) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId()); BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
result.setCrossName(baseCrossInfoPO.getName()); result.setCrossName(baseCrossInfoPO.getName());
......
package net.wanji.opt.synthesis.service.impl; package net.wanji.opt.synthesis.service.impl;
import com.alibaba.excel.util.DateUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveRealtimeMapper;
import net.wanji.opt.common.enums.GreenBeltDirEnum;
import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper; import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.synthesis.pojo.vo.GreenBeltAreaIndexVO;
import net.wanji.opt.synthesis.service.StrategyGreenBeltService; import net.wanji.opt.synthesis.service.StrategyGreenBeltService;
import net.wanji.opt.vo.GreenBeltChartVO; import net.wanji.opt.vo.GreenBeltChartVO;
import net.wanji.opt.vo.GreenBeltInfoVO; import net.wanji.opt.vo.GreenBeltInfoVO;
import net.wanji.opt.vo.GreenBeltStopTimesQueueLengthVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -28,6 +37,63 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -28,6 +37,63 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
@Resource @Resource
StrategyGreenOptHistMapper strategyGreenOptHistMapper; StrategyGreenOptHistMapper strategyGreenOptHistMapper;
@Resource
GreenwaveHistMapper greenwaveHistMapper;
@Resource
GreenwaveRealtimeMapper greenwaveRealtimeMapper;
@Override
public GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId) {
LambdaQueryWrapper<GreenwaveRealtimePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GreenwaveRealtimePO::getGreenId, greenId);
List<GreenwaveRealtimePO> realtimePOS = greenwaveRealtimeMapper.selectList(queryWrapper);
GreenBeltAreaIndexVO greenBeltAreaIndexVO = new GreenBeltAreaIndexVO();
Integer status = 1;
if (!CollectionUtils.isEmpty(realtimePOS)) {
List<GreenBeltAreaIndexVO.DirDetail> dirDetails = new ArrayList<>();
for (GreenwaveRealtimePO realtimePO : realtimePOS) {
GreenBeltAreaIndexVO.DirDetail dirDetail = new GreenBeltAreaIndexVO.DirDetail();
String roadDirection = realtimePO.getRoadDirection();
dirDetail.setDirName(GreenBeltDirEnum.getDesc(roadDirection));
dirDetail.setTravelTime(realtimePO.getTrvalTime());
dirDetail.setStopTimes(realtimePO.getStopTimes());
status = status >= realtimePO.getStatus() ? status : realtimePO.getStatus();
dirDetails.add(dirDetail);
}
greenBeltAreaIndexVO.setDirDetail(dirDetails);
greenBeltAreaIndexVO.setStatus(status);
greenBeltAreaIndexVO.setStrategyName("绿波带");
}
return greenBeltAreaIndexVO;
}
@Override
public List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId) {
long currentTimeMillis = System.currentTimeMillis();
LambdaQueryWrapper<GreenwaveHistPO> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(GreenwaveHistPO::getGreenId, greenId);
// 查询两个小时之前的
Integer startTime = (int) (currentTimeMillis / 1000) - 3600 * 2;
queryWrapper.ge(GreenwaveHistPO::getStartTime, new Date(startTime * 1000L));
List<GreenwaveHistPO> greenwaveHistPOS = greenwaveHistMapper.selectList(queryWrapper);
List<GreenBeltStopTimesQueueLengthVO> results = new ArrayList<>();
if (!CollectionUtils.isEmpty(greenwaveHistPOS)) {
for (GreenwaveHistPO greenwaveHistPO : greenwaveHistPOS) {
GreenBeltStopTimesQueueLengthVO vo = new GreenBeltStopTimesQueueLengthVO();
vo.setGreenId(greenwaveHistPO.getGreenId());
vo.setTimeStamp(greenwaveHistPO.getStartTime());
vo.setHourMinute(DateUtils.format(greenwaveHistPO.getStartTime(), "HH:mm"));
vo.setStopTimes(greenwaveHistPO.getStopTimes());
vo.setCordQueueRatio(greenwaveHistPO.getCordQueueRatio() * 100);
vo.setTravelTime(greenwaveHistPO.getTrvalTime());
results.add(vo);
}
}
List<GreenBeltStopTimesQueueLengthVO> distincts = results.stream().distinct().collect(Collectors.toList());
return distincts;
}
@Override @Override
public GreenBeltChartVO selectChart(Integer greenId, Date queryDate) { public GreenBeltChartVO selectChart(Integer greenId, Date queryDate) {
...@@ -98,6 +164,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -98,6 +164,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
Map<String, Double> backDistanceMap = new TreeMap<>(); Map<String, Double> backDistanceMap = new TreeMap<>();
String decideSpeed = ""; String decideSpeed = "";
String backDecideSpeed = ""; String backDecideSpeed = "";
String travelTime = "";
String backtravelTime = "";
// 处理绿波时序图数据 // 处理绿波时序图数据
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = greenBeltInfoVO.getDirGreenDetails(); List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = greenBeltInfoVO.getDirGreenDetails();
Double greenWidthTime = 0.0; Double greenWidthTime = 0.0;
...@@ -111,6 +179,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -111,6 +179,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
List<GreenBeltInfoVO.CrossGreenDetail> list = dirGreenDetail.getCrossGreenDetailList(); List<GreenBeltInfoVO.CrossGreenDetail> list = dirGreenDetail.getCrossGreenDetailList();
getaDouble(crossRedTimesMap, crossGreenStartMap, distanceMap, cycle, list); getaDouble(crossRedTimesMap, crossGreenStartMap, distanceMap, cycle, list);
decideSpeed = String.join("~", String.valueOf(dirGreenDetail.getMinSpeed()), String.valueOf(dirGreenDetail.getMaxSpeed())); decideSpeed = String.join("~", String.valueOf(dirGreenDetail.getMinSpeed()), String.valueOf(dirGreenDetail.getMaxSpeed()));
List<Double> travelTimeList = list.stream().map(GreenBeltInfoVO.CrossGreenDetail::getTravelTime).collect(Collectors.toList());
travelTime = mapper.writeValueAsString(travelTimeList);
} }
if (dirType == 0) { if (dirType == 0) {
backDecideSpeed = String.join("~", String.valueOf(dirGreenDetail.getMinSpeed()), String.valueOf(dirGreenDetail.getMaxSpeed())); backDecideSpeed = String.join("~", String.valueOf(dirGreenDetail.getMinSpeed()), String.valueOf(dirGreenDetail.getMaxSpeed()));
...@@ -118,7 +188,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -118,7 +188,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
List<GreenBeltInfoVO.CrossGreenDetail> list = dirGreenDetail.getCrossGreenDetailList(); List<GreenBeltInfoVO.CrossGreenDetail> list = dirGreenDetail.getCrossGreenDetailList();
Collections.reverse(list); Collections.reverse(list);
getaDouble(backCrossRedTimesMap, backCrossGreenStartMap, backDistanceMap, cycle, list); getaDouble(backCrossRedTimesMap, backCrossGreenStartMap, backDistanceMap, cycle, list);
List<Double> travelTimeList = list.stream().map(GreenBeltInfoVO.CrossGreenDetail::getTravelTime).collect(Collectors.toList());
backtravelTime = mapper.writeValueAsString(travelTimeList);
} }
} }
} }
...@@ -132,6 +203,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -132,6 +203,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
greenBeltChartVO.setDistanceMap(mapper.writeValueAsString(distanceMap)); greenBeltChartVO.setDistanceMap(mapper.writeValueAsString(distanceMap));
greenBeltChartVO.setDecideSpeed(decideSpeed.concat("km/h")); greenBeltChartVO.setDecideSpeed(decideSpeed.concat("km/h"));
greenBeltChartVO.setBackDecideSpeed(backDecideSpeed.concat("km/h")); greenBeltChartVO.setBackDecideSpeed(backDecideSpeed.concat("km/h"));
greenBeltChartVO.setTravelTime(travelTime);
greenBeltChartVO.setBackTravelTime(backtravelTime);
return greenBeltChartVO; return greenBeltChartVO;
} }
......
...@@ -3,10 +3,16 @@ package net.wanji.opt.task; ...@@ -3,10 +3,16 @@ package net.wanji.opt.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import freemarker.template.TemplateException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.Constants;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.GreenwaveCrossPO;
import net.wanji.databus.dao.entity.GreenwaveCrossPOExt; import net.wanji.databus.dao.entity.GreenwaveCrossPOExt;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper; import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.GreenwaveCrossMapper; import net.wanji.databus.dao.mapper.GreenwaveCrossMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
...@@ -16,11 +22,12 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper; ...@@ -16,11 +22,12 @@ import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper;
import net.wanji.opt.dto.induce.MessageParam; import net.wanji.opt.dto.induce.MessageParam;
import net.wanji.opt.entity.GreenwaveInduces; import net.wanji.opt.entity.GreenwaveInduces;
import net.wanji.opt.entity.GreenwaveInducesHist; import net.wanji.opt.entity.GreenwaveInducesHist;
import net.wanji.opt.entity.InduceTemplate;
import net.wanji.opt.po.StrategyGreenOptHistEntity; import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.opt.service.induce.GreenwaveInducesHistService; import net.wanji.opt.service.induce.GreenwaveInducesHistService;
import net.wanji.opt.service.induce.GreenwaveInducesService; import net.wanji.opt.service.induce.GreenwaveInducesService;
import net.wanji.opt.service.induce.InduceSendService; import net.wanji.opt.service.induce.InduceSendService;
import net.wanji.opt.service.induce.InduceTemplateService;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity; import net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity;
import net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity; import net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity;
...@@ -30,6 +37,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -30,6 +37,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -38,6 +46,7 @@ import java.util.List; ...@@ -38,6 +46,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -77,23 +86,28 @@ public class InducesMonitorTask { ...@@ -77,23 +86,28 @@ public class InducesMonitorTask {
@Autowired @Autowired
private InduceSendService induceSendService; private InduceSendService induceSendService;
@Autowired
private InduceTemplateService induceTemplateService;
/** /**
* #绿波调度计划扫描周期 * #绿波调度计划扫描周期
* 5 分钟 300000 * 5 分钟 300000
*/ */
//@Scheduled(fixedRate = 300000) @Scheduled(fixedRate = 300000)
public void refresh() throws Exception { public void refresh() throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
AtomicLong synCount = new AtomicLong(); AtomicLong synCount = new AtomicLong();
try { try {
log.info("每5分钟刷新绿波优化下发数据..................."); log.info("每5分钟刷新绿波优化下发数据...................");
// List<GreenwaveInfoPO> greenwaveInfoPOList=greenwaveInfoMapper.selectAll(); List<GreenwaveInfoPO> greenwaveInfoPOList=greenwaveInfoMapper.selectAll();
// for(GreenwaveInfoPO greenwaveInfoPO :greenwaveInfoPOList) { for(GreenwaveInfoPO greenwaveInfoPO :greenwaveInfoPOList) {
AtomicBoolean flag = new AtomicBoolean(false);//是否已发布优化
AtomicReference<Integer> strategyId=new AtomicReference<Integer>(0);
//1、查询所有绿波带路口信息,获取路口下的绿波策略计划 //1、查询所有绿波带路口信息,获取路口下的绿波策略计划
List<GreenwaveCrossPOExt> greenwaveCrossList = greenwaveCrossMapper.selectAllGreeenCross(); List<GreenwaveCrossPO> greenwaveCrossList = greenwaveCrossMapper.selectByGreenwaveId(greenwaveInfoPO.getId());
greenwaveCrossList.stream().forEach(o -> { greenwaveCrossList.stream().forEach(o -> {
//System.out.println("绿波路口--->"+o.getGreenwaveName()+"=="+o.getCrossId()); //System.out.println("绿波路口--->"+o.getGreenwaveName()+"=="+o.getCrossId());
AtomicBoolean flag = new AtomicBoolean(false);//是否已发布优化
//创建路口策略列表 //创建路口策略列表
List<StrategyPlanInfoEntity> strategyPlanInfoEntityList = strategyPlanInfoMapper.selectByCrossId(o.getCrossId()); List<StrategyPlanInfoEntity> strategyPlanInfoEntityList = strategyPlanInfoMapper.selectByCrossId(o.getCrossId());
//strategyPlanInfoEntityList.stream().filter(x->Objects.nonNull(x.getCrossId()) && x.getCrossId().equals(o.getCrossId()) ).forEach(x-> //strategyPlanInfoEntityList.stream().filter(x->Objects.nonNull(x.getCrossId()) && x.getCrossId().equals(o.getCrossId()) ).forEach(x->
...@@ -138,54 +152,100 @@ public class InducesMonitorTask { ...@@ -138,54 +152,100 @@ public class InducesMonitorTask {
System.out.println("当前时间在范围内: " + LocalTime.now()); System.out.println("当前时间在范围内: " + LocalTime.now());
//3、如果在绿波时段内,未上屏,则获取固定配时绿波信息 //3、如果在绿波时段内,未上屏,则获取固定配时绿波信息
//4、获取优化绿波方案,如果不存在,则执行固定绿波方案 //4、获取优化绿波方案,如果不存在,则执行固定绿波方案
List<StrategyGreenOptHistEntity> strategyGreenOptHistEntitiesList = strategyGreenOptHistMapper.selectByGreenId(String.valueOf(o.getGreenId())).stream().distinct().collect(Collectors.toList()); flag.set(true);
strategyId.set(p.getDailyPlanId());
}
}
}
});
}
}
}
}
});
//如果在绿波时段内,未上屏,则获取固定配时绿波信息
if (flag.get()) {
List<StrategyGreenOptHistEntity> strategyGreenOptHistEntitiesList = strategyGreenOptHistMapper.selectByGreenId(String.valueOf(greenwaveInfoPO.getId())).stream().distinct().collect(Collectors.toList());
if (Objects.nonNull(strategyGreenOptHistEntitiesList)) { if (Objects.nonNull(strategyGreenOptHistEntitiesList)) {
for (StrategyGreenOptHistEntity greenOptHistEntity : strategyGreenOptHistEntitiesList) { for (StrategyGreenOptHistEntity greenOptHistEntity : strategyGreenOptHistEntitiesList) {
LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, o.getGreenId()); greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, greenwaveInfoPO.getId());
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getDir, getDir(greenOptHistEntity.getDir())); greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getDir, getDir(greenOptHistEntity.getDir()));
GreenwaveInducesHist greenwaveInducesHist = greenwaveInducesHistService.getOne(greenwaveInducesHistQueryWrapper); GreenwaveInducesHist greenwaveInducesHist = greenwaveInducesHistService.getOne(greenwaveInducesHistQueryWrapper);
if (Objects.isNull(greenwaveInducesHist)) { if (Objects.isNull(greenwaveInducesHist)) {
greenwaveInducesHist = new GreenwaveInducesHist(); greenwaveInducesHist = new GreenwaveInducesHist();
greenwaveInducesHist.setCreateTime(new Date()); greenwaveInducesHist.setCreateTime(new Date());
greenwaveInducesHist.setGreenId(o.getGreenId()); greenwaveInducesHist.setGreenId(greenwaveInfoPO.getId());
greenwaveInducesHist.setDir(getDir(greenOptHistEntity.getDir())); greenwaveInducesHist.setDir(getDir(greenOptHistEntity.getDir()));
} }
greenwaveInducesHist.setStrategyId(strategyPlanInfoEntity.getPlanId()); greenwaveInducesHist.setStrategyId(strategyId.get());
greenwaveInducesHist.setStrategyName(o.getGreenwaveName());//当前策略名称 greenwaveInducesHist.setStrategyName(greenwaveInfoPO.getName());//当前策略名称
greenwaveInducesHist.setControlOptTimes(greenOptHistEntity.getControlTime());//执行时段 if (StringUtils.isNotBlank(greenOptHistEntity.getControlTime()) && greenOptHistEntity.getControlDuration() > 0) {
greenwaveInducesHist.setType(strategyPlanInfoEntity.getType());// 执行策略 greenwaveInducesHist.setControlOptTimes(greenOptHistEntity.getControlTime() + "|" + DateUtil.format(DateUtil.addSecond(greenOptHistEntity.getControlTime(), greenOptHistEntity.getControlDuration()), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));//执行时段
}
greenwaveInducesHist.setType(greenOptHistEntity.getType());// 执行策略
greenwaveInducesHist.setMinSpeed(greenOptHistEntity.getMinSpeed()); greenwaveInducesHist.setMinSpeed(greenOptHistEntity.getMinSpeed());
greenwaveInducesHist.setMaxSpeed(greenOptHistEntity.getMaxSpeed()); greenwaveInducesHist.setMaxSpeed(greenOptHistEntity.getMaxSpeed());
greenwaveInducesHist.setDir(greenOptHistEntity.getDirType()); greenwaveInducesHist.setDir(greenOptHistEntity.getDirType());
//5、获取绿波信息,调用上屏服务;发布互联网诱导方案 //5、获取绿波信息,调用上屏服务;发布互联网诱导方案
flag.set(true);
//[{"crossId":"13MOD0B5SI0","phaseStartTime":32.0,"phaseEndTime":122.0,"greenStartTime":35.0,"speed":"39.71","offset":208.0,"travelTime":57.0,"distance":"628.81"},{"crossId":"13MQJ0B5SI0","phaseStartTime":43.0,"phaseEndTime":158.0,"greenStartTime":0.0,"speed":"35.54","offset":69.0,"travelTime":42.0,"distance":"414.62"},{"crossId":"13MS20B5SI0","phaseStartTime":32.0,"phaseEndTime":142.0,"greenStartTime":8.0,"speed":"22.72","offset":114.0,"travelTime":116.0,"distance":"732.00"},{"crossId":"13MUK0B5SH0","phaseStartTime":0.0,"phaseEndTime":135.0,"greenStartTime":0.0,"speed":"42.33","offset":50.0,"travelTime":45.0,"distance":"529.16"},{"crossId":"13N0F0B5SH0","phaseStartTime":25.0,"phaseEndTime":156.0,"greenStartTime":70.0,"speed":"40.67","offset":0.0,"travelTime":40.0,"distance":"451.89"},{"crossId":"13N200B5SH0","phaseStartTime":23.0,"phaseEndTime":150.0,"greenStartTime":0.0,"speed":"-1.00","offset":112.0,"travelTime":-1.0,"distance":"-1.00"}] //[{"crossId":"13MOD0B5SI0","phaseStartTime":32.0,"phaseEndTime":122.0,"greenStartTime":35.0,"speed":"39.71","offset":208.0,"travelTime":57.0,"distance":"628.81"},{"crossId":"13MQJ0B5SI0","phaseStartTime":43.0,"phaseEndTime":158.0,"greenStartTime":0.0,"speed":"35.54","offset":69.0,"travelTime":42.0,"distance":"414.62"},{"crossId":"13MS20B5SI0","phaseStartTime":32.0,"phaseEndTime":142.0,"greenStartTime":8.0,"speed":"22.72","offset":114.0,"travelTime":116.0,"distance":"732.00"},{"crossId":"13MUK0B5SH0","phaseStartTime":0.0,"phaseEndTime":135.0,"greenStartTime":0.0,"speed":"42.33","offset":50.0,"travelTime":45.0,"distance":"529.16"},{"crossId":"13N0F0B5SH0","phaseStartTime":25.0,"phaseEndTime":156.0,"greenStartTime":70.0,"speed":"40.67","offset":0.0,"travelTime":40.0,"distance":"451.89"},{"crossId":"13N200B5SH0","phaseStartTime":23.0,"phaseEndTime":150.0,"greenStartTime":0.0,"speed":"-1.00","offset":112.0,"travelTime":-1.0,"distance":"-1.00"}]
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetailList = new ArrayList<>(); // List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetailList = new ArrayList<>();
try { // try {
crossGreenDetailList = JacksonUtils.getInstance().readValue(greenOptHistEntity.getCrossGreenDetail(), new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() { // crossGreenDetailList = JacksonUtils.getInstance().readValue(greenOptHistEntity.getCrossGreenDetail(), new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {});
}); // } catch (JsonProcessingException e) {
} catch (JsonProcessingException e) { // log.error("绿波详情转换失败:" + greenOptHistEntity.getGreenId() + "---" + e.getMessage());
log.error("绿波详情转换失败:" + greenOptHistEntity.getGreenId() + "---" + e.getMessage()); // }
}
greenwaveInducesHist.setStatus(1);
greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist); greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist);
synCount.getAndIncrement(); ////自动发送诱导消息
log.info("同步绿波状态信息成功->" + o.getPlanName()); MessageParam messageParam = new MessageParam();
} messageParam.setFlg(1);
messageParam.setGreenId(greenwaveInfoPO.getId());
messageParam.setContents(new String[]{greenOptHistEntity.getMaxSpeed()+"-"+greenOptHistEntity.getMaxSpeed()+"km/h"});
messageParam.setType("TFMH");
try {
if(greenwaveInducesHist.getStatus()==0||greenwaveInducesHist.getModifyTime()!=greenOptHistEntity.getCreateTime()) {
LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, greenwaveInfoPO.getId());
List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(greenwaveInducesQueryWrapper);
for(GreenwaveInduces greenwaveCross :greenwaveInducesList){
LambdaQueryWrapper<InduceTemplate> induceTemplateQueryWrapper = new LambdaQueryWrapper<>();
induceTemplateQueryWrapper.eq(InduceTemplate::getEquipCode, greenwaveCross.getEquipCode());
List<InduceTemplate> induceTemplateList=induceTemplateService.list(induceTemplateQueryWrapper);
for(InduceTemplate induceTemplate:induceTemplateList) {
messageParam.setTemplateId(induceTemplate.getId());
messageParam.setInduceId(greenwaveCross.getId());
messageParam.setEquipCode(greenwaveCross.getEquipCode());
messageParam.setPlayorder(induceTemplateList.size());
messageParam.setDuration(greenwaveCross.getDuration());
if ( greenwaveInducesHist.getControlOptTimes().split("\\|").length > 0 && DateUtil.isBetween(new Date(), DateUtil.parse(greenwaveInducesHist.getControlOptTimes().split("\\|")[0], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND), DateUtil.parse(greenwaveInducesHist.getControlOptTimes().split("\\|")[1], Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND))) {
messageParam.setStartTime(greenwaveInducesHist.getControlOptTimes().split("\\|")[0]);
messageParam.setEndTime(greenwaveInducesHist.getControlOptTimes().split("\\|")[1]);
} else {
messageParam.setStartTime(DateUtil.format(new Date(), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
messageParam.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
} }
induceSendService.send(messageParam);
} }
} }
greenwaveInducesHist.setStatus(1);
greenwaveInducesHist.setModifyTime(greenOptHistEntity.getCreateTime());
greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist);
} }
}); } catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
log.info("发送上屏信息异常" + e.getMessage());
} }
synCount.getAndIncrement();
log.info("同步绿波状态信息成功->" + greenwaveInfoPO.getName());
} }
} }
} }
//如果没有绿波方案则调用下屏服务 //如果没有绿波方案则调用下屏服务
if (!flag.get()) { if (!flag.get()) {
LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GreenwaveInducesHist> greenwaveInducesHistQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, o.getGreenId()); greenwaveInducesHistQueryWrapper.eq(GreenwaveInducesHist::getGreenId, greenwaveInfoPO.getId());
List<GreenwaveInducesHist> greenwaveInducesHistList = greenwaveInducesHistService.list(greenwaveInducesHistQueryWrapper); List<GreenwaveInducesHist> greenwaveInducesHistList = greenwaveInducesHistService.list(greenwaveInducesHistQueryWrapper);
greenwaveInducesHistList.stream().forEach(n -> { greenwaveInducesHistList.stream().forEach(n -> {
//调用下屏 //调用下屏
...@@ -194,14 +254,20 @@ public class InducesMonitorTask { ...@@ -194,14 +254,20 @@ public class InducesMonitorTask {
MessageParam messageParam = new MessageParam(); MessageParam messageParam = new MessageParam();
messageParam.setFlg(2); messageParam.setFlg(2);
LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, o.getGreenId()); greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, greenwaveInfoPO.getId());
List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(greenwaveInducesQueryWrapper); List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(greenwaveInducesQueryWrapper);
greenwaveInducesList.stream().forEach(v -> { greenwaveInducesList.stream().forEach(v -> {
messageParam.setEquipCode(v.getEquipCode()); messageParam.setEquipCode(v.getEquipCode());
messageParam.setSourceId(v.getSourceId()); messageParam.setSourceId(v.getSourceId());
messageParam.setType("TFMH"); messageParam.setType("TFMH");
//屏蔽此处功能,因为上屏的时候可以设置生效时间 //屏蔽此处功能,因为上屏的时候可以设置生效时间
//induceSendService.send(messageParam); try {
induceSendService.send(messageParam);
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
log.info("发送下屏信息异常"+e.getMessage());
}
log.info("发送下屏信息成功."); log.info("发送下屏信息成功.");
}); });
} }
...@@ -209,14 +275,14 @@ public class InducesMonitorTask { ...@@ -209,14 +275,14 @@ public class InducesMonitorTask {
log.error("发送下屏信息失败"); log.error("发送下屏信息失败");
} }
//保存绿波状态 //保存绿波状态
//n.setStatus(0); n.setStatus(0);
//greenwaveInducesHistService.saveOrUpdate(n); n.setModifyTime(new Date());
log.info("同步绿波状态信息(下屏)->" + o.getPlanName()); greenwaveInducesHistService.saveOrUpdate(n);
log.info("同步绿波状态信息(下屏)->" + greenwaveInfoPO.getName());
synCount.getAndIncrement(); synCount.getAndIncrement();
}); });
} }
}); }
//}
} catch (Exception e) { } catch (Exception e) {
throw new Exception("每5分钟刷新绿波下发状态失败", e); throw new Exception("每5分钟刷新绿波下发状态失败", e);
} finally { } finally {
......
...@@ -43,6 +43,8 @@ public class GreenBeltChartVO { ...@@ -43,6 +43,8 @@ public class GreenBeltChartVO {
private Double BackGreenWidthTime; private Double BackGreenWidthTime;
private String decideSpeed; private String decideSpeed;
private String backDecideSpeed; private String backDecideSpeed;
private String travelTime;
private String backTravelTime;
@JsonCreator @JsonCreator
public GreenBeltChartVO(){ public GreenBeltChartVO(){
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
* @date 2024/12/02 13:47
*/
@Data
@ApiModel(value = "绿波带历史流量停车次数")
public class GreenBeltFlowStopTimeVO {
@ApiModelProperty("时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty("流量停车次数列表")
private List<FlowStopTimeDetail> detailList;
@Data
public static class FlowStopTimeDetail {
@ApiModelProperty("路口编号")
private String crossId;
@ApiModelProperty("流量")
private Integer flow;
@ApiModelProperty("停车次数")
private Double stopTimes;
@ApiModelProperty("行程时间")
private Double travelTime;
}
}
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author duanruiming
* @date 2024/12/03 13:58
*/
@Data
@ApiModel(value = "重点路口监测实体", description = "重点路口监测实体")
public class GreenBeltStopTimesQueueLengthVO {
@ApiModelProperty("绿波编号")
private Integer greenId;
@ApiModelProperty("时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date timeStamp;
@ApiModelProperty("时间分钟")
private String hourMinute;
@ApiModelProperty("绿波方向")
private String roadDirection;
@ApiModelProperty("停车次数")
private Double stopTimes;
@ApiModelProperty("空间占比")
private Double cordQueueRatio;
@ApiModelProperty("行程时间")
private Integer travelTime;
}
spring: spring:
application:
# dubbo启动需要程序名称
name: signal-optimize-service
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 37.12.182.29:8848 server-addr: 173.17.0.1:8848
file-extension: yaml file-extension: yaml
group: signal group: signal
namespace: signal namespace: signal
username: nacos username: nacos
password: nacos password: nacos
application:
# dubbo启动需要程序名称
name: signal-optimize-service
main: main:
allow-circular-references: true allow-circular-references: true
...@@ -4,4 +4,8 @@ ...@@ -4,4 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper"> <mapper namespace="net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper">
<select id="selectByGreenId" resultType="net.wanji.opt.po.StrategyGreenOptHistEntity" parameterType="String" >
select * from t_strategy_green_opt_hist where `green_id` = #{greenId} and TIMESTAMPDIFF(SECOND,`control_time`, now()) &lt; `control_duration` order by create_time desc limit 2;
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -21,7 +21,7 @@ public class VNtcipTimeBaseScheduleView { ...@@ -21,7 +21,7 @@ public class VNtcipTimeBaseScheduleView {
@TableField("NTIMEBASESCHEDULEDAY") @TableField("NTIMEBASESCHEDULEDAY")
private Integer nTimeBaseScheduleDay; private Integer nTimeBaseScheduleDay;
@TableField("NTIMEBASESCHEDULEDATE") @TableField("NTIMEBASESCHEDULEDATE")
private Integer nTimeBaseScheduleDate; private Long nTimeBaseScheduleDate;
@TableField("NTIMEBASESCHEDULEDAYPLAN") @TableField("NTIMEBASESCHEDULEDAYPLAN")
private Integer nTimeBaseScheduleDayPlan; private Integer nTimeBaseScheduleDayPlan;
} }
...@@ -369,7 +369,7 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -369,7 +369,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
optResult = 2; optResult = 2;
} }
//方案优化记录 //方案优化记录
crossSchemeOptLog(tempSchemeSendVO, tempSchemeSendVO.getSplit(), optResult); crossSchemeOptLogBak(tempSchemeSendVO, tempSchemeSendVO.getSplit(), optResult);
return jsonViewObject; return jsonViewObject;
} }
......
...@@ -639,11 +639,11 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -639,11 +639,11 @@ public class StaticInfoServiceImpl implements StaticInfoService {
// 星期 // 星期
Integer hisenseWeek = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDay(); Integer hisenseWeek = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDay();
// 日期 2147483647 // 日期 2147483647
Integer hisenseDays = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDate(); Long hisenseDays = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDate();
// 时段表号 // 时段表号
Integer hisensePlanId = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDayPlan(); Integer hisensePlanId = vNtcipTimeBaseScheduleView.getNTimeBaseScheduleDayPlan();
String monthsStr = ScheduleUtil.getSchedule(hisenseMonth.longValue(), 1); String monthsStr = ScheduleUtil.getSchedule(hisenseMonth.longValue(), 1);
String daysStr = ScheduleUtil.getSchedule(hisenseDays.longValue(), 2); String daysStr = ScheduleUtil.getSchedule(hisenseDays, 2);
String weekStr = ScheduleUtil.getSchedule(hisenseWeek.longValue(), 3); String weekStr = ScheduleUtil.getSchedule(hisenseWeek.longValue(), 3);
if (StringUtils.isNotBlank(weekStr)) { if (StringUtils.isNotBlank(weekStr)) {
String[] weekSplit = weekStr.split(","); String[] weekSplit = weekStr.split(",");
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<dependency> <dependency>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -278,6 +278,157 @@ ...@@ -278,6 +278,157 @@
</executions> </executions>
</plugin> </plugin>
<!-- mvn clean package -Dmaven.test.skip=true jib:build -DsendCredentialsOverHttp=true -->
<!-- 使用jib 无需深入学习docker, 无需编写Dockerfile -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.5.2</version>
<!-- 将jib与mvn构建的生命周期绑定 -->
<executions>
<execution>
<id>build-image</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<!--from节点用来设置镜像的基础镜像,相当于Docerkfile中的FROM关键字-->
<from>
<!--使用harbor上的openjdk镜像-->
<image>${harbor.ip.port}/xinkong/openjdk:8-alpine3.9</image>
<!--harbor服务器的登录信息-->
<auth>
<username>admin</username>
<password>Wanji300552</password>
</auth>
</from>
<to>
<image>${harbor.ip.port}/xinkong/${artifactId}:${version}</image>
<auth>
<username>admin</username>
<password>Wanji300552</password>
</auth>
</to>
<container>
<!--配置jvm虚拟机参数-->
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15119</jvmFlag>
</jvmFlags>
<!--配置使用的时区-->
<environment>
<TZ>Asia/Shanghai</TZ>
<spring.profiles.active>dev</spring.profiles.active>
</environment>
<!--要暴露的端口-->
<ports>
<port>39003</port>
<port>15119</port>
<port>5050</port>
</ports>
<!-- <creationTime>2022-10-14T10:08:59.304+08:00</creationTime>-->
<creationTime>${maven.build.timestamp}</creationTime>
<mainClass>net.wanji.utc.hisense.HisenseApplication</mainClass>
</container>
<!--可以进行HTTP-->
<allowInsecureRegistries>true</allowInsecureRegistries>
</configuration>
</plugin>
<!-- maven 打包方式-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<!--<version>2.6</version>-->
<executions>
<!--将启动脚本复制到指定目录-->
<execution>
<id>copy-bin</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.parent.basedir}/assembly/${project.name}/bin</outputDirectory>
<resources>
<resource>
<directory>src/main/bin</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
<!--将配置文件复制到指定目录-->
<execution>
<id>copy-configs</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.parent.basedir}/assembly/${project.name}/resources
</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/bin/*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<!--将依赖jar包复制到lib目录-->
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.parent.basedir}/assembly/${project.name}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--指定生成jar包目录-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!--<classpathPrefix>lib/</classpathPrefix>-->
<classpathPrefix></classpathPrefix>
<mainClass> net.wanji.utc.UtcApplication</mainClass>
</manifest>
<manifestEntries>
<Class-Path>../resources/</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>*.**</exclude>
<exclude>*/*.xml</exclude>
<!--<exclude>configs/**/**</exclude>-->
</excludes>
<outputDirectory>${project.parent.basedir}/assembly/${project.name}/lib</outputDirectory>
<classesDirectory>
</classesDirectory>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -13,6 +13,7 @@ import net.wanji.databus.po.CrossInfoPO; ...@@ -13,6 +13,7 @@ import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.po.ManufacturerInfoPO; import net.wanji.databus.po.ManufacturerInfoPO;
import net.wanji.databus.vo.LightsStatusVO; import net.wanji.databus.vo.LightsStatusVO;
import net.wanji.databus.vo.LightsStatusVO2; import net.wanji.databus.vo.LightsStatusVO2;
import net.wanji.feign.service.EHualuFeignClients;
import net.wanji.feign.service.UtcDTFeignClients; import net.wanji.feign.service.UtcDTFeignClients;
import net.wanji.feign.service.UtcHisenseFeignClients; import net.wanji.feign.service.UtcHisenseFeignClients;
import net.wanji.utc.common.constant.Constants; import net.wanji.utc.common.constant.Constants;
...@@ -78,6 +79,9 @@ public class SignalStatusTask { ...@@ -78,6 +79,9 @@ public class SignalStatusTask {
@Qualifier("net.wanji.feign.service.UtcHisenseFeignClients") @Qualifier("net.wanji.feign.service.UtcHisenseFeignClients")
@Autowired @Autowired
private UtcHisenseFeignClients utcHisenseFeignClients; private UtcHisenseFeignClients utcHisenseFeignClients;
@Qualifier("net.wanji.feign.service.EHualuFeignClients")
@Autowired
private EHualuFeignClients eHualuFeignClients;
private static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>();
...@@ -174,6 +178,11 @@ public class SignalStatusTask { ...@@ -174,6 +178,11 @@ public class SignalStatusTask {
return mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() { return mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {
}); });
} }
if (StringUtils.endsWithIgnoreCase(BasicEnum.ManufacturerEnum.EHULU.getCode(), manufacturerInfoPO.getCode())) {
JsonViewObject jsonViewObject = eHualuFeignClients.lightStatus(crossId);
return mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {
});
}
if (StringUtils.endsWithIgnoreCase("STATIC", manufacturerInfoPO.getCode())) { if (StringUtils.endsWithIgnoreCase("STATIC", manufacturerInfoPO.getCode())) {
LightsStatusVO lightsStatusVO = SignalStatus4StaticSchemeTask.currentCrossLightStatusCache.get(crossId); LightsStatusVO lightsStatusVO = SignalStatus4StaticSchemeTask.currentCrossLightStatusCache.get(crossId);
List<LightsStatusVO> lightsStatusVOS = new ArrayList<>(); List<LightsStatusVO> lightsStatusVOS = new ArrayList<>();
...@@ -198,6 +207,9 @@ public class SignalStatusTask { ...@@ -198,6 +207,9 @@ public class SignalStatusTask {
Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap(); Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap();
List<LightsStatusVO2.DirInfo> dirList = new ArrayList<>(); List<LightsStatusVO2.DirInfo> dirList = new ArrayList<>();
Map<String, Object> phaseMap = lightsStatusVO.getPhaseMap(); Map<String, Object> phaseMap = lightsStatusVO.getPhaseMap();
if (Objects.isNull(phaseMap) || phaseMap.isEmpty()) {
continue;
}
for (Map.Entry<String, Object> groupEntry : dirLampGroupMap.entrySet()) { for (Map.Entry<String, Object> groupEntry : dirLampGroupMap.entrySet()) {
LightsStatusVO2.DirInfo dirInfo = new LightsStatusVO2.DirInfo(); LightsStatusVO2.DirInfo dirInfo = new LightsStatusVO2.DirInfo();
String dir = groupEntry.getKey(); String dir = groupEntry.getKey();
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.wanji</groupId> <groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId> <artifactId>wj-databus</artifactId>
<version>0.0.1</version> <version>0.0.3</version>
<name>wj-databus</name> <name>wj-databus</name>
<description>wj-databus</description> <description>wj-databus</description>
......
...@@ -35,6 +35,8 @@ public class CrossSchedulesPO { ...@@ -35,6 +35,8 @@ public class CrossSchedulesPO {
/** 星期:1周一;2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期 */ /** 星期:1周一;2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期 */
@ApiModelProperty(value = "星期:1周一",notes = "2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期") @ApiModelProperty(value = "星期:1周一",notes = "2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期")
private Integer week ; private Integer week ;
@ApiModelProperty(value = "", notes = "预留,字符串形式星期")
private String weeks;
/** 特殊日期 */ /** 特殊日期 */
@ApiModelProperty(value = "特殊日期",notes = "") @ApiModelProperty(value = "特殊日期",notes = "")
private Date specialDate ; private Date specialDate ;
......
package net.wanji.databus.dao.entity; package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -9,10 +11,13 @@ import lombok.Data; ...@@ -9,10 +11,13 @@ import lombok.Data;
*/ */
@Data @Data
@TableName("t_greenwave_hist")
public class GreenwaveHistPO extends GreenwaveRealtimePO{ public class GreenwaveHistPO extends GreenwaveRealtimePO{
@ApiModelProperty(value = "绿波名称") @ApiModelProperty(value = "绿波名称")
@TableField(exist = false)
private String greenwaveName; private String greenwaveName;
@ApiModelProperty(value = "协调方向:0正向;1反向;2双向") @ApiModelProperty(value = "协调方向:0正向;1反向;2双向")
@TableField(exist = false)
private Integer dir; private Integer dir;
} }
package net.wanji.databus.dao.entity; package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName("t_greenwave_realtime")
public class GreenwaveRealtimePO { public class GreenwaveRealtimePO {
/** 绿波ID */ /** 绿波ID */
@ApiModelProperty(name = "id",notes = "") @ApiModelProperty(name = "id",notes = "")
...@@ -56,6 +63,7 @@ public class GreenwaveRealtimePO { ...@@ -56,6 +63,7 @@ public class GreenwaveRealtimePO {
private Double uncoordinatePhaseQueue ; private Double uncoordinatePhaseQueue ;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty(name = "数据时间",notes = "") @ApiModelProperty(name = "数据时间",notes = "")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime ; private Date startTime ;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "") @ApiModelProperty(name = "创建时间",notes = "")
...@@ -63,4 +71,30 @@ public class GreenwaveRealtimePO { ...@@ -63,4 +71,30 @@ public class GreenwaveRealtimePO {
/** 修改时间 */ /** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "") @ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ; private Date gmtModified ;
/** add 20241123 适配神思数据 */
@ApiModelProperty(value = "执行策略 失衡 2拥堵 3溢出 4死锁 5 空放", notes = "")
private Integer strategy;
@ApiModelProperty(value = "策略执行持续时间;单位:s", notes = "")
private Integer strategyDuration;
@ApiModelProperty(value = "优化执行次数", notes = "")
private Integer optimizeCount;
@ApiModelProperty(value = "优化时长,单位秒", notes = "")
private Integer optimizeSeconds;
@ApiModelProperty(value = "绿波带宽,单位秒", notes = "")
private Integer greenWaveWidth;
@ApiModelProperty(value = "协调方向 0正向 1反向 2双向", notes = "")
private Integer direction;
@ApiModelProperty(value = "方案周期,单位秒", notes = "")
private Integer planCycle;
@ApiModelProperty(value = "方推荐速度上限 km/h", notes = "")
private Integer speedHigh;
@ApiModelProperty(value = "推荐速度下限 km/h", notes = "")
@JsonProperty("speedLow")
private Integer speedDown;
@ApiModelProperty(value = "推荐速度下限 km/h", notes = "")
private String roadDirection;
@ApiModelProperty(value = "饱和度", notes = "")
private Integer sturation;
@ApiModelProperty(name = "采集时间(10位时间戳)",notes = "")
public Integer batchTime ;
} }
package net.wanji.databus.dao.mapper; package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.GreenwaveHistPO; import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.entity.GreenwaveHistPOExt; import net.wanji.databus.dao.entity.GreenwaveHistPOExt;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -13,7 +14,7 @@ import java.util.List; ...@@ -13,7 +14,7 @@ import java.util.List;
* @date 2022/10/31 11:03 * @date 2022/10/31 11:03
*/ */
@Repository @Repository
public interface GreenwaveHistMapper { public interface GreenwaveHistMapper extends BaseMapper<GreenwaveHistPO> {
List<GreenwaveHistPOExt> selectRunMonitor(Date nowTime); List<GreenwaveHistPOExt> selectRunMonitor(Date nowTime);
List<GreenwaveHistPO> selectByTimeSection(String startTimeStr, String endTimeStr); List<GreenwaveHistPO> selectByTimeSection(String startTimeStr, String endTimeStr);
......
...@@ -5,6 +5,7 @@ import net.wanji.databus.vo.GreenwaveListVO; ...@@ -5,6 +5,7 @@ import net.wanji.databus.vo.GreenwaveListVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 态势监测-绿波基础信息 * 态势监测-绿波基础信息
...@@ -23,4 +24,6 @@ public interface GreenwaveInfoMapper { ...@@ -23,4 +24,6 @@ public interface GreenwaveInfoMapper {
List<GreenwaveInfoPO> selectAll(); List<GreenwaveInfoPO> selectAll();
GreenwaveInfoPO selectByName(String greenwaveName); GreenwaveInfoPO selectByName(String greenwaveName);
List<GreenwaveInfoPO> findByMap(Map params);
} }
package net.wanji.databus.dao.mapper; package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import feign.Param; import feign.Param;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO; import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
...@@ -11,10 +13,12 @@ import java.util.List; ...@@ -11,10 +13,12 @@ import java.util.List;
* @date 2022/10/31 11:03 * @date 2022/10/31 11:03
*/ */
@Repository @Repository
public interface GreenwaveRealtimeMapper { public interface GreenwaveRealtimeMapper extends BaseMapper<GreenwaveRealtimePO> {
GreenwaveRealtimePO selectById(Integer id); GreenwaveRealtimePO selectById(Integer id);
int insertBatch(@Param("list") List<GreenwaveRealtimePO> list); int insertBatch(@Param("list") List<GreenwaveRealtimePO> list);
int deleteOne(@Param("greenId") Integer greenId); int deleteOne(@Param("greenId") Integer greenId);
void deleteBatch(@Param("list") Collection<Integer> greenIds);
} }
...@@ -2,9 +2,11 @@ package net.wanji.databus.po; ...@@ -2,9 +2,11 @@ package net.wanji.databus.po;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.omg.CORBA.UNKNOWN;
import java.util.Date; import java.util.Date;
...@@ -190,4 +192,19 @@ public class CrossDataRealtimePO { ...@@ -190,4 +192,19 @@ public class CrossDataRealtimePO {
private double timeOccupancy; private double timeOccupancy;
@ApiModelProperty(value = "空间占有率", notes = "平均空间密度(长度占比)") @ApiModelProperty(value = "空间占有率", notes = "平均空间密度(长度占比)")
private double vehicleLengthRatioMean; private double vehicleLengthRatioMean;
/** add 20241123 适配神思数据 */
@ApiModelProperty(value = "执行策略 失衡 2拥堵 3溢出 4死锁 5 空放", notes = "")
private Integer strategy;
@ApiModelProperty(value = "策略执行持续时间;单位:s", notes = "")
@TableField("strategy_duration")
private Integer strategyDuration;
@ApiModelProperty(value = "优化执行次数", notes = "")
@TableField("optimize_count")
private Integer optimizeCount;
@ApiModelProperty(value = "优化时长,单位秒", notes = "")
@TableField("optimize_seconds")
private Integer optimizeSeconds;
@ApiModelProperty(value = "是否空放 0否 1是", notes = "")
@TableField("empty_pass")
private Integer emptyPass;
} }
...@@ -50,6 +50,8 @@ public class AbnormalCrossListVO { ...@@ -50,6 +50,8 @@ public class AbnormalCrossListVO {
private Integer isSpillover; private Integer isSpillover;
@ApiModelProperty(value = "是否拥堵:0否;1是") @ApiModelProperty(value = "是否拥堵:0否;1是")
private Integer isCongestion; private Integer isCongestion;
@ApiModelProperty(value = "交通指数")
private Double trafficIndex;
@ApiModelProperty(value = "拥堵指数") @ApiModelProperty(value = "拥堵指数")
private Double congestionIndex; private Double congestionIndex;
@ApiModelProperty(value = "失衡指数") @ApiModelProperty(value = "失衡指数")
......
...@@ -42,6 +42,8 @@ public class GreenwaveListVO { ...@@ -42,6 +42,8 @@ public class GreenwaveListVO {
@ApiModelProperty(value = "行程速度") @ApiModelProperty(value = "行程速度")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class) @JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double speed; private Double speed;
@ApiModelProperty(value = "停车次数")
private Integer stopTimes;
@ApiModelProperty(value = "路口列表") @ApiModelProperty(value = "路口列表")
private List<CrossListElement> crossList; private List<CrossListElement> crossList;
......
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
AND schedules.`week` = #{week} AND schedules.`week` = #{week}
AND DATE_FORMAT( NOW(), '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( NOW(), '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_time AS TIME ), '%H:%i' )
AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) AND DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' )
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1
</select> </select>
......
...@@ -45,6 +45,12 @@ ...@@ -45,6 +45,12 @@
<result column="traffic_flow_C" property="trafficFlowC"></result> <result column="traffic_flow_C" property="trafficFlowC"></result>
<result column="vehicle_length_ratio_mean" property="vehicleLengthRatioMean"></result> <result column="vehicle_length_ratio_mean" property="vehicleLengthRatioMean"></result>
<result column="time_occupancy" property="timeOccupancy"></result> <result column="time_occupancy" property="timeOccupancy"></result>
<!-- add 20241123 适配神思数据 -->
<result column="strategy" property="strategy"></result>
<result column="strategy_duration" property="strategyDuration"></result>
<result column="optimize_count" property="optimizeCount"></result>
<result column="optimize_seconds" property="optimizeSeconds"></result>
<result column="empty_pass" property="emptyPass"></result>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -53,7 +59,8 @@ ...@@ -53,7 +59,8 @@
flow, flow_rate, speed, queue_length, stop_times, delay_time, sturation, batch_time, gmt_create, gmt_modified, flow, flow_rate, speed, queue_length, stop_times, delay_time, sturation, batch_time, gmt_create, gmt_modified,
clear_rate,load_balance,not_clear_car_nums,green_light_efficiency,effusion_rate, clear_rate,load_balance,not_clear_car_nums,green_light_efficiency,effusion_rate,
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,non_motor_flow,v_85, no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,non_motor_flow,v_85,
traffic_flow_A,traffic_flow_B,traffic_flow_C,vehicle_length_ratio_mean,time_occupancy traffic_flow_A,traffic_flow_B,traffic_flow_C,vehicle_length_ratio_mean,time_occupancy,
strategy, strategy_duration, optimize_count, optimize_seconds, empty_pass
</sql> </sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDataHistPO"> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDataHistPO">
...@@ -67,7 +74,9 @@ ...@@ -67,7 +74,9 @@
#{entity.clearRate},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate}, #{entity.clearRate},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate},
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB}, #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},
#{entity.trafficFlowC},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy}) #{entity.trafficFlowC},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy},
#{entity.strategy}, #{entity.strategyDuration}, #{entity.optimizeCount}, #{entity.optimizeSeconds}, #{entity.emptyPass}
)
</foreach> </foreach>
</insert> </insert>
......
...@@ -45,6 +45,12 @@ ...@@ -45,6 +45,12 @@
<result column="traffic_flow_C" property="trafficFlowC"></result> <result column="traffic_flow_C" property="trafficFlowC"></result>
<result column="vehicle_length_ratio_mean" property="vehicleLengthRatioMean"></result> <result column="vehicle_length_ratio_mean" property="vehicleLengthRatioMean"></result>
<result column="time_occupancy" property="timeOccupancy"></result> <result column="time_occupancy" property="timeOccupancy"></result>
<!-- add 20241123 适配神思数据 -->
<result column="strategy_duration" property="strategyDuration"></result>
<result column="optimize_count" property="optimizeCount"></result>
<result column="optimize_seconds" property="optimizeSeconds"></result>
<result column="empty_pass" property="emptyPass"></result>
<result column="strategy" property="strategy"></result>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -53,7 +59,8 @@ ...@@ -53,7 +59,8 @@
queue_length,stop_times,delay_time,sturation,batch_time,gmt_create,gmt_modified,clear_rate,end_time, queue_length,stop_times,delay_time,sturation,batch_time,gmt_create,gmt_modified,clear_rate,end_time,
load_balance,not_clear_car_nums,green_light_efficiency,effusion_rate, load_balance,not_clear_car_nums,green_light_efficiency,effusion_rate,
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,non_motor_flow,v_85, no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,non_motor_flow,v_85,
traffic_flow_A,traffic_flow_B,traffic_flow_C,vehicle_length_ratio_mean,time_occupancy traffic_flow_A,traffic_flow_B,traffic_flow_C,vehicle_length_ratio_mean,time_occupancy,
strategy, strategy_duration, optimize_count, optimize_seconds, empty_pass
</sql> </sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDataRealtimePO"> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDataRealtimePO">
...@@ -67,7 +74,9 @@ ...@@ -67,7 +74,9 @@
#{entity.clearRate},#{entity.endTime},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate}, #{entity.clearRate},#{entity.endTime},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate},
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC}, #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC},
#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy}) #{entity.vehicleLengthRatioMean},#{entity.timeOccupancy},
#{entity.strategy}, #{entity.strategyDuration}, #{entity.optimizeCount}, #{entity.optimizeSeconds}, #{entity.emptyPass}
)
</foreach> </foreach>
</insert> </insert>
...@@ -84,7 +93,7 @@ ...@@ -84,7 +93,7 @@
select select
t2.id, t2.name, t2.is_signal, t1.unbalance_dirs, t1.congestion_dirs, t1.spillover_dirs, t1.status as realtimeStatus, t2.id, t2.name, t2.is_signal, t1.unbalance_dirs, t1.congestion_dirs, t1.spillover_dirs, t1.status as realtimeStatus,
t1.start_time, t1.duration, t2.location as locationStr, t1.is_unbalance, t1.is_spillover, t1.is_congestion, t1.start_time, t1.duration, t2.location as locationStr, t1.is_unbalance, t1.is_spillover, t1.is_congestion,
t1.congestion_index, t1.unbalance_index, t1.spillover_index, t1.batch_time t1.congestion_index, t1.unbalance_index, t1.spillover_index, t1.batch_time, t1.traffic_index
from t_cross_data_realtime t1 JOIN t_base_cross_info t2 from t_cross_data_realtime t1 JOIN t_base_cross_info t2
on t1.cross_id = t2.id on t1.cross_id = t2.id
<where> <where>
......
...@@ -11,14 +11,18 @@ ...@@ -11,14 +11,18 @@
<result property="specialDate" column="special_date"/> <result property="specialDate" column="special_date"/>
<result property="gmtCreate" column="gmt_create"/> <result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
<result property="months" column="months"/>
<result property="weeks" column="weeks"/>
<result property="days" column="days"/>
</resultMap> </resultMap>
<!-- 批量新增数据 --> <!-- 批量新增数据 -->
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_cross_schedules(id,schedule_no,name,cross_id,plan_id,week,special_date) insert into t_cross_schedules(id,schedule_no,name,cross_id,plan_id,week,special_date,months,weeks,days)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#{entity.id},#{entity.scheduleNo},#{entity.name},#{entity.crossId},#{entity.planId},#{entity.week},#{entity.specialDate}) (#{entity.id},#{entity.scheduleNo},#{entity.name},#{entity.crossId},#{entity.planId},#{entity.week},
#{entity.specialDate},#{entity.months},#{entity.weeks},#{entity.days})
</foreach> </foreach>
</insert> </insert>
...@@ -29,7 +33,7 @@ ...@@ -29,7 +33,7 @@
<select id="selectByCrossIds" resultMap="BaseResultMap"> <select id="selectByCrossIds" resultMap="BaseResultMap">
select select
id,schedule_no,name,cross_id,plan_id,week,special_date,gmt_create,gmt_modified id,schedule_no,name,cross_id,plan_id,week,special_date,gmt_create,gmt_modified,months,weeks,days
from t_cross_schedules from t_cross_schedules
where cross_id in where cross_id in
<foreach collection="crossIds" item="crossId" separator="," open="(" close=")"> <foreach collection="crossIds" item="crossId" separator="," open="(" close=")">
......
...@@ -21,11 +21,21 @@ ...@@ -21,11 +21,21 @@
<result property="startTime" column="start_time"/> <result property="startTime" column="start_time"/>
<result property="gmtCreate" column="gmt_create"/> <result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
<!-- add 20241123 适配神思数据 -->
<result column="strategy" property="strategy"></result>
<result column="strategy_duration" property="strategyDuration"></result>
<result column="optimize_count" property="optimizeCount"></result>
<result column="optimize_seconds" property="optimizeSeconds"></result>
<result column="empty_pass" property="emptyPass"></result>
<result column="batch_time" property="batchTime"></result>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate, id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability,cord_queue_ratio,uncoordinate_phase_queue, start_time, gmt_create,gmt_modified cord_reliability,cord_queue_ratio,uncoordinate_phase_queue, start_time, gmt_create,gmt_modified,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time
</sql> </sql>
<select id="selectRunMonitor" resultType="net.wanji.databus.dao.entity.GreenwaveHistPOExt"> <select id="selectRunMonitor" resultType="net.wanji.databus.dao.entity.GreenwaveHistPOExt">
...@@ -82,7 +92,11 @@ ...@@ -82,7 +92,11 @@
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed}, (#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate}, #{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio}, #{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified}) #{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
#{entity.strategy}, #{entity.strategyDuration}, #{entity.optimizeCount}, #{entity.optimizeSeconds},
#{entity.greenWaveWidth}, #{entity.direction}, #{entity.planCycle}, #{entity.speedHigh},
#{entity.speedDown}, #{entity.roadDirection}, #{entity.sturation}, #{entity.batchTime}
)
</foreach> </foreach>
</insert> </insert>
......
...@@ -48,4 +48,13 @@ ...@@ -48,4 +48,13 @@
where name = #{greenwaveName} where name = #{greenwaveName}
</select> </select>
<select id="findByMap" resultType="net.wanji.databus.dao.entity.GreenwaveInfoPO" parameterType="java.util.Map">
SELECT <include refid="Base_Column_List"></include>
FROM t_greenwave_info WHERE 1=1
<if test="keyword != null and keyword != ''">
AND ( locate(#{keyword,jdbcType=VARCHAR}, `name`)>0 )
</if>
</select>
</mapper> </mapper>
...@@ -21,11 +21,28 @@ ...@@ -21,11 +21,28 @@
<result property="startTime" column="start_time"/> <result property="startTime" column="start_time"/>
<result property="gmtCreate" column="gmt_create"/> <result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
<!-- add 20241123 适配神思数据 -->
<result column="strategy" property="strategy"></result>
<result column="strategy_duration" property="strategyDuration"></result>
<result column="optimize_count" property="optimizeCount"></result>
<result column="optimize_seconds" property="optimizeSeconds"></result>
<result column="green_wave_width" property="greenWaveWidth"></result>
<result column="direction" property="direction"></result>
<result column="plan_cycle" property="planCycle"></result>
<result column="speed_high" property="speedHigh"></result>
<result column="speed_down" property="speedDown"></result>
<result column="road_direction" property="roadDirection"></result>
<result column="sturation" property="sturation"></result>
<result column="batch_time" property="batchTime"></result>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate, id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability, cord_queue_ratio, uncoordinate_phase_queue, start_time, gmt_create,gmt_modified cord_reliability, cord_queue_ratio, uncoordinate_phase_queue, start_time, gmt_create,gmt_modified,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time
</sql> </sql>
<select id="selectById" resultType="net.wanji.databus.dao.entity.GreenwaveRealtimePO"> <select id="selectById" resultType="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
...@@ -43,7 +60,11 @@ ...@@ -43,7 +60,11 @@
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed}, (#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate}, #{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio}, #{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified}) #{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
#{entity.strategy}, #{entity.strategyDuration}, #{entity.optimizeCount}, #{entity.optimizeSeconds},
#{entity.greenWaveWidth}, #{entity.direction}, #{entity.planCycle}, #{entity.speedHigh},
#{entity.speedDown}, #{entity.roadDirection}, #{entity.sturation}, #{entity.batchTime}
)
</foreach> </foreach>
</insert> </insert>
...@@ -56,4 +77,12 @@ ...@@ -56,4 +77,12 @@
</where> </where>
</delete> </delete>
<delete id="deleteBatch" parameterType="String">
delete from t_greenwave_realtime
where green_id in
<foreach collection="list" item="greenId" separator="," open="(" close=")">
#{greenId}
</foreach>
</delete>
</mapper> </mapper>
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