123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- package com.platform.yijia.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.google.gson.Gson;
- import com.platform.yijia.param.request.StationRequest;
- import com.platform.yijia.param.response.StationInfoVo;
- import com.platform.yijia.pojo.AppUserInfo;
- import com.platform.yijia.pojo.StationInfo;
- import com.platform.yijia.pojo.StationNoticeManage;
- import com.platform.yijia.pojo.StationOilGun;
- import com.platform.yijia.service.AppUserInfoService;
- import com.platform.yijia.service.StationNoticeManageService;
- import com.platform.yijia.service.StationOilGunService;
- import com.platform.yijia.service.StationService;
- import com.platform.yijia.utils.CodeMsg;
- import com.platform.yijia.utils.FeiEPrinterUtil;
- import com.platform.yijia.utils.ResultData;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.List;
- @Controller
- @RequestMapping("/api")
- public class StationController {
- @Resource
- private StationService stationService;
- @Resource
- private StationNoticeManageService stationNoticeManageService;
- @Resource
- private StationOilGunService stationOilGunService;
- @Resource
- private AppUserInfoService appUserInfoService;
- /**
- * 根据坐标获取油站列表
- */
- @RequestMapping(value = "/getStationInfoList", method = RequestMethod.GET)
- @ResponseBody
- public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize, String appId){
- Gson gson =new Gson();
- //返回结果集
- ResultData resultData=null;
- if(stationLongitude!=null && stationLatitude !=null){
- if(StringUtils.isNotBlank(stationLongitude)&&StringUtils.isNotBlank(stationLatitude)){
- StationRequest stationRequest=new StationRequest();
- stationRequest.setStationLatitude(stationLatitude);
- stationRequest.setStationLongitude(stationLongitude);
- stationRequest.setPageNum(pageNum);
- stationRequest.setPageSize(pageSize);
- stationRequest.setAppId(appId);
- //调用接口 根据坐标筛选距离最近的加油站
- StationInfoVo stationInfoVo = stationService.stationInfoList(stationRequest);
- resultData=ResultData.success(stationInfoVo);
- }else{
- resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
- }
- }else{
- resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
- }
- return gson.toJson(resultData);
- }
- /**
- * 根据公众号appId获取油站列表信息
- */
- @RequestMapping(value = "/getGzhStationList", method = RequestMethod.GET)
- @ResponseBody
- public String getGzhStationList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize, String appId){
- Gson gson =new Gson();
- //返回结果集
- ResultData resultData=null;
- if(stationLongitude!=null && stationLatitude !=null){
- if(StringUtils.isNotBlank(stationLongitude)&&StringUtils.isNotBlank(stationLatitude)){
- StationRequest stationRequest=new StationRequest();
- stationRequest.setStationLatitude(stationLatitude);
- stationRequest.setStationLongitude(stationLongitude);
- stationRequest.setPageNum(pageNum);
- stationRequest.setPageSize(pageSize);
- stationRequest.setAppId(appId);
- //调用接口 根据坐标筛选距离最近的加油站
- StationInfoVo stationInfoVo = stationService.gzhStationInfoList(stationRequest);
- resultData=ResultData.success(stationInfoVo);
- }else{
- resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
- }
- }else{
- resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
- }
- return gson.toJson(resultData);
- }
- /**
- * 添加油站信息
- */
- @RequestMapping(value = "/addStationInfo", method = RequestMethod.POST)
- @ResponseBody
- public String addStationInfo(@RequestParam StationRequest request){
- Gson gson =new Gson();
- ResultData resultData=null;
- StationInfo stationInfo =new StationInfo();
- if(request.getStationId()!=null){
- stationInfo.setStationId(request.getStationId());
- }
- if(StringUtils.isNotBlank(request.getStationName())){
- stationInfo.setStationName(request.getStationName());
- }
- if(StringUtils.isNotBlank(request.getContacts())){
- stationInfo.setContacts(request.getContacts());
- }
- if(StringUtils.isNotBlank(request.getPhone())){
- stationInfo.setPhone(request.getPhone());
- }
- if(StringUtils.isNotBlank(request.getStationAddress())){
- stationInfo.setStationAddress(request.getStationAddress());
- }
- if(request.getStationGroupId()!=null){
- stationInfo.setStationGroupId(request.getStationGroupId());
- }
- if(request.getStationGroupName()!=null){
- stationInfo.setStationGroupName(request.getStationGroupName());
- }
- if(request.getContacts()!=null){
- stationInfo.setContacts(request.getContacts());
- }
- try{
- stationService.AddStationInfo(stationInfo);
- resultData=ResultData.success(CodeMsg.SUCCESS);
- }catch (Exception e){
- resultData=ResultData.error(CodeMsg.INSERT_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- * 修改油站信息
- */
- @RequestMapping(value = "/updateStationInfo", method = RequestMethod.POST)
- @ResponseBody
- public String updateStationInfo(@RequestBody StationInfo stationInfo){
- Gson gson=new Gson();
- ResultData resultData=null;
- try{
- stationService.updateStationInfo(stationInfo);
- resultData=ResultData.success(CodeMsg.SUCCESS);
- }catch (Exception e){
- resultData=ResultData.error(CodeMsg.UPDATE_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- * 删除油站信息
- */
- @RequestMapping(value = "/deleteStationInfo", method = RequestMethod.POST)
- @ResponseBody
- public String deleteStationInfo(@RequestBody StationInfo stationInfo){
- Gson gson=new Gson();
- ResultData resultData=null;
- try{
- stationService.deleteStationInfo(stationInfo);
- resultData=ResultData.success(CodeMsg.SUCCESS);
- }catch (Exception e){
- resultData=ResultData.error(CodeMsg.DELETE_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- * 油站设备管理查询
- */
- @RequestMapping(value = "/getStationNoticeManageList", method = RequestMethod.GET)
- @ResponseBody
- public String getStationNoticeManageList(@RequestParam StationRequest request){
- Gson gson=new Gson();
- ResultData resultData=null;
- try{
- StationNoticeManage stationNoticeManage =new StationNoticeManage();
- List<StationNoticeManage> stationNoticeManageList = stationNoticeManageService.getStationNoticeManageList(stationNoticeManage);
- resultData=ResultData.success(stationNoticeManageList);
- }catch (Exception e){
- resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- *修改油站设备管理
- */
- @RequestMapping(value = "/updateStationNoticeManage", method = RequestMethod.POST)
- @ResponseBody
- public String updateStationNoticeManage(@RequestBody StationNoticeManage stationNoticeManage){
- Gson gson=new Gson();
- ResultData resultData=null;
- try{
- stationNoticeManageService.updateStationNoticeManage(stationNoticeManage);
- resultData=ResultData.success(CodeMsg.SUCCESS);
- }catch (Exception e){
- resultData=ResultData.success(CodeMsg.UPDATE_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- * 删除油站设备信息
- */
- @RequestMapping(value = "/deleteStationNoticeManage", method = RequestMethod.POST)
- @ResponseBody
- public String deleteStationNoticeManage(@RequestBody StationNoticeManage stationNoticeManage){
- Gson gson=new Gson();
- ResultData resultData=null;
- try{
- stationNoticeManageService.deleteStationNoticeManage(stationNoticeManage);
- resultData=ResultData.success(CodeMsg.SUCCESS);
- }catch (Exception e){
- resultData=ResultData.success(CodeMsg.DELETE_FAIL);
- e.printStackTrace();
- }
- return gson.toJson(resultData);
- }
- /**
- * 油枪管理
- */
- @RequestMapping(value = "/stationOilGunList", method = RequestMethod.GET)
- @ResponseBody
- // public void stationOilGunList(@RequestParam StationRequest request,HttpServletResponse response){
- // public String stationOilGunList(@RequestParam String userType,String token,Integer stationId){
- public String stationOilGunList(@RequestParam Integer stationId){
- Gson gson =new Gson();
- StationOilGun stationOilGun =new StationOilGun();
- //查询登录人是否存在
- // AppUserInfo appUserInfo =new AppUserInfo();
- //订单类型 是小程序还是公众号
- // appUserInfo.setUserType(userType);
- // if(userType.equals("1")){
- // //1 是公众号
- // appUserInfo.setBlogToken(token);
- // }else if(userType.equals("2")){
- // //2是小程序
- // appUserInfo.setMinaToken(token);
- // }
- // List<AppUserInfo> appUserInfoList =appUserInfoService.Authentication(appUserInfo);
- // if(appUserInfoList!=null&&appUserInfoList.size()>0){
- //获取油站id根据油站号查询油站对应的所有油枪信息
- stationOilGun.setStationId(stationId);
- List<StationOilGun> stationOilGunList = stationOilGunService.stationOilGunList(stationOilGun);
- ResultData resultData=ResultData.success(stationOilGunList);
- return gson.toJson(resultData);
- // }else {
- // ResultData resultData=ResultData.error(CodeMsg.USER_NOT_EXSIST);
- // return gson.toJson(resultData);
- // }
- }
- }
|