StationController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. package com.platform.yijia.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.google.gson.Gson;
  4. import com.platform.yijia.param.request.StationRequest;
  5. import com.platform.yijia.param.response.StationInfoVo;
  6. import com.platform.yijia.pojo.AppUserInfo;
  7. import com.platform.yijia.pojo.StationInfo;
  8. import com.platform.yijia.pojo.StationNoticeManage;
  9. import com.platform.yijia.pojo.StationOilGun;
  10. import com.platform.yijia.service.AppUserInfoService;
  11. import com.platform.yijia.service.StationNoticeManageService;
  12. import com.platform.yijia.service.StationOilGunService;
  13. import com.platform.yijia.service.StationService;
  14. import com.platform.yijia.utils.CodeMsg;
  15. import com.platform.yijia.utils.FeiEPrinterUtil;
  16. import com.platform.yijia.utils.ResultData;
  17. import org.apache.commons.lang3.StringUtils;
  18. import org.springframework.stereotype.Controller;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.annotation.Resource;
  21. import java.util.List;
  22. @Controller
  23. @RequestMapping("/api")
  24. public class StationController {
  25. @Resource
  26. private StationService stationService;
  27. @Resource
  28. private StationNoticeManageService stationNoticeManageService;
  29. @Resource
  30. private StationOilGunService stationOilGunService;
  31. @Resource
  32. private AppUserInfoService appUserInfoService;
  33. /*
  34. * 新增打印机
  35. * @param jsonObject
  36. * @return
  37. */
  38. @RequestMapping(value = "/addprinter", consumes = "application/json", method = RequestMethod.POST)
  39. @ResponseBody
  40. public String addprinter(@RequestBody JSONObject jsonObject){
  41. String snlist = jsonObject.getString("sn")+"#"+jsonObject.getString("key");
  42. return FeiEPrinterUtil.addprinter(snlist);
  43. }
  44. /*
  45. * 班结打印
  46. * @return
  47. */
  48. @RequestMapping(value = "/printClassesSummary", consumes = "application/json", method = RequestMethod.POST)
  49. @ResponseBody
  50. public String printClassesSummary(@RequestBody JSONObject jsonObject){
  51. //打印机编号
  52. String sn="";
  53. //打印内容
  54. String content;
  55. content = "<CB>班结小票</CB><BR>";
  56. content += "--------------------------------<BR>";
  57. content += "油品      升数 金额 单数 优惠<BR>";
  58. content += "--------------------------------<BR>";
  59. content += "饭       1.0 1 1.0<BR>";
  60. content += "炒饭      10.0 10 10.0<BR>";
  61. content += "蛋炒饭     10.0 10 100.0<BR>";
  62. content += "鸡蛋炒饭    100.0 1 100.0<BR>";
  63. content += "番茄蛋炒饭   1000.0 1 100.0<BR>";
  64. content += "西红柿蛋炒饭  1000.0 1 100.0<BR>";
  65. content += "西红柿鸡蛋炒饭 100.0 10 100.0<BR>";
  66. content += "备注:加辣<BR>";
  67. content += "--------------------------------<BR>";
  68. content += "合计:xx.0元<BR>";
  69. content += "送货地点:广州市南沙区xx路xx号<BR>";
  70. content += "联系电话:13888888888888<BR>";
  71. content += "订餐时间:2016-08-08 08:08:08<BR>";
  72. content += "<QR>http://www.dzist.com</QR>";
  73. return FeiEPrinterUtil.printReceipt(sn, content);
  74. }
  75. /**
  76. * 根据坐标获取油站列表
  77. */
  78. @RequestMapping(value = "/getStationInfoList", method = RequestMethod.GET)
  79. @ResponseBody
  80. public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize){
  81. Gson gson =new Gson();
  82. //返回结果集
  83. ResultData resultData=null;
  84. if(stationLongitude!=null && stationLatitude !=null){
  85. if(StringUtils.isNotBlank(stationLongitude)&&StringUtils.isNotBlank(stationLatitude)){
  86. StationRequest stationRequest=new StationRequest();
  87. stationRequest.setStationLatitude(stationLatitude);
  88. stationRequest.setStationLongitude(stationLongitude);
  89. stationRequest.setPageNum(pageNum);
  90. stationRequest.setPageSize(pageSize);
  91. //调用接口 根据坐标筛选距离最近的加油站
  92. StationInfoVo stationInfoVo = stationService.stationInfoList(stationRequest);
  93. resultData=ResultData.success(stationInfoVo);
  94. }else{
  95. resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
  96. }
  97. }else{
  98. resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
  99. }
  100. return gson.toJson(resultData);
  101. }
  102. /**
  103. * 获取油站列表信息
  104. */
  105. @RequestMapping(value = "/getStationList", method = RequestMethod.GET)
  106. @ResponseBody
  107. public String getStationList(@RequestParam StationRequest request){
  108. Gson gson =new Gson();
  109. StationInfo stationInfo =new StationInfo();
  110. List<StationInfo> stationInfoList = stationService.getStationList(stationInfo);
  111. return gson.toJson(stationInfoList);
  112. }
  113. /**
  114. * 获取油站列表信息
  115. */
  116. @RequestMapping(value = "/addStationInfo", method = RequestMethod.POST)
  117. @ResponseBody
  118. public String addStationInfo(@RequestParam StationRequest request){
  119. Gson gson =new Gson();
  120. ResultData resultData=null;
  121. StationInfo stationInfo =new StationInfo();
  122. if(request.getStationId()!=null){
  123. stationInfo.setStationId(request.getStationId());
  124. }
  125. if(StringUtils.isNotBlank(request.getStationName())){
  126. stationInfo.setStationName(request.getStationName());
  127. }
  128. if(StringUtils.isNotBlank(request.getContacts())){
  129. stationInfo.setContacts(request.getContacts());
  130. }
  131. if(StringUtils.isNotBlank(request.getPhone())){
  132. stationInfo.setPhone(request.getPhone());
  133. }
  134. if(StringUtils.isNotBlank(request.getStationAddress())){
  135. stationInfo.setStationAddress(request.getStationAddress());
  136. }
  137. if(request.getStationGroupId()!=null){
  138. stationInfo.setStationGroupId(request.getStationGroupId());
  139. }
  140. if(request.getStationGroupName()!=null){
  141. stationInfo.setStationGroupName(request.getStationGroupName());
  142. }
  143. if(request.getContacts()!=null){
  144. stationInfo.setContacts(request.getContacts());
  145. }
  146. try{
  147. stationService.AddStationInfo(stationInfo);
  148. resultData=ResultData.success(CodeMsg.SUCCESS);
  149. }catch (Exception e){
  150. resultData=ResultData.error(CodeMsg.INSERT_FAIL);
  151. e.printStackTrace();
  152. }
  153. return gson.toJson(resultData);
  154. }
  155. /**
  156. * 修改油站信息
  157. */
  158. @RequestMapping(value = "/updateStationInfo", method = RequestMethod.POST)
  159. @ResponseBody
  160. public String updateStationInfo(@RequestBody StationInfo stationInfo){
  161. Gson gson=new Gson();
  162. ResultData resultData=null;
  163. try{
  164. stationService.updateStationInfo(stationInfo);
  165. resultData=ResultData.success(CodeMsg.SUCCESS);
  166. }catch (Exception e){
  167. resultData=ResultData.error(CodeMsg.UPDATE_FAIL);
  168. e.printStackTrace();
  169. }
  170. return gson.toJson(resultData);
  171. }
  172. /**
  173. * 删除油站信息
  174. */
  175. @RequestMapping(value = "/deleteStationInfo", method = RequestMethod.POST)
  176. @ResponseBody
  177. public String deleteStationInfo(@RequestBody StationInfo stationInfo){
  178. Gson gson=new Gson();
  179. ResultData resultData=null;
  180. try{
  181. stationService.deleteStationInfo(stationInfo);
  182. resultData=ResultData.success(CodeMsg.SUCCESS);
  183. }catch (Exception e){
  184. resultData=ResultData.error(CodeMsg.DELETE_FAIL);
  185. e.printStackTrace();
  186. }
  187. return gson.toJson(resultData);
  188. }
  189. /**
  190. * 油站设备管理查询
  191. */
  192. @RequestMapping(value = "/getStationNoticeManageList", method = RequestMethod.GET)
  193. @ResponseBody
  194. public String getStationNoticeManageList(@RequestParam StationRequest request){
  195. Gson gson=new Gson();
  196. ResultData resultData=null;
  197. try{
  198. StationNoticeManage stationNoticeManage =new StationNoticeManage();
  199. List<StationNoticeManage> stationNoticeManageList = stationNoticeManageService.getStationNoticeManageList(stationNoticeManage);
  200. resultData=ResultData.success(stationNoticeManageList);
  201. }catch (Exception e){
  202. resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
  203. e.printStackTrace();
  204. }
  205. return gson.toJson(resultData);
  206. }
  207. /**
  208. *修改油站设备管理
  209. */
  210. @RequestMapping(value = "/updateStationNoticeManage", method = RequestMethod.POST)
  211. @ResponseBody
  212. public String updateStationNoticeManage(@RequestBody StationNoticeManage stationNoticeManage){
  213. Gson gson=new Gson();
  214. ResultData resultData=null;
  215. try{
  216. stationNoticeManageService.updateStationNoticeManage(stationNoticeManage);
  217. resultData=ResultData.success(CodeMsg.SUCCESS);
  218. }catch (Exception e){
  219. resultData=ResultData.success(CodeMsg.UPDATE_FAIL);
  220. e.printStackTrace();
  221. }
  222. return gson.toJson(resultData);
  223. }
  224. /**
  225. * 删除油站设备信息
  226. */
  227. @RequestMapping(value = "/deleteStationNoticeManage", method = RequestMethod.POST)
  228. @ResponseBody
  229. public String deleteStationNoticeManage(@RequestBody StationNoticeManage stationNoticeManage){
  230. Gson gson=new Gson();
  231. ResultData resultData=null;
  232. try{
  233. stationNoticeManageService.deleteStationNoticeManage(stationNoticeManage);
  234. resultData=ResultData.success(CodeMsg.SUCCESS);
  235. }catch (Exception e){
  236. resultData=ResultData.success(CodeMsg.DELETE_FAIL);
  237. e.printStackTrace();
  238. }
  239. return gson.toJson(resultData);
  240. }
  241. /**
  242. * 油枪管理
  243. */
  244. @RequestMapping(value = "/stationOilGunList", method = RequestMethod.GET)
  245. @ResponseBody
  246. // public void stationOilGunList(@RequestParam StationRequest request,HttpServletResponse response){
  247. // public String stationOilGunList(@RequestParam String userType,String token,Integer stationId){
  248. public String stationOilGunList(@RequestParam Integer stationId){
  249. Gson gson =new Gson();
  250. StationOilGun stationOilGun =new StationOilGun();
  251. //查询登录人是否存在
  252. // AppUserInfo appUserInfo =new AppUserInfo();
  253. //订单类型 是小程序还是公众号
  254. // appUserInfo.setUserType(userType);
  255. // if(userType.equals("1")){
  256. // //1 是公众号
  257. // appUserInfo.setBlogToken(token);
  258. // }else if(userType.equals("2")){
  259. // //2是小程序
  260. // appUserInfo.setMinaToken(token);
  261. // }
  262. // List<AppUserInfo> appUserInfoList =appUserInfoService.Authentication(appUserInfo);
  263. // if(appUserInfoList!=null&&appUserInfoList.size()>0){
  264. //获取油站id根据油站号查询油站对应的所有油枪信息
  265. stationOilGun.setStationId(stationId);
  266. List<StationOilGun> stationOilGunList = stationOilGunService.stationOilGunList(stationOilGun);
  267. ResultData resultData=ResultData.success(stationOilGunList);
  268. return gson.toJson(resultData);
  269. // }else {
  270. // ResultData resultData=ResultData.error(CodeMsg.USER_NOT_EXSIST);
  271. // return gson.toJson(resultData);
  272. // }
  273. }
  274. }