Commit d7edecad authored by wangtao's avatar wangtao

Merge remote-tracking branch 'origin/master'

parents 2a945f39 e752778d
...@@ -73,6 +73,18 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble ...@@ -73,6 +73,18 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble
* @param * @param
*/ */
List<CrossPoint> findAreaPoint(); List<CrossPoint> findAreaPoint();
/**
* 查询表t_base_area_info信息
* @param
*/
List<AnalysisProblemCrossDay> checkData();
/**
* 新增表t_analysis_problem_cross_day信息
* @param
*/
Integer insertAnalysisProblemCrossDay();
} }
...@@ -41,6 +41,19 @@ public interface AnalysisProblemGreenDayMapper extends BaseMapper<AnalysisProble ...@@ -41,6 +41,19 @@ public interface AnalysisProblemGreenDayMapper extends BaseMapper<AnalysisProble
* @param analysisProblemGreenDay * @param analysisProblemGreenDay
*/ */
Integer addAnalysisProblemGreenDay(AnalysisProblemGreenDay analysisProblemGreenDay); Integer addAnalysisProblemGreenDay(AnalysisProblemGreenDay analysisProblemGreenDay);
/**
* 新增表t_analysis_problem_green_day信息
* @param
*/
Integer insertAnalysisProblemGreenDay();
/**
* 根据条件查询表t_analysis_problem_green_day信息
* @param
*/
List<AnalysisProblemGreenDay> checkData();
} }
package net.wanji.opt.servicev2.implv2; package net.wanji.opt.servicev2.implv2;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -19,6 +18,7 @@ import net.wanji.databus.dao.mapper.GreenwaveHistMapper; ...@@ -19,6 +18,7 @@ import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.po.CrossDataHistPO; import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossSchemeRings; import net.wanji.databus.po.CrossSchemeRings;
import net.wanji.databus.vo.LightsStatusVO2; import net.wanji.databus.vo.LightsStatusVO2;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.common.RedisUtils; import net.wanji.opt.common.RedisUtils;
import net.wanji.opt.common.enums.EventInfoTypeEnum; import net.wanji.opt.common.enums.EventInfoTypeEnum;
import net.wanji.opt.common.enums.GreenBeltDirEnum; import net.wanji.opt.common.enums.GreenBeltDirEnum;
...@@ -70,6 +70,8 @@ public class TrendServiceV2Impl implements TrendServiceV2 { ...@@ -70,6 +70,8 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
private RedisUtils redisUtil; private RedisUtils redisUtil;
@Resource @Resource
private BaseCrossSchemeMapper baseCrossSchemeMapper; private BaseCrossSchemeMapper baseCrossSchemeMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
private static List<OptMonitoringVO> greenListCache = new ArrayList<>(10); private static List<OptMonitoringVO> greenListCache = new ArrayList<>(10);
private static List<OptMonitoringVO> crossListCache = new ArrayList<>(80); private static List<OptMonitoringVO> crossListCache = new ArrayList<>(80);
...@@ -310,10 +312,12 @@ public class TrendServiceV2Impl implements TrendServiceV2 { ...@@ -310,10 +312,12 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
if (last.getCount() == 0 || last.getDuration() == 0) { if (last.getCount() == 0 || last.getDuration() == 0) {
continue; continue;
} }
double countRate = (result.getCount() - last.getCount()) / last.getCount() * 100; double countOffset = (double) result.getCount() - last.getCount();
double durationRate = (result.getDuration() - last.getDuration()) / last.getCount() * 100; double durationOffset = (double) result.getDuration() - last.getDuration();
result.setCountRate((int) countRate); double countRate = countOffset / last.getCount();
result.setDurationRate((int) durationRate); double durationRate = durationOffset / last.getDuration();
result.setCountRate((int) (Math.round(countRate * 100) ));
result.setDurationRate((int) (Math.round(durationRate * 100) ));
} }
} }
...@@ -407,10 +411,14 @@ public class TrendServiceV2Impl implements TrendServiceV2 { ...@@ -407,10 +411,14 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
for (GreenwaveCrossPO greenwaveCrossPO : greenwaveCrossPOS) { for (GreenwaveCrossPO greenwaveCrossPO : greenwaveCrossPOS) {
String crossId = greenwaveCrossPO.getCrossId(); String crossId = greenwaveCrossPO.getCrossId();
String crossName = baseCrossInfoCache.getCrossName(crossId);
GreenOptCrossOffsetVO.CrossOffsetDetail oriOffsetDetail = getOriOffsetDetail(crossId); GreenOptCrossOffsetVO.CrossOffsetDetail oriOffsetDetail = getOriOffsetDetail(crossId);
oriOffsetDetail.setCrossName(crossName);
oriOffsetDetails.add(oriOffsetDetail); oriOffsetDetails.add(oriOffsetDetail);
GreenOptCrossOffsetVO.CrossOffsetDetail curOffsetDetail = getCurOffsetDetail(crossId, oriOffsetDetail); GreenOptCrossOffsetVO.CrossOffsetDetail curOffsetDetail = getCurOffsetDetail(crossId, oriOffsetDetail);
curOffsetDetail.setCrossName(crossName);
curOffsetDetails.add(curOffsetDetail); curOffsetDetails.add(curOffsetDetail);
} }
......
package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDayMapper;
import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemGreenDayMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemGreenDay;
import net.wanji.opt.servicev2.judgeanalysis.impl.AnalysisProblemCrossDayServiceImpl;
import net.wanji.opt.servicev2.judgeanalysis.impl.AnalysisProblemGreenDayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
@Component
@Configurable
@EnableScheduling
@Slf4j
@Profile("!dev")
public class AnalysisProblemDayTask {
@Autowired
private AnalysisProblemCrossDayServiceImpl analysisProblemCrossDayServiceImpl;
@Autowired
private AnalysisProblemCrossDayMapper analysisProblemCrossDayMapper;
@Autowired
private AnalysisProblemGreenDayMapper analysisProblemGreenDayMapper;
@Autowired
private AnalysisProblemGreenDayServiceImpl nalysisProblemGreenDayServiceImpl;
@Scheduled(cron = "0 15 0 ? * *")
@PostConstruct
public void task(){
//执行检查路口id是否还有area_id没赋值的数据
analysisProblemCrossDayServiceImpl.updateCrossAreaIdByCondition();
//执行检查绿波id是否还有area_id没赋值的数据
nalysisProblemGreenDayServiceImpl.updateGreenAreaIdByCondition();
//检查昨日数据是否有统计
List<AnalysisProblemCrossDay> list = analysisProblemCrossDayMapper.checkData();
if(list.isEmpty())
{
analysisProblemCrossDayMapper.insertAnalysisProblemCrossDay();
}
//检查昨日数据是否有统计
List<AnalysisProblemGreenDay> list1 = analysisProblemGreenDayMapper.checkData();
if(list1.isEmpty())
{
analysisProblemGreenDayMapper.insertAnalysisProblemGreenDay();
}
}
}
...@@ -23,6 +23,8 @@ public class GreenOptCrossOffsetVO { ...@@ -23,6 +23,8 @@ public class GreenOptCrossOffsetVO {
public static class CrossOffsetDetail { public static class CrossOffsetDetail {
@ApiModelProperty(value = "路口编号") @ApiModelProperty(value = "路口编号")
private String crossId; private String crossId;
@ApiModelProperty(value = "路口名称")
private String crossName;
@ApiModelProperty(value = "方案相位差") @ApiModelProperty(value = "方案相位差")
private Integer offset; private Integer offset;
@ApiModelProperty(value = "方案号") @ApiModelProperty(value = "方案号")
......
...@@ -29,5 +29,7 @@ public class StatisticsEventTypeCountTimeVO { ...@@ -29,5 +29,7 @@ public class StatisticsEventTypeCountTimeVO {
private Integer countRate; private Integer countRate;
@ApiModelProperty(value = "同比比例,上一周同一持续时间次数比例") @ApiModelProperty(value = "同比比例,上一周同一持续时间次数比例")
private Integer durationRate; private Integer durationRate;
@ApiModelProperty(value = "发生时间")
private String startTime;
} }
...@@ -296,7 +296,7 @@ ...@@ -296,7 +296,7 @@
WHERE dt = CURDATE() WHERE dt = CURDATE()
AND type IN ('701', '702', '703', '707') AND type IN ('701', '702', '703', '707')
AND start_time <![CDATA[ < ]]> NOW() AND start_time <![CDATA[ < ]]> NOW()
AND IFNULL(end_time, NOW()) <![CDATA[ < ]]> NOW() AND IFNULL(end_time, NOW()) <![CDATA[ > ]]> NOW()
GROUP BY cross_id GROUP BY cross_id
) latest_event ON t1.id = latest_event.cross_id ) latest_event ON t1.id = latest_event.cross_id
LEFT JOIN t_event_info t2 LEFT JOIN t_event_info t2
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
AND t2.dt = CURDATE() AND t2.dt = CURDATE()
AND t2.type IN ('701', '702', '703', '707') AND t2.type IN ('701', '702', '703', '707')
AND t2.start_time <![CDATA[ < ]]> NOW() AND t2.start_time <![CDATA[ < ]]> NOW()
AND IFNULL(t2.end_time, NOW()) <![CDATA[ < ]]> NOW() AND IFNULL(t2.end_time, NOW()) <![CDATA[ > ]]> NOW()
WHERE t1.is_signal = 1 WHERE t1.is_signal = 1
ORDER BY t2.start_time DESC ORDER BY t2.start_time DESC
</select> </select>
...@@ -359,7 +359,7 @@ ...@@ -359,7 +359,7 @@
( (
select distinct t1.name, t1.id, ifnull(t2.type, '708') type, t1.wkt, select distinct t1.name, t1.id, ifnull(t2.type, '708') type, t1.wkt,
ifnull(TIMESTAMPDIFF(SECOND, t2.start_time, ifnull(t2.end_time,now())), 0) duration, ifnull(TIMESTAMPDIFF(SECOND, t2.start_time, ifnull(t2.end_time,now())), 0) duration,
DATE_FORMAT(ifnull(t2.start_time, curdate()), '%H:%i:%s') as startTime, DATE_FORMAT(ifnull(t2.start_time, curdate()), '%Y年%m月%d日%H:%i:%s') as startTime,
case case
when t2.type = '706' then "干线缓行" when t2.type = '706' then "干线缓行"
when t2.type = '707' then "干线拥堵" when t2.type = '707' then "干线拥堵"
...@@ -371,7 +371,7 @@ ...@@ -371,7 +371,7 @@
union all union all
select distinct t1.name, t1.id, ifnull(t2.type, '700') type, REPLACE(SUBSTRING(location, 7, 18), ' ', ',') as wkt, select distinct t1.name, t1.id, ifnull(t2.type, '700') type, REPLACE(SUBSTRING(location, 7, 18), ' ', ',') as wkt,
ifnull(TIMESTAMPDIFF(SECOND, t2.start_time, ifnull(t2.end_time,now())), 0) duration, ifnull(TIMESTAMPDIFF(SECOND, t2.start_time, ifnull(t2.end_time,now())), 0) duration,
DATE_FORMAT(ifnull(t2.start_time, curdate()), '%Y年%m月%d日%H:%i') as startTime, DATE_FORMAT(ifnull(t2.start_time, curdate()), '%Y年%m月%d日%H:%i:%s') as startTime,
case case
when t2.type = '701' then "相位空放" when t2.type = '701' then "相位空放"
when t2.type = '702' then "路口失衡" when t2.type = '702' then "路口失衡"
......
...@@ -201,4 +201,22 @@ ...@@ -201,4 +201,22 @@
id=#{id} id=#{id}
</update> </update>
<!-- 新增表t_analysis_problem_cross_day信息 -->
<insert id="insertAnalysisProblemCrossDay">
insert into t_analysis_problem_cross_day (id,cross_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
select UUID(), a.cross_id, b.area_id,a.category,a.type,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) ) as duration ,
DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d') as dt , now()
from t_event_info a
left join t_base_cross_info b on a.cross_id = b.id
where DATE_FORMAT(a.start_time,'%Y-%m-%d') = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y-%m-%d') and a.type in (701,702,703)
group by a.cross_id, b.area_id,a.category,a.type
</insert>
<!-- 根据条件查询表t_analysis_problem_cross_day信息 -->
<select id="checkData" resultMap="AnalysisProblemCrossDayMap">
SELECT dt
FROM t_analysis_problem_cross_day
WHERE dt = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d')
</select>
</mapper> </mapper>
...@@ -163,4 +163,23 @@ ...@@ -163,4 +163,23 @@
,#{insertTime} ,#{insertTime}
) )
</insert> </insert>
<!-- 新增表t_analysis_problem_green_day信息 -->
<insert id="insertAnalysisProblemGreenDay">
insert into t_analysis_problem_green_day (id,green_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
select UUID(), a.green_id, b.area_id,a.category,a.type,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) ) as duration ,
DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d') as dt , now()
from t_event_info a
left join t_greenwave_info b on a.green_id = b.id
where DATE_FORMAT(a.start_time,'%Y-%m-%d') = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y-%m-%d') and a.type in (705,706,707) and a.green_id != ''
group by a.cross_id, b.area_id,a.category,a.type
</insert>
<!-- 根据条件查询表t_analysis_problem_green_day信息 -->
<select id="checkData" resultMap="AnalysisProblemGreenDayMap">
SELECT dt
FROM t_analysis_problem_green_day
WHERE dt = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d')
</select>
</mapper> </mapper>
...@@ -69,8 +69,8 @@ public class CodeGeneratorMyBatis1 { ...@@ -69,8 +69,8 @@ public class CodeGeneratorMyBatis1 {
// 全局配置 // 全局配置
GlobalConfig gc = new GlobalConfig(); GlobalConfig gc = new GlobalConfig();
String projectPath = "./signal-optimize-service"; // String projectPath = "./signal-optimize-service";
// String projectPath = "./wj-gernerator/output"; String projectPath = "./wj-gernerator/output";
gc.setOutputDir(projectPath+"/src/main/java"); gc.setOutputDir(projectPath+"/src/main/java");
gc.setAuthor(AUTHOR); gc.setAuthor(AUTHOR);
...@@ -144,6 +144,8 @@ public class CodeGeneratorMyBatis1 { ...@@ -144,6 +144,8 @@ public class CodeGeneratorMyBatis1 {
templateConfig.setServiceImpl("templates/mybatis1/providerImpl.java"); templateConfig.setServiceImpl("templates/mybatis1/providerImpl.java");
templateConfig.setController("templates/mybatis1/restServer.java"); templateConfig.setController("templates/mybatis1/restServer.java");
//使默认的xml目录不再生成,使用自定义的resource/mapper输出目录
templateConfig.setXml(null);
mpg.setTemplate(templateConfig); mpg.setTemplate(templateConfig);
...@@ -168,10 +170,10 @@ public class CodeGeneratorMyBatis1 { ...@@ -168,10 +170,10 @@ public class CodeGeneratorMyBatis1 {
strategy.setFieldPrefix("t_","s_","dt_","i_","bs_"); strategy.setFieldPrefix("t_","s_","dt_","i_","bs_");
strategy.setTablePrefix("t_"); strategy.setTablePrefix("t_");
mpg.setStrategy(strategy); mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine()); mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute(); mpg.execute();
System.out.println("MyBatis Plus Code Generator Finished!!"); System.out.println("MyBatis Plus Code Generator Finished!!");
......
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