|
@@ -1,60 +1,240 @@
|
|
|
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.StationInfoExample;
|
|
|
+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.ResultData;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@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 void getStationInfoList(HttpServletRequest request, HttpServletResponse response){
|
|
|
- JSONObject req = new JSONObject();
|
|
|
- //获取当前用户坐标
|
|
|
- String zuobiao=request.getParameter("zuobiao");
|
|
|
+ public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize){
|
|
|
Gson gson =new Gson();
|
|
|
- if(zuobiao!=null){
|
|
|
- if(zuobiao==""){
|
|
|
- StationInfo stationInfo=new StationInfo();
|
|
|
-
|
|
|
+ //返回结果集
|
|
|
+ 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);
|
|
|
//调用接口 根据坐标筛选距离最近的加油站
|
|
|
- List<StationInfo> stationInfoList = stationService.stationInfoList(stationInfo);
|
|
|
- req.put("code","000");
|
|
|
- req.put("msg","请求成功");
|
|
|
- req.put("data","");
|
|
|
+ StationInfoVo stationInfoVo = stationService.stationInfoList(stationRequest);
|
|
|
+ resultData=ResultData.success(stationInfoVo);
|
|
|
}else{
|
|
|
- req.put("code","002");
|
|
|
- req.put("msg","获取坐标失败");
|
|
|
+ resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
|
|
|
}
|
|
|
}else{
|
|
|
- req.put("code","001");
|
|
|
- req.put("msg","坐标未传参数");
|
|
|
- }
|
|
|
- try {
|
|
|
- response.setContentType("application/json; charset=UTF-8");
|
|
|
- response.setCharacterEncoding("UTF-8");
|
|
|
- response.getWriter().print(req);
|
|
|
- response.getWriter().flush();
|
|
|
- response.getWriter().close();
|
|
|
+ resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
|
|
|
+ }
|
|
|
+ return gson.toJson(resultData);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取油站列表信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getStationList", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public String getStationList(@RequestParam StationRequest request){
|
|
|
+ Gson gson =new Gson();
|
|
|
+ StationInfo stationInfo =new StationInfo();
|
|
|
+ List<StationInfo> stationInfoList = stationService.getStationList(stationInfo);
|
|
|
+ return gson.toJson(stationInfoList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取油站列表信息
|
|
|
+ */
|
|
|
+ @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){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|