Commit f223e189 authored by Zheng Yi Fan's avatar Zheng Yi Fan

Merge remote-tracking branch 'origin/master'

parents 40b7c809 d7edecad
package net.wanji.opt.controllerv2.evaluation;
import net.wanji.common.framework.Constants;
import net.wanji.common.framework.dubbointerface.BaseDubboInterface;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.AbstractRestServer;
import net.wanji.common.framework.dubbointerface.BaseDubboInterface;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.AbstractRestServer;
import net.wanji.common.framework.rest.impl.AbstractRestServerImpl;
import net.wanji.opt.servicev2.evaluation.EventInfoService;
import net.wanji.opt.entity.evaluation.EventInfo;
import net.wanji.common.framework.rest.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 交通事件信息 接口API
* </p>
* @version 1.0
* @author wangtao
* @Date 2025-03-18
*/
@RestController
@Slf4j
@RequestMapping("/event-info")
@Api(value="EventInfoController", description="交通事件信息接口", tags = "交通事件信息")
public class EventInfoController extends AbstractRestServerImpl<EventInfo> implements AbstractRestServer<EventInfo>{
@Autowired
private EventInfoService eventInfoService;
@Override
public EventInfoService getBaseDubboInterface() {
return this.eventInfoService;
}
/**
* 获取所有交通事件信息记录
*
* @return JsonViewObject
*/
@ApiOperation(value = "交通事件信息-获取所有记录", notes = "获取所有交通事件信息记录", response = EventInfo.class, produces = MediaType.APPLICATION_JSON,hidden = true)
@GetMapping(value = "/byAll", produces = MediaType.APPLICATION_JSON)
@Override
public JsonViewObject getAll() {
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
List<EventInfo> list = this.getBaseDubboInterface().findAll();
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@ApiOperation(value = "交通事件信息-根据开始以及结束时间查询交通事件信息", notes = "获取所有交通事件信息记录", response = EventInfo.class, produces = MediaType.APPLICATION_JSON,hidden = false)
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String"),
@ApiImplicitParam(name = "crossId", value = "路口id", required = true, dataType = "String"),
})
@GetMapping(value = "getListByStartAndEnd")
public JsonViewObject getListByStartAndEnd(String startTime, String endTime, String crossId){
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
Map<String, Object> map = new HashMap<>();
map.put("startTime",startTime);
map.put("endTime",endTime);
map.put("crossId",crossId);
try {
List<EventInfo> list = this.getBaseDubboInterface().getListByStartAndEnd(map);
jsonView.success(list);
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
/**
* 根据id查询交通事件信息记录
*
* @param id
* @return JsonViewObject
*/
@ApiOperation(value = "交通事件信息-根据id查询记录", notes = "根据id查询交通事件信息记录", response = EventInfo.class, produces = MediaType.APPLICATION_JSON,hidden = true)
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON)
@Override
public JsonViewObject getById(@PathVariable String id) {
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
try {
EventInfo entity = this.getBaseDubboInterface().findById(id);
jsonView.success(entity);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("AbstractRestServerImpl getById error, id:{}", id, e);
}
return jsonView;
}
@ApiOperation(value = "交通事件信息-根据条件查询记录", notes = "根据条件查询记录", consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/byCondition", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@Override
public JsonViewObject getByWhere(@RequestBody EventInfo entity) {
return super.getByWhere(entity);
}
@ApiOperation(value = "交通事件信息-根据条件分页查询记录", notes = "根据条件分页查询记录", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,hidden = true)
@PostMapping(value = "/byPage", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ResponseBody
public JsonViewObject getPage(@RequestBody Page<EventInfo> page){
return super.getPage(page);
}
/**
* 根据id删除
*
* @param ids
* @return JsonViewObject
*/
@ApiOperation(value = "交通事件信息-根据多个id删除记录", notes = "根据多个id删除记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON ,hidden = true)
@ApiImplicitParams(value = {
@ApiImplicitParam(paramType = "query", name = "ids", dataType = "String", required = true, value = "多个记录id,用逗号分隔", example = "1,2")
})
@GetMapping(value = "/deleting", produces = MediaType.APPLICATION_JSON)
public JsonViewObject deleteByIds(String ids) {
return super.deleteByIds(ids);
}
/**
* 新建记录
*
* @param entity
* @return JsonViewObject
*/
@ApiOperation(value = "交通事件信息-新建记录", notes = "新建记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,hidden = true)
@PostMapping(value = "/creating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public JsonViewObject save( @RequestBody EventInfo entity){
return super.save(entity);
}
/**
* 修改记录
*
* @param entity
* @return
*/
@ApiOperation(value = "交通事件信息-修改记录", notes = "修改记录", response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,hidden = true)
@PostMapping(value = "/updating", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public JsonViewObject update(@RequestBody EventInfo entity){
return super.update(entity);
}
}
package net.wanji.opt.dao.mapper.evaluation;
import net.wanji.opt.entity.evaluation.EventInfo;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
/**
* <p>
* 交通事件信息
* </p>
*
* @Author wangtao
* @Date 2025-03-18
*/
public interface EventInfoMapper extends BaseInterfaceMapper<EventInfo> {
List<EventInfo> getListByStartAndEnd(Map<String, Object> map);
}
......@@ -73,6 +73,18 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble
* @param
*/
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
* @param 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.entity.evaluation;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import net.wanji.common.framework.domain.TrackableEntity;
import java.util.Date;
import java.math.BigDecimal;
/**
* <p>
* 交通事件信息
* </p>
*
* @Author wangtao
* @Date 2025-03-18
*/
@Data
@ApiModel(value="EventInfo对象", description="交通事件信息")
public class EventInfo extends TrackableEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long oid;
@ApiModelProperty(value = "车牌号")
private String plateNo;
@ApiModelProperty(value = "参与者类别 1:机动车 2:非机动车 3:行人")
private String objectType;
@ApiModelProperty(value = "可信度")
private Integer confidence;
@ApiModelProperty(value = "检测时间")
private Date detectTime;
@ApiModelProperty(value = "事件等级:1扣分 2 罚款 3警告 0 未知")
private Integer grade;
@ApiModelProperty(value = "事件地点描述")
private String placeDesc;
@ApiModelProperty(value = "发生地点经度")
private BigDecimal lng;
@ApiModelProperty(value = "发生地点纬度")
private BigDecimal lat;
@ApiModelProperty(value = "事件一级类别 事件一级类别 1:机动车事件 2:非机动车事件 3:行人事件")
private String category;
@ApiModelProperty(value = "二级类别")
private String type;
@ApiModelProperty(value = "事件发生时间")
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date startTime;
@ApiModelProperty(value = "事件结束时间")
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date endTime;
@ApiModelProperty(value = "事件持续时长,单位秒")
private Integer duration;
@ApiModelProperty(value = "事件来源 1:系统检测 2:接处警 3:互联网 4:交管部门 5:大脑")
private String source;
@ApiModelProperty(value = "入库时间")
private Date ruksj;
@ApiModelProperty(value = "车道id")
private String laneId;
@ApiModelProperty(value = "路段id")
private String rid;
@ApiModelProperty(value = "渠化id")
private String segmentId;
@ApiModelProperty(value = "路口id")
private String crossId;
@ApiModelProperty(value = "路口所属绿波编号")
private String greenId;
@ApiModelProperty(value = "关联的事件摄像头信息ID")
private Long cameraOid;
@ApiModelProperty(value = "事件序列号作为主键")
private String eventSerialNumber;
private String dataStatus;
@ApiModelProperty(value = "目标id")
private String globalId;
private Integer stationId;
private String eventId;
@ApiModelProperty(value = "备注")
private String remark;
private String extend;
@ApiModelProperty(value = "分区字段")
private Integer dt;
@ApiModelProperty(value = "视频地址")
private String videoUrls;
@ApiModelProperty(value = "目标具体类型")
private Integer targetType;
@ApiModelProperty(value = "告警状态 0未处理 1分析中 2优化中 3优化完 4已结束")
private Integer alarmStatus;
@ApiModelProperty(value = "优化状态 0 未优化 1-优化过 根据上面告警状态如果有2 3状态认为优化过 ")
private Integer optStatus;
@ApiModelProperty(value = "修改时间")
private Date modifyTime;
@ApiModelProperty(value = "方向 1北...8西北")
private String dir;
@ApiModelProperty(value = "事件转向")
private String turn;
@ApiModelProperty(value = "失衡指数1-10")
private Double unbalanceIndex;
@ApiModelProperty(value = "溢出指数1-10 溢出程度的刻画(没溢出:1,即将溢出:3,溢出:5,溢停:7)")
private Double spilloverIndex;
@ApiModelProperty(value = "交通指数")
private Double trafficIndex;
/*****非数据库字段*******/
private String typeName;
//用于存放日期差-分钟
private String diffTime;
}
package net.wanji.opt.servicev2.evaluation;
import net.wanji.opt.entity.evaluation.EventInfo;
import net.wanji.common.framework.dubbointerface.BaseDubboInterface;
import java.util.List;
import java.util.Map;
/**
* <p>
* 交通事件信息
* </p>
*
* @Author wangtao
* @Date 2025-03-18
*/
public interface EventInfoService extends BaseDubboInterface<EventInfo> {
List<EventInfo> getListByStartAndEnd(Map<String, Object> map);
}
package net.wanji.opt.servicev2.evaluation.impl;
import net.wanji.common.framework.dubbointerface.impl.BaseDubboInterfaceImpl;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.entity.evaluation.EventInfo;
import net.wanji.opt.servicev2.evaluation.EventInfoService;
import net.wanji.opt.dao.mapper.evaluation.EventInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* <p>
* 交通事件信息
* </p>
*
* @Author wangtao
* @Date 2025-03-18
*/
@Slf4j
@Component
@Service
public class EventInfoServiceImpl extends BaseDubboInterfaceImpl<EventInfo> implements EventInfoService {
@Resource
private EventInfoMapper eventInfoMapper;
@Override
public BaseInterfaceMapper<EventInfo> getBaseInterfaceMapper() {
return this.eventInfoMapper;
}
public List<EventInfo> getListByStartAndEnd(Map<String, Object> map){
return this.eventInfoMapper.getListByStartAndEnd(map);
}
}
package net.wanji.opt.servicev2.implv2;
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 com.github.pagehelper.PageHelper;
......@@ -19,6 +18,7 @@ import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossSchemeRings;
import net.wanji.databus.vo.LightsStatusVO2;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.common.RedisUtils;
import net.wanji.opt.common.enums.EventInfoTypeEnum;
import net.wanji.opt.common.enums.GreenBeltDirEnum;
......@@ -70,6 +70,8 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
private RedisUtils redisUtil;
@Resource
private BaseCrossSchemeMapper baseCrossSchemeMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
private static List<OptMonitoringVO> greenListCache = new ArrayList<>(10);
private static List<OptMonitoringVO> crossListCache = new ArrayList<>(80);
......@@ -310,10 +312,12 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
if (last.getCount() == 0 || last.getDuration() == 0) {
continue;
}
double countRate = (result.getCount() - last.getCount()) / last.getCount() * 100;
double durationRate = (result.getDuration() - last.getDuration()) / last.getCount() * 100;
result.setCountRate((int) countRate);
result.setDurationRate((int) durationRate);
double countOffset = (double) result.getCount() - last.getCount();
double durationOffset = (double) result.getDuration() - last.getDuration();
double countRate = countOffset / last.getCount();
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 {
for (GreenwaveCrossPO greenwaveCrossPO : greenwaveCrossPOS) {
String crossId = greenwaveCrossPO.getCrossId();
String crossName = baseCrossInfoCache.getCrossName(crossId);
GreenOptCrossOffsetVO.CrossOffsetDetail oriOffsetDetail = getOriOffsetDetail(crossId);
oriOffsetDetail.setCrossName(crossName);
oriOffsetDetails.add(oriOffsetDetail);
GreenOptCrossOffsetVO.CrossOffsetDetail curOffsetDetail = getCurOffsetDetail(crossId, oriOffsetDetail);
curOffsetDetail.setCrossName(crossName);
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 {
public static class CrossOffsetDetail {
@ApiModelProperty(value = "路口编号")
private String crossId;
@ApiModelProperty(value = "路口名称")
private String crossName;
@ApiModelProperty(value = "方案相位差")
private Integer offset;
@ApiModelProperty(value = "方案号")
......
......@@ -29,5 +29,7 @@ public class StatisticsEventTypeCountTimeVO {
private Integer countRate;
@ApiModelProperty(value = "同比比例,上一周同一持续时间次数比例")
private Integer durationRate;
@ApiModelProperty(value = "发生时间")
private String startTime;
}
......@@ -296,7 +296,7 @@
WHERE dt = CURDATE()
AND type IN ('701', '702', '703', '707')
AND start_time <![CDATA[ < ]]> NOW()
AND IFNULL(end_time, NOW()) <![CDATA[ < ]]> NOW()
AND IFNULL(end_time, NOW()) <![CDATA[ > ]]> NOW()
GROUP BY cross_id
) latest_event ON t1.id = latest_event.cross_id
LEFT JOIN t_event_info t2
......@@ -305,7 +305,7 @@
AND t2.dt = CURDATE()
AND t2.type IN ('701', '702', '703', '707')
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
ORDER BY t2.start_time DESC
</select>
......@@ -359,7 +359,7 @@
(
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,
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
when t2.type = '706' then "干线缓行"
when t2.type = '707' then "干线拥堵"
......@@ -371,7 +371,7 @@
union all
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,
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
when t2.type = '701' then "相位空放"
when t2.type = '702' then "路口失衡"
......
......@@ -201,4 +201,22 @@
id=#{id}
</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>
......@@ -163,4 +163,23 @@
,#{insertTime}
)
</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>
......@@ -69,8 +69,8 @@ public class CodeGeneratorMyBatis1 {
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = "./signal-optimize-service";
// String projectPath = "./wj-gernerator/output";
// String projectPath = "./signal-optimize-service";
String projectPath = "./wj-gernerator/output";
gc.setOutputDir(projectPath+"/src/main/java");
gc.setAuthor(AUTHOR);
......@@ -144,6 +144,8 @@ public class CodeGeneratorMyBatis1 {
templateConfig.setServiceImpl("templates/mybatis1/providerImpl.java");
templateConfig.setController("templates/mybatis1/restServer.java");
//使默认的xml目录不再生成,使用自定义的resource/mapper输出目录
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
......@@ -168,10 +170,10 @@ public class CodeGeneratorMyBatis1 {
strategy.setFieldPrefix("t_","s_","dt_","i_","bs_");
strategy.setTablePrefix("t_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
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