Commit 2ab71974 authored by zhoushiguang's avatar zhoushiguang
parents c71feebc b8ebae42
......@@ -645,14 +645,14 @@ public class PlanSendServiceImpl implements PlanSendService {
List<CrossSchemeInfoPO> crossSchemeInfoPOS = baseCrossSchemeMapper.selectSchemeInfoByCrossIdAndSchemeId(crossIdAndTimeDTO.getCrossId(), schemeId);
if (ObjectUtil.isNotEmpty(crossSchemeInfoPOS)) {
//根据相位号分组
Map<String, List<CrossSchemeInfoPO>> collect = crossSchemeInfoPOS.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getPhaseNo));
LinkedHashMap<String, List<CrossSchemeInfoPO>> collect = crossSchemeInfoPOS.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getPhaseNo, LinkedHashMap::new, Collectors.toList()));
Set<String> set = collect.keySet();
for (String s : set) {
List<CrossSchemeInfoPO> infoPOS = collect.get(s);
CrossSchemeInfoPO crossSchemeInfoPO = infoPOS.get(0);
SaveSchemeConfigDTO.PhaseListElement phaseListElement = new SaveSchemeConfigDTO.PhaseListElement();
phaseListElement.setPhaseId(Integer.valueOf(crossSchemeInfoPO.getPhaseId()));
phaseListElement.setPhaseNo(crossSchemeInfoPO.getPhaseTime());
phaseListElement.setPhaseNo(crossSchemeInfoPO.getPhaseNo());
phaseListElement.setGreenTime(Integer.valueOf(crossSchemeInfoPO.getGreenTime()));
phaseListElement.setYellowTime(Integer.valueOf(crossSchemeInfoPO.getYellowTime()));
phaseListElement.setRedTime(Integer.valueOf(crossSchemeInfoPO.getRedTime()));
......@@ -702,22 +702,22 @@ public class PlanSendServiceImpl implements PlanSendService {
List<CrossSchemeStageOptLogPO> crossSchedulesPOList = mapper.convertValue(optView.getContent(), new TypeReference<List<CrossSchemeStageOptLogPO>>() {
});
if (ObjectUtils.isNotEmpty(crossSchedulesPOList)) {
optPhaseList.addAll(oriPhaseList);
for (int i = 0; i < optPhaseList.size(); i++) {
if (i == crossSchedulesPOList.size()){
for (int i = 0; i < crossSchedulesPOList.size(); i++) {
if (i == oriPhaseList.size()){
break;
}
CrossSchemeStageOptLogPO optLogPO = crossSchedulesPOList.get(i);
SaveSchemeConfigDTO.PhaseListElement optPhase = optPhaseList.get(i);
optPhase.setMinGreenTime(0);
optPhase.setMaxGreenTime(0);
optPhase.setGreenTime(optLogPO.getPhaseTime());
optPhase.setGreenFlashTime(0);
optPhase.setYellowFlashTime(0);
optPhase.setRedFlashTime(0);
optPhase.setYellowTime(0);
optPhase.setRedTime(0);
optPhase.setYellowFlash(0);
SaveSchemeConfigDTO.PhaseListElement phaseListElement = oriPhaseList.get(i);
SaveSchemeConfigDTO.PhaseListElement optPhase = new SaveSchemeConfigDTO.PhaseListElement();
BeanUtils.copyProperties(phaseListElement,optPhase);
Integer yellowTime = phaseListElement.getYellowTime();
Integer redTime = phaseListElement.getRedTime();
//相位时间
Integer phaseTime = optLogPO.getPhaseTime();
//绿灯时间
int greenTime = phaseTime - yellowTime - redTime;
optPhase.setGreenTime(greenTime);
optPhaseList.add(optPhase);
}
}
}
......
......@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -74,7 +75,8 @@ public class BaseCrossInfoCache implements CommandLineRunner {
public void init() {
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll(new CrossInfoVO());
if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) {
crossInfoList.addAll(baseCrossInfoPOS);
List<BaseCrossInfoPO> collect = baseCrossInfoPOS.stream().filter(po -> Objects.equals(po.getIsSignal(), 1)).collect(Collectors.toList());
crossInfoList.addAll(collect);
}
}
}
package net.wanji.opt.config;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.text.DecimalFormat;
/**
* @author duanruiming
* @date 2024/12/01 16:17
*/
public class Double2TwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value != null) {
String formattedValue = df.format(value);
gen.writeString(formattedValue);
} else {
gen.writeNull();
}
}
}
......@@ -113,7 +113,7 @@ public class TrendController {
return JsonViewObject.newInstance().success(res);
}
@ApiOperation(value = "问题子区列表", notes = "问题子区列表", response = JsonViewObject.class,
@ApiOperation(value = "问题子区干线列表", notes = "交通体检-干线列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/greenwaveList",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
......@@ -101,7 +101,6 @@ public class GreenwaveInducesController {
induceDTO.setResolutionHeight(deviceInduces.get(0).getResolutionHeight());
induceDTO.setWkt(deviceInduces.get(0).getWkt());
}
//获取上屏状态
induceDTO.setStatus(o.getStatus());
//获取关联绿波信息
......@@ -122,9 +121,11 @@ public class GreenwaveInducesController {
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")));
greenwaveDTO.setControlOptTimes(startTime.substring(0,startTime.lastIndexOf(":"))+"-"+endTime.substring(0,endTime.lastIndexOf(":")));
}catch (ParseException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}catch (StringIndexOutOfBoundsException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
}else {
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
......@@ -144,23 +145,22 @@ public class GreenwaveInducesController {
return jsonView;
}
/**
* 根据条件查询记录
*
* @param GreenwaveInduces 查询条件
* @param greenwaveInduces 查询条件
* @return JsonViewObject
*/
@ApiOperation(value = "根据条件查询记录", notes = "根据条件查询记录", response = JsonViewObject.class, 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}) GreenwaveInduces GreenwaveInduces){
JsonViewObject getByWhere(@ApiParam(value = "查询条件", required = true) @RequestBody @Validated({ValidationGroups.Query.class}) GreenwaveInduces greenwaveInduces){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
String jsonStr = JSON.toJSONString(GreenwaveInduces);
String jsonStr = JSON.toJSONString(greenwaveInduces);
try {
//参数校验过程中修改,兼容实现,restful入参不用map,便于进行参数逐个校验
Map params = JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInduces), Map.class);
Map params = JSONObject.parseObject(JSONObject.toJSONString(greenwaveInduces), Map.class);
// Map<String, Object> params = new HashMap<>();
// JSONObject.parseObject(JSONObject.toJSONString(GreenwaveInduces), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
List<GreenwaveInduces> greenwaveInducesList = this.greenwaveInducesMapper.findByMap(params);
......@@ -202,9 +202,11 @@ public class GreenwaveInducesController {
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")));
greenwaveDTO.setControlOptTimes(startTime.substring(0,startTime.lastIndexOf(":"))+"-"+endTime.substring(0,endTime.lastIndexOf(":")));
}catch (ParseException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}catch (StringIndexOutOfBoundsException ex){ex.printStackTrace();
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
}
}else {
greenwaveDTO.setControlOptTimes(m.getControlOptTimes());
......@@ -221,7 +223,6 @@ public class GreenwaveInducesController {
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getByWhere error,jsonStr:{}", this.getClass().getSimpleName(), jsonStr, e);
}
return jsonView;
}
......@@ -237,7 +238,6 @@ public class GreenwaveInducesController {
JsonViewObject getById(@ApiParam(value = "记录的id", required = true, example = "1") @PathVariable("id") @NotBlank(message = "查询id不能为空") String id){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
GreenwaveInduces GreenwaveInduces = this.greenwaveInducesService.getById(id);
jsonView.success(GreenwaveInduces);
......@@ -280,22 +280,22 @@ public class GreenwaveInducesController {
/**
* 新建记录
*
* @param GreenwaveInduces
* @param greenwaveInduces
* @return JsonViewObject
*/
@ApiOperation(value = "新建记录", notes = "新建记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/creating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) GreenwaveInduces GreenwaveInduces){
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) GreenwaveInduces greenwaveInduces){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (GreenwaveInduces != null) {
jsonView = this.greenwaveInducesService.saveOrUpdate(GreenwaveInduces)?jsonView.success():jsonView.fail();
if (greenwaveInduces != null) {
jsonView = this.greenwaveInducesService.saveOrUpdate(greenwaveInduces)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(GreenwaveInduces), e);
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(greenwaveInduces), e);
}
return jsonView;
}
......@@ -303,21 +303,21 @@ public class GreenwaveInducesController {
/**
* 修改记录
*
* @param GreenwaveInduces
* @param greenwaveInduces
* @return
*/
@ApiOperation(value = "修改记录", notes = "修改记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/updating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) GreenwaveInduces GreenwaveInduces){
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) GreenwaveInduces greenwaveInduces){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (GreenwaveInduces != null) {
jsonView = this.greenwaveInducesService.saveOrUpdate(GreenwaveInduces)?jsonView.success():jsonView.fail();
if (greenwaveInduces != null) {
jsonView = this.greenwaveInducesService.saveOrUpdate(greenwaveInduces)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("UPDATE_FAILED_MSG"));
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(GreenwaveInduces), e);
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(greenwaveInduces), e);
}
return jsonView;
}
......
......@@ -64,22 +64,21 @@ public class InduceHistController {
/**
* 根据条件查询记录
*
* @param InduceHist 查询条件
* @param induceHist 查询条件
* @return JsonViewObject
*/
@ApiOperation(value = "根据条件查询记录", notes = "根据条件查询记录", response = JsonViewObject.class, 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}) InduceHist InduceHist){
JsonViewObject getByWhere(@ApiParam(value = "查询条件", required = true) @RequestBody @Validated({ValidationGroups.Query.class}) InduceHist induceHist){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
String jsonStr = JSON.toJSONString(InduceHist);
String jsonStr = JSON.toJSONString(induceHist);
try {
//参数校验过程中修改,兼容实现,restful入参不用map,便于进行参数逐个校验
// Map params = JSONObject.parseObject(JSONObject.toJSONString(InduceHist), Map.class);
Map<String, Object> params = new HashMap<>();
JSONObject.parseObject(JSONObject.toJSONString(InduceHist), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
JSONObject.parseObject(JSONObject.toJSONString(induceHist), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
List list = this.induceHistService.listByMap(params);
jsonView.success(list);
} catch (Exception e) {
......@@ -144,22 +143,22 @@ public class InduceHistController {
/**
* 新建记录
*
* @param InduceHist
* @param induceHist
* @return JsonViewObject
*/
@ApiOperation(value = "新建记录", notes = "新建记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/creating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) InduceHist InduceHist){
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) InduceHist induceHist){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (InduceHist != null) {
jsonView = this.induceHistService.saveOrUpdate(InduceHist)?jsonView.success():jsonView.fail();
if (induceHist != null) {
jsonView = this.induceHistService.saveOrUpdate(induceHist)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(InduceHist), e);
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(induceHist), e);
}
return jsonView;
}
......@@ -167,21 +166,21 @@ public class InduceHistController {
/**
* 修改记录
*
* @param InduceHist
* @param induceHist
* @return
*/
@ApiOperation(value = "修改记录", notes = "修改记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/updating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) InduceHist InduceHist){
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) InduceHist induceHist){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (InduceHist != null) {
jsonView = this.induceHistService.saveOrUpdate(InduceHist)?jsonView.success():jsonView.fail();
if (induceHist != null) {
jsonView = this.induceHistService.saveOrUpdate(induceHist)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("UPDATE_FAILED_MSG"));
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(InduceHist), e);
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(induceHist), e);
}
return jsonView;
}
......
......@@ -125,8 +125,7 @@ public class InduceSendController {
// 根据 equipCode 获取文件名
LambdaQueryWrapper<InduceHist> InduceHistQueryWrapper = new LambdaQueryWrapper<>();
InduceHistQueryWrapper.eq(InduceHist::getEquipCode, equipCode);
InduceHistQueryWrapper.orderByAsc(InduceHist::getCreateTime);
// InduceHist pictureFile=this.induceHistService.getOne(InduceHistQueryWrapper);
InduceHistQueryWrapper.orderByDesc(InduceHist::getCreateTime);
InduceHist pictureFile = this.induceHistService.getOne(InduceHistQueryWrapper,false);
if (Objects.isNull(pictureFile) && pictureFile.getFilePath() == null) {
return ResponseEntity.status(HttpStatus.OK)
......
......@@ -67,21 +67,21 @@ public class InduceTemplateController {
/**
* 根据条件查询记录
*
* @param InduceTemplate 查询条件
* @param induceTemplate 查询条件
* @return JsonViewObject
*/
@ApiOperation(value = "根据条件查询记录", notes = "根据条件查询记录", response = JsonViewObject.class, 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}) InduceTemplate InduceTemplate){
JsonViewObject getByWhere(@ApiParam(value = "查询条件", required = true) @RequestBody @Validated({ValidationGroups.Query.class}) InduceTemplate induceTemplate){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
String jsonStr = JSON.toJSONString(InduceTemplate);
String jsonStr = JSON.toJSONString(induceTemplate);
try {
//参数校验过程中修改,兼容实现,restful入参不用map,便于进行参数逐个校验
// Map params = JSONObject.parseObject(JSONObject.toJSONString(InduceTemplate), Map.class);
Map<String, Object> params = new HashMap<>();
JSONObject.parseObject(JSONObject.toJSONString(InduceTemplate), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
JSONObject.parseObject(JSONObject.toJSONString(induceTemplate), Map.class).forEach((k,v) -> params.put(StringUtils.camelToCapital(k.toString()).toLowerCase(), v));
List list = this.induceTemplateService.listByMap(params);
jsonView.success(list);
......@@ -147,22 +147,22 @@ public class InduceTemplateController {
/**
* 新建记录
*
* @param InduceTemplate
* @param induceTemplate
* @return JsonViewObject
*/
@ApiOperation(value = "新建记录", notes = "新建记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/creating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) InduceTemplate InduceTemplate){
JsonViewObject save(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Create.class}) InduceTemplate induceTemplate){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (InduceTemplate != null) {
jsonView = this.induceTemplateService.saveOrUpdate(InduceTemplate)?jsonView.success():jsonView.fail();
if (induceTemplate != null) {
jsonView = this.induceTemplateService.saveOrUpdate(induceTemplate)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("SAVE_FAILED_MSG"));
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(InduceTemplate), e);
log.error("AbstractRestServerImpl save error, jsonStr:{}", JSON.toJSONString(induceTemplate), e);
}
return jsonView;
}
......@@ -170,21 +170,21 @@ public class InduceTemplateController {
/**
* 修改记录
*
* @param InduceTemplate
* @param induceTemplate
* @return
*/
@ApiOperation(value = "修改记录", notes = "修改记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/updating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) InduceTemplate InduceTemplate){
JsonViewObject update(@ApiParam(value = "记录的JSON格式字符串", required = true) @RequestBody @Validated({ValidationGroups.Update.class}) InduceTemplate induceTemplate){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
if (InduceTemplate != null) {
jsonView = this.induceTemplateService.saveOrUpdate(InduceTemplate)?jsonView.success():jsonView.fail();
if (induceTemplate != null) {
jsonView = this.induceTemplateService.saveOrUpdate(induceTemplate)?jsonView.success():jsonView.fail();
}
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("UPDATE_FAILED_MSG"));
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(InduceTemplate), e);
log.error("AbstractRestServerImpl update error, jsonStr:{}", JSON.toJSONString(induceTemplate), e);
}
return jsonView;
}
......
......@@ -5,8 +5,8 @@ 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.GreenBeltCrossDetailVO;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltKeyCrossFlowTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
......@@ -18,6 +18,7 @@ import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
......@@ -35,7 +36,7 @@ public class GreenBeltController {
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltCrossDetailHist")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
@ApiResponse(code = 200, message = "OK", response = GreenBeltFlowStopTimeVO.class),
})
public JsonViewObject greenBeltCrossDetailHist(Integer greenId) {
List<GreenBeltFlowStopTimeVO> greenBeltFlowStopTimeVOS = Collections.EMPTY_LIST;
......@@ -51,31 +52,47 @@ public class GreenBeltController {
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltSpeedWidth")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
@ApiResponse(code = 200, message = "OK", response = GreenBeltSpeedWidthVO.class),
})
public JsonViewObject greenBeltSpeedWidth(Integer greenId) {
List<GreenBeltSpeedWidthVO> greenBeltFlowStopTimeVOS = Collections.EMPTY_LIST;
Map<String, List<GreenBeltSpeedWidthVO>> map = Collections.EMPTY_MAP;
try {
greenBeltFlowStopTimeVOS = greenBeltInfoService.greenBeltSpeedWidth(greenId);
map = greenBeltInfoService.greenBeltSpeedWidth(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波带宽曲线异常");
}
return JsonViewObject.newInstance().success(greenBeltFlowStopTimeVOS);
return JsonViewObject.newInstance().success(map);
}
@ApiOperation(value = "绿波关键路口流量绿信比", notes = "优化监测-绿波关键路口流量绿信比", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltKeyCrossFlowTime")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AddOrUpdateSceneDTO.class),
@ApiResponse(code = 200, message = "OK", response = GreenBeltKeyCrossFlowTimeVO.class),
})
public JsonViewObject greenBeltKeyCrossFlowTime(Integer greenId) {
List<GreenBeltKeyCrossFlowTimeVO> greenBeltKeyCrossFlowTimeVOS = Collections.EMPTY_LIST;
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = Collections.EMPTY_MAP;
try {
greenBeltKeyCrossFlowTimeVOS = greenBeltInfoService.greenBeltKeyCrossFlowTime(greenId);
map = greenBeltInfoService.greenBeltKeyCrossFlowTime(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("绿波带宽曲线异常");
}
return JsonViewObject.newInstance().success(greenBeltKeyCrossFlowTimeVOS);
return JsonViewObject.newInstance().success(map);
}
@ApiOperation(value = "干线详情", notes = "优化监测-干线详情", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltCrossDetailList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenBeltKeyCrossFlowTimeVO.class),
})
public JsonViewObject greenBeltCrossDetailList(Integer greenId) {
GreenBeltCrossDetailVO greenBeltCrossDetailVO = new GreenBeltCrossDetailVO();
try {
greenBeltCrossDetailVO = greenBeltInfoService.greenBeltCrossDetailList(greenId);
} catch (Exception e) {
JsonViewObject.newInstance().fail("优化监测-干线详情");
}
return JsonViewObject.newInstance().success(greenBeltCrossDetailVO);
}
}
......@@ -58,14 +58,14 @@ public class InduceTemplate implements Serializable {
/**
* 文字左上角X坐标
*/
@TableField("text_x")
private Integer textX;
@TableField("top_left")
private String topLeft;
/**
* 文字左上角Y坐标
*/
@TableField("text_y")
private Integer textY;
@TableField("bottom_right")
private String bottomRight;
/**
* 文字大小
......
......@@ -18,6 +18,7 @@ import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.CrossSchemeRingsDTO;
import net.wanji.databus.dto.QueryByCrossIdAndTimeDTO;
import net.wanji.databus.po.*;
import net.wanji.databus.vo.SchemeOptSendVO;
import net.wanji.databus.vo.SchemeSendVO;
......@@ -40,7 +41,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -234,34 +234,37 @@ public class DiagnoServiceImpl implements DiagnoService {
@Override
public List<SchemeOptVO.PhaseOptTime> schemeComparison(CrossIdAndSchemeIdDTO crossIdAndSchemeIdDTO) {
String crossId = crossIdAndSchemeIdDTO.getCrossId();
Integer schemeId = crossIdAndSchemeIdDTO.getSchemeId();
List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = new ArrayList<>();
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(String.valueOf(schemeId));
//查询当前路口运行的方案
LocalDate now = LocalDate.now();
int week = now.getDayOfWeek().getValue();
if (week == 7) {
//表中周日用0表示
week = 0;
QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO = new QueryByCrossIdAndTimeDTO();
queryByCrossIdAndTimeDTO.setCrossId(crossId);
queryByCrossIdAndTimeDTO.setDatetime(new Date());
//查询路口当前方案
JsonViewObject jsonViewObjectScheme = utcFeignClients.selectSchemeByParams(queryByCrossIdAndTimeDTO);
Integer jsonViewObjectSchemeCode = jsonViewObjectScheme.getCode();
if (jsonViewObjectSchemeCode != 200){
log.info("未查询到当前路口号,crossId:{}",crossId);
return phaseOptTimeList;
}
//通过路口号和方案号查询方案id
CrossNowSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectByCrossIdAndWeek(crossId,week);
ObjectMapper mapper1 = JacksonUtils.getInstance();
BaseCrossSchemePO baseCrossSchemePO = mapper1.convertValue(jsonViewObjectScheme.getContent(), new TypeReference<BaseCrossSchemePO>() {
});
if (ObjectUtils.isEmpty(baseCrossSchemePO)){
return phaseOptTimeList;
}
Integer schemeNo = baseCrossSchemePO.getSchemeId();
if (ObjectUtil.isEmpty(schemeNo)){
Integer schemeNo = Integer.valueOf(baseCrossSchemePO.getSchemeNo());
if (ObjectUtil.isEmpty(schemeNo) || schemeNo == 85){
log.info("当前路口为黃闪,crossId:{}",crossId);
return phaseOptTimeList;
}
schemeNo = (schemeNo+2)/3;
List<CrossPhasePO> phasePOList = baseCrossPhaseMapper.selectByCrossIdAndSchemeId(crossId, schemeNo);
List<CrossPhasePO> phasePOList = baseCrossPhaseMapper.selectByCrossIdAndSchemeNo(crossId, schemeNo);
if (ObjectUtils.isEmpty(phasePOList) || ObjectUtils.isEmpty(schemeNo)) {
return phaseOptTimeList;
}
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(String.valueOf(schemeNo));
JsonViewObject jsonViewObject = utcFeignClients.schemeOptLog(crossSchemeRingsDTO);
Integer code = jsonViewObject.getCode();
ObjectMapper mapper = JacksonUtils.getInstance();
......@@ -282,7 +285,7 @@ public class DiagnoServiceImpl implements DiagnoService {
} else {
for (CrossPhasePO crossPhasePO : phasePOList) {
SchemeOptVO.PhaseOptTime phaseOptTime = new SchemeOptVO.PhaseOptTime();
phaseOptTime.setPhaseNo(crossPhasePO.getPhaseNo());
phaseOptTime.setPhaseNo(String.valueOf(crossPhasePO.getSort()));
Integer oriPhaseTime = crossPhasePO.getPhaseTime();
phaseOptTime.setOriGreenTime(oriPhaseTime);
List<CrossSchemeStageOptLogPO> list = crossSchedulesPOList.stream().filter(x -> x.getPhaseNo().equals(String.valueOf(crossPhasePO.getSort()))).collect(Collectors.toList());
......@@ -293,8 +296,7 @@ public class DiagnoServiceImpl implements DiagnoService {
CrossSchemeStageOptLogPO optLogPO = list.get(0);
Integer optPhaseTime = optLogPO.getPhaseTime();
phaseOptTime.setOptGreenTime(optPhaseTime);
//两个时间的绝对值
int optTime = Math.abs(oriPhaseTime - optPhaseTime);
int optTime = oriPhaseTime - optPhaseTime;
phaseOptTime.setOptTime(optTime);
}
phaseOptTimeList.add(phaseOptTime);
......
......@@ -202,6 +202,9 @@ public class TrendServiceImpl implements TrendService {
Integer greenId = entry.getKey();
List<GreenwaveListVO> value = entry.getValue();
if (Objects.equals(1, value.size())) {
value.forEach(vo -> {
vo.setType("单向绿波");
});
greenwaveListVOList.addAll(value);
}
if (Objects.equals(2, value.size())) {
......@@ -227,6 +230,7 @@ public class TrendServiceImpl implements TrendService {
wDirVo.setStopTimes((int) (stopTimes / 2));
wDirVo.setTrafficIndex(trafficIndex / 2 < 1 ? 1 : trafficIndex / 2);
wDirVo.setTravelTime(travelTime / 2);
wDirVo.setType("双向绿波");
greenwaveListVOList.add(wDirVo);
}
......@@ -247,7 +251,8 @@ public class TrendServiceImpl implements TrendService {
List<GreenwaveListVO.CrossListElement> crossList = buildCrossList(greenwaveId);
greenwaveListVO.setCrossList(crossList);
}
return greenwaveListVOList;
List<GreenwaveListVO> sorted = greenwaveListVOList.stream().sorted(Comparator.comparingDouble(GreenwaveListVO::getTrafficIndex).reversed()).collect(Collectors.toList());
return sorted;
}
@Override
......@@ -331,12 +336,12 @@ public class TrendServiceImpl implements TrendService {
double roundedTrafficIndex = Math.round(abnormalCrossListVO.getCongestionIndex() * 100.0) / 100.0;
abnormalCrossListVO.setCongestionIndex(roundedTrafficIndex);
Double congestionIndex = abnormalCrossListVO.getCongestionIndex();
double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800);
double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300);
abnormalCrossListVO.setLastWeekIndex(Math.floor(lastWeekIndex));
abnormalCrossListVO.setLastPeriodIndex(Math.floor(lastPeriodIndex));
// todo
//Double congestionIndex = abnormalCrossListVO.getCongestionIndex();
//double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800);
//double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300);
//abnormalCrossListVO.setLastWeekIndex(Math.floor(lastWeekIndex));
//abnormalCrossListVO.setLastPeriodIndex(Math.floor(lastPeriodIndex));
// 常发性偶发性 一个月内超过三次
int frequent = getFrequent(crossId, batchTime);
......@@ -344,8 +349,8 @@ public class TrendServiceImpl implements TrendService {
abnormalCrossListVO.setFrequent(frequent);
}
abnormalCrossVO.setAbnormalCrossList(abnormalCrossListVOList);
List<AbnormalCrossListVO> sorted = abnormalCrossListVOList.stream().sorted(Comparator.comparingDouble(AbnormalCrossListVO::getTrafficIndex).reversed()).collect(Collectors.toList());
abnormalCrossVO.setAbnormalCrossList(sorted);
// 构造统计信息
List<AbnormalCrossListVO> listForStats =
crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
......@@ -451,8 +456,7 @@ public class TrendServiceImpl implements TrendService {
String serviceLevel = CrossUtil.getServiceLevel(sturation);
abnormalCrossDetailVO.setServiceLevel(serviceLevel);
abnormalCrossDetailVO.setHourFlow(crossDataRealtimePO.getFlow() * 12);
BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getCongestionIndex()).setScale(2, RoundingMode.HALF_UP);
BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getTrafficIndex()).setScale(2, RoundingMode.HALF_UP);
abnormalCrossDetailVO.setCongestionIndex(bigDecimal);
// 构造转向实时数据
List<AbnormalCrossDetailVO.TurnDataElement> turnData = buildTurnData(crossId);
......@@ -1913,7 +1917,7 @@ public class TrendServiceImpl implements TrendService {
List<AbnormalCrossListVO> signalCrossRealTimeList = crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
if (!CollectionUtils.isEmpty(signalCrossRealTimeList)) {
List<AbnormalCrossListVO> top5 = signalCrossRealTimeList.stream()
.sorted(Comparator.comparingDouble(AbnormalCrossListVO::getCongestionIndex))
.sorted(Comparator.comparingDouble(AbnormalCrossListVO::getTrafficIndex))
.collect(Collectors.toList());
Collections.reverse(top5);
top5 = top5.subList(0, Math.min(top5.size(), 5));
......
......@@ -14,8 +14,6 @@ import net.wanji.opt.service.DeviceInducesService;
import net.wanji.opt.service.induce.*;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -101,11 +99,29 @@ public class InduceSendServiceImpl implements InduceSendService {
byte[] imageBytes = induceTemplate.getFileContent();
if (imageBytes != null || imageBytes.length > 0) {
// 将字节数组转换为字节对象
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageBytes));
BufferedImage image =null;
try {
image = ImageIO.read(new ByteArrayInputStream(imageBytes));
// 修改图像中文字
addTextToImage(image, param.getContents(), induceTemplate.getTextX(), induceTemplate.getTextY(), induceTemplate.getTextSize(), induceTemplate.getTextSign());
//addTextToImage(image, param.getContents(), induceTemplate.getTextX(), induceTemplate.getTextY(), induceTemplate.getTextSize(), induceTemplate.getTextSign());
// 定义文字区域四个角的坐标
String[] topLeft = induceTemplate.getTopLeft().split(",");
String[] bottomRight = induceTemplate.getBottomRight().split(",");
if (topLeft.length != 2 || bottomRight.length != 2) {
return;
}
int topLeftX = Integer.parseInt(topLeft[0]);
int topLeftY = Integer.parseInt(topLeft[1]);
int bottomRightX = Integer.parseInt(bottomRight[0]);
int bottomRightY = Integer.parseInt(bottomRight[1]);
// 图片生成操作
boolean upDown = param.getContents()[0].contains("▲") || param.getContents()[0].contains("▼");
createImageWithText(induceTemplate, image, param.getContents(), induceTemplate.getTextSign(), upDown, topLeftX, topLeftY, bottomRightX, bottomRightY);
}catch (Exception ex){
log.error(ex.getMessage());
}
// 测试阶段保存图片到本地
//ImageIO.write(image, "bmp", new File("D:\\tmp\\" + induceTemplate.getFileName()));
// ImageIO.write(image, "bmp", new File("D:\\tmp\\" + induceTemplate.getFileName()));
// 上传文件至ftp
if (param.getFlg() == 1) {
String dirName=LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
......@@ -159,9 +175,9 @@ public class InduceSendServiceImpl implements InduceSendService {
induceHist.setGreenId(param.getGreenId());
induceHistService.save(induceHist);
//保存诱导状态信息
if(Objects.nonNull(greenwaveinduces)) {
greenwaveinduces.setInducesCount(Objects.isNull(greenwaveinduces.getInducesCount()) ? 0 : greenwaveinduces.getInducesCount() + 1);
greenwaveinduces.setStatus(1);
if(Objects.nonNull(greenwaveinduces) && param.getFlg()==1) {
greenwaveinduces.setInducesCount(Objects.isNull(greenwaveinduces.getInducesCount()) ? 0 : greenwaveinduces.getInducesCount() + ((param.getFlg()==1)?1:0));
greenwaveinduces.setStatus(param.getFlg()==1?1:0);
greenwaveInducesService.saveOrUpdate(greenwaveinduces);
}
}
......@@ -271,6 +287,121 @@ public class InduceSendServiceImpl implements InduceSendService {
}
/**
* 根据绘制的区域,动态调整字体大小,以适应文本区域
*
* @param g2d graphics2d对象
* @param sign 绘制方向标识
* @param text 绘制内容
* @param width 绘制区域宽度
* @param height 绘制区域高度
*/
private static FontMetrics autoFont(InduceTemplate pictureFile, Graphics2D g2d, boolean sign, String[] text, int width, int height) {
// 初始化字体
Font font = new Font("Arial", Font.BOLD, 1);
g2d.setFont(font);
FontMetrics metrics = g2d.getFontMetrics();
// 字体最大、最小限制
int minFontSize = 1;
int maxFontSize = 100;
// 动态调整字体大小以适应文本区域
for (int fontSize = minFontSize; fontSize <= maxFontSize; fontSize++) {
font = new Font("Arial", Font.BOLD, fontSize);
g2d.setFont(font);
metrics = g2d.getFontMetrics();
pictureFile.setTextSize(fontSize);
// 确保绘制区域能够容纳文本,考虑字体长度和高度
if (sign) {
// 高度考虑上下边距
if (metrics.stringWidth(text[0]) > width || (metrics.getHeight() - 4) > height) {
// 设置字体大小
font = new Font("Arial", Font.BOLD, --fontSize);
g2d.setFont(font);
metrics = g2d.getFontMetrics();
pictureFile.setTextSize(fontSize);
return metrics;
}
} else {
// 高度只考虑上边距
if (metrics.stringWidth(text[0]) > width || (metrics.getHeight() - 1) * text.length > height) {
// 设置字体大小
font = new Font("Arial", Font.BOLD, --fontSize);
g2d.setFont(font);
metrics = g2d.getFontMetrics();
pictureFile.setTextSize(fontSize);
return metrics;
}
}
}
// 若字体大小超出限制,则返回最小字体
return metrics;
}
/**
* 根据图片、文字内容、图片分辨率、绘制方向、区域坐标生成带有文字的图片
*
* @param image 图片
* @param text 内容数组
* @param sign 绘制方向
* @param topLeftX 区域左上角x坐标
* @param topLeftY 区域左上角y坐标
* @param bottomRightX 区域右下角x坐标
* @param bottomRightY 区域右下角y坐标
*/
public static void createImageWithText(InduceTemplate pictureFile, BufferedImage image, String[] text, boolean sign,boolean updown, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) {
// 创建Graphics2D对象
Graphics2D g2d = image.createGraphics();
// 转换坐标,原始坐标从底部开始,转换为顶部坐标
topLeftY = image.getHeight() - topLeftY;
bottomRightY = image.getHeight() - bottomRightY;
System.out.println("转换后坐标:" + topLeftY + " " + bottomRightY);
// 计算绘制区域总宽度和高度
int width = bottomRightX - topLeftX;
int height = bottomRightY - topLeftY;
// 动态调整字体大小,以适应文本区域
FontMetrics metrics = autoFont(pictureFile, g2d, sign, text, width, height);
// 绘制坐标点
int textWidth;
// 考虑文字绘制方向、文字居中。垂直居中要根据文字高度,水平居中要根据文字宽度。
// int currentX = topLeftX + (width - textWidth) / 2;
int currentX;
int currentY = topLeftY + metrics.getAscent();
// 设置文字颜色
g2d.setColor(Color.green);
// 根据方向开始文字绘制
if (sign) {
// 因文字动态调整的字体大小,所以此处代码不应该被执行
// if (currentX < topLeftX) {
// currentX = topLeftX; // 若超出左边界,调整为左边界
// } else if (currentX + textWidth > topLeftX + width) {
// currentX = topLeftX + width - textWidth; // 若超出右边界,调整为右边界
// }
textWidth = metrics.stringWidth(text[0]);
currentX = topLeftX + (width - textWidth) / 2;
// 计算居中的y坐标
currentY = currentY + (height - metrics.getHeight()) / 2;
if (updown) {
currentX -= 33;
}
g2d.drawString(text[0], currentX, currentY);
} else {
// 计算每个文本内容的竖向绘制坐标
for (String con : text) {
// 考虑每个字符的宽度,计算居中X坐标
textWidth = metrics.stringWidth(con);
currentX = topLeftX + (width - textWidth) / 2;
if (con.contains("km/h")) {
currentX = currentX + metrics.getDescent();
}
g2d.drawString(con, currentX, currentY);
// 每绘制一个字符后Y坐标向下移,间距为文字的0.8倍
currentY += (int) (metrics.getHeight() * 0.8);
}
}
// 释放资源
g2d.dispose();
}
/**
* 在指定位置添加文字到图像
*
......
package net.wanji.opt.service.signalopt;
import net.wanji.opt.vo.GreenBeltCrossDetailVO;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltKeyCrossFlowTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
......@@ -12,6 +14,7 @@ import java.util.List;
*/
public interface GreenBeltInfoService {
List<GreenBeltFlowStopTimeVO> greenBeltCrossDetailHist(Integer greenId) throws Exception;
List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception;
List<GreenBeltKeyCrossFlowTimeVO> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception;
Map<String, List<GreenBeltSpeedWidthVO>> greenBeltSpeedWidth(Integer greenId) throws Exception;
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception;
GreenBeltCrossDetailVO greenBeltCrossDetailList(Integer greenId) throws Exception;
}
package net.wanji.opt.service.signalopt.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
......@@ -8,19 +9,20 @@ 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.StringUtils;
import net.wanji.databus.dao.entity.GreenwaveCrossPO;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.entity.GreenwaveRealtimePO;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.cache.GreenWaveInfoCache;
import net.wanji.opt.common.enums.GreenBeltDirEnum;
import net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
import net.wanji.opt.service.signalopt.GreenBeltInfoService;
import net.wanji.opt.vo.GreenBeltFlowStopTimeVO;
import net.wanji.opt.vo.GreenBeltInfoVO;
import net.wanji.opt.vo.GreenBeltKeyCrossFlowTimeVO;
import net.wanji.opt.vo.GreenBeltSpeedWidthVO;
import net.wanji.opt.vo.*;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -49,13 +51,58 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
@Resource
private StrategyGreenOptHistMapper strategyGreenOptHistMapper;
@Resource
private GreenwaveRealtimeMapper greenwaveRealtimeMapper;
@Resource
private GreenwaveHistMapper greenwaveHistMapper;
@Resource
private GreenwaveCrossMapper greenwaveCrossMapper;
@Resource
private CrossDataRealtimeMapper crossDataRealtimeMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
@Override
public GreenBeltCrossDetailVO greenBeltCrossDetailList(Integer greenId) throws Exception {
List<GreenwaveCrossPO> crossPOS = greenwaveCrossMapper.selectByGreenwaveId(greenId);
List<CrossDataRealtimePO> realtimePOS = crossDataRealtimeMapper.selectAll();
GreenBeltCrossDetailVO greenBeltCrossDetailVO = new GreenBeltCrossDetailVO();
LambdaQueryWrapper<GreenwaveRealtimePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GreenwaveRealtimePO::getGreenId, greenId);
if (!CollectionUtils.isEmpty(crossPOS) && !CollectionUtils.isEmpty(realtimePOS)) {
List<GreenBeltCrossDetailVO.CrossDetail> detailList = new ArrayList<>();
for (GreenwaveCrossPO crossPO : crossPOS) {
String crossId = crossPO.getCrossId();
GreenBeltCrossDetailVO.CrossDetail crossDetail = new GreenBeltCrossDetailVO.CrossDetail();
for (CrossDataRealtimePO realtimePO : realtimePOS) {
if (StringUtils.equalsIgnoreCase(crossPO.getCrossId(), realtimePO.getCrossId())) {
String crossName = baseCrossInfoCache.getCrossName(crossId);
crossDetail.setCrossName(crossName);
crossDetail.setCrossIndex(realtimePO.getTrafficIndex());
detailList.add(crossDetail);
}
}
}
List<GreenwaveRealtimePO> greenRealTimes = greenwaveRealtimeMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(greenRealTimes)) {
double asDouble = greenRealTimes.stream().mapToDouble(GreenwaveRealtimePO::getTrafficIndex).average().getAsDouble();
greenBeltCrossDetailVO.setGreenIndex(asDouble);
}
greenBeltCrossDetailVO.setDetailList(detailList);
Map<Integer, GreenwaveInfoPO> greenWaveMap = GreenWaveInfoCache.greenWaveMap;
GreenwaveInfoPO greenwaveInfoPO = greenWaveMap.get(greenId);
greenBeltCrossDetailVO.setGreenName(greenwaveInfoPO.getName());
greenBeltCrossDetailVO.setCrossNum(detailList.size());
}
return greenBeltCrossDetailVO;
}
@Override
public List<GreenBeltKeyCrossFlowTimeVO> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception {
public Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception {
try {
ObjectMapper mapper = JacksonUtils.getInstance();
DecimalFormat df = new DecimalFormat("#.00");
DecimalFormat df = new DecimalFormat("#0.00");
List<GreenBeltKeyCrossFlowTimeVO> tempResult = new ArrayList<>();
List<GreenBeltKeyCrossFlowTimeVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now();
......@@ -74,7 +121,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
GreenBeltKeyCrossFlowTimeVO vo = new GreenBeltKeyCrossFlowTimeVO();
String keyCross = entity.getKeyCross();
vo.setCrossId(keyCross);
vo.setDirName(entity.getDir());
vo.setDirName(GreenBeltDirEnum.getDesc(entity.getDir()));
Date controlTime = get5MinuteDate(entity.getControlTime());
vo.setStartTime(controlTime);
String crossGreenDetail = entity.getCrossGreenDetail();
......@@ -111,6 +158,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
resultVO.setFlow(0);
resultVO.setGreenTimeRatio(0.0);
resultVO.setCrossId(tempCrossId);
resultVO.setDirName("未执行");
for (GreenBeltKeyCrossFlowTimeVO result : tempResult) {
if (StringUtils.equalsIgnoreCase(tempCrossId, result.getCrossId())
&& minuteDate.getTime() == result.getStartTime().getTime()) {
......@@ -122,12 +170,17 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
}
}
}
return results;
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO::getDirName));
return map;
} catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e);
throw new RuntimeException(e);
}
}
@Override
public List<GreenBeltSpeedWidthVO> greenBeltSpeedWidth(Integer greenId) throws Exception {
public Map<String, List<GreenBeltSpeedWidthVO>> greenBeltSpeedWidth(Integer greenId) throws Exception {
try {
List<GreenBeltSpeedWidthVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now();
......@@ -170,8 +223,8 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
}
}
}
return results;
Map<String, List<GreenBeltSpeedWidthVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltSpeedWidthVO::getDirName));
return map;
} catch (Exception e) {
log.error("绿波带宽曲线异常:", e);
throw new RuntimeException(e);
......
......@@ -7,8 +7,8 @@ import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.service.StrategyControlService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......
......@@ -19,7 +19,6 @@ import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.cache.GreenWaveInfoCache;
import net.wanji.opt.common.enums.CrossOptStrategyEnum;
import net.wanji.opt.common.enums.StrategyControlEnum;
import net.wanji.opt.dao.mapper.*;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
......@@ -72,6 +71,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private StrategyGreenOptHistMapper strategyGreenOptHistMapper;
@Resource
private StrategyCrossResultMapper strategyCrossResultMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
@Override
......@@ -355,7 +356,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() {
});
for (StrategyControlDataVO.TimeTable timeTable : timeTables) {
int currentWeek = DateUtil.thisDayOfWeek() - 1;
String[] timeList = timeTable.getTimeList();
for (String s : timeList) {
String[] hours = s.split(",");
......@@ -370,28 +370,25 @@ public class StrategyControlServiceImpl implements StrategyControlService {
DateTime currentTime = DateUtil.parse(format, "HH:mm");
DateTime startHourDate = DateUtil.parse(startHour, "HH:mm");
DateTime endHourDate = DateUtil.parse(entHour, "HH:mm");
if (currentTime.after(startHourDate) && currentTime.before(endHourDate)) {
if (currentTime.isAfter(startHourDate) && currentTime.isBefore(endHourDate)) {
result.setTime(hour);
result.setStatus(1);
} else {
// 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置
result.setStatus(0);
result.setTime(null);
}
}
}
}
if (type == 0) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
result.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
result.setWkt(location);
}
if (type == 1) {
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId()));
Map<Integer, GreenwaveInfoPO> greenWaveMap = GreenWaveInfoCache.greenWaveMap;
if (!greenWaveMap.isEmpty()) {
GreenwaveInfoPO greenwaveInfoPO = greenWaveMap.get(Integer.valueOf(entity.getBizId()));
result.setCrossName(greenwaveInfoPO.getName());
result.setWkt(greenwaveInfoPO.getWkt());
}
}
results.add(result);
}
return results;
......@@ -403,19 +400,44 @@ public class StrategyControlServiceImpl implements StrategyControlService {
try {
List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type);
List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>();
List<StrategyControlDataExt> results = new ArrayList<>();
for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) {
Integer strategy = strategyControlDataEntity.getStrategy();
StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt();
BeanUtils.copyProperties(strategyControlDataEntity, strategyControlDataExt);
strategyControlDataExt.setStrategyName(StrategyControlEnum.getDesc(strategy));
strategyControlDataExt.setOptStatus("未执行");
if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) {
strategyControlDataExt.setOptStatus("优化中");
}
strategyControlDataExts.add(strategyControlDataExt);
}
strategyControlDataExts.sort(Comparator.comparing(StrategyControlDataExt::getOptStatus));
return jsonViewObject.success(strategyControlDataExts, "路网优化监测查询成功");
}
if (Objects.equals(0, type)) {
List<BaseCrossInfoPO> crossInfoCache = baseCrossInfoCache.getCrossInfoCache();
if (!CollectionUtils.isEmpty(crossInfoCache)) {
for (BaseCrossInfoPO baseCrossInfoPO : crossInfoCache) {
StrategyControlDataExt ext = new StrategyControlDataExt();
ext.setBizId(baseCrossInfoPO.getId());
ext.setStrategyName("无策略");
ext.setOptStatus("未优化");
ext.setStatus(0);
for (StrategyControlDataExt strategyControlDataExt : strategyControlDataExts) {
if (StringUtils.equals(baseCrossInfoPO.getId(), strategyControlDataExt.getBizId())) {
ext = strategyControlDataExt;
}
}
String location = baseCrossInfoPO.getLocation();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
ext.setWkt(location);
ext.setCrossName(baseCrossInfoPO.getName());
results.add(ext);
}
}
}
if (Objects.equals(1, type)) {
results.addAll(strategyControlDataExts);
}
results.sort(Comparator.comparing(StrategyControlDataExt::getOptStatus));
return jsonViewObject.success(results, "路网优化监测查询成功");
} catch (Exception e) {
log.error("路网优化监测查询失败: {}", e);
return jsonViewObject.fail("路网优化监测查询失败");
......
......@@ -85,7 +85,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
vo.setTimeStamp(greenwaveHistPO.getStartTime());
vo.setHourMinute(DateUtils.format(greenwaveHistPO.getStartTime(), "HH:mm"));
vo.setStopTimes(greenwaveHistPO.getStopTimes());
vo.setCordQueueRatio(greenwaveHistPO.getCordQueueRatio() * 100);
vo.setCordQueueRatio(Objects.isNull(greenwaveHistPO.getCordQueueRatio()) ? 0.0 : greenwaveHistPO.getCordQueueRatio() * 100);
vo.setTravelTime(greenwaveHistPO.getTrvalTime());
results.add(vo);
}
......
......@@ -91,12 +91,11 @@ public class InducesMonitorTask {
@Autowired
private InduceTemplateService induceTemplateService;
/**
* #绿波调度计划扫描周期
* 5 分钟 300000
*/
@Scheduled(fixedRate = 30000)
@Scheduled(fixedRate = 300000)
public void refresh() throws Exception {
long start = System.currentTimeMillis();
AtomicLong synCount = new AtomicLong();
......@@ -183,6 +182,7 @@ public class InducesMonitorTask {
greenwaveInducesHist.setCreateTime(greenOptHistEntity.getCreateTime());
greenwaveInducesHist.setGreenId(greenwaveInfoPO.getId());
greenwaveInducesHist.setDir(getDir(greenOptHistEntity.getDir()));
greenwaveInducesHistService.save(greenwaveInducesHist);
}else{
greenwaveInducesHist=greenwaveInducesHistList.get(0);
}
......@@ -192,6 +192,16 @@ public class InducesMonitorTask {
greenwaveInducesHist.setControlOptTimes(greenOptHistEntity.getControlTime() + "|" + DateUtil.format(DateUtil.addSecond(greenOptHistEntity.getControlTime(), greenOptHistEntity.getControlDuration()), Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));//执行时段
}
greenwaveInducesHist.setType(greenOptHistEntity.getType());// 执行策略
String upDown="";
// 计算绿波速度变化趋势
if(Objects.nonNull(greenwaveInducesHist.getMinSpeed()) && Objects.nonNull(greenwaveInducesHist.getMaxSpeed()) && Objects.nonNull(greenOptHistEntity.getMinSpeed()) && Objects.nonNull(greenOptHistEntity.getMaxSpeed())) {
if (greenwaveInducesHist.getMinSpeed() > greenOptHistEntity.getMinSpeed() || greenwaveInducesHist.getMaxSpeed() > greenOptHistEntity.getMaxSpeed()) {
upDown = "▼ ";
}
if (greenwaveInducesHist.getMinSpeed() < greenOptHistEntity.getMinSpeed() || greenwaveInducesHist.getMaxSpeed() < greenOptHistEntity.getMaxSpeed()) {
upDown = "▲ ";
}
}
greenwaveInducesHist.setMinSpeed(greenOptHistEntity.getMinSpeed());
greenwaveInducesHist.setMaxSpeed(greenOptHistEntity.getMaxSpeed());
// greenwaveInducesHist.setDir(greenOptHistEntity.getDirType());
......@@ -208,12 +218,14 @@ public class InducesMonitorTask {
MessageParam messageParam = new MessageParam();
messageParam.setFlg(1);
messageParam.setGreenId(greenwaveInfoPO.getId());
messageParam.setContents(new String[]{greenOptHistEntity.getMaxSpeed()+"-"+greenOptHistEntity.getMaxSpeed()+"km/h"});
messageParam.setContents(new String[]{(upDown+(Objects.nonNull(greenOptHistEntity.getMinSpeed())?greenOptHistEntity.getMinSpeed().intValue()+"-":"")+(Objects.nonNull(greenOptHistEntity.getMaxSpeed())?greenOptHistEntity.getMaxSpeed().intValue():""))+"km/h"});
messageParam.setType("TFMH");
try {
if(greenwaveInducesHist.getStatus()==0||greenwaveInducesHist.getModifyTime().before(greenOptHistEntity.getCreateTime())) {
LambdaQueryWrapper<GreenwaveInduces> greenwaveInducesQueryWrapper = new LambdaQueryWrapper<>();
greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getGreenId, greenwaveInfoPO.getId());
greenwaveInducesQueryWrapper.eq(GreenwaveInduces::getDir, getDir(greenOptHistEntity.getDir()));
List<GreenwaveInduces> greenwaveInducesList = greenwaveInducesService.list(greenwaveInducesQueryWrapper);
for(GreenwaveInduces greenwaveCross :greenwaveInducesList){
LambdaQueryWrapper<InduceTemplate> induceTemplateQueryWrapper = new LambdaQueryWrapper<>();
......@@ -233,6 +245,7 @@ public class InducesMonitorTask {
messageParam.setEndTime(DateUtil.format(System.currentTimeMillis() + 1000 * 60, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND));
}
induceSendService.send(messageParam);
Thread.sleep(1000);
}
}
greenwaveInducesHist.setStatus(1);
......@@ -243,7 +256,7 @@ public class InducesMonitorTask {
} catch (TemplateException e) {
log.info("发送上屏信息异常" + e.getMessage());
}
greenwaveInducesHistService.saveOrUpdate(greenwaveInducesHist);
greenwaveInducesHistService.updateById(greenwaveInducesHist);
synCount.getAndIncrement();
log.info("同步绿波状态信息成功->" + greenwaveInfoPO.getName()+greenwaveInducesHist.getDir());
}
......@@ -284,7 +297,7 @@ public class InducesMonitorTask {
//保存绿波状态
n.setStatus(0);
n.setModifyTime(new Date());
greenwaveInducesHistService.saveOrUpdate(n);
greenwaveInducesHistService.updateById(n);
log.info("同步绿波状态信息(下屏)->" + greenwaveInfoPO.getName()+"####"+n.getDir());
synCount.getAndIncrement();
});
......@@ -339,7 +352,7 @@ public class InducesMonitorTask {
// System.out.println("当前时间不在范围内: " + now);
// }
System.out.print(new Date().before(DateUtil.parse("2024-12-04", Constants.DATE_FORMAT.E_DATE_FORMAT_DAY)));
// System.out.print(new Date().before(DateUtil.parse("2024-12-04", Constants.DATE_FORMAT.E_DATE_FORMAT_DAY)));
}
}
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 net.wanji.opt.config.Double2TwoDecimalPlacesSerializer;
import java.util.List;
/**
* @author duanruiming
* @date 2024/12/07 11:34
*/
@Data
@ApiModel(value = "优化监测干线详情返回实体")
public class GreenBeltCrossDetailVO {
@ApiModelProperty("干线名称")
private String greenName;
@ApiModelProperty("路口数量")
private Integer crossNum;
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
@ApiModelProperty("干线指数")
private Double greenIndex;
private List<CrossDetail> detailList;
@Data
public static class CrossDetail {
@ApiModelProperty("路口名称")
private String crossName;
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
@ApiModelProperty("路口指数")
private Double crossIndex;
}
}
......@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
......
......@@ -277,158 +277,6 @@
</execution>
</executions>
</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>
</build>
......
......@@ -12,7 +12,7 @@ import java.text.DecimalFormat;
* @date 2024/12/01 16:17
*/
public class DoubleToTwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#.00");
private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
......
......@@ -41,6 +41,9 @@ public interface BaseCrossPhaseMapper {
List<CrossPhasePO> selectByCrossIdAndSchemeId(@Param("crossId") String crossId,
@Param("schemeId") Integer schemeId);
List<CrossPhasePO> selectByCrossIdAndSchemeNo(@Param("crossId") String crossId,
@Param("schemeNo") Integer schemeNo);
void update(CrossPhasePO crossPhasePO);
void insertBatch(List<CrossPhasePO> crossPhaseList);
......
......@@ -2,10 +2,12 @@ package net.wanji.databus.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
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.databus.config.DoubleToTwoDecimalPlacesSerializer;
import java.util.Date;
import java.util.List;
......@@ -51,6 +53,7 @@ public class AbnormalCrossListVO {
@ApiModelProperty(value = "是否拥堵:0否;1是")
private Integer isCongestion;
@ApiModelProperty(value = "交通指数")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double trafficIndex;
@ApiModelProperty(value = "拥堵指数")
private Double congestionIndex;
......
......@@ -18,6 +18,8 @@ import java.util.List;
public class GreenwaveListVO {
@ApiModelProperty(value = "绿波ID")
private Integer id;
@ApiModelProperty(value = "绿波方向类型")
private String type;
@ApiModelProperty(value = "子区名称")
private String name;
@ApiModelProperty(value = "协调方式:0未开启;1相位差优化;2选择方案")
......
......@@ -172,4 +172,18 @@
order by sort
</select>
<select id="selectByCrossIdAndSchemeNo" resultMap="BaseResultMap">
SELECT
phase.id,phase.phase_no,phase.NAME,phase.sort,phase.cross_id,phase.plan_id,phase.ring_no,phase.group_no,phase.phase_type,phase.control_mode,phase.phase_time,phase.green_time,phase.green_flash_time,phase.yellow_flash_time,phase.red_flash_time,phase.ped_flash_time,phase.yellow_time,phase.red_time,phase.min_green_time,phase.max_green_time,phase.gmt_create,phase.gmt_modified
FROM
t_base_cross_phase phase
LEFT JOIN t_base_cross_scheme scheme ON phase.cross_id = scheme.cross_id
AND phase.plan_id = scheme.id
WHERE
phase.cross_id = #{crossId}
AND scheme.scheme_no = #{schemeNo}
ORDER BY
sort
</select>
</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