123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- package com.care.keeper.controller;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.care.common.exception.BDException;
- import com.care.common.service.FileUploadService;
- import com.care.common.util.PageResult;
- import com.care.common.util.Result;
- import com.care.common.vo.PageReqVO;
- import com.care.common.vo.order.*;
- import com.care.keeper.service.KeeperApiService;
- import com.care.keeper.service.KeeperPassportService;
- import com.care.keeper.vo.HouseContactVO;
- import com.care.keeper.vo.KeeperInfoVO;
- import io.swagger.annotations.*;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @Author: lilt
- * @Date: 2021/5/26
- * @Desc:
- */
- @RestController
- @Api(value = "EventHandleController")
- @Slf4j
- @RequestMapping("/keeper/api/event")
- public class KeeperEventApiController {
- @Resource
- private KeeperApiService keeperApiService;
- @Resource
- private KeeperPassportService keeperPassportService;
- @Resource
- private FileUploadService fileUploadService;
- @GetMapping("/queryTodoList")
- @ApiOperation(tags = {"我的"},value = "未处理事件 分页")
- public PageResult<List<ChambEventOrderVO>> queryTodoList(@RequestHeader String token,PageReqVO pageReqVo){
- try {
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryTodoEventByChambId(pageReqVo,current.getId());
- return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
- }catch (BDException e) {
- log.error("我的未处理事件 分页列表出现异常",e);
- return PageResult.error(e.getMessage());
- } catch (Exception e) {
- log.error("我的事件处理: 未处理事件查询出现异常",e);
- return PageResult.error( "获取列表失败");
- }
- }
- @GetMapping("/queryDoingList")
- @ApiOperation(tags = {"我的"},value = "处理中事件 分页")
- public PageResult<List<ChambEventOrderVO>> queryDoingList(@RequestHeader String token,PageReqVO pageReqVo){
- try {
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryDoingEventByChambId(pageReqVo,current.getId());
- return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
- }catch (BDException e) {
- log.error("我的处理中事件 分页列表出现异常",e);
- return PageResult.error(e.getMessage());
- } catch (Exception e) {
- log.error("我的事件处理: 处理中事件查询出现异常",e);
- return PageResult.error( "获取列表失败");
- }
- }
- @GetMapping("/queryDoneList")
- @ApiOperation(tags = {"我的"},value = "已完成事件 分页")
- public PageResult<List<ChambEventOrderVO>> queryDoneList(@RequestHeader String token,PageReqVO pageReqVo){
- try {
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- IPage<ChambEventOrderVO> pageResponse = this.keeperApiService.queryDoneEventByChambId(pageReqVo,current.getId());
- return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
- }catch (BDException e) {
- log.error("我的已完成事件 分页列表出现异常",e);
- return PageResult.error(e.getMessage());
- } catch (Exception e) {
- log.error("我的已完成事件: 分页列表出现异常",e);
- return PageResult.error( "获取列表失败");
- }
- }
- @GetMapping("/getEventInfo")
- @ApiOperation(tags = {"事件处理"},value = "事件处理或者详情")
- public Result<Map<String,Object>> getEventInfo(@RequestParam("orderId") Long orderId){
- EventOrderVO eventOrderVO = this.keeperApiService.getEventInfo(orderId);
- List<OrderOlderVO> olderVOList = this.keeperApiService.queryOrderOlderList(orderId);
- List<HouseContactVO> houseContactVOList = this.keeperApiService.queryContactByOrderId(orderId);
- Map<String,Object> data = new HashMap<>(3);
- //订单信息
- data.put("info",eventOrderVO);
- //老人
- data.put("older",olderVOList);
- // 联系人
- data.put("contact",houseContactVOList);
- return Result.success("查询成功!",data);
- }
- @GetMapping("/getApplyKeyInfo")
- @ApiOperation(tags = {"事件处理"},value = "获取钥匙信息,data如果为NULL,需要进行申请")
- public Result<OrderKeyApplyVO> getApplyKeyInfo(@RequestHeader("token") String token, @RequestParam("orderId") Long orderId){
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- OrderKeyApplyVO orderKeyApplyVO = this.keeperApiService.getApplyKeyInfo(orderId,current.getId());
- return Result.success("查询成功!",orderKeyApplyVO);
- }
- @GetMapping("/toApplyKey")
- @ApiOperation(tags = {"事件处理"},value = "申请钥匙")
- public Result<Map<String,Object>> toApplyKey(@RequestHeader("token") String token, @RequestParam("orderId") Long orderId){
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- this.keeperApiService.applyKey(orderId,current);
- return Result.success("申请成功!");
- }
- @PostMapping("/daoda")
- @ApiOperation(tags = {"事件处理"},value = "到达确认")
- public Result<Object> daoDaConfirm(@RequestParam("chambOrderId") Long chambOrderId){
- if (this.keeperApiService.daoDaConfirm(chambOrderId)){
- return Result.success("到达确认成功!");
- }else{
- return Result.error("操作失败!");
- }
- }
- @PostMapping("/likai")
- @ApiOperation(tags = {"事件处理"},value = "离开确认")
- public Result<Object> liKaiConfirm(@RequestParam("chambOrderId") Long chambOrderId,@RequestParam("remark") String remark,@RequestParam("scenePic") String scenePic){
- if (this.keeperApiService.liKaiConfirm(chambOrderId,remark,scenePic)){
- return Result.success("离开确认成功!");
- }else{
- return Result.error("操作失败!");
- }
- }
- @GetMapping("/queryDoHis")
- @ApiOperation(tags = {"事件处理"},value = "处理日志")
- public Result<List<OrderHandleHisVO>> queryDoHis(@RequestParam("orderId") Long orderId){
- return Result.success("查询成功!",this.keeperApiService.queryOrderHandleHis(orderId));
- }
- @ApiOperation(tags = {"APP-图片上传"},value = "图片上传接口", notes = "图片上传接口")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "token", value = "放在请求头中的令牌",
- dataType = "String", paramType = "header",
- required = true)
- })
- @CrossOrigin
- @PostMapping(value = "/img/upload", headers="content-type=multipart/form-data",produces = "application/json;charset=UTF-8")
- public Result<String> imgUpload( @ApiParam(value="图片",required=true) MultipartFile file,
- @RequestHeader(name = "token") String token) {
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- String url = fileUploadService.upload(file,"order");
- return Result.success("上传成功!",url);
- }
- @GetMapping("/getKeeperStatus")
- @ApiOperation(tags = {"事件处理"},value = "获取管家当前的状态 0:未到达 1 到达、服务中 2 离开")
- public Result<Integer> getKeeperStatus(@RequestParam("chambOrderId") Long chambOrderId){
- Integer status = 0;
- ChambEventOrderVO orderVO = this.keeperApiService.getChambOrder(chambOrderId);
- if (orderVO!=null ){
- if (orderVO.getDaodaTime()!=null && orderVO.getLikaiTime()==null){
- status = 1;
- }else if (orderVO.getDaodaTime()!=null && orderVO.getLikaiTime()!=null){
- status = 2 ;
- }
- }
- return Result.success("查询成功!",status);
- }
- @GetMapping("/getFuwuCount")
- @ApiOperation(tags = {"首页"},value = "获取管家的服务人数")
- public Result<Integer> getFuwuCount( @RequestHeader(name = "token") String token){
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- return Result.success("查询成功!",this.keeperApiService.queryOlderCount(current));
- }
- @GetMapping("/myOrderStat")
- @ApiOperation(tags = {"我的"},value = "工单统计")
- public Result<ChambEventOrderCountVO> myOrderStat( @RequestHeader(name = "token") String token){
- KeeperInfoVO current = this.keeperPassportService.checkToken(token);
- return Result.success("查询成功!",this.keeperApiService.getOrderCountByChambId(current.getId()));
- }
- }
|