|
@@ -6,19 +6,20 @@ import java.util.Map;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
+import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
|
|
|
|
+import com.jpsoft.bus.modules.base.entity.OrderInfo;
|
|
|
|
+import com.jpsoft.bus.modules.base.service.MergeOrderInfoService;
|
|
|
|
+import com.jpsoft.bus.modules.base.service.OrderInfoService;
|
|
import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
|
|
import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
|
|
-import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
|
|
|
|
-import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
|
|
|
|
-import com.jpsoft.bus.modules.bus.service.GpsService;
|
|
|
|
-import com.jpsoft.bus.modules.bus.service.PassengerInfoService;
|
|
|
|
|
|
+import com.jpsoft.bus.modules.bus.entity.*;
|
|
|
|
+import com.jpsoft.bus.modules.bus.service.*;
|
|
import com.sun.xml.bind.v2.TODO;
|
|
import com.sun.xml.bind.v2.TODO;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.jpsoft.bus.modules.bus.dao.ShiftInfoDAO;
|
|
import com.jpsoft.bus.modules.bus.dao.ShiftInfoDAO;
|
|
-import com.jpsoft.bus.modules.bus.entity.ShiftInfo;
|
|
|
|
-import com.jpsoft.bus.modules.bus.service.ShiftInfoService;
|
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
import com.jpsoft.bus.modules.common.dto.Sort;
|
|
import com.jpsoft.bus.modules.common.dto.Sort;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -32,9 +33,24 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
|
|
@Autowired
|
|
@Autowired
|
|
private GpsService gpsService;
|
|
private GpsService gpsService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MergeOrderInfoService mergeOrderInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrderInfoService orderInfoService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private PassengerInfoService passengerInfoService;
|
|
private PassengerInfoService passengerInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private StationInfoService stationInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private PassengerMessageService passengerMessageService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ShiftInfo get(String id) {
|
|
public ShiftInfo get(String id) {
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
@@ -137,8 +153,6 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void finishShift(ShiftInfo shiftInfo) {
|
|
public void finishShift(ShiftInfo shiftInfo) {
|
|
-
|
|
|
|
-
|
|
|
|
shiftInfo.setStatus("2");
|
|
shiftInfo.setStatus("2");
|
|
shiftInfo.setFinishTime(new Date());
|
|
shiftInfo.setFinishTime(new Date());
|
|
shiftInfo.setUpdateTime(new Date());
|
|
shiftInfo.setUpdateTime(new Date());
|
|
@@ -156,4 +170,118 @@ public class ShiftInfoServiceImpl implements ShiftInfoService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void stationChange(ShiftInfo shiftInfo, String stationId) {
|
|
|
|
+ StationInfo currentStation = stationInfoService.get(stationId);
|
|
|
|
+
|
|
|
|
+ //站点发生变化时
|
|
|
|
+ if (!shiftInfo.getCurrentStationId().equals(stationId)){
|
|
|
|
+ shiftInfo.setCurrentStationId(stationId);
|
|
|
|
+ shiftInfo.setUpdateTime(new Date());
|
|
|
|
+ update(shiftInfo);
|
|
|
|
+
|
|
|
|
+ rabbitTemplate.convertAndSend("stationRemindQueue", shiftInfo);
|
|
|
|
+
|
|
|
|
+ //此线路的所有站点
|
|
|
|
+ List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
|
|
|
|
+
|
|
|
|
+ int currentStationIndex = currentStation.getSortNo();
|
|
|
|
+
|
|
|
|
+ //线路终点站
|
|
|
|
+ StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
|
|
|
|
+ boolean frontToEnd = true;
|
|
|
|
+
|
|
|
|
+ if(endStation.getId().equals(stationInfoList.get(0).getId())){
|
|
|
|
+ //反向行驶
|
|
|
|
+ frontToEnd = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询乘客表是否有过站的情况
|
|
|
|
+ List<PassengerInfo> passengerInfoList = passengerInfoService.findByShiftStatusPayStatusNotTicketDown(shiftInfo.getId(),"1","1",stationId);
|
|
|
|
+
|
|
|
|
+ if (passengerInfoList.size()>0){
|
|
|
|
+ for (PassengerInfo passengerInfo : passengerInfoList){
|
|
|
|
+ //乘客购票的下车站点
|
|
|
|
+ StationInfo downStation = stationInfoService.get(passengerInfo.getTicketDownStationId());
|
|
|
|
+
|
|
|
|
+ //按照线路顺行并且当前站点大于乘客购票站点,则过站
|
|
|
|
+ if (frontToEnd){
|
|
|
|
+ if(currentStationIndex > downStation.getSortNo()) {
|
|
|
|
+ passengerInfo.setPayStatus("2");
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ passengerInfo.setPayStatus("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ passengerInfoService.update(passengerInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //按照线路逆行并且当前站点小于乘客购票站点,则过站
|
|
|
|
+ if (!frontToEnd){
|
|
|
|
+ if(currentStationIndex < downStation.getSortNo()) {
|
|
|
|
+ passengerInfo.setPayStatus("2");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ passengerInfo.setPayStatus("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ passengerInfoService.update(passengerInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //过站发消息
|
|
|
|
+ if (passengerInfo.getPayStatus().equals("2")){
|
|
|
|
+ List<OrderInfo> orderInfoList = orderInfoService.findByPassengerIdAndPayStatus(passengerInfo.getId(),20);
|
|
|
|
+ OrderInfo orderInfo = orderInfoList.get(0);
|
|
|
|
+ //综合账单
|
|
|
|
+ MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
|
|
|
|
+ if (StringUtils.isNotBlank(mergeOrderInfo.getOpenId())){
|
|
|
|
+ PassengerMessage passengerMessage = passengerMessageService.findByPassengerId(orderInfo.getPassengerId());
|
|
|
|
+
|
|
|
|
+ if (passengerMessage ==null){
|
|
|
|
+ passengerMessage = new PassengerMessage();
|
|
|
|
+ passengerMessage.setId(cn.hutool.core.lang.UUID.randomUUID().toString());
|
|
|
|
+ passengerMessage.setOpenId(mergeOrderInfo.getOpenId());
|
|
|
|
+ passengerMessage.setPassengerId(passengerInfo.getId());
|
|
|
|
+ passengerMessage.setCreateTime(new Date());
|
|
|
|
+ passengerMessageService.insert(passengerMessage);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ passengerMessage.setReadStatus(false);
|
|
|
|
+ passengerMessageService.update(passengerMessage);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询乘客有过站的情况
|
|
|
|
+ List<PassengerInfo> passengerInfoList1 = passengerInfoService.findByShiftStatusPayStatusNotTicketDown(shiftInfo.getId(),"1","2",stationId);
|
|
|
|
+
|
|
|
|
+ if (passengerInfoList1.size()>0){
|
|
|
|
+ for (PassengerInfo passengerInfo : passengerInfoList1){
|
|
|
|
+ List<OrderInfo> orderInfoList = orderInfoService.findByPassengerIdAndPayStatus(passengerInfo.getId(),20);
|
|
|
|
+ OrderInfo orderInfo = orderInfoList.get(0);
|
|
|
|
+ //综合账单
|
|
|
|
+ MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotBlank(mergeOrderInfo.getOpenId())){
|
|
|
|
+ PassengerMessage passengerMessage = passengerMessageService.findByPassengerId(orderInfo.getPassengerId());
|
|
|
|
+ if (passengerMessage ==null){
|
|
|
|
+ passengerMessage = new PassengerMessage();
|
|
|
|
+ passengerMessage.setId(cn.hutool.core.lang.UUID.randomUUID().toString());
|
|
|
|
+ passengerMessage.setOpenId(mergeOrderInfo.getOpenId());
|
|
|
|
+ passengerMessage.setPassengerId(passengerInfo.getId());
|
|
|
|
+ passengerMessage.setCreateTime(new Date());
|
|
|
|
+ passengerMessageService.insert(passengerMessage);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ passengerMessage.setReadStatus(false);
|
|
|
|
+ passengerMessageService.update(passengerMessage);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|