xboot-core/src/main/java/cn/exrick/xboot/core/entity/Department.java
@@ -49,6 +49,12 @@ @ApiModelProperty(value = "是否启用 0启用 -1禁用") private Integer status = CommonConstant.STATUS_NORMAL; @ApiModelProperty(value = "经度") private String lng; @ApiModelProperty(value = "维度") private String lat; @Transient @TableField(exist = false) @ApiModelProperty(value = "父节点名称") xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/EventLogController.java
New file @@ -0,0 +1,77 @@ package cn.exrick.xboot.your.controller; import cn.exrick.xboot.core.common.utils.PageUtil; import cn.exrick.xboot.core.common.utils.ResultUtil; import cn.exrick.xboot.core.common.vo.PageVo; import cn.exrick.xboot.core.common.vo.Result; import cn.exrick.xboot.your.entity.EventLog; import cn.exrick.xboot.your.service.IEventLogService; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @author whj */ @Slf4j @RestController @Api(tags = "事件日志表管理接口") @RequestMapping("/xboot/eventLog") @Transactional public class EventLogController { @Autowired private IEventLogService iEventLogService; @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @ApiOperation(value = "通过id获取") public Result<EventLog> get(@PathVariable String id) { EventLog eventLog = iEventLogService.getById(id); return new ResultUtil<EventLog>().setData(eventLog); } @RequestMapping(value = "/getAll", method = RequestMethod.GET) @ApiOperation(value = "获取全部数据") public Result<List<EventLog>> getAll() { List<EventLog> list = iEventLogService.list(); return new ResultUtil<List<EventLog>>().setData(list); } @RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "分页获取") public Result<IPage<EventLog>> getByPage(PageVo page) { IPage<EventLog> data = iEventLogService.page(PageUtil.initMpPage(page)); return new ResultUtil<IPage<EventLog>>().setData(data); } @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST) @ApiOperation(value = "编辑或更新数据") public Result<EventLog> saveOrUpdate(EventLog eventLog) { if (iEventLogService.saveOrUpdate(eventLog)) { return new ResultUtil<EventLog>().setData(eventLog); } return new ResultUtil<EventLog>().setErrorMsg("操作失败"); } @RequestMapping(value = "/delByIds", method = RequestMethod.POST) @ApiOperation(value = "批量通过id删除") public Result<Object> delAllByIds(@RequestParam String[] ids) { for (String id : ids) { iEventLogService.removeById(id); } return ResultUtil.success("批量通过id删除数据成功"); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java
@@ -5,7 +5,9 @@ import cn.exrick.xboot.core.common.utils.SecurityUtil; import cn.exrick.xboot.core.common.vo.PageVo; import cn.exrick.xboot.core.common.vo.Result; import cn.exrick.xboot.core.entity.Department; import cn.exrick.xboot.core.entity.User; import cn.exrick.xboot.core.service.DepartmentService; import cn.exrick.xboot.core.service.UserService; import cn.exrick.xboot.your.entity.*; import cn.exrick.xboot.your.service.*; @@ -59,6 +61,9 @@ @Autowired private ICarService iCarService; @Autowired private DepartmentService departmentService; @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @ApiOperation(value = "通过id获取") public Result<OrderTask> get(@PathVariable String id) { @@ -105,11 +110,21 @@ map.put("sum",sum); map.put("name",""); if(list.size()>0){ String areaSectionId = list.get(0).getAreaSectionId(); OrderTask orderTask = list.get(0); String areaSectionId = orderTask.getAreaSectionId(); AreaSection a = iAreaSectionService.getById(areaSectionId); map.put("name",a.getName()); Area area2 = iAreaService.getById(orderTask.getAreaId()); map.put("name",area2.getName()+a.getName()); list.clear(); } map.put("lng",""); map.put("lat",""); List<String> deparmentIds = securityUtil.getDeparmentIds(); if(deparmentIds.size()>0){ Department department = departmentService.get(deparmentIds.get(0)); map.put("lng",department.getLng()); map.put("lat",department.getLat()); } return new ResultUtil<Object>().setData(map); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
@@ -1,8 +1,20 @@ package cn.exrick.xboot.your.controller.pc; import cn.exrick.xboot.core.common.redis.RedisTemplateHelper; import cn.exrick.xboot.core.common.utils.PageUtil; import cn.exrick.xboot.core.common.utils.ResultUtil; import cn.exrick.xboot.core.common.vo.PageVo; import cn.exrick.xboot.core.common.vo.Result; import cn.exrick.xboot.your.entity.Car; import cn.exrick.xboot.your.entity.EventLog; import cn.exrick.xboot.your.entity.OrderTask; import cn.exrick.xboot.your.service.ICarService; import cn.exrick.xboot.your.service.IEventLogService; import cn.exrick.xboot.your.service.IOrderTaskService; import cn.exrick.xboot.your.util.HaiKangPost; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -25,6 +37,15 @@ @Autowired private RedisTemplateHelper redisTemplateHelper; @Autowired private IOrderTaskService iOrderTaskService; @Autowired private IEventLogService iEventLogService; @Autowired private ICarService iCarService; @RequestMapping(value = "/getIndex1", method = RequestMethod.GET) @ApiOperation(value = "获取首页数据") public Result<Object> getIndex1() { @@ -35,4 +56,38 @@ } return new ResultUtil<Object>().setData(map); } @RequestMapping(value = "/getTodayTask", method = RequestMethod.GET) @ApiOperation(value = "获取今日配送任务") public Result<Object> getTodayTask() { QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); String format = DateUtil.format(new Date(), "yyyy-MM-dd"); wrapper2.eq("a.send_date",format); // wrapper2.orderByAsc("a.seq"); List<OrderTask> list = iOrderTaskService.list3(format); return new ResultUtil<Object>().setData(list); } @RequestMapping(value = "/getEventLog", method = RequestMethod.GET) @ApiOperation(value = "获取事件日志") public Result<Object> getEventLog() { QueryWrapper<EventLog> wrapper2 = new QueryWrapper<EventLog>(); PageVo page = new PageVo(); page.setPageNumber(1); page.setPageSize(20); page.setOrder("desc"); page.setSort("createTime"); IPage<EventLog> data = iEventLogService.page(PageUtil.initMpPage(page),wrapper2); return new ResultUtil<Object>().setData(data.getRecords()); } // @RequestMapping(value = "/getCars", method = RequestMethod.GET) // @ApiOperation(value = "获取车辆信息") // public Result<Object> getCars() { // List<Car> list = iCarService.list(); // String codes[] = new String[list.size()]; // // HaiKangPost.findLatestGps() // return new ResultUtil<Object>().setData(data.getRecords()); // } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Alarm.java
@@ -28,6 +28,11 @@ @ApiModelProperty(value = "车辆id") private String carId; //1:疲劳驾驶 //2:接打电话 //3:不系安全带 //4:抽烟 //5:车厢异常开启 @ApiModelProperty(value = "具体类型如下") private int type; xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/EventLog.java
New file @@ -0,0 +1,49 @@ package cn.exrick.xboot.your.entity; import cn.exrick.xboot.core.base.XbootBaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.Transient; import java.util.Date; import java.util.List; /** * @author Exrick */ @Data @Entity @DynamicInsert @DynamicUpdate @Table(name = "t_event_log") @TableName("t_event_log") @ApiModel(value = "事件日志表") public class EventLog extends XbootBaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "车牌号") private String carNo; //1:疲劳驾驶 //2:接打电话 //3:不系安全带 //4:抽烟 //5:车厢异常开启 //6:配送完成 @ApiModelProperty(value = "事件类型") private int type; @ApiModelProperty(value = "事件关联id") private String refId; } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderTask.java
@@ -109,6 +109,21 @@ @Transient @TableField(exist = false) @ApiModelProperty(value = "车牌号") private String carNo; @Transient @TableField(exist = false) @ApiModelProperty(value = "区域名称") private String areaName; @Transient @TableField(exist = false) @ApiModelProperty(value = "分段名称") private String areaSectionName; @Transient @TableField(exist = false) @ApiModelProperty(value = "订单详情") private List<OrderDetail> orderDetails; } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/EventLogMapper.java
New file @@ -0,0 +1,14 @@ package cn.exrick.xboot.your.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.exrick.xboot.your.entity.EventLog; import java.util.List; /** * 事件日志表数据处理层 * @author whj */ public interface EventLogMapper extends BaseMapper<EventLog> { } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/OrderTaskMapper.java
@@ -7,10 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.*; import org.apache.ibatis.type.JdbcType; import java.util.List; @@ -36,4 +33,12 @@ @Select("SELECT count(id) FROM t_order_task where likes=1") int countLike(); @Select("select b.car_no as carNo1,c.name as name1,d.name as name2,count(a.area_section_id) as num1,sum(case when a.status=0 then 1 else 0 end) as num2 from t_order_task a LEFT JOIN t_car b on a.car_id=b.id LEFT JOIN t_area c on a.area_id=c.id LEFT JOIN t_area_ection d on a.area_section_id=d.id where DATE_FORMAT(a.send_date,'%Y-%m-%d')=#{date} GROUP BY a.area_section_id,b.car_no,c.name,d.name") @Results({@Result(column="carNo1", property="carNo", jdbcType = JdbcType.VARCHAR), @Result(column="name1", property="areaName", jdbcType = JdbcType.VARCHAR), @Result(column="name2", property="areaSectionName", jdbcType = JdbcType.VARCHAR), @Result(column="num1", property="num", jdbcType = JdbcType.INTEGER), @Result(column="num2", property="level", jdbcType = JdbcType.INTEGER)}) List<OrderTask> list3(String date); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IEventLogService.java
New file @@ -0,0 +1,14 @@ package cn.exrick.xboot.your.service; import com.baomidou.mybatisplus.extension.service.IService; import cn.exrick.xboot.your.entity.EventLog; import java.util.List; /** * 事件日志表接口 * @author whj */ public interface IEventLogService extends IService<EventLog> { } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IOrderTaskService.java
@@ -21,4 +21,6 @@ int sumStatus(int i); int countLike(); List<OrderTask> list3(String date); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IEventLogServiceImpl.java
New file @@ -0,0 +1,26 @@ package cn.exrick.xboot.your.serviceimpl; import cn.exrick.xboot.your.mapper.EventLogMapper; import cn.exrick.xboot.your.entity.EventLog; import cn.exrick.xboot.your.service.IEventLogService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; /** * 事件日志表接口实现 * @author whj */ @Slf4j @Service @Transactional public class IEventLogServiceImpl extends ServiceImpl<EventLogMapper, EventLog> implements IEventLogService { @Autowired private EventLogMapper eventLogMapper; } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IOrderTaskServiceImpl.java
@@ -53,4 +53,9 @@ public int countLike() { return orderTaskMapper.countLike(); } @Override public List<OrderTask> list3(String date) { return orderTaskMapper.list3(date); } } xboot-modules/xboot-your/src/main/resources/mapper/EventLogMapper.xml
New file @@ -0,0 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="cn.exrick.xboot.your.mapper.EventLogMapper"> </mapper>