Commit 90b9967623d15eaea18dc8e40d7897b3f72aea9a
1 parent
12d0046c
新增定时任务,每月25号创建下个月的gps表
Showing
5 changed files
with
48 additions
and
1 deletions
trash-common/src/main/java/com/trash/common/utils/DateUtils.java
| ... | ... | @@ -183,4 +183,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils |
| 183 | 183 | } |
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | + | |
| 187 | + public static String getNextMonth(Date date) { | |
| 188 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM"); | |
| 189 | + String format = sdf.format(date); | |
| 190 | + String year = format.substring(0,4); | |
| 191 | + String month = format.substring(4,6); | |
| 192 | + int i = Integer.parseInt(month); | |
| 193 | + if(i==12){ | |
| 194 | + year = String.valueOf(Integer.parseInt(year)+1); | |
| 195 | + month = "01"; | |
| 196 | + }else{ | |
| 197 | + month = String.valueOf(i+1); | |
| 198 | + } | |
| 199 | + return year+month; | |
| 200 | + } | |
| 186 | 201 | } | ... | ... |
trash-quartz/src/main/java/com/trash/quartz/task/GpsTask.java
| ... | ... | @@ -10,6 +10,7 @@ import org.springframework.stereotype.Component; |
| 10 | 10 | |
| 11 | 11 | import java.util.ArrayList; |
| 12 | 12 | import java.util.Collection; |
| 13 | +import java.util.Date; | |
| 13 | 14 | import java.util.List; |
| 14 | 15 | |
| 15 | 16 | @Component("GpsTask") |
| ... | ... | @@ -44,4 +45,10 @@ public class GpsTask { |
| 44 | 45 | |
| 45 | 46 | } |
| 46 | 47 | } |
| 48 | + | |
| 49 | + public void createGps(){ | |
| 50 | + //获取下个月的年月yyyyMM | |
| 51 | + String nextMonth = DateUtils.getNextMonth(new Date()); | |
| 52 | + gpsOrientationMapper.createGpsTable(nextMonth); | |
| 53 | + } | |
| 47 | 54 | } | ... | ... |
trash-ui/src/views/gps/trajectory/index.vue
| ... | ... | @@ -235,7 +235,7 @@ export default { |
| 235 | 235 | }).then(async (AMap) => { |
| 236 | 236 | _this.map = await new AMap.Map("trajectoryMap", { //设置地图容器id |
| 237 | 237 | center: [113.01814545605467, 28.201039299894283], // 初始化地图中心点位置 |
| 238 | - zoom: 17, //初始化地图层级 | |
| 238 | + zoom: 11, //初始化地图层级 | |
| 239 | 239 | resizeEnable: true, |
| 240 | 240 | }); |
| 241 | 241 | if (_this.lineArr.length !== 0) { | ... | ... |
trash-unit/src/main/java/com/trash/gps/mapper/GpsOrientationMapper.java
| ... | ... | @@ -62,5 +62,18 @@ public interface GpsOrientationMapper { |
| 62 | 62 | int deleteGpsOrientationByIds(Long[] ids); |
| 63 | 63 | |
| 64 | 64 | |
| 65 | + /** | |
| 66 | + * 查询gps数据轨迹回放列表 | |
| 67 | + * | |
| 68 | + * @param yearMonth 年月 | |
| 69 | + * @return gps数据轨迹回放集合 | |
| 70 | + */ | |
| 65 | 71 | List<GpsOrientation> selectCarCodeList(String yearMonth); |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 创建gps数据轨迹回放表 | |
| 75 | + * @param yearMonth 年月 | |
| 76 | + * @return 结果 | |
| 77 | + */ | |
| 78 | + int createGpsTable(String yearMonth); | |
| 66 | 79 | } | ... | ... |
trash-unit/src/main/resources/mapper/unit/GpsOrientationMapper.xml
| ... | ... | @@ -77,4 +77,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 77 | 77 | group by terminal_number,car_code |
| 78 | 78 | </select> |
| 79 | 79 | |
| 80 | + <update id="createGpsTable" parameterType="String"> | |
| 81 | + CREATE TABLE IF NOT EXISTS gps_orientation_${yearMonth} ( | |
| 82 | + id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 83 | + terminal_number varchar(20) DEFAULT NULL COMMENT '终端号', | |
| 84 | + longitude varchar(20) DEFAULT NULL COMMENT '经度', | |
| 85 | + latitude varchar(20) DEFAULT NULL COMMENT '纬度', | |
| 86 | + create_time datetime DEFAULT NULL COMMENT '创建时间', | |
| 87 | + car_code varchar(20) DEFAULT NULL COMMENT '车牌号', | |
| 88 | + PRIMARY KEY (id) | |
| 89 | + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='gps定位表'; | |
| 90 | + </update> | |
| 91 | + | |
| 80 | 92 | </mapper> |
| 81 | 93 | \ No newline at end of file | ... | ... |