|
@@ -51,7 +51,7 @@ public class StationRemindApiController {
|
|
|
@Autowired
|
|
|
private PassengerInfoService passengerInfoService;
|
|
|
|
|
|
- @ApiOperation(value="添加订阅")
|
|
|
+ @ApiOperation(value = "添加订阅")
|
|
|
@PostMapping("add")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "startStationId", value = "起始站点编号", paramType = "form"),
|
|
@@ -61,8 +61,8 @@ public class StationRemindApiController {
|
|
|
@ApiImplicitParam(name = "vehicleShiftId", value = "车辆班次编号", paramType = "form", allowEmptyValue = true),
|
|
|
@ApiImplicitParam(name = "openId", value = "微信openId", paramType = "form")
|
|
|
})
|
|
|
- public MessageResult<StationRemind> add(String startStationId,String remindStationId,Integer stopInAdvance,
|
|
|
- Integer remindType,String vehicleShiftId,String openId){
|
|
|
+ public MessageResult<StationRemind> add(String startStationId, String remindStationId, Integer stopInAdvance,
|
|
|
+ Integer remindType, String vehicleShiftId, String openId) {
|
|
|
MessageResult<StationRemind> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -74,7 +74,7 @@ public class StationRemindApiController {
|
|
|
|
|
|
StationInfo advanceStation = getAdvanceStation(startStationId, remindStationId, stopInAdvance);
|
|
|
|
|
|
- if(advanceStation!=null) {
|
|
|
+ if (advanceStation != null) {
|
|
|
stationRemind.setAdvanceStationId(advanceStation.getId());
|
|
|
}
|
|
|
|
|
@@ -84,7 +84,7 @@ public class StationRemindApiController {
|
|
|
stationRemind.setDelFlag(false);
|
|
|
stationRemind.setCreateBy(openId);
|
|
|
stationRemind.setCreateTime(new Date());
|
|
|
-
|
|
|
+
|
|
|
int affectCount = stationRemindService.insert(stationRemind);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
@@ -94,9 +94,8 @@ public class StationRemindApiController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("订阅失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -105,7 +104,7 @@ public class StationRemindApiController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="更新订阅")
|
|
|
+ @ApiOperation(value = "更新订阅")
|
|
|
@PostMapping("update")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "remindId", value = "订阅编号", paramType = "form"),
|
|
@@ -116,8 +115,8 @@ public class StationRemindApiController {
|
|
|
@ApiImplicitParam(name = "vehicleShiftId", value = "车辆班次编号", paramType = "form", allowEmptyValue = true),
|
|
|
@ApiImplicitParam(name = "openId", value = "微信openId", paramType = "form")
|
|
|
})
|
|
|
- public MessageResult<StationRemind> update(String remindId,String startStationId,String remindStationId,Integer stopInAdvance,
|
|
|
- Integer remindType,String vehicleShiftId,String openId){
|
|
|
+ public MessageResult<StationRemind> update(String remindId, String startStationId, String remindStationId, Integer stopInAdvance,
|
|
|
+ Integer remindType, String vehicleShiftId, String openId) {
|
|
|
MessageResult<StationRemind> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -128,7 +127,7 @@ public class StationRemindApiController {
|
|
|
|
|
|
StationInfo advanceStation = getAdvanceStation(startStationId, remindStationId, stopInAdvance);
|
|
|
|
|
|
- if(advanceStation!=null) {
|
|
|
+ if (advanceStation != null) {
|
|
|
stationRemind.setAdvanceStationId(advanceStation.getId());
|
|
|
}
|
|
|
|
|
@@ -148,9 +147,8 @@ public class StationRemindApiController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("订阅失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -165,13 +163,13 @@ public class StationRemindApiController {
|
|
|
List<StationInfo> stationList = stationInfoService.findByRouteId(station.getRouteId());
|
|
|
StationInfo advanceStation = null;
|
|
|
|
|
|
- if(stationList.size()>0){
|
|
|
+ if (stationList.size() > 0) {
|
|
|
StationInfo firstStation = stationList.get(0);
|
|
|
|
|
|
int curIndex = 0;
|
|
|
|
|
|
- for(int i=0;i<stationList.size();i++){
|
|
|
- if(stationList.get(i).getId().equals(remindStationId)){
|
|
|
+ for (int i = 0; i < stationList.size(); i++) {
|
|
|
+ if (stationList.get(i).getId().equals(remindStationId)) {
|
|
|
curIndex = i;
|
|
|
break;
|
|
|
}
|
|
@@ -179,34 +177,32 @@ public class StationRemindApiController {
|
|
|
|
|
|
int advanceIndex = 0;
|
|
|
|
|
|
- if (firstStation.getId().equals(startStationId)){
|
|
|
+ if (firstStation.getId().equals(startStationId)) {
|
|
|
//首站->终点站
|
|
|
advanceIndex = curIndex - stopInAdvance;
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
//终点站->首站
|
|
|
advanceIndex = curIndex + stopInAdvance;
|
|
|
}
|
|
|
|
|
|
- if(advanceIndex<0){
|
|
|
+ if (advanceIndex < 0) {
|
|
|
advanceIndex = 0;
|
|
|
}
|
|
|
|
|
|
- if (advanceIndex>=stationList.size()){
|
|
|
+ if (advanceIndex >= stationList.size()) {
|
|
|
advanceIndex = stationList.size() - 1;
|
|
|
}
|
|
|
|
|
|
advanceStation = stationList.get(advanceIndex);
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
throw new Exception("当前站点没有关联路线");
|
|
|
}
|
|
|
return advanceStation;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="取消订阅")
|
|
|
+ @ApiOperation(value = "取消订阅")
|
|
|
@PostMapping("cancel")
|
|
|
- public MessageResult<Integer> cancel(String id){
|
|
|
+ public MessageResult<Integer> cancel(String id) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -223,9 +219,8 @@ public class StationRemindApiController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("取消订阅失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -234,29 +229,29 @@ public class StationRemindApiController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
String openId,
|
|
|
String vehicleShiftId,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize){
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(openId)) {
|
|
|
- searchParams.put("openId",openId);
|
|
|
+ searchParams.put("openId", openId);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(vehicleShiftId)) {
|
|
|
- searchParams.put("vehicleShiftId",vehicleShiftId);
|
|
|
+ searchParams.put("vehicleShiftId", vehicleShiftId);
|
|
|
}
|
|
|
|
|
|
- Page<StationRemind> page = stationRemindService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ Page<StationRemind> page = stationRemindService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(PojoUtils.pageWrapper(page));
|
|
@@ -265,8 +260,8 @@ public class StationRemindApiController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("sendMessage")
|
|
|
- @ApiOperation(value="sendMessage")
|
|
|
- public MessageResult<String> sendMessage(String shiftId){
|
|
|
+ @ApiOperation(value = "sendMessage")
|
|
|
+ public MessageResult<String> sendMessage(String shiftId) {
|
|
|
MessageResult<String> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -274,9 +269,8 @@ public class StationRemindApiController {
|
|
|
rabbitTemplate.convertAndSend("stationRemindQueue", shiftInfo);
|
|
|
|
|
|
messageResult.setResult(true);
|
|
|
- }
|
|
|
- catch (Exception ex){
|
|
|
- log.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
@@ -287,17 +281,17 @@ public class StationRemindApiController {
|
|
|
|
|
|
|
|
|
@GetMapping("findCurrentVehicle")
|
|
|
- @ApiOperation(value="查询当前乘坐车辆")
|
|
|
- public MessageResult<List> findCurrentVehicle(String openId){
|
|
|
+ @ApiOperation(value = "查询当前乘坐车辆")
|
|
|
+ public MessageResult<List> findCurrentVehicle(String openId) {
|
|
|
MessageResult<List> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- List<PassengerInfo> passengers = passengerInfoService.findByOpenIdAndStatus(openId,"1", "1");
|
|
|
+ List<PassengerInfo> passengers = passengerInfoService.findByOpenIdAndStatus(openId, "1", "1");
|
|
|
|
|
|
Set<String> vehicleShiftSet = new HashSet<>();
|
|
|
|
|
|
for (PassengerInfo passenger : passengers) {
|
|
|
- if(!vehicleShiftSet.contains(passenger.getVehicleShiftId())){
|
|
|
+ if (!vehicleShiftSet.contains(passenger.getVehicleShiftId())) {
|
|
|
vehicleShiftSet.add(passenger.getVehicleShiftId());
|
|
|
}
|
|
|
}
|
|
@@ -307,7 +301,7 @@ public class StationRemindApiController {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
for (String vehicleShiftId : vehicleShiftSet) {
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
map.put("vehicleShiftId", vehicleShiftId);
|
|
|
|
|
|
ShiftInfo shiftInfo = shiftInfoService.get(vehicleShiftId);
|
|
@@ -323,46 +317,47 @@ public class StationRemindApiController {
|
|
|
StationInfo currentStation = stationInfoService.get(shiftInfo.getCurrentStationId());
|
|
|
StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
|
|
|
|
|
|
- map.put("startStationId",startStation.getId());
|
|
|
- map.put("startStationName",startStation.getName());
|
|
|
- map.put("endStationId",endStation.getId());
|
|
|
- map.put("endStationName",endStation.getName());
|
|
|
+ map.put("startStationId", startStation.getId());
|
|
|
+ map.put("startStationName", startStation.getName());
|
|
|
+ map.put("endStationId", endStation.getId());
|
|
|
+ map.put("endStationName", endStation.getName());
|
|
|
|
|
|
- if(currentStation!=null){
|
|
|
- map.put("currentStationId",currentStation.getId());
|
|
|
- map.put("currentStationName",currentStation.getName());
|
|
|
+ if (currentStation != null) {
|
|
|
+ map.put("currentStationId", currentStation.getId());
|
|
|
+ map.put("currentStationName", currentStation.getName());
|
|
|
}
|
|
|
|
|
|
//查询目的地
|
|
|
- List<PassengerInfo> passengerInfos = passengerInfoService.findByOpenIdAndVehicleShiftId(openId,vehicleShiftId, "1" ,"1");
|
|
|
+ List<PassengerInfo> passengerInfos = passengerInfoService.findByOpenIdAndVehicleShiftId(openId, vehicleShiftId, "1", "1");
|
|
|
|
|
|
- if (passengerInfos.size()>0){
|
|
|
+ if (passengerInfos.size() > 0) {
|
|
|
PassengerInfo passengerInfo = passengerInfos.get(0);
|
|
|
StationInfo ticketDownStation = stationInfoService.get(passengerInfo.getTicketDownStationId());
|
|
|
|
|
|
map.put("ticketDownStationId", ticketDownStation.getId());
|
|
|
- map.put("ticketDownStationName",ticketDownStation.getName());
|
|
|
+ map.put("ticketDownStationName", ticketDownStation.getName());
|
|
|
}
|
|
|
|
|
|
//是否创建消息提醒,显示消息提醒的到达站点信息
|
|
|
- map.put("openId",openId);
|
|
|
+ map.put("openId", openId);
|
|
|
+
|
|
|
+ List<StationRemind> stationRemindList = stationRemindService.findByOpenIdAndVehicleShiftId(openId, vehicleShiftId);
|
|
|
+ if (stationRemindList.size() > 0) {
|
|
|
+ map.put("remindId", stationRemindList.get(0).getId());
|
|
|
+ map.put("stopInAdvance", stationRemindList.get(0).getStopInAdvance());
|
|
|
|
|
|
- StationRemind stationRemind = stationRemindService.findByOpenIdAndVehicleShiftId(openId,vehicleShiftId);
|
|
|
|
|
|
- if(stationRemind!=null){
|
|
|
- map.put("remindId", stationRemind.getId());
|
|
|
- map.put("stopInAdvance", stationRemind.getStopInAdvance());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
|
|
|
//todo 填写具体代码
|
|
|
messageResult.setData(mapList);
|
|
|
messageResult.setResult(true);
|
|
|
- }
|
|
|
- catch (Exception ex){
|
|
|
- log.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|