Commit 4e3f7b6b authored by zhouleilei's avatar zhouleilei

1、修改controller打包方式2、修改方案优化对比等

parent 295bd1cf
......@@ -394,6 +394,94 @@
</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/resources/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.web.SignalApplication</mainClass>
</manifest>
<manifestEntries>
<Class-Path>../resources/</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>*.**</exclude>
<exclude>*/**/*.xml</exclude>
</excludes>
<outputDirectory>${project.parent.basedir}/assembly/${project.name}/lib</outputDirectory>
<classesDirectory>
</classesDirectory>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
......@@ -14,8 +15,11 @@ import java.util.Date;
@Data
public class CrossIdAndTimeDTO {
@ApiModelProperty(value = "路口ID,如:c7e7b1f352dd4acab4a60088eb391cca", required = true)
@NotNull(message = "crossId不可为空")
private String crossId;
@ApiModelProperty(value = "当前日期时间 yyyy-MM-dd HH:mm:ss", required = true)
@NotNull(message = "datetime不可为空")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date datetime;
}
......@@ -15,7 +15,6 @@ import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.*;
import net.wanji.databus.po.BaseCrossLightsPO;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.databus.po.CrossSchemeInfoPO;
import net.wanji.databus.po.SaveToUtcPO;
import net.wanji.databus.vo.*;
......@@ -629,22 +628,20 @@ public class PlanSendServiceImpl implements PlanSendService {
RingPhasePO ringPhasePO = new RingPhasePO();
List<SaveSchemeConfigDTO.PhaseListElement> oriPhaseList = new ArrayList<>();
List<SaveSchemeConfigDTO.PhaseListElement> optPhaseList = new ArrayList<>();
//TODO
CrossIdDTO crossIdDTO = new CrossIdDTO();
crossIdDTO.setCrossId(crossIdAndTimeDTO.getCrossId());
//查询当前运行的方案
JsonViewObject jsonViewObject = utcFeignClients.getSchemeNoStr(crossIdDTO.getCrossId());
Integer code = jsonViewObject.getCode();
if (code != 200) {
log.error("获取当前方案号失败,路口id:{}", crossIdAndTimeDTO.getCrossId());
QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO = new QueryByCrossIdAndTimeDTO();
queryByCrossIdAndTimeDTO.setCrossId(crossIdAndTimeDTO.getCrossId());
queryByCrossIdAndTimeDTO.setDatetime(crossIdAndTimeDTO.getDatetime());
JsonViewObject jsonViewObject = utcFeignClients.selectSchemeByParams(queryByCrossIdAndTimeDTO);
if (jsonViewObject.getCode() != 200){
return ringPhasePO;
}
ObjectMapper objectMapper = JacksonUtils.getInstance();
CoordinationStatus content = objectMapper.convertValue(jsonViewObject.getContent(), CoordinationStatus.class);
String coordPatternStatus = content.getCoordPatternStatus();
//方案号
int schemeId = (Integer.valueOf(coordPatternStatus) + 2) / 3;
System.out.println(schemeId);
BaseCrossSchemePO content = objectMapper.convertValue(jsonViewObject.getContent(), BaseCrossSchemePO.class);
if (ObjectUtil.isEmpty(content)){
return ringPhasePO;
}
int schemeId = Integer.valueOf(content.getSchemeNo());
List<CrossSchemeInfoPO> crossSchemeInfoPOS = baseCrossSchemeMapper.selectSchemeInfoByCrossIdAndSchemeId(crossIdAndTimeDTO.getCrossId(), schemeId);
if (ObjectUtil.isNotEmpty(crossSchemeInfoPOS)) {
//根据相位号分组
......@@ -660,7 +657,7 @@ public class PlanSendServiceImpl implements PlanSendService {
phaseListElement.setYellowTime(Integer.valueOf(crossSchemeInfoPO.getYellowTime()));
phaseListElement.setRedTime(Integer.valueOf(crossSchemeInfoPO.getRedTime()));
List<SaveSchemeConfigDTO.DirListElement> dirListElements = new ArrayList<>();
Map<String, List<CrossSchemeInfoPO>> dircollect = infoPOS.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getDir));
Map<String, List<CrossSchemeInfoPO>> dircollect = infoPOS.stream().filter(x -> x.getDir() != null).collect(Collectors.groupingBy(CrossSchemeInfoPO::getDir));
if (ObjectUtil.isNotEmpty(dircollect)) {
Set<String> dirSet = dircollect.keySet();
for (String string : dirSet) {
......@@ -669,7 +666,7 @@ public class PlanSendServiceImpl implements PlanSendService {
SaveSchemeConfigDTO.DirListElement dirListElement = new SaveSchemeConfigDTO.DirListElement();
dirListElement.setDir(Integer.valueOf(po.getDir()));
List<SaveSchemeConfigDTO.LaneListElement> laneList = new ArrayList<>();
Map<String, List<CrossSchemeInfoPO>> laneCollect = crossSchemeInfoPOS1.stream().collect(Collectors.groupingBy(CrossSchemeInfoPO::getLandId));
Map<String, List<CrossSchemeInfoPO>> laneCollect = crossSchemeInfoPOS1.stream().filter(x -> x.getLandId() != null).collect(Collectors.groupingBy(CrossSchemeInfoPO::getLandId));
if (ObjectUtil.isNotEmpty(laneCollect)) {
Set<String> stringSet = laneCollect.keySet();
for (String s1 : stringSet) {
......@@ -690,7 +687,6 @@ public class PlanSendServiceImpl implements PlanSendService {
phaseListElement.setDirList(dirListElements);
oriPhaseList.add(phaseListElement);
}
}
if (ObjectUtil.isNotEmpty(oriPhaseList)) {
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
......@@ -708,6 +704,9 @@ public class PlanSendServiceImpl implements PlanSendService {
if (ObjectUtils.isNotEmpty(crossSchedulesPOList)) {
optPhaseList.addAll(oriPhaseList);
for (int i = 0; i < optPhaseList.size(); i++) {
if (i == crossSchedulesPOList.size()){
break;
}
CrossSchemeStageOptLogPO optLogPO = crossSchedulesPOList.get(i);
SaveSchemeConfigDTO.PhaseListElement optPhase = optPhaseList.get(i);
optPhase.setMinGreenTime(0);
......@@ -721,12 +720,8 @@ public class PlanSendServiceImpl implements PlanSendService {
optPhase.setYellowFlash(0);
}
}
}
}
ringPhasePO.setOriPhaseList(oriPhaseList);
ringPhasePO.setOptPhaseList(optPhaseList);
return ringPhasePO;
......
......@@ -146,4 +146,8 @@ public interface FeignCommon {
@PostMapping("/staticInfo/schemeOptLog")
JsonViewObject schemeOptLog(@RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO);
// 海信-查询方案优化记录
@PostMapping("/staticInfo/selectSchemeByParams")
JsonViewObject selectSchemeByParams(@RequestBody QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO);
}
......@@ -248,11 +248,15 @@ public class DiagnoServiceImpl implements DiagnoService {
week = 0;
}
//通过路口号和方案号查询方案id
BaseCrossSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectByCrossIdAndWeek(crossId,week);
CrossNowSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectByCrossIdAndWeek(crossId,week);
if (ObjectUtils.isEmpty(baseCrossSchemePO)){
return phaseOptTimeList;
}
Integer schemeNo = Integer.valueOf(baseCrossSchemePO.getSchemeNo());
Integer schemeNo = baseCrossSchemePO.getSchemeId();
if (ObjectUtil.isEmpty(schemeNo)){
log.info("当前路口为黃闪,crossId:{}",crossId);
return phaseOptTimeList;
}
schemeNo = (schemeNo+2)/3;
List<CrossPhasePO> phasePOList = baseCrossPhaseMapper.selectByCrossIdAndSchemeId(crossId, schemeNo);
if (ObjectUtils.isEmpty(phasePOList) || ObjectUtils.isEmpty(schemeNo)) {
......
......@@ -138,4 +138,15 @@ public class StaticInfoController {
public JsonViewObject schemeOptLog(@RequestBody @Validated CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
return JsonViewObject.newInstance().success(staticInfoService.schemeOptLog(crossSchemeRingsDTO));
}
@AspectLog(description = "根据时间和路口号查询方案号", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/selectSchemeByParams")
@ApiOperation(value = "根据时间和路口号查询方案号", notes = "查询方案优化记录", response = CrossSchemeRings.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchemeRings.class)
})
public JsonViewObject selectSchemeByParams(@RequestBody @Validated QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception {
return JsonViewObject.newInstance().success(staticInfoService.selectSchemeByParams(queryByCrossIdAndTimeDTO));
}
}
package net.wanji.utc.hisense.service;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dao.entity.CrossSchemeStageOptLogPO;
import net.wanji.databus.dto.*;
......@@ -39,4 +40,11 @@ public interface StaticInfoService {
**/
List<CrossSchemeStageOptLogPO> schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
/**
* @Description : 根据时间和路口号查询方案号
* @Param crossId 路口编号
* @Param datetime 时间
**/
BaseCrossSchemePO selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception;
}
......@@ -17,6 +17,7 @@ import net.wanji.databus.dto.*;
import net.wanji.databus.po.CoordinationStatus;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.po.CrossInfoPOExt;
import net.wanji.databus.po.CrossNowSchemePO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.hisense.cache.CrossInfoCache;
......@@ -40,7 +41,9 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
......@@ -171,10 +174,34 @@ public class StaticInfoServiceImpl implements StaticInfoService {
}
phaseLightsVO.setCrossPhaseLightsPOList(crossPhaseLightsPOList);
phaseLightsVO.setCrossLightsList(crossLightsList);
CrossSchemePO crossSchemePO = addNewScheme(crossId);
crossSchemeList.add(crossSchemePO);
phaseLightsVO.setCrossSchemeList(crossSchemeList);
phaseLightsVO.setCrossPhaseList(crossPhaseList);
return phaseLightsVO;
}
//初始化一个黃闪方案
private CrossSchemePO addNewScheme(String crossId){
CrossSchemePO crossSchemePO = new CrossSchemePO();
//方案号
int schemeNo = 85;
crossSchemePO.setSchemeNo(schemeNo + "");
crossSchemePO.setName("方案" + schemeNo);
crossSchemePO.setCrossId(crossId);
crossSchemePO.setCycle(0);
//协调相位id先默认给1
crossSchemePO.setCoordPhase(1);
crossSchemePO.setOffset(0);
//来源默认信号机
crossSchemePO.setSource(1);
//默认给0
crossSchemePO.setIsDeleted(0);
//默认给0
crossSchemePO.setStatus(0);
crossSchemePO.setGmtCreate(null);
crossSchemePO.setGmtModified(null);
return crossSchemePO;
}
/**
* @return java.util.Map<java.lang.Integer, java.util.List < net.wanji.utc.hisense.pojo.dto.RingPhaseDTO>>
......@@ -690,20 +717,23 @@ public class StaticInfoServiceImpl implements StaticInfoService {
//表中周日用0表示
week = 0;
}
BaseCrossSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectByCrossIdAndWeek(crossId, week);
CrossNowSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectByCrossIdAndWeek(crossId, week);
if (ObjectUtil.isNotEmpty(baseCrossSchemePO)) {
coordinationStatus = new CoordinationStatus();
//从缓存中拿路口信息
CrossInfoPO crossInfoPO = CrossInfoCache.getCrossInfoCache().get(crossId);
if (ObjectUtil.isNotNull(crossInfoPO)) {
coordinationStatus.setSpot(crossInfoPO.getCode());
Integer poSchemeId = baseCrossSchemePO.getSchemeId();
if (baseCrossSchemePO.getControlMode() == 3 || ObjectUtil.isEmpty(poSchemeId)) {
//控制模式为3或者方案号为空,判断为黃闪
coordinationStatus.setCoordPatternStatus(String.valueOf(255));
} else {
//海信的方案号
int schemeNo = Integer.valueOf(baseCrossSchemePO.getSchemeNo()) * 3 - 2;
if (schemeNo == 253) {
//黃闪
schemeNo = 255;
}
int schemeNo = Integer.valueOf(baseCrossSchemePO.getSchemeId()) * 3 - 2;
coordinationStatus.setCoordPatternStatus(String.valueOf(schemeNo));
}
coordinationStatus.setCoordCycleStatus(String.valueOf(baseCrossSchemePO.getCycle()));
}
......@@ -771,9 +801,9 @@ public class StaticInfoServiceImpl implements StaticInfoService {
CoordinationStatus coordinationStatus = crossPlan(crossSchemeRingsDTO.getCrossId());
if (ObjectUtil.isEmpty(coordinationStatus)) {
//获取方案号失败
log.error("请求方案环图前,获取当前运行方案号失败,crossId:{}",crossSchemeRingsDTO.getCrossId());
log.error("请求方案环图前,获取当前运行方案号失败,crossId:{}", crossSchemeRingsDTO.getCrossId());
return null;
}else if ("255".equals(coordinationStatus.getCoordPatternStatus())){
} else if ("255".equals(coordinationStatus.getCoordPatternStatus())) {
//黃闪
CrossSchemeRings crossSchemeRings = new CrossSchemeRings();
crossSchemeRings.setSpot(crossSchemeRingsDTO.getCrossId());
......@@ -848,9 +878,9 @@ public class StaticInfoServiceImpl implements StaticInfoService {
}
/**
* @return net.wanji.utc.hisense.pojo.result.CrossSchemeRings
* @Description 获取环图请求原有的逻辑
* @Param [crossSchemeRingsDTO]
* @return net.wanji.utc.hisense.pojo.result.CrossSchemeRings
**/
public CrossSchemeRings crossSchemeRingsHisen(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
......@@ -926,4 +956,34 @@ public class StaticInfoServiceImpl implements StaticInfoService {
List<CrossSchemeStageOptLogPO> crossSchemeStageOptLogPOS = crossSchemeStageOptLogMapper.selectList(queryWrapper);
return crossSchemeStageOptLogPOS;
}
@Override
public BaseCrossSchemePO selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception {
Date datetime = queryByCrossIdAndTimeDTO.getDatetime();
//java.util.date转LocalDate
LocalDate localDate = datetime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
int week = localDate.getDayOfWeek().getValue();
if (week == 7) {
//表中周日用0表示
week = 0;
}
// 创建一个 SimpleDateFormat 对象,并指定日期格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 将 Date 对象格式化为字符串
String formattedDate = sdf.format(datetime);
BaseCrossSchemePO baseCrossSchemePO = baseCrossSchemeMapper.selectSchemeByParams(queryByCrossIdAndTimeDTO.getCrossId(), formattedDate, week);
if (ObjectUtil.isNull(baseCrossSchemePO)) {
//获取当前方案号
CoordinationStatus coordinationStatus = crossPlan(queryByCrossIdAndTimeDTO.getCrossId());
if (ObjectUtil.isNotNull(coordinationStatus)) {
baseCrossSchemePO = new BaseCrossSchemePO();
String coordPatternStatus = coordinationStatus.getCoordPatternStatus();
int schemaId = (Integer.valueOf(coordPatternStatus) + 2) / 3;
baseCrossSchemePO.setSchemeNo(String.valueOf(schemaId));
baseCrossSchemePO.setCrossId(queryByCrossIdAndTimeDTO.getCrossId());
baseCrossSchemePO.setCycle(Integer.valueOf(coordinationStatus.getCoordCycleStatus()));
}
}
return baseCrossSchemePO;
}
}
......@@ -177,6 +177,15 @@ public class StaticInfoController {
public JsonViewObject schemeOptLog(@Validated @RequestBody CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception {
return staticInfoService.schemeOptLog(crossSchemeRingsDTO);
}
@AspectLog(description = "根据时间和路口号查询方案号", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/selectSchemeByParams", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "根据时间和路口号查询方案号", notes = "查询方案优化记录")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
public JsonViewObject selectSchemeByParams(@Validated @RequestBody QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception {
return staticInfoService.selectSchemeByParams(queryByCrossIdAndTimeDTO);
}
}
......@@ -32,4 +32,5 @@ public interface StaticInfoService {
JsonViewObject crossSchemeNo(String crossId) throws Exception;
JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception;
}
......@@ -3,6 +3,7 @@ package net.wanji.utc.service.staticinfo;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossSchemeRingsDTO;
import net.wanji.databus.dto.QueryByCrossIdAndTimeDTO;
import net.wanji.utc.common.Result;
import java.util.List;
......@@ -54,4 +55,5 @@ public interface WanJiCommonStaticInfoService {
JsonViewObject crossSchemeRings(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject schemeOptLog(CrossSchemeRingsDTO crossSchemeRingsDTO) throws Exception;
JsonViewObject selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception;
}
......@@ -236,4 +236,11 @@ public class StaticInfoServiceImpl implements StaticInfoService {
jsonViewObject = wanjiCommonStaticInfoService.schemeOptLog(crossSchemeRingsDTO);
return jsonViewObject;
}
@Override
public JsonViewObject selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
jsonViewObject = wanjiCommonStaticInfoService.selectSchemeByParams(queryByCrossIdAndTimeDTO);
return jsonViewObject;
}
}
......@@ -11,6 +11,7 @@ import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.CrossSchemeRingsDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.QueryByCrossIdAndTimeDTO;
import net.wanji.databus.vo.CrossIdVO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
......@@ -138,6 +139,7 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
CrossSchemePO baseCrossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, crossSectionPO.getSchemeId());
if (Objects.nonNull(baseCrossSchemePO)) {
crossSectionPO.setSchemeId(baseCrossSchemePO.getId());
// crossSectionPO.setSchemeId(crossSectionPO.getSchemeId());
crossSectionMapper.insertOne(crossSectionPO);
}
});
......@@ -217,4 +219,15 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
return jsonViewObject;
}
@Override
public JsonViewObject selectSchemeByParams(QueryByCrossIdAndTimeDTO queryByCrossIdAndTimeDTO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(queryByCrossIdAndTimeDTO.getCrossId());
FeignCommon utcFeignClientService = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode);
JsonViewObject jsonViewObject = utcFeignClientService.selectSchemeByParams(queryByCrossIdAndTimeDTO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("查询方案优化记录远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
return jsonViewObject;
}
}
package net.wanji.databus.dao.mapper;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.po.CrossNowSchemePO;
import net.wanji.databus.po.CrossSchemeInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -60,5 +61,6 @@ public interface BaseCrossSchemeMapper {
BaseCrossSchemePO selectByCrossIdAndSchemeId(String crossId, Integer schemeId);
List<CrossSchemeInfoPO> selectSchemeInfoByCrossIdAndSchemeId(String crossId, Integer schemeId);
BaseCrossSchemePO selectByCrossIdAndWeek(@Param("crossId") String crossId,@Param("week") int week);
CrossNowSchemePO selectByCrossIdAndWeek(@Param("crossId") String crossId, @Param("week") int week);
BaseCrossSchemePO selectSchemeByParams(@Param("crossId") String crossId,@Param("queryTime") String queryTime,@Param("week") int week);
}
package net.wanji.databus.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
/**
* @ClassName QueryByCrossIdAndTimeDTO
* @Description 根据路口编号和时间查询参数
* @Author zhouleilei
* @Date 2024/12/5 10:11
*/
@Data
public class QueryByCrossIdAndTimeDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
@NotNull(message = "crossId不能为空")
private String crossId;
@ApiModelProperty(value = "当前日期时间 yyyy-MM-dd HH:mm:ss", required = true)
@NotNull(message = "datetime不可为空")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date datetime;
}
package net.wanji.databus.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName CrossSchemePO
* @Description 路口方案信息
* @Author zhouleilei
* @Date 2024/12/5 14:41
*/
@Data
public class CrossNowSchemePO {
/** 方案号 */
@ApiModelProperty(name = "方案号",notes = "")
private Integer schemeId ;
/** 方案名称 */
@ApiModelProperty(name = "方案名称",notes = "")
private String name ;
/** 路口ID */
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId ;
/** 周期 */
@ApiModelProperty(name = "周期",notes = "")
private Integer cycle = 0;
/** 相位差 */
@ApiModelProperty(name = "相位差",notes = "")
private Integer offset = 0;
/** 时段号 */
@ApiModelProperty(name = "时段号",notes = "")
private Integer sectionNo ;
/** 开始时间 */
@ApiModelProperty(name = "开始时间",notes = "")
private String startTime ;
/** 结束时间 */
@ApiModelProperty(name = "结束时间",notes = "")
private String endTime ;
/** 控制模式 */
@ApiModelProperty(name = "控制模式",notes = "1定周期;2绿波协调;3黄闪;4全红;5关灯;6单点自适应;7全感应;8半感应;9',")
private Integer controlMode ;
}
......@@ -219,9 +219,17 @@
ORDER BY
phaseNo ASC
</select>
<select id="selectByCrossIdAndWeek" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
<select id="selectByCrossIdAndWeek" resultType="net.wanji.databus.po.CrossNowSchemePO">
SELECT
scheme.id AS id,scheme.scheme_no AS schemeNo,scheme.name AS name,scheme.cross_id AS crossId,scheme.cycle AS cycle,scheme.coord_phase AS coordPhase,scheme.offset AS offset,scheme.source AS source,scheme.is_deleted AS isDeleted,scheme.status AS status,scheme.gmt_create AS gmtCreate,scheme.gmt_modified AS gmtModified
schedules.cross_id AS corssId,
section.section_no AS sectionNo,
section.start_time AS startTime,
section.end_time AS endTime,
scheme.scheme_no AS schemeId,
scheme.`name` AS name,
scheme.cycle AS cycle,
scheme.`offset` AS offset,
section.control_mode AS controlMode
FROM
t_cross_schedules schedules
LEFT JOIN t_cross_section section ON section.cross_id = schedules.cross_id
......@@ -236,5 +244,22 @@
ORDER BY DATE_FORMAT( CAST( section.end_time AS TIME ), '%H:%i' ) ASC LIMIT 1
</select>
<select id="selectSchemeByParams" resultType="net.wanji.databus.dao.entity.BaseCrossSchemePO">
SELECT
scheme.id AS id,scheme.scheme_no AS schemeNo,scheme.name AS name,scheme.cross_id AS crossId,scheme.cycle AS cycle,scheme.coord_phase AS coordPhase,scheme.offset AS offset,scheme.source AS source,scheme.is_deleted AS isDeleted,scheme.status AS status,scheme.gmt_create AS gmtCreate,scheme.gmt_modified AS gmtModified
FROM
t_cross_schedules schedules
LEFT JOIN t_cross_section section ON section.cross_id = schedules.cross_id
AND schedules.plan_id = section.plan_id
LEFT JOIN t_cross_scheme scheme ON scheme.cross_id = section.cross_id
AND section.scheme_id = scheme.id
WHERE
schedules.cross_id = #{crossId}
AND schedules.`week` = #{week}
AND DATE_FORMAT( #{queryTime}, '%H:%i' ) BETWEEN DATE_FORMAT( CAST( section.start_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>
</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