KeeperEventApiController.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. package com.care.keeper.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.care.common.exception.BDException;
  4. import com.care.common.service.FileUploadService;
  5. import com.care.common.util.PageResult;
  6. import com.care.common.util.Result;
  7. import com.care.common.vo.PageReqVO;
  8. import com.care.common.vo.order.*;
  9. import com.care.keeper.service.KeeperApiService;
  10. import com.care.keeper.service.KeeperPassportService;
  11. import com.care.keeper.vo.HouseContactVO;
  12. import com.care.keeper.vo.KeeperInfoVO;
  13. import io.swagger.annotations.*;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.springframework.web.bind.annotation.*;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import javax.annotation.Resource;
  18. import java.util.HashMap;
  19. import java.util.List;
  20. import java.util.Map;
  21. /**
  22. * @Author: lilt
  23. * @Date: 2021/5/26
  24. * @Desc:
  25. */
  26. @RestController
  27. @Api(value = "EventHandleController")
  28. @Slf4j
  29. @RequestMapping("/keeper/api/event")
  30. public class KeeperEventApiController {
  31. @Resource
  32. private KeeperApiService keeperApiService;
  33. @Resource
  34. private KeeperPassportService keeperPassportService;
  35. @Resource
  36. private FileUploadService fileUploadService;
  37. @GetMapping("/queryTodoList")
  38. @ApiOperation(tags = {"我的"},value = "未处理事件 分页")
  39. public PageResult<List<ChambEventOrderVO>> queryTodoList(@RequestHeader String token,PageReqVO pageReqVo){
  40. try {
  41. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  42. IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryTodoEventByChambId(pageReqVo,current.getId());
  43. return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
  44. }catch (BDException e) {
  45. log.error("我的未处理事件 分页列表出现异常",e);
  46. return PageResult.error(e.getMessage());
  47. } catch (Exception e) {
  48. log.error("我的事件处理: 未处理事件查询出现异常",e);
  49. return PageResult.error( "获取列表失败");
  50. }
  51. }
  52. @GetMapping("/queryDoingList")
  53. @ApiOperation(tags = {"我的"},value = "处理中事件 分页")
  54. public PageResult<List<ChambEventOrderVO>> queryDoingList(@RequestHeader String token,PageReqVO pageReqVo){
  55. try {
  56. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  57. IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryDoingEventByChambId(pageReqVo,current.getId());
  58. return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
  59. }catch (BDException e) {
  60. log.error("我的处理中事件 分页列表出现异常",e);
  61. return PageResult.error(e.getMessage());
  62. } catch (Exception e) {
  63. log.error("我的事件处理: 处理中事件查询出现异常",e);
  64. return PageResult.error( "获取列表失败");
  65. }
  66. }
  67. @GetMapping("/queryDoneList")
  68. @ApiOperation(tags = {"我的"},value = "已完成事件 分页")
  69. public PageResult<List<ChambEventOrderVO>> queryDoneList(@RequestHeader String token,PageReqVO pageReqVo){
  70. try {
  71. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  72. IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryDoneEventByChambId(pageReqVo,current.getId());
  73. return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
  74. }catch (BDException e) {
  75. log.error("我的已完成事件 分页列表出现异常",e);
  76. return PageResult.error(e.getMessage());
  77. } catch (Exception e) {
  78. log.error("我的已完成事件: 分页列表出现异常",e);
  79. return PageResult.error( "获取列表失败");
  80. }
  81. }
  82. @GetMapping("/getEventInfo")
  83. @ApiOperation(tags = {"事件处理"},value = "事件处理或者详情")
  84. public Result<Map<String,Object>> getEventInfo(@RequestParam("orderId") Long orderId){
  85. EventOrderVO eventOrderVO = this.keeperApiService.getEventInfo(orderId);
  86. List<OrderOlderVO> olderVOList = this.keeperApiService.queryOrderOlderList(orderId);
  87. List<HouseContactVO> houseContactVOList = this.keeperApiService.queryContactByOrderId(orderId);
  88. Map<String,Object> data = new HashMap<>(3);
  89. //订单信息
  90. data.put("info",eventOrderVO);
  91. //老人
  92. data.put("older",olderVOList);
  93. // 联系人
  94. data.put("contact",houseContactVOList);
  95. return Result.success("查询成功!",data);
  96. }
  97. @GetMapping("/getApplyKeyInfo")
  98. @ApiOperation(tags = {"事件处理"},value = "获取钥匙信息,data如果为NULL,需要进行申请")
  99. public Result<OrderKeyApplyVO> getApplyKeyInfo(@RequestHeader("token") String token, @RequestParam("orderId") Long orderId){
  100. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  101. OrderKeyApplyVO orderKeyApplyVO = this.keeperApiService.getApplyKeyInfo(orderId,current.getId());
  102. return Result.success("查询成功!",orderKeyApplyVO);
  103. }
  104. @GetMapping("/toApplyKey")
  105. @ApiOperation(tags = {"事件处理"},value = "申请钥匙")
  106. public Result<Map<String,Object>> toApplyKey(@RequestHeader("token") String token, @RequestParam("orderId") Long orderId){
  107. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  108. this.keeperApiService.applyKey(orderId,current);
  109. return Result.success("申请成功!");
  110. }
  111. @PostMapping("/daoda")
  112. @ApiOperation(tags = {"事件处理"},value = "到达确认")
  113. public Result<Object> daoDaConfirm(@RequestParam("chambOrderId") Long chambOrderId){
  114. if (this.keeperApiService.daoDaConfirm(chambOrderId)){
  115. return Result.success("到达确认成功!");
  116. }else{
  117. return Result.error("操作失败!");
  118. }
  119. }
  120. @PostMapping("/likai")
  121. @ApiOperation(tags = {"事件处理"},value = "离开确认")
  122. public Result<Object> liKaiConfirm(@RequestParam("chambOrderId") Long chambOrderId,@RequestParam("remark") String remark,@RequestParam("scenePic") String scenePic){
  123. if (this.keeperApiService.liKaiConfirm(chambOrderId,remark,scenePic)){
  124. return Result.success("离开确认成功!");
  125. }else{
  126. return Result.error("操作失败!");
  127. }
  128. }
  129. @GetMapping("/queryDoHis")
  130. @ApiOperation(tags = {"事件处理"},value = "处理日志")
  131. public Result<List<OrderHandleHisVO>> queryDoHis(@RequestParam("orderId") Long orderId){
  132. return Result.success("查询成功!",this.keeperApiService.queryOrderHandleHis(orderId));
  133. }
  134. @ApiOperation(tags = {"APP-图片上传"},value = "图片上传接口", notes = "图片上传接口")
  135. @ApiImplicitParams({
  136. @ApiImplicitParam(name = "token", value = "放在请求头中的令牌",
  137. dataType = "String", paramType = "header",
  138. required = true)
  139. })
  140. @CrossOrigin
  141. @PostMapping(value = "/img/upload", headers="content-type=multipart/form-data",produces = "application/json;charset=UTF-8")
  142. public Result<String> imgUpload( @ApiParam(value="图片",required=true) MultipartFile file,
  143. @RequestHeader(name = "token") String token) {
  144. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  145. String url = fileUploadService.upload(file,"order");
  146. return Result.success("上传成功!",url);
  147. }
  148. @GetMapping("/getKeeperStatus")
  149. @ApiOperation(tags = {"事件处理"},value = "获取管家当前的状态 0:未到达 1 到达、服务中 2 离开")
  150. public Result<Integer> getKeeperStatus(@RequestParam("chambOrderId") Long chambOrderId){
  151. Integer status = 0;
  152. ChambEventOrderVO orderVO = this.keeperApiService.getChambOrder(chambOrderId);
  153. if (orderVO!=null ){
  154. if (orderVO.getDaodaTime()!=null && orderVO.getLikaiTime()==null){
  155. status = 1;
  156. }else if (orderVO.getDaodaTime()!=null && orderVO.getLikaiTime()!=null){
  157. status = 2 ;
  158. }
  159. }
  160. return Result.success("查询成功!",status);
  161. }
  162. @GetMapping("/getFuwuCount")
  163. @ApiOperation(tags = {"首页"},value = "获取管家的服务人数")
  164. public Result<Integer> getFuwuCount( @RequestHeader(name = "token") String token){
  165. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  166. return Result.success("查询成功!",this.keeperApiService.queryOlderCount(current));
  167. }
  168. @GetMapping("/myOrderStat")
  169. @ApiOperation(tags = {"我的"},value = "工单统计")
  170. public Result<ChambEventOrderCountVO> myOrderStat( @RequestHeader(name = "token") String token){
  171. KeeperInfoVO current = this.keeperPassportService.checkToken(token);
  172. return Result.success("查询成功!",this.keeperApiService.getOrderCountByChambId(current.getId()));
  173. }
  174. }