Commit 748d9bf8 authored by zhoushiguang's avatar zhoushiguang
parents f7baaa67 62936068
......@@ -9,8 +9,9 @@ import lombok.Getter;
*/
@Getter
@AllArgsConstructor
public enum CrossOptStrategyEnum {
ZERO(0, "无策略"),
public enum CrossOptResultStrategyEnum {
// 优化策略
ZERO(0, "均衡调控"),
ONE(1, "绿灯空放"),
TWO(2, "失衡"),
THREE(3, "溢出");
......@@ -19,11 +20,11 @@ public enum CrossOptStrategyEnum {
private String desc;
public static String getDesc(int code) {
for (CrossOptStrategyEnum value : CrossOptStrategyEnum.values()) {
for (CrossOptResultStrategyEnum value : CrossOptResultStrategyEnum.values()) {
if (code == value.code) {
return value.getDesc();
}
}
return "无策略";
return CrossOptResultStrategyEnum.ZERO.getDesc();
}
}
......@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -153,6 +154,45 @@ public class InduceSendController {
.body("程序查询错误请联系管理员".getBytes(StandardCharsets.UTF_8));
}
}
@ApiOperation(value = "根据设备编号和发布时间获取诱导发布图片", notes = "根据设备编号和发布时间获取诱导发布图片")
@GetMapping(value = "/fileCodeHist")
public ResponseEntity<byte[]> ftpFileByCodeAndTime(@RequestParam("equipCode") String equipCode, @RequestParam("date") Date date) {
LambdaQueryWrapper<InduceHist> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InduceHist::getEquipCode, equipCode);
queryWrapper.le(InduceHist::getCreateTime, date);
queryWrapper.orderByDesc(InduceHist::getCreateTime);
queryWrapper.last("limit 1");
InduceHist pictureFile = this.induceHistService.getOne(queryWrapper,false);
if (Objects.isNull(pictureFile) || pictureFile.getFilePath() == null) {
return ResponseEntity.status(HttpStatus.OK)
.body("无效的文件ID".getBytes(StandardCharsets.UTF_8));
}
try {
// 获取ftp服务器图片
byte[] imageBytes = this.induceSendService.downloadImage(pictureFile.getFilePath());
if (imageBytes != null && imageBytes.length > 0) {
// 设置响应头
HttpHeaders headers = new HttpHeaders();
// 图片类型
headers.set("Content-Type", "image/jpeg");
// 设置内容长度
headers.set("Content-Length", String.valueOf(imageBytes.length));
// 设置文件名
headers.set("Content-Disposition", "inline; filename=\"" + pictureFile.getSourceId() + ".bmp\"");
// 返回响应
return new ResponseEntity<>(imageBytes, headers, HttpStatus.OK);
} else {
return ResponseEntity.status(HttpStatus.OK)
.body("未查询到对应文件".getBytes(StandardCharsets.UTF_8));
}
} catch (IOException e) {
log.error("ftp文件下载失败: ", e.getMessage());
return ResponseEntity.status(HttpStatus.OK)
.body("程序查询错误请联系管理员".getBytes(StandardCharsets.UTF_8));
}
}
/**
* 获取ftp图片
*/
......
......@@ -10,7 +10,7 @@ import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.CrossDirDataHistMapper;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.po.*;
import net.wanji.opt.common.enums.CrossOptStrategyEnum;
import net.wanji.opt.common.enums.CrossOptResultStrategyEnum;
import net.wanji.opt.common.enums.OptStatusEnum;
import net.wanji.opt.common.enums.StrategyControlEnum;
import net.wanji.opt.dao.mapper.HoloEventMapper;
......@@ -95,7 +95,6 @@ public class CrossIndexServiceImpl implements CrossIndexService {
for (StrategyCrossResultEntity entity : list) {
CrossOptResult crossOptResult = new CrossOptResult();
Date date = entity.getIssueTime();
//Date date = DateUtil.parse(entity.getIssueTime(), "yyyy-MM-dd HH:mm:ss");
crossOptResult.setTimeStamp(date);
Integer countDown = entity.getCountDown();
if (entity.getCurrentAlgo() == 2) {
......@@ -104,7 +103,7 @@ public class CrossIndexServiceImpl implements CrossIndexService {
crossOptResult.setCountDown(countDown);
Integer currentAlgo = entity.getCurrentAlgo();
crossOptResult.setStrategy(currentAlgo);
crossOptResult.setStrategyName(CrossOptStrategyEnum.getDesc(currentAlgo));
crossOptResult.setStrategyName(CrossOptResultStrategyEnum.getDesc(currentAlgo));
crossOptResults.add(crossOptResult);
}
}
......@@ -172,13 +171,13 @@ public class CrossIndexServiceImpl implements CrossIndexService {
for (Map.Entry<Integer, List<StrategyCrossResultEntity>> entry : listMap.entrySet()) {
Integer currentAlgo = entry.getKey();
List<StrategyCrossResultEntity> value = entry.getValue();
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.ONE.getCode())) {
if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.ONE.getCode())) {
crossStatusCountVO.setPhaseEmptyCount(value.size());
}
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.TWO.getCode())) {
if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.TWO.getCode())) {
crossStatusCountVO.setUnbalanceCount(value.size());
}
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.THREE.getCode())) {
if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.THREE.getCode())) {
crossStatusCountVO.setOverFlowCount(value.size());
}
}
......
......@@ -138,11 +138,12 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
detail.setStartTime(dirDataHistPO.getStartTime());
detail.setGreenTimeRatio(greenTimeRatio);
for (GreenBeltKeyCrossFlowTimeVO.Detail optResult : optResults) {
Integer curDir = GreenBeltDirEnum.getInDir(optResult.getDir());
if (StringUtils.equalsIgnoreCase("cancel", optResult.getDir()) && Objects.equals(curDir, dirType)
if (StringUtils.equalsIgnoreCase("cancel", optResult.getDir())
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
greenTimeRatio = 0.0;
}
Integer curDir = GreenBeltDirEnum.getInDir(optResult.getDir());
if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType)
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
detail.setGreenTimeRatio(optResult.getGreenTimeRatio() * 100);
......@@ -262,7 +263,6 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlMethod, 1);
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(greenwaveHistPOS)) {
Map<String, List<GreenwaveHistPO>> greenDirMap = greenwaveHistPOS.stream().collect(Collectors.groupingBy(GreenwaveHistPO::getRoadDirection));
......@@ -289,7 +289,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
&& minuteDate.getTime() == startTimeminuteDate.getTime()) {
greenWidthTime = entity.getGreenWidthTime();
}
if (entity.getControlMethod() <= 0) {
if (entity.getControlMethod() < 0 && minuteDate.getTime() == startTimeminuteDate.getTime()) {
greenWidthTime = 0.0;
}
}
......
......@@ -259,6 +259,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
StrategyControlDataEntity strategyControlDataEntity = strategyList.get(0);
histVO.setStrategy(strategyControlDataEntity.getStrategy());
histVO.setStrategyName("绿波带");
} else {
histVO.setStrategy(0);
histVO.setStrategyName("绿波带");
}
histVO.setOptTime(entity.getControlTime());
histVO.setResult(Objects.equals(1, entity.getControlMethod()) ? "失败" : "成功");
......@@ -313,6 +316,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName());
strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt());
strategyControlDataEntity.setOptMethod("效率提升");
results.add(strategyControlDataEntity);
}
}
......@@ -366,8 +370,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
queryWrapper.le(StrategyControlDataEntity::getScheduleStart, current);
queryWrapper.ge(StrategyControlDataEntity::getScheduleEnd, current);
//queryWrapper.ge(StrategyControlDataEntity::getScheduleStart, current);
//queryWrapper.le(StrategyControlDataEntity::getScheduleEnd, current);
List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
List<StrategyControlDataEntity> results = new ArrayList<>(entities.size());
for (StrategyControlDataEntity entity : entities) {
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.wanji.opt.config.Double2TwoDecimalPlacesSerializer;
/**
* @author Kent HAN
......@@ -20,6 +22,7 @@ public class MainlineEvaluateBottomCurveVO {
private String scopeName;
@ApiModelProperty(value = "数值")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double value;
@ApiModelProperty(value = "指标时间戳")
......
......@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -235,9 +236,9 @@ public class ControlCommandServiceImpl implements ControlCommandService {
// boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进成功,路口号: " + code);
return jsonViewObject.fail("第 "+ (i+1) +" 次相位步进失败,取消步进成功,路口号: " + code);
} else {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进失败,路口号: " + code);
return jsonViewObject.fail("第 "+ (i+1) +" 次相位步进失败,取消步进失败,路口号: " + code);
}
}
//停顿10ms
......@@ -252,9 +253,9 @@ public class ControlCommandServiceImpl implements ControlCommandService {
// boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,但取消步进成功,路口号: " + code);
return jsonViewObject.fail("第 "+(i+1)+" 次相位步进失败,但取消步进成功,路口号: " + code);
} else {
return jsonViewObject.fail("第 "+i+1+" 次相位步进失败,取消步进失败,路口号: " + code);
return jsonViewObject.fail("第 "+(i+1)+" 次相位步进失败,取消步进失败,路口号: " + code);
}
}
......
......@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
......@@ -89,19 +90,7 @@ public class SignalCommandSyncTask {
log.error("路口在线状态控制模式更新失败,路口编号信息:{}", entry, e);
}
}
if (!CollectionUtils.isEmpty(insertList)) {
signalCommandPOMapper.insertBatch(insertList);
List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(insertList.size());
BeanListUtils.populateList(insertList, signalCommandLogPOS, SignalCommandLogPO.class);
signalCommandLogPOMapper.insertBatch(signalCommandLogPOS);
}
if (!CollectionUtils.isEmpty(updateList)) {
signalCommandPOMapper.updateBatch(updateList);
List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(updateList.size());
BeanListUtils.populateList(updateList, signalCommandLogPOS, SignalCommandLogPO.class);
signalCommandLogPOMapper.insertBatch(signalCommandLogPOS);
log.info("路口状态控制模式变动,数据库更新成功:{}", updateList);
}
saveAndUpdate(insertList, updateList);
List<SignalCommandPO> sendList = new ArrayList<>();
sendList.addAll(insertList);
sendList.addAll(updateList);
......@@ -116,13 +105,33 @@ public class SignalCommandSyncTask {
}
}
@Transactional(rollbackFor = Exception.class)
public void saveAndUpdate(List<SignalCommandPO> insertList, List<SignalCommandPO> updateList) {
try {
if (!CollectionUtils.isEmpty(insertList)) {
signalCommandPOMapper.insertBatch(insertList);
List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(insertList.size());
BeanListUtils.populateList(insertList, signalCommandLogPOS, SignalCommandLogPO.class);
signalCommandLogPOMapper.insertBatch(signalCommandLogPOS);
}
if (!CollectionUtils.isEmpty(updateList)) {
signalCommandPOMapper.updateBatch(updateList);
List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(updateList.size());
BeanListUtils.populateList(updateList, signalCommandLogPOS, SignalCommandLogPO.class);
signalCommandLogPOMapper.insertBatch(signalCommandLogPOS);
log.info("路口状态控制模式变动,数据库更新成功:{}", updateList);
}
} catch (Exception e) {
log.error("路口状态控制模式变动,数据库更新失败:", e);
throw new RuntimeException(e);
}
}
private static SignalCommandPO insertSignalCommandPO(String crossId, Integer statusCache, String runModeCache, String lampTime) {
SignalCommandPO insertPO = new SignalCommandPO();
insertPO.setCrossId(crossId);
insertPO.setStatus(statusCache);
insertPO.setRunMode(runModeCache);
insertPO.setCommandResult(1);
insertPO.setUpdateCount(0);
insertPO.setInsertTime(new Date());
insertPO.setLampTime(lampTime);
return insertPO;
......
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