chenfeng 6 months ago
parent 29cc2eb5e0
commit 9f6bb20a77
  1. 9
      src/main/java/com/cjy/back/ybsjHandset/dao/YbsjHandsetMapper.java
  2. 83
      src/main/java/com/cjy/back/ybsjHandset/dao/YbsjHandsetMapper.xml
  3. 37
      src/main/java/com/cjy/back/ybsjHandset/service/Impl/YbsjHandsetServiceImpl.java

@ -16,7 +16,14 @@ public interface YbsjHandsetMapper {
* @param scenicId * @param scenicId
* @return * @return
*/ */
Map<String, Object> getPeopleCounting(Integer scenicId); int getPeopleCounting(Integer scenicId);
/**
* 手持机-查询今日总检票人数和今日总预约人数
*
* @param scenicId
* @return
*/
int getPeopleCountingTwo(Integer scenicId);
/** /**
* 手持机-查询检票记录 * 手持机-查询检票记录

@ -4,35 +4,66 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cjy.back.ybsjHandset.dao.YbsjHandsetMapper"> <mapper namespace="com.cjy.back.ybsjHandset.dao.YbsjHandsetMapper">
<select id="getPeopleCounting" resultType="map"> <select id="getPeopleCounting" resultType="int">
SELECT SELECT
SUM( IFNULL(subquery1.count_result + subquery2.sum_result,0)
CASE
WHEN ( cm.appointment_type_id = 5701 AND nmd.write_off = 1 )
OR ( cm.appointment_type_id != 5701 AND cm.appointment_documents_write_off = 1 ) THEN
IFNULL( cm.appointment_count, 1 ) ELSE 0
END
) AS totalTicketCapacity,
SUM(
CASE
WHEN ( cm.appointment_type_id = 5701 AND nmd.write_off IN ( 0, 1 ) )
OR ( cm.appointment_type_id != 5701 AND cm.appointment_documents_write_off IN ( 0, 1 ) ) THEN
IFNULL( cm.appointment_count, 1 ) ELSE 0
END
) AS totalBookingCapacity
FROM FROM
ybsj_appointment_documents_info cm (
LEFT JOIN ybsj_appointment_people_info nmd ON cm.id = nmd.appointment_documents_id SELECT
AND cm.appointment_type_id = 5701 COUNT(nmd.id) AS count_result
WHERE FROM
cm.appointment_date = CURDATE( ) ybsj_appointment_documents_info cm
AND cm.scenic_id = #{scenicId} LEFT JOIN ybsj_appointment_people_info nmd ON cm.id = nmd.appointment_documents_id
AND cm.del_flag = 0 WHERE
AND ( ( cm.appointment_type_id = 5701 AND nmd.id IS NOT NULL ) OR cm.appointment_type_id != 5701 ); cm.appointment_type_id IN (5701, 5702)
AND cm.appointment_date = CURDATE()
AND cm.scenic_id = #{scenicId}
AND nmd.write_off IN (0, 1)
AND cm.del_flag = 0
) AS subquery1,
(
SELECT
SUM(cm.appointment_count) AS sum_result
FROM
ybsj_appointment_documents_info cm
WHERE
cm.appointment_type_id = 5703
AND cm.appointment_date = CURDATE()
AND cm.scenic_id = #{scenicId}
AND cm.appointment_documents_write_off IN (0, 1)
AND cm.del_flag = 0
) AS subquery2;
</select>
<select id="getPeopleCountingTwo" resultType="int">
SELECT
IFNULL(subquery1.count_result + subquery2.sum_result,0)
FROM
(
SELECT
COUNT(nmd.id) AS count_result
FROM
ybsj_appointment_documents_info cm
LEFT JOIN ybsj_appointment_people_info nmd ON cm.id = nmd.appointment_documents_id
WHERE
cm.appointment_type_id IN (5701, 5702)
AND cm.appointment_date = CURDATE()
AND cm.scenic_id = #{scenicId}
AND nmd.write_off IN (1)
AND cm.del_flag = 0
) AS subquery1,
(
SELECT
SUM(cm.appointment_count) AS sum_result
FROM
ybsj_appointment_documents_info cm
WHERE
cm.appointment_type_id = 5703
AND cm.appointment_date = CURDATE()
AND cm.scenic_id = #{scenicId}
AND cm.appointment_documents_write_off IN (1)
AND cm.del_flag = 0
) AS subquery2;
</select> </select>
<select id="getHaveTicketsCheckedPage" parameterType="map" resultType="map"> <select id="getHaveTicketsCheckedPage" parameterType="map" resultType="map">
SELECT SELECT
CAST( cn.id AS CHAR) id, CAST( cn.id AS CHAR) id,

@ -78,8 +78,8 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
if (getParamType(writeOffVo.getReservationCode()) == 1) { if (getParamType(writeOffVo.getReservationCode()) == 1) {
writeOffVo.setQrContent(writeOffVo.getReservationCode()); writeOffVo.setQrContent(writeOffVo.getReservationCode());
reservationCode = null; reservationCode = null;
}else if (getParamType(writeOffVo.getReservationCode()) == 3){ } else if (getParamType(writeOffVo.getReservationCode()) == 3) {
writeOffVo.setDocumentsNumber(Encryption.encrypt(writeOffVo.getReservationCode(), rule) ); writeOffVo.setDocumentsNumber(Encryption.encrypt(writeOffVo.getReservationCode(), rule));
reservationCode = null; reservationCode = null;
} }
} }
@ -99,7 +99,7 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
return ServerResponse.createByErrorCodeMessage(400, "预约码不能为空"); return ServerResponse.createByErrorCodeMessage(400, "预约码不能为空");
} }
// 查询预约信息 // 查询预约信息
Map<String, Object> appointmentInfo = ybsjHandsetMapper.getAppointmentPeopleInfo(reservationCode, writeOffVo.getQrContent(),writeOffVo.getDocumentsNumber()); Map<String, Object> appointmentInfo = ybsjHandsetMapper.getAppointmentPeopleInfo(reservationCode, writeOffVo.getQrContent(), writeOffVo.getDocumentsNumber());
if (appointmentInfo == null) { if (appointmentInfo == null) {
logger.warn("手持机核销异常:预约单不存在,预约码:{}", logIdentifier); logger.warn("手持机核销异常:预约单不存在,预约码:{}", logIdentifier);
return ServerResponse.createByErrorCodeMessage(400, "票据无效"); return ServerResponse.createByErrorCodeMessage(400, "票据无效");
@ -126,11 +126,11 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
logger.error("手持机核销失败:数据库更新异常,预约码:{}", logIdentifier); logger.error("手持机核销失败:数据库更新异常,预约码:{}", logIdentifier);
return ServerResponse.createByErrorCodeMessage(400, "核销失败,请重试"); return ServerResponse.createByErrorCodeMessage(400, "核销失败,请重试");
} }
if (Integer.parseInt(appointmentInfo.getOrDefault("appointment_type_id", "0").toString()) == 5703){ if (Integer.parseInt(appointmentInfo.getOrDefault("appointment_type_id", "0").toString()) == 5703) {
updateSuccess = Integer.parseInt(appointmentInfo.getOrDefault("appointment_count", "0").toString()); updateSuccess = Integer.parseInt(appointmentInfo.getOrDefault("appointment_count", "0").toString());
} }
// 构建成功响应 // 构建成功响应
return buildSuccessResponse(appointmentInfo.get("reservation_code").toString(), writeOffVo.getTicketChecker(), updateSuccess,appointmentInfo.get("id").toString()); return buildSuccessResponse(appointmentInfo.get("reservation_code").toString(), writeOffVo.getTicketChecker(), updateSuccess, appointmentInfo.get("id").toString());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
logger.error("手持机核销异常:数据格式转换错误", e); logger.error("手持机核销异常:数据格式转换错误", e);
@ -162,7 +162,7 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(getParamType("130530199810271028")); System.out.println(getParamType("130530199810271028"));
} }
// 辅助方法:检查预约时间是否有效 // 辅助方法:检查预约时间是否有效
@ -263,7 +263,7 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
// 辅助方法:构建成功响应 // 辅助方法:构建成功响应
private ServerResponse buildSuccessResponse(String reservationCode, String ticketChecker, private ServerResponse buildSuccessResponse(String reservationCode, String ticketChecker,
int updateSuccess,String id ) { int updateSuccess, String id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("reservationCode", reservationCode); result.put("reservationCode", reservationCode);
result.put("TicketChecker", ticketChecker); result.put("TicketChecker", ticketChecker);
@ -337,7 +337,10 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
@Override @Override
public ServerResponse getPeopleCounting(Integer scenicId) { public ServerResponse getPeopleCounting(Integer scenicId) {
return ServerResponse.createBySuccess(ybsjHandsetMapper.getPeopleCounting(scenicId)); Map<String, Object> map = new HashMap<>();
map.put("totalBookingCapacity",ybsjHandsetMapper.getPeopleCounting(scenicId));
map.put("totalTicketCapacity",ybsjHandsetMapper.getPeopleCountingTwo(scenicId));
return ServerResponse.createBySuccess(map);
} }
@Override @Override
@ -364,9 +367,9 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
param.put("essentialInformation", getHaveTicketsDetails); param.put("essentialInformation", getHaveTicketsDetails);
param.put("visitorList", getVisitorList); param.put("visitorList", getVisitorList);
if (getHaveTicketsDetails.get("submissionType").equals("线下提交")){ if (getHaveTicketsDetails.get("submissionType").equals("线下提交")) {
param.put("visitorListCount", getHaveTicketsDetails.get("appointment_count")); param.put("visitorListCount", getHaveTicketsDetails.get("appointment_count"));
}else { } else {
param.put("visitorListCount", getVisitorList.size()); param.put("visitorListCount", getVisitorList.size());
} }
return ServerResponse.createBySuccess(param); return ServerResponse.createBySuccess(param);
@ -397,9 +400,9 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
} }
param.put("essentialInformation", getAppointmentRecordDetails); param.put("essentialInformation", getAppointmentRecordDetails);
param.put("visitorList", getVisitorList); param.put("visitorList", getVisitorList);
if (getAppointmentRecordDetails.get("submissionType").equals("线下提交")){ if (getAppointmentRecordDetails.get("submissionType").equals("线下提交")) {
param.put("visitorListCount", getAppointmentRecordDetails.get("appointment_count")); param.put("visitorListCount", getAppointmentRecordDetails.get("appointment_count"));
}else { } else {
param.put("visitorListCount", getVisitorList.size()); param.put("visitorListCount", getVisitorList.size());
} }
return ServerResponse.createBySuccess(param); return ServerResponse.createBySuccess(param);
@ -407,12 +410,12 @@ public class YbsjHandsetServiceImpl implements YbsjHandsetService {
@Override @Override
public List<Map<String, Object>> selectScjCount(Integer dateType) { public List<Map<String, Object>> selectScjCount(Integer dateType) {
List<Map<String, Object>> selectScjCount =ybsjHandsetMapper.selectScjCount(dateType); List<Map<String, Object>> selectScjCount = ybsjHandsetMapper.selectScjCount(dateType);
List<Map<String, Object>> selectScjCountTwo = ybsjHandsetMapper.selectScjCountTwo(dateType); List<Map<String, Object>> selectScjCountTwo = ybsjHandsetMapper.selectScjCountTwo(dateType);
List<Map<String, Object>> mergedList = Stream.concat(selectScjCount.stream(), selectScjCountTwo.stream()) List<Map<String, Object>> mergedList = Stream.concat(selectScjCount.stream(), selectScjCountTwo.stream())
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
map -> String.valueOf(map.get("generated_date")) , map -> String.valueOf(map.get("generated_date")),
Collectors.summingInt(map -> Integer.parseInt(map.get("total_data").toString()) ) Collectors.summingInt(map -> Integer.parseInt(map.get("total_data").toString()))
)) ))
.entrySet() .entrySet()
.stream() .stream()

Loading…
Cancel
Save