Commit e12abcb2 authored by daniel's avatar daniel

feat(road): 新增轨迹排序功能

parent c2cf9f8d
......@@ -40,6 +40,9 @@ public class Path {
private String createTime;
@ApiModelProperty(value = "轨迹排序", notes = "轨迹排序")
private Integer sort;
@Override
public boolean equals(Object o) {
if (this == o) {
......
......@@ -46,6 +46,12 @@ public class Road {
private String createTime;
@ApiModelProperty(value = "轨迹排序", notes = "轨迹排序")
private Integer sort;
@Override
public boolean equals(Object o) {
if (this == o) {
......
......@@ -53,4 +53,7 @@ public class RoadGpsPoint {
private double fileSize;
@ApiModelProperty(value = "排序", notes = "排序")
private Integer sort;
}
package com.dlbridge.jadp.plugins.cmpt.dao.mapper;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusTicketParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusVerifyRecordParam;
import com.dlbridge.jadp.plugins.cmpt.dto.*;
import feign.Param;
......@@ -70,5 +71,12 @@ public interface BusMapper {
*/
List<BusVerificationRecord> selectVerifyRecordByPage(BusVerifyRecordParam queryDTO);
/**
* 查询车票记录列表
* @param queryDTO 查询参数
* @return 查询车票记录列表
*/
List<BusTicketVerification> queryBusTicketByPage(BusTicketParam queryDTO);
}
......@@ -232,4 +232,19 @@
AND bvr.ticket_no = #{ticketNo}
</if>
</select>
<select id="queryBusTicketByPage" resultType="com.dlbridge.jadp.plugins.cmpt.dto.BusTicketVerification">
SELECT
*
FROM gksite.bus_ticket_verification
WHERE cmpt_id = #{cmptId}
<if test="keyword != null and keyword != '' ">
AND (ticket_no LIKE #{keyword} OR passenger_name LIKE #{keyword} OR passenger_phone LIKE #{keyword})
</if>
<if test="ticketStatus != null and ticketStatus != '' ">
AND ticket_status = #{ticketStatus}
</if>
<if test="scheduleId != null and scheduleId != ''">
AND schedule_id = #{scheduleId}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -39,4 +39,12 @@ public interface RoadMapper {
* @return 配置信息
*/
Map<String, String> getMultiRouteInfo(Integer cmptId);
/**
* 更新路线排序
* @param pathId 路线ID
* @param sort 排序
* @return 更新数量
*/
int updateGpsPathSort(int pathId, int sort);
}
......@@ -11,6 +11,7 @@
, a.id pathId
, a.path_name pathName
, a.create_time createTime
, a.sort
from gk_roads_gps a
WHERE 1=1
AND a.is_delete = 0
......@@ -46,11 +47,13 @@
, case when b.item_type = 2 then '团队赛' when b.item_type = 1 then '个人赛' else '其他' end roadTypeName
, c.id pathId
, c.path_name pathName
, c.sort
from gk_road a
LEFT JOIN geerunner.cmpt_item b ON a.cmpt_id = b.cmpt_id AND a.road_id = b.item_id
LEFT JOIN gk_roads_gps c ON c.cmpt_id = a.cmpt_id AND a.road_id=c.road_id AND c.is_delete = 0
LEFT JOIN gk_roads_gps c ON c.cmpt_id = a.cmpt_id AND a.road_id = c.road_id AND c.is_delete = 0
WHERE a.cmpt_id = #{cmptId}
AND a.is_delete = 0
ORDER BY c.sort ASC
</select>
<update id="delete">
......@@ -82,8 +85,8 @@
</insert>
<insert id="saveGps" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into gk_roads_gps(cmpt_id ,road_id,points,path_name,file_name,file_url,file_size,create_time)
values (#{cmptId},#{roadId},#{points},#{pathName},#{fileName},#{fileUrl},#{fileSize},now())
insert into gk_roads_gps(cmpt_id ,road_id,points,path_name,file_name,file_url,file_size,create_time,sort)
values (#{cmptId},#{roadId},#{points},#{pathName},#{fileName},#{fileUrl},#{fileSize},now(),#{sort})
</insert>
<update id="updateRoadGps" parameterType="com.dlbridge.jadp.plugins.cmpt.bean.RoadGpsPoint">
......@@ -94,11 +97,12 @@
, file_url=#{fileUrl}
, file_size=#{fileSize}
, create_time=now()
, sort = #{sort}
where id = #{pathId}
</update>
<select id="getGps" resultType="com.dlbridge.jadp.plugins.cmpt.bean.RoadGpsPoint">
SELECT id,cmpt_id cmptId,road_id roadId,points,path_name pathName,file_name fileName,file_url fileUrl,file_size fileSize
SELECT id,cmpt_id cmptId,road_id roadId,points,path_name pathName,file_name fileName,file_url fileUrl,file_size fileSize,sort
FROM gk_roads_gps
WHERE road_id = #{roadId}
AND id = #{pathId}
......@@ -107,7 +111,7 @@
</select>
<select id="getRoadGpsList" resultType="com.dlbridge.jadp.plugins.cmpt.bean.RoadGpsPoint">
select id,cmpt_id cmptId,road_id roadId,points,path_name pathName,file_name fileName,file_url fileUrl,file_size fileSize
select id,cmpt_id cmptId,road_id roadId,points,path_name pathName,file_name fileName,file_url fileUrl,file_size fileSize,sort
from gk_roads_gps
where road_id = #{roadId}
AND is_delete = 0
......@@ -123,7 +127,11 @@
update gk_road set times = times+1
where road_id = #{roadId}
</update>
<update id="updateGpsPathSort">
update gk_roads_gps
set sort = #{sort}
where id = #{pathId}
</update>
<select id="getMultiRouteInfo" resultType="java.util.Map">
SELECT b.cmptName, concat(b.createUserId,'') createUserId, IFNULL(c.partner_id,'') partnerId
,IFNULL(c.is_multi_route, '1') isMultiRoute
......
package com.dlbridge.jadp.plugins.cmpt.dao.model.param;
import com.dlbridge.jadp.plugins.cmpt.dto.PageDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false)
@Data
public class BusTicketParam extends PageDTO {
private Integer cmptId;
private Integer ticketStatus;
private String keyword;
private Integer scheduleId;
}
......@@ -8,11 +8,13 @@ import lombok.Data;
@Data
public class BusVerifyStatistics {
private String scheduleName;
private Integer scheduleId;
private Integer verifyCount;
public BusVerifyStatistics() {}
public BusVerifyStatistics(String scheduleName, Integer verifyCount) {
public BusVerifyStatistics(Integer scheduleId, String scheduleName, Integer verifyCount) {
this.scheduleId = scheduleId;
this.scheduleName = scheduleName;
this.verifyCount = verifyCount;
}
......
......@@ -3,6 +3,7 @@ package com.dlbridge.jadp.plugins.cmpt.service;
import com.dlbridge.jadp.common.web.Result;
import com.dlbridge.jadp.plugins.cmpt.dao.mapper.BusMapper;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusTicketParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusVerifyRecordParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.vo.BusVerifyStatistics;
import com.dlbridge.jadp.plugins.cmpt.dto.*;
......@@ -25,6 +26,7 @@ import com.dlbridge.jadp.plugins.cmpt.utils.PageConvertUtil;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -227,18 +229,50 @@ public class BusService {
return busMapper.selectVerificationRecord(cmptId, verifierId, ticketNo);
}
// public List<BusVerifyStatistics> busVerifyStatistics(Integer cmptId) {
// List<BusVerificationRecord> records = busMapper.selectVerificationRecord(cmptId, null, null);
// Map<String, Long> scheduleCountMap = records.stream()
// .collect(Collectors.groupingBy(
// BusVerificationRecord::getScheduleName,
// Collectors.counting()
// ));
//
// // 转换为BusVerifyStatistics列表
// return scheduleCountMap.entrySet().stream()
// .map(entry -> new BusVerifyStatistics(entry.getKey(), entry.getValue().intValue()))
// .collect(Collectors.toList());
// }
/**
* 查询班车核销统计列表
* @param cmptId 赛事ID
* @return List<BusVerifyStatistics>
*/
public List<BusVerifyStatistics> busVerifyStatistics(Integer cmptId) {
List<BusVerificationRecord> records = busMapper.selectVerificationRecord(cmptId, null, null);
Map<String, Long> scheduleCountMap = records.stream()
// 按 scheduleId 和 scheduleName 进行分组统计
Map<Integer, Map<String, Long>> scheduleCountMap = records.stream()
.collect(Collectors.groupingBy(
BusVerificationRecord::getScheduleId, // 按 scheduleId 分组
Collectors.groupingBy(
BusVerificationRecord::getScheduleName,
Collectors.counting()
)
));
// 转换为BusVerifyStatistics列表
return scheduleCountMap.entrySet().stream()
.map(entry -> new BusVerifyStatistics(entry.getKey(), entry.getValue().intValue()))
.collect(Collectors.toList());
// 转换为 BusVerifyStatistics 列表
List<BusVerifyStatistics> statisticsList = new ArrayList<>();
for (Map.Entry<Integer, Map<String, Long>> entry : scheduleCountMap.entrySet()) {
Integer scheduleId = entry.getKey();
for (Map.Entry<String, Long> inner : entry.getValue().entrySet()) {
String scheduleName = inner.getKey();
Integer verifyCount = inner.getValue().intValue();
statisticsList.add(new BusVerifyStatistics(scheduleId, scheduleName, verifyCount));
}
}
return statisticsList;
}
/**
......@@ -268,10 +302,27 @@ public class BusService {
// List<BusVerificationRecord> list = busMapper.selectVerifyRecordByPage(queryDTO);
// return new PageInfo<>(list);
// }
/**
* 查询班车核销记录列表
* @param queryDTO 查询参数
* @return 班车核销记录分页列表
*/
public Page<List<BusVerificationRecord>> verifyPageRecord(BusVerifyRecordParam queryDTO) {
PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize());
List<BusVerificationRecord> list = busMapper.selectVerifyRecordByPage(queryDTO);
PageInfo<BusVerificationRecord> pageInfo = new PageInfo<>(list);
return PageConvertUtil.convert(pageInfo);
}
/**
* 查询车票记录列表
* @param queryDTO 查询参数
* @return 查询车票记录列表
*/
public Page<List<BusTicketVerification>> busTicketPage(BusTicketParam queryDTO) {
PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize());
List<BusTicketVerification> list = busMapper.queryBusTicketByPage(queryDTO);
PageInfo<BusTicketVerification> pageInfo = new PageInfo<>(list);
return PageConvertUtil.convert(pageInfo);
}
}
......@@ -49,37 +49,40 @@ public class RoadService {
/**
* 根据赛事、组别 获取路线列表
*
* @param cmptId 赛事ID
* @param roadId 路线ID
* @return 路线列表
*/
public List<Path> queryPaths(Integer cmptId, Integer roadId){
public List<Path> queryPaths(Integer cmptId, Integer roadId) {
return roadMapper.queryPaths(cmptId, roadId);
}
public List<Road> queryRoads(Integer cmptId) {
// log.info("=====queryRoads -> RoadService enter");
// log.info("=====queryRoads -> RoadService enter");
List<Road> roads = remoteService.getRoads(cmptId);
if(roads == null) {
if (roads == null) {
return null;
}
// for (Road road : roads) {
// log.info("RoadService api接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : roads) {
// log.info("RoadService api接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
List<Road> localRoads = roadMapper.queryRoadsMultiPath(cmptId);
// for (Road road : localRoads) {
// log.info("RoadService 数据库接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : localRoads) {
// log.info("RoadService 数据库接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
for (Road road : roads) { // 更新 插入操作
if (localRoads.contains(road)) {
Road rd = localRoads.get(localRoads.indexOf(road));
if (!rd.getName().equals(road.getName())) {
if (!rd.getName()
.equals(road.getName())) {
rd.setName(road.getName());
roadMapper.update(road);
}
// log.info("RoadService contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
// log.info("RoadService contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
} else {
roadMapper.save(road);
// log.info("RoadService not contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
// log.info("RoadService not contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
}
}
for (Road road : localRoads) { // 删除操作
......@@ -88,41 +91,43 @@ public class RoadService {
}
}
// for (Road road : localRoads) {
// log.info("RoadService 接口和api更新后数据 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : localRoads) {
// log.info("RoadService 接口和api更新后数据 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
return roadMapper.queryRoadsMultiPath(cmptId);
}
/**
* 获取组别(多路线支持)
*
* @param cmptId
* @return
*/
public List<Road> queryRoadsMultiPath(Integer cmptId) {
// log.info("===== queryRoadsMultiPath -> RoadService enter");
// log.info("===== queryRoadsMultiPath -> RoadService enter");
List<Road> roads = remoteService.getRoads(cmptId);
if(roads == null) {
if (roads == null) {
return null;
}
// for (Road road : roads) {
// log.info("RoadService api接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : roads) {
// log.info("RoadService api接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
List<Road> localRoads = roadMapper.queryRoadsMultiPath(cmptId);
// for (Road road : localRoads) {
// log.info("RoadService 数据库接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : localRoads) {
// log.info("RoadService 数据库接口 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
for (Road road : roads) { // 更新 插入操作
if (localRoads.contains(road)) {
Road rd = localRoads.get(localRoads.indexOf(road));
if (!rd.getName().equals(road.getName())) {
if (!rd.getName()
.equals(road.getName())) {
rd.setName(road.getName());
roadMapper.update(road);
}
// log.info("RoadService contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
// log.info("RoadService contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
} else {
roadMapper.save(road);
// log.info("RoadService not contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
// log.info("RoadService not contains getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName());
}
}
for (Road road : localRoads) { // 删除操作
......@@ -131,14 +136,15 @@ public class RoadService {
}
}
// for (Road road : localRoads) {
// log.info("RoadService 接口和api更新后数据 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
// for (Road road : localRoads) {
// log.info("RoadService 接口和api更新后数据 getName:" + road.getName() + " getRoadId:" + road.getRoadId() + " getFileName:" + road.getFileName() + " getFileUrl:" + road.getFileUrl());
// }
return roadMapper.queryRoadsMultiPath(cmptId);
}
/**
* 将gps文件转化为json文件
*
* @param url
* @return
*/
......@@ -146,7 +152,8 @@ public class RoadService {
ResponseEntity<org.springframework.core.io.Resource> entity = restTemplate.getForEntity(url, org.springframework.core.io.Resource.class);
InputStream inputStream = null;
try {
inputStream = entity.getBody().getInputStream();
inputStream = entity.getBody()
.getInputStream();
String json = "";
if (url.indexOf(".gpx") > -1) {
json = GpxParserUtil.parseGpx(inputStream);
......@@ -162,13 +169,13 @@ public class RoadService {
public int saveGps(RoadGpsPoint point) {
// 存在pathId的时候先把原来的路线删除再保存
// if(point.getPathId() > 0){
// roadMapper.deleteGps(point.getRoadId(), point.getPathId());
// }
// if(point.getPathId() > 0){
// roadMapper.deleteGps(point.getRoadId(), point.getPathId());
// }
return roadMapper.saveGps(point);
}
public int updateRoadGps(RoadGpsPoint point){
public int updateRoadGps(RoadGpsPoint point) {
return roadMapper.updateRoadGps(point);
}
......@@ -184,7 +191,11 @@ public class RoadService {
roadMapper.countDownload(roadId);
}
public Map<String, String> getMultiRouteInfo(Integer cmptId){
public Map<String, String> getMultiRouteInfo(Integer cmptId) {
return roadMapper.getMultiRouteInfo(cmptId);
}
public int updateGpsPathSort(int pathId, int sort) {
return roadMapper.updateGpsPathSort(pathId, sort);
}
}
......@@ -2,6 +2,7 @@ package com.dlbridge.jadp.plugins.cmpt.web;
import com.dlbridge.jadp.common.web.Result;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusTicketParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusVerifyRecordParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.vo.BusVerifyStatistics;
import com.dlbridge.jadp.plugins.cmpt.dto.*;
......@@ -162,5 +163,18 @@ public class BusController {
Page<List<BusVerificationRecord>> result = busService.verifyPageRecord(queryDTO);
return Result.success(result);
}
/**
* 查询车票记录分页列表接口
*
* @param queryDTO 查询参数
* @return 查询车票记录列表
*/
@ResponseBody
@PostMapping("/bus-ticket-page")
@ApiOperation(value = "获取班车车票列表", notes = "获取班车车票列表")
public Result<?> busTicketPage(@RequestBody BusTicketParam queryDTO) {
Page<List<BusTicketVerification>> result = busService.busTicketPage(queryDTO);
return Result.success(result);
}
}
......@@ -98,7 +98,7 @@ public class RoadController {
setPoints(json).setRoadId(road.getRoadId())
.setCmptId(road.getCmptId()).setPathName(road.getPathName())
.setFileName(road.getFileName()).setFileUrl(road.getFileUrl())
.setFileSize(road.getFileSize()).setPathId(road.getPathId());
.setFileSize(road.getFileSize()).setPathId(road.getPathId()).setSort(road.getSort());
roadService.saveGps(roadGpsPoint);
newPahtId = roadGpsPoint.getId();
log.info("=====生成新的路线ID:{}",newPahtId);
......@@ -110,7 +110,7 @@ public class RoadController {
setPoints(json).setRoadId(road.getRoadId())
.setCmptId(road.getCmptId()).setPathName(road.getPathName())
.setFileName(road.getFileName()).setFileUrl(road.getFileUrl())
.setFileSize(road.getFileSize()).setPathId(road.getPathId());
.setFileSize(road.getFileSize()).setPathId(road.getPathId()).setSort(road.getSort());
roadService.updateRoadGps(roadGpsPoint);
}
......@@ -155,6 +155,12 @@ public class RoadController {
int count = roadService.deleteGpsPath(pathId);
return Result.success();
}
@PostMapping("updateGpsPathSort/{pathId}/{sort}")
@ResponseBody
public Result updateGpsPathSort(@PathVariable("pathId") int pathId, @PathVariable("sort") int sort) {
int count = roadService.updateGpsPathSort(pathId, sort);
return Result.success();
}
/**
* 上传轨迹的接口,针对不同的项目,上传不同的gpx,kml轨迹文件
......
This diff is collapsed.
......@@ -130,6 +130,75 @@ $(document).ready(function () {
}
})*/
});
$('body').on('click', '.edit-sort', function () {
// layer.msg('click触发了',{icon:3,time:1500});
var parent = $(this).parent();
var pathId = parent.attr('data-path-id');
var pathName = parent.attr('data-path-name');
var sort = parent.attr('data-sort');
if (!sort) {
return layer.msg('请先上传路线', { icon: 3, time: 1500 });
}
const index = layer.open({
type: 1,
title: '设置' + pathName + '排序',
content: `
<div style="padding:20px;">
<div class="form-group">
<label>排序数字(越小越靠前)</label>
<input type="number" class="form-control" id="sort"
placeholder="请输入排序数字" value="${sort || 100}">
</div>
</div>
`,
btn: ['确定', '取消'],
yes: () => {
let loadIndex = 0;
const newSort = $('#sort').val();
if (newSort === '') {
layer.msg('请输入排序数字');
return;
}
if (isNaN(newSort)) {
layer.msg('排序必须是数字');
return;
}
$.ajax({
url: '/gk/road/updateGpsPathSort/' + pathId + '/' + newSort,
contentType: 'application/json',
type: 'post',
beforeSend: function () {
loadIndex = layer.load();
},
success: () => {
layer.close(loadIndex);
layer.msg('排序更新成功', () => layer.close(index));
window.location.reload();
}
});
}
});
/*$.ajax({
url: '/gk/road/save',
data: {
'roadId': id,
'fileName': fileName,
'fileUrl': fileUrl,
'name': name,
cmptId: getCmptId(),
'fileSize': fileSize
},
type: 'post',
success: function (data) {
if (data.status) {
// parent.attr('data-id', data.content.roadId);
$('.map-container').css('transform', 'none');
$('.map-container').attr('data-id', data.content.roadId);
$('.force').hide();
}
}
})*/
});
// 新增路线
$('body').on('click', '.add-new', function () {
......
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