New file |
| | |
| | | package com.panzhihua.community_backstage.api; |
| | | |
| | | /** |
| | | * 西区手环接口 |
| | | */ |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.bracelet.BraceletEarlyWarningDO; |
| | | import com.panzhihua.common.model.dtos.bracelet.BraceletUserDataDO; |
| | | import com.panzhihua.common.model.dtos.bracelet.SetSOS; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.service.bracelet.CommunityBraceletService; |
| | | import com.panzhihua.common.utlis.HttpClientUtil; |
| | | import com.panzhihua.community_backstage.model.vos.PutmessageBody; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"金汇手环接口"}) |
| | | @RestController |
| | | @RequestMapping("/JinhuibraceletApi/") |
| | | public class JinhuiBraceletApi extends BaseController |
| | | { |
| | | |
| | | @Resource |
| | | private CommunityBraceletService communityBraceletService; |
| | | |
| | | /** |
| | | * 手环数据获取 |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "手环数据获取") |
| | | @GetMapping("getData") |
| | | public R getData(@RequestParam("pageNum") Integer pageNum, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam("userName") String userName, |
| | | @RequestParam("phone") String phone) |
| | | { |
| | | return communityBraceletService.getData(pageNum,pageSize,getCommunityId()+"",userName,phone); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手环数据编辑接口 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "手环数据编辑接口") |
| | | @PostMapping("upBracelet") |
| | | public R upBracelet(@RequestBody BraceletUserDataDO braceletUserDataDO) |
| | | { |
| | | if(StringUtils.isEmpty(braceletUserDataDO.getDeviceId())) |
| | | { |
| | | return R.fail("设备id不能为空"); |
| | | } |
| | | return communityBraceletService.upBracelet(braceletUserDataDO); |
| | | } |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * @param id 设备id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除设备") |
| | | @DeleteMapping("delectData") |
| | | public R delectData(@RequestParam("id") String id) |
| | | { |
| | | return communityBraceletService.delectData(id); |
| | | } |
| | | |
| | | /** |
| | | * 用户手环参数变化 新增数据 |
| | | * @param braceletUserDataDO |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "用户手环新增用户接口") |
| | | @PostMapping("addBraceletUser") |
| | | public R addBraceletUser(@RequestBody BraceletUserDataDO braceletUserDataDO) |
| | | { |
| | | braceletUserDataDO.setCommunityId(getCommunityId()+""); |
| | | if(braceletUserDataDO==null) |
| | | { |
| | | return R.fail("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(braceletUserDataDO.getDeviceId())) |
| | | { |
| | | return R.fail("设备ID 不能为空"); |
| | | } |
| | | |
| | | // log.info("用户手环 putmessage : "+braceletUserDataDO.toString()); |
| | | return communityBraceletService.addBracelet(braceletUserDataDO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户手环参数变化 更新数据 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "手环设置SOS联系人") |
| | | @PostMapping("setSOS") |
| | | public R setSOS(@RequestBody SetSOS setSOS) |
| | | { |
| | | if(setSOS==null) |
| | | { |
| | | return R.fail("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(setSOS.getDeviceId())) |
| | | { |
| | | return R.fail("设备ID 不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(setSOS.getEmergencyContact1()) && StringUtils.isEmpty(setSOS.getEmergencyContact2()) |
| | | && StringUtils.isEmpty(setSOS.getEmergencyContact3())) |
| | | { |
| | | return R.fail("联系人不能全部为空"); |
| | | } |
| | | |
| | | |
| | | // 3 W11 智能手表 |
| | | // 2 W5 智能手环 |
| | | // 1 W6 智能手表 |
| | | Map allMap=new HashMap(); |
| | | Map phone=new HashMap(); |
| | | |
| | | // if(StringUtils.equals(braceletUserDataDO.getDeviceModel(),"W11")) |
| | | // { |
| | | // allMap.put("deviceModelId",3); |
| | | // } |
| | | // else if(StringUtils.equals(braceletUserDataDO.getDeviceModel(),"W5")) |
| | | // { |
| | | // allMap.put("deviceModelId",2); |
| | | // } |
| | | // else |
| | | // { |
| | | // allMap.put("deviceModelId",1); |
| | | // } |
| | | allMap.put("deviceModelId",3); |
| | | |
| | | |
| | | BraceletUserDataDO dataDO=new BraceletUserDataDO(); |
| | | dataDO.setDeviceId(setSOS.getDeviceId()); |
| | | dataDO.setOnoff("1"); |
| | | phone.put("sgtel1",setSOS.getEmergencyContact1()); |
| | | dataDO.setSgtel1(setSOS.getEmergencyContact1()); |
| | | |
| | | phone.put("sgtel2",setSOS.getEmergencyContact2()); |
| | | dataDO.setSgtel2(setSOS.getEmergencyContact2()); |
| | | |
| | | phone.put("sgtel3",setSOS.getEmergencyContact3()); |
| | | dataDO.setSgtel3(setSOS.getEmergencyContact3()); |
| | | |
| | | |
| | | allMap.put("deviceID",setSOS.getDeviceId()); |
| | | allMap.put("apiKey","C71584EDE98983A1976AAE8DBCF6B9CF"); |
| | | allMap.put("type",1); |
| | | allMap.put("dataInfo",phone); |
| | | |
| | | |
| | | String resultJson = HttpClientUtil.sendPostByJson("http://apps.jkez.net/openapi/mobile/saveDeviceSet", JSON.toJSONString(allMap), |
| | | 0,null,null); |
| | | JSONObject result = JSON.parseObject(resultJson); |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(dataDO.getSgtel1()) || !StringUtils.isEmpty(dataDO.getSgtel2()) || |
| | | !StringUtils.isEmpty(dataDO.getSgtel3())) |
| | | { |
| | | communityBraceletService.upBracelet(dataDO); |
| | | } |
| | | |
| | | R r=new R(); |
| | | int code=result.getIntValue("code"); |
| | | if(code==400) |
| | | { |
| | | dataDO.setOnoff("0"); |
| | | } |
| | | communityBraceletService.upBracelet(dataDO); |
| | | r.setCode(code); |
| | | r.setMsg(result.getString("message")); |
| | | return r; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户 手环数据详情 |
| | | * @param deviceID |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取用户 手环数据详情") |
| | | @GetMapping("getDetails") |
| | | public R getDetails(@RequestParam("deviceID") String deviceID) |
| | | { |
| | | return communityBraceletService.getDetails(deviceID); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 编辑手环预警数据 |
| | | * @param braceletEarlyWarningDO |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "编辑手环预警数据") |
| | | @PostMapping("upEarlyWarning") |
| | | public R upEarlyWarning(@RequestBody BraceletEarlyWarningDO braceletEarlyWarningDO) { |
| | | return communityBraceletService.upEarlyWarning(braceletEarlyWarningDO); |
| | | } |
| | | |
| | | /** |
| | | * 删除预警数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除预警数据") |
| | | @DeleteMapping("delectEarlyWarning") |
| | | public R delectEarlyWarning(@RequestParam("id") String id) { |
| | | return communityBraceletService.delectEarlyWarning(id); |
| | | } |
| | | |
| | | /** |
| | | * 获取预警数据 |
| | | * @param communityId |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取预警数据") |
| | | @GetMapping("getEarlyWarningList") |
| | | public R getList(@RequestParam("pageNum") Integer pageNum, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam("communityId") String communityId, |
| | | @RequestParam("equipmentNumber") String equipmentNumber, |
| | | @RequestParam("type") String type, |
| | | @RequestParam("userName") String userName, |
| | | @RequestParam("phone") String phone) |
| | | { |
| | | return communityBraceletService.getList(pageNum,pageSize,communityId,equipmentNumber,"",type,userName,phone); |
| | | } |
| | | |
| | | /** |
| | | * 获取单个预警信息详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取单个预警信息详情") |
| | | @GetMapping("getEarlyWarningDetails") |
| | | public R getEarlyWarningDetails(@RequestParam("id") String id) |
| | | { |
| | | return communityBraceletService.getEarlyWarningDetails(id); |
| | | } |
| | | |
| | | /** |
| | | * 处理接口 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "处理接口") |
| | | @PostMapping("dispose") |
| | | public R dispose(@RequestBody BraceletEarlyWarningDO braceletEarlyWarningDO) |
| | | { |
| | | return communityBraceletService.dispose(braceletEarlyWarningDO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理人 |
| | | * @param communityId |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "处理人") |
| | | @GetMapping("conductorList") |
| | | public R conductorList(@RequestParam("communityId") String communityId) |
| | | { |
| | | return communityBraceletService.conductorList(communityId); |
| | | } |
| | | |
| | | } |