Commit ce47d72c authored by Administrator's avatar Administrator

班车模块增加接口

parent 32c634a1
...@@ -25,11 +25,11 @@ public interface BusMapper { ...@@ -25,11 +25,11 @@ public interface BusMapper {
/** /**
* 核销信息查询 * 核销信息查询
* @param idNumber 证件号 * @param ticketNo 票号
* @param scheduleId 班次ID * @param scheduleId 班次ID
* @return * @return
*/ */
BusTicketVerification selectTicketForVerification(@Param("cmptId") Integer cmptId, @Param("idNumber") String idNumber, BusTicketVerification selectTicketForVerification(@Param("cmptId") Integer cmptId, @Param("ticketNo") String ticketNo,
@Param("scheduleId") Integer scheduleId); @Param("scheduleId") Integer scheduleId);
/** /**
...@@ -63,4 +63,6 @@ public interface BusMapper { ...@@ -63,4 +63,6 @@ public interface BusMapper {
List<BusStation> selectStationsByScheduleId(@Param("scheduleId") Integer scheduleId); List<BusStation> selectStationsByScheduleId(@Param("scheduleId") Integer scheduleId);
List<BusStation> selectStationsByCmptId(@Param("cmptId") Integer cmptId); List<BusStation> selectStationsByCmptId(@Param("cmptId") Integer cmptId);
List<BusVerificationRecord> selectVerificationRecord(@Param("cmptId") Integer cmptId, @Param("verifierId") String verifierId, @Param("ticketNo") String ticketNo);
} }
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
<!-- 关联字段 --> <!-- 关联字段 -->
<result column="schedule_name" property="scheduleName" /> <result column="schedule_name" property="scheduleName" />
<result column="license_plate" property="licensePlate" /> <result column="license_plate" property="licensePlate" />
<result column="driver_name" property="driverName" />
<result column="driver_phone" property="driverPhone" />
<result column="volunteer_name" property="volunteerName" />
<result column="volunteer_phone" property="volunteerPhone" />
<result column="remark1" property="remark1" />
<result column="remark2" property="remark2" />
<result column="departure_time_from" property="departureTimeFrom" /> <result column="departure_time_from" property="departureTimeFrom" />
<result column="departure_time_to" property="departureTimeTo" /> <result column="departure_time_to" property="departureTimeTo" />
<result column="allow_multiple_verification" property="allowMultipleVerification" /> <result column="allow_multiple_verification" property="allowMultipleVerification" />
...@@ -29,6 +35,8 @@ ...@@ -29,6 +35,8 @@
SELECT tv.*, SELECT tv.*,
bs.schedule_name, bs.schedule_name,
bs.license_plate, bs.license_plate,
bs.driver_phone,
bs.remark1,
bs.departure_time_from, bs.departure_time_from,
bs.departure_time_to bs.departure_time_to
FROM gksite.bus_ticket_verification tv FROM gksite.bus_ticket_verification tv
...@@ -44,6 +52,12 @@ ...@@ -44,6 +52,12 @@
SELECT tv.*, SELECT tv.*,
bs.schedule_name, bs.schedule_name,
bs.license_plate, bs.license_plate,
bs.driver_name,
bs.driver_phone,
bs.volunteer_name,
bs.volunteer_phone,
bs.remark1,
bs.remark2,
bs.departure_time_from, bs.departure_time_from,
bs.departure_time_to bs.departure_time_to
FROM gksite.bus_ticket_verification tv FROM gksite.bus_ticket_verification tv
...@@ -63,7 +77,7 @@ ...@@ -63,7 +77,7 @@
FROM gksite.bus_ticket_verification tv FROM gksite.bus_ticket_verification tv
LEFT JOIN gksite.bus_schedule bs ON tv.schedule_id = bs.id LEFT JOIN gksite.bus_schedule bs ON tv.schedule_id = bs.id
WHERE tv.cmpt_id = #{cmptId} WHERE tv.cmpt_id = #{cmptId}
AND tv.id_number = #{idNumber} AND tv.ticket_no = #{ticketNo}
AND tv.schedule_id = #{scheduleId} AND tv.schedule_id = #{scheduleId}
AND tv.del_flag = 0 AND tv.del_flag = 0
</select> </select>
...@@ -145,6 +159,8 @@ ...@@ -145,6 +159,8 @@
<result column="station_name" property="stationName" /> <result column="station_name" property="stationName" />
<result column="station_description" property="stationDescription" /> <result column="station_description" property="stationDescription" />
<result column="station_coordinates" property="stationCoordinates" /> <result column="station_coordinates" property="stationCoordinates" />
<result column="longitude" property="longitude" />
<result column="latitude" property="latitude" />
<result column="station_address" property="stationAddress" /> <result column="station_address" property="stationAddress" />
<result column="station_order" property="stationOrder" /> <result column="station_order" property="stationOrder" />
<result column="status" property="status" /> <result column="status" property="status" />
...@@ -165,5 +181,32 @@ ...@@ -165,5 +181,32 @@
FROM gksite.bus_station bs FROM gksite.bus_station bs
WHERE bs.del_flag = 0 WHERE bs.del_flag = 0
AND bs.cmpt_id = #{cmptId} AND bs.cmpt_id = #{cmptId}
ORDER BY bs.station_order ASC
</select>
<select id="selectVerificationRecord" resultType="com.dlbridge.jadp.plugins.cmpt.dto.BusVerificationRecord">
SELECT
bvr.id,
bvr.schedule_id scheduleId,
bvr.verifier_id verifierId,
bvr.verification_time verificationTime,
bvr.ticket_id ticketId,
btv.cmpt_id cmptId,
btv.ticket_no ticketNo,
btv.passenger_name passengerName,
bs.schedule_name scheduleName,
bs.license_plate licensePlate
FROM gksite.bus_verification_record bvr
INNER JOIN gksite.bus_ticket_verification btv ON btv.id = bvr.ticket_id
INNER JOIN gksite.bus_schedule bs ON bs.id = bvr.schedule_id
WHERE 1 = 1
AND bvr.cmpt_id = #{cmptId}
<if test="verifierId != null and verifierId != ''">
AND bvr.verifier_id = #{verifierId}
</if>
<if test="ticketNo != null and ticketNo != '' ">
AND bvr.ticket_no = #{ticketNo}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
package com.dlbridge.jadp.plugins.cmpt.dao.model.vo;
import lombok.Data;
/**
* 班车模块:核销统计
*/
@Data
public class BusVerifyStatistics {
private String scheduleName;
private Integer verifyCount;
public BusVerifyStatistics() {}
public BusVerifyStatistics(String scheduleName, Integer verifyCount) {
this.scheduleName = scheduleName;
this.verifyCount = verifyCount;
}
}
...@@ -33,6 +33,12 @@ public class BusTicketVerification { ...@@ -33,6 +33,12 @@ public class BusTicketVerification {
// 关联字段 // 关联字段
private String scheduleName; private String scheduleName;
private String licensePlate; private String licensePlate;
private String driverName;
private String driverPhone;
private String volunteerName;
private String volunteerPhone;
private String remark1;
private String remark2;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime departureTimeFrom; private LocalDateTime departureTimeFrom;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
...@@ -20,4 +20,8 @@ public class BusVerificationRecord { ...@@ -20,4 +20,8 @@ public class BusVerificationRecord {
private LocalDateTime verificationTime; private LocalDateTime verificationTime;
private String verifierId; private String verifierId;
private String deviceId; private String deviceId;
// 关联字段
private String scheduleName;
private String licensePlate;
private String passengerName;
} }
...@@ -2,6 +2,7 @@ package com.dlbridge.jadp.plugins.cmpt.service; ...@@ -2,6 +2,7 @@ package com.dlbridge.jadp.plugins.cmpt.service;
import com.dlbridge.jadp.plugins.cmpt.dao.mapper.BusMapper; 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.BusParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.vo.BusVerifyStatistics;
import com.dlbridge.jadp.plugins.cmpt.dto.BusSchedule; import com.dlbridge.jadp.plugins.cmpt.dto.BusSchedule;
import com.dlbridge.jadp.plugins.cmpt.dto.BusStation; import com.dlbridge.jadp.plugins.cmpt.dto.BusStation;
import com.dlbridge.jadp.plugins.cmpt.dto.BusTicketVerification; import com.dlbridge.jadp.plugins.cmpt.dto.BusTicketVerification;
...@@ -11,6 +12,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter; ...@@ -11,6 +12,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.QRCodeWriter;
import com.neusoft.www.utils.web.Result; import com.neusoft.www.utils.web.Result;
import feign.Param;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -69,10 +71,10 @@ public class BusService { ...@@ -69,10 +71,10 @@ public class BusService {
// 生成二维码内容:票号+时间戳 // 生成二维码内容:票号+时间戳
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
String qrContent = String.format("idNumber=%s&timestamp=%d", ticket.getIdNumber(), timestamp); String qrContent = String.format("ticketNo=%s&timestamp=%d", ticket.getTicketNo(), timestamp);
QRCodeWriter qrCodeWriter = new QRCodeWriter(); QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(qrContent, BarcodeFormat.QR_CODE, 200, 200); BitMatrix bitMatrix = qrCodeWriter.encode(qrContent, BarcodeFormat.QR_CODE, 250, 250);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream); MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
...@@ -91,7 +93,7 @@ public class BusService { ...@@ -91,7 +93,7 @@ public class BusService {
*/ */
@Transactional @Transactional
public Result verifyTicket(BusParam param) { public Result verifyTicket(BusParam param) {
if (param.getCmptId() == null || param.getScheduleId() == null || StringUtils.isBlank(param.getIdNumber()) || param.getQrTimestamp() == null) { if (param.getCmptId() == null || param.getScheduleId() == null || StringUtils.isBlank(param.getTicketNo()) || param.getQrTimestamp() == null) {
return Result.fail().setMsg("主要参数不能为空"); return Result.fail().setMsg("主要参数不能为空");
} }
...@@ -102,7 +104,7 @@ public class BusService { ...@@ -102,7 +104,7 @@ public class BusService {
} }
// 查询票务信息 // 查询票务信息
BusTicketVerification ticket = busMapper.selectTicketForVerification(param.getCmptId(), param.getIdNumber(), param.getScheduleId()); BusTicketVerification ticket = busMapper.selectTicketForVerification(param.getCmptId(), param.getTicketNo(), param.getScheduleId());
if (ticket == null) { if (ticket == null) {
return Result.fail().setMsg("未找到有效的车票信息"); return Result.fail().setMsg("未找到有效的车票信息");
} }
...@@ -150,7 +152,7 @@ public class BusService { ...@@ -150,7 +152,7 @@ public class BusService {
/** /**
* 查询班次站点列表 * 查询班次途经站点列表
* @param scheduleId 班次ID * @param scheduleId 班次ID
* @return * @return
*/ */
...@@ -158,4 +160,31 @@ public class BusService { ...@@ -158,4 +160,31 @@ public class BusService {
return busMapper.selectStationsByScheduleId(scheduleId); return busMapper.selectStationsByScheduleId(scheduleId);
} }
/**
* 查询赛事班车站点列表
* @param cmptId
* @return
*/
public List<BusStation> selectStationsByCmptId(Integer cmptId) {
return busMapper.selectStationsByCmptId(cmptId);
}
public List<BusVerificationRecord> selectVerificationRecord(Integer cmptId,String verifierId, String ticketNo) {
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());
}
} }
package com.dlbridge.jadp.plugins.cmpt.web; package com.dlbridge.jadp.plugins.cmpt.web;
import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusParam; import com.dlbridge.jadp.plugins.cmpt.dao.model.param.BusParam;
import com.dlbridge.jadp.plugins.cmpt.dao.model.vo.BusVerifyStatistics;
import com.dlbridge.jadp.plugins.cmpt.dto.BusSchedule; import com.dlbridge.jadp.plugins.cmpt.dto.BusSchedule;
import com.dlbridge.jadp.plugins.cmpt.dto.BusStation; import com.dlbridge.jadp.plugins.cmpt.dto.BusStation;
import com.dlbridge.jadp.plugins.cmpt.dto.BusTicketVerification; import com.dlbridge.jadp.plugins.cmpt.dto.BusTicketVerification;
import com.dlbridge.jadp.plugins.cmpt.dto.BusVerificationRecord;
import com.dlbridge.jadp.plugins.cmpt.service.BusService; import com.dlbridge.jadp.plugins.cmpt.service.BusService;
import com.neusoft.www.utils.web.Result; import com.neusoft.www.utils.web.Result;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -84,14 +86,48 @@ public class BusController { ...@@ -84,14 +86,48 @@ public class BusController {
} }
/** /**
* 查询班车站点列表 * 查询班次途经站点列表
* @return * @return
*/ */
@ResponseBody @ResponseBody
@RequestMapping(value = "/stations", method = RequestMethod.POST) @RequestMapping(value = "/schedule-stations", method = RequestMethod.POST)
public Result selectStationsByScheduleId(@RequestBody BusParam param) { public Result selectStationsByScheduleId(@RequestBody BusParam param) {
List<BusStation> stations = busService.selectStationsByScheduleId(param.getScheduleId()); List<BusStation> stations = busService.selectStationsByScheduleId(param.getScheduleId());
return Result.success().setContent(stations); return Result.success().setContent(stations);
} }
/**
* 查询赛事班车站点列表
* @return
*/
@ResponseBody
@RequestMapping(value = "/cmpt-stations", method = RequestMethod.POST)
public Result selectStationsByCmptId(@RequestBody BusParam param) {
List<BusStation> stations = busService.selectStationsByCmptId(param.getCmptId());
return Result.success().setContent(stations);
}
/**
* 查询核销记录接口
* @return
*/
@ResponseBody
@RequestMapping(value = "/verification-record", method = RequestMethod.POST)
public Result selectVerificationRecord(@RequestBody BusParam param) {
List<BusVerificationRecord> records = busService.selectVerificationRecord(param.getCmptId(), param.getVerifierId(), param.getTicketNo());
return Result.success().setContent(records);
}
/**
* 赛事核销统计
* @param cmptId 赛事ID
* @return
*/
@ResponseBody
@RequestMapping(value = "/verify-statistics/{cmptId}", method = RequestMethod.GET)
public Result busVerifyStatistics(@PathVariable("cmptId") Integer cmptId) {
List<BusVerifyStatistics> statistics = busService.busVerifyStatistics(cmptId);
return Result.success().setContent(statistics);
}
} }
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