Commit 2a945f39 authored by wangtao's avatar wangtao

交通事件信息 增加根据条件查询数据 以及相关基础代码生成

parent eecedc55
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);
}
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);
}
}
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