|
@@ -1,22 +1,39 @@
|
|
|
package com.template.controller;
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
-import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.template.api.HouseNumberStateAPI;
|
|
import com.template.api.HouseNumberStateAPI;
|
|
|
|
|
+import com.template.common.utils.AesUtils;
|
|
|
|
|
+import com.template.common.utils.DateUtil;
|
|
|
|
|
+import com.template.common.utils.HttpClientHelper;
|
|
|
|
|
+import com.template.common.utils.MD5;
|
|
|
|
|
+import com.template.config.DoorLockConfig;
|
|
|
|
|
+import com.template.model.enumModel.PasswordUrlEnum;
|
|
|
|
|
+import com.template.model.pojo.*;
|
|
|
import com.template.model.result.CommonResult;
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
import com.template.model.result.PageUtils;
|
|
|
-import com.template.model.vo.HouseStateVo;
|
|
|
|
|
-import com.template.model.vo.HouseVo;
|
|
|
|
|
-import com.template.services.HouseNumberService;
|
|
|
|
|
-import com.template.services.HouseNumberStateService;
|
|
|
|
|
-import com.template.services.HouseService;
|
|
|
|
|
|
|
+import com.template.model.vo.*;
|
|
|
|
|
+import com.template.services.*;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.time.*;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
@@ -38,6 +55,21 @@ public class HouseNumberStateController implements HouseNumberStateAPI {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
HouseNumberService houseNumberService;
|
|
HouseNumberService houseNumberService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ HousePriceService housePriceService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ HouseOrderService houseOrderService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ HouseLockService houseLockService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ HouseOrderBillService houseOrderBillService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ DoorLockConfig doorLockConfig;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public CommonResult page(String keyWord, String houseType, int page, int size) {
|
|
public CommonResult page(String keyWord, String houseType, int page, int size) {
|
|
|
|
|
|
|
@@ -46,28 +78,335 @@ public class HouseNumberStateController implements HouseNumberStateAPI {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(size) && size <= 0) {
|
|
if (ObjectUtils.isEmpty(size) && size <= 0) {
|
|
|
- size= 10;
|
|
|
|
|
|
|
+ size = 10;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 当时时间
|
|
// 当时时间
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
- PageUtils<HouseStateVo> pageVo=houseNumberService.houseStatePage(keyWord,houseType,page,size,date);
|
|
|
|
|
|
|
+ PageUtils<HouseStateVo> pageVo = houseNumberService.houseStatePage(keyWord, houseType, page, size, date);
|
|
|
|
|
|
|
|
return CommonResult.ok(pageVo);
|
|
return CommonResult.ok(pageVo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult calendarPage(String startTime, String endTime, String keyWord, String houseType, int page, int size) {
|
|
|
|
|
|
|
+ public CommonResult calendarPage(String datetime, String keyWord, String houseType, int page, int size) {
|
|
|
|
|
+ if (ObjectUtils.isEmpty(page) && page <= 0) {
|
|
|
|
|
+ page = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isEmpty(size) && size <= 0) {
|
|
|
|
|
+ size = 10;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 返回格式
|
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当时时间
|
|
|
|
|
+ LocalDate localDate;
|
|
|
|
|
+ DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ if (ObjectUtils.isEmpty(datetime)) {
|
|
|
|
|
+ localDate = LocalDate.now();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ localDate = LocalDate.parse(datetime, dateTimeFormatter2);
|
|
|
|
|
+ }
|
|
|
|
|
+// 需获取21天内的所有改价信息
|
|
|
|
|
+ LocalDate endLocalDate = localDate.plusDays(20);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取所有房间号
|
|
|
|
|
+ List<HouseNumber> houseNumberList = houseNumberService.list(new LambdaQueryWrapper<HouseNumber>());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前房型的所有id
|
|
|
|
|
+ String houseNumberIds = "";
|
|
|
|
|
+ for (int i = 0; i < houseNumberList.size(); i++) {
|
|
|
|
|
+ String houseNumber = houseNumberList.get(i).getId() + "";
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
|
+ houseNumberIds = houseNumberIds + houseNumber;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ houseNumberIds = houseNumberIds + "," + houseNumber;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("houseNumberIds = " + houseNumberIds);
|
|
|
|
|
+
|
|
|
|
|
+// 通过房型id获取房态状态
|
|
|
|
|
+ List<HouseNumberState> houseNumberStates = houseNumberStateService.houseNumberStateList(localDate, endLocalDate, houseNumberIds);
|
|
|
|
|
+
|
|
|
|
|
+// 房间总数
|
|
|
|
|
+ int totalCount = houseNumberList.size();
|
|
|
|
|
+
|
|
|
|
|
+ // 时间日期
|
|
|
|
|
+ ArrayList<HouseNumberStateDateVo> list = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < 21; i++) {
|
|
|
|
|
+ LocalDate localDate1 = localDate.plusDays(i);
|
|
|
|
|
+ String format = localDate1.format(dateTimeFormatter2);
|
|
|
|
|
+ HouseNumberStateDateVo houseNumberStateDateVo = new HouseNumberStateDateVo();
|
|
|
|
|
+ houseNumberStateDateVo.setDate(format);
|
|
|
|
|
+ int count = totalCount;
|
|
|
|
|
+ for (HouseNumberState houseNumberState : houseNumberStates) {
|
|
|
|
|
+ if (houseNumberState.getStatus() != 1) {
|
|
|
|
|
+// 开始时间
|
|
|
|
|
+ String startTime = houseNumberState.getStartTime();
|
|
|
|
|
+// 结束时间
|
|
|
|
|
+ String endTime = houseNumberState.getEndTime();
|
|
|
|
|
+
|
|
|
|
|
+ Date startDate = DateUtil.parseDateOnly(startTime);
|
|
|
|
|
+ Date endDate = DateUtil.parseDateOnly(endTime);
|
|
|
|
|
+ Date date1 = Date.from(localDate1.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
+ boolean effectiveDate = DateUtil.isEffectiveDate(date1, startDate, endDate);
|
|
|
|
|
+ if (effectiveDate) {
|
|
|
|
|
+ count = count - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ houseNumberStateDateVo.setCount(count);
|
|
|
|
|
+ list.add(houseNumberStateDateVo);
|
|
|
|
|
+ }
|
|
|
|
|
+// 时间格式
|
|
|
|
|
+ map.put("dateTime", list);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ PageUtils<CalendarPageVo> pageVo = houseNumberService.houseStateCalendarPage(keyWord, houseType, page, size);
|
|
|
|
|
+
|
|
|
|
|
+ List<CalendarPageVo> listVo = pageVo.getList();
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isEmpty(listVo) && listVo.size() <= 0) {
|
|
|
|
|
+ map.put("page", pageVo);
|
|
|
|
|
+ return CommonResult.ok(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取当前房型的所有id
|
|
|
|
|
+ String houseIds = "";
|
|
|
|
|
+ for (int i = 0; i < listVo.size(); i++) {
|
|
|
|
|
+ String id = listVo.get(i).getHouseId();
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
|
+ houseIds = houseIds + id;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ houseIds = houseIds + "," + id;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("houseIds = " + houseIds);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// 获取在这时间内所属房型的所有改价记录
|
|
|
|
|
+ List<HousePrice> housePrices = housePriceService.housePrice(localDate, endLocalDate, houseIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ ArrayList<HouseNumberStatePageVo> pageVos = new ArrayList<>();
|
|
|
|
|
+// 数据组合
|
|
|
|
|
+ for (CalendarPageVo calendarPageVo : listVo) {
|
|
|
|
|
+ HouseNumberStatePageVo houseNumberStatePageVo = new HouseNumberStatePageVo();
|
|
|
|
|
+
|
|
|
|
|
+ houseNumberStatePageVo.setCalendarPageVo(calendarPageVo);
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<HousePriceVo> housePriceVos = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < 21; i++) {
|
|
|
|
|
+ HousePriceVo housePriceVo = new HousePriceVo();
|
|
|
|
|
+ LocalDate localDate1 = localDate.plusDays(i);
|
|
|
|
|
+ String format = localDate1.format(dateTimeFormatter2);
|
|
|
|
|
+ housePriceVo.setDate(format);
|
|
|
|
|
+ housePriceVo.setPrice(calendarPageVo.getPrice());
|
|
|
|
|
+// 判断这个时间内是否有
|
|
|
|
|
+ for (HousePrice housePrice : housePrices) {
|
|
|
|
|
+ if (housePrice.getHouseId().equals(calendarPageVo.getHouseId())) {
|
|
|
|
|
+ String setDate = housePrice.getSetDate();
|
|
|
|
|
+ String[] split = setDate.split(",");
|
|
|
|
|
+ Date startDate = DateUtil.parseDateOnly(split[0]);
|
|
|
|
|
+ Date endDate = DateUtil.parseDateOnly(split[1]);
|
|
|
|
|
+ Date date1 = Date.from(localDate1.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
+ // 判断当前时间是否在[startTime, endTime]区间
|
|
|
|
|
+ assert startDate != null;
|
|
|
|
|
+ boolean effectiveDate = DateUtil.isEffectiveDate(date1, startDate, endDate);
|
|
|
|
|
+ if (effectiveDate) {
|
|
|
|
|
+ BigDecimal price = housePrice.getPrice();
|
|
|
|
|
+ housePriceVo.setPrice(price);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ housePriceVos.add(housePriceVo);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ houseNumberStatePageVo.setHousePriceVos(housePriceVos);
|
|
|
|
|
+ pageVos.add(houseNumberStatePageVo);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<HouseNumberStatePageVo> houseNumberStatePageVoPage = new Page<>();
|
|
|
|
|
+ BeanUtils.copyProperties(pageVo, houseNumberStatePageVoPage);
|
|
|
|
|
+
|
|
|
|
|
+ houseNumberStatePageVoPage.setTotal(pageVo.getTotalCount());
|
|
|
|
|
+ houseNumberStatePageVoPage.setPages(pageVo.getTotalPage());
|
|
|
|
|
+
|
|
|
|
|
+ houseNumberStatePageVoPage.setRecords(pageVos);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ map.put("page", houseNumberStatePageVoPage);
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CommonResult particular(String houseNumberId) {
|
|
|
|
|
+ if (ObjectUtils.isEmpty(houseNumberId)) {
|
|
|
|
|
+ return CommonResult.fail("参数异常");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HouseNumber houseNumber = houseNumberService.getById(houseNumberId);
|
|
|
|
|
+
|
|
|
|
|
+ ParticularHouseNumberStatusVo vo = new ParticularHouseNumberStatusVo();
|
|
|
|
|
+ vo.setHouseNumber(houseNumber.getRoomNumber());
|
|
|
|
|
+
|
|
|
|
|
+ House house = houseService.getById(houseNumber.getHouseId());
|
|
|
|
|
+
|
|
|
|
|
+ vo.setHouseName(house.getRoomName());
|
|
|
|
|
+ vo.setHouseType(house.getRoomType());
|
|
|
|
|
+
|
|
|
|
|
+// 状态 1.空闲 2.正在使用
|
|
|
|
|
+ Integer status = houseNumber.getStatus();
|
|
|
|
|
+ if (status != 1) {
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<HouseNumberState> wrapperHNS = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperHNS.eq(HouseNumberState::getHouseNumberId, houseNumberId)
|
|
|
|
|
+ .le(HouseNumberState::getStartTime, date)
|
|
|
|
|
+ .ge(HouseNumberState::getEndTime, date);
|
|
|
|
|
+ HouseNumberState houseNumberState = houseNumberStateService.getOne(wrapperHNS);
|
|
|
|
|
+
|
|
|
|
|
+// 状态 1空闲、2预定、3入住、4脏房、5锁定、6维修
|
|
|
|
|
+ Integer status1 = houseNumberState.getStatus();
|
|
|
|
|
+// 订单id
|
|
|
|
|
+ String bookingId = houseNumberState.getBookingId();
|
|
|
|
|
+ vo.setHouseStatus(status1);
|
|
|
|
|
+// 预定
|
|
|
|
|
+ if (status1 == 2) {
|
|
|
|
|
+// 预定
|
|
|
|
|
+ String statusBar = "2,5,11";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(bookingId)) {
|
|
|
|
|
+ HouseOrder houseOrder = houseOrderService.getById(bookingId);
|
|
|
|
|
+ String reserveName = houseOrder.getReserveName();
|
|
|
|
|
+ vo.setName(reserveName);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (status1 == 3) {
|
|
|
|
|
+// 入住
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(bookingId)) {
|
|
|
|
|
+ HouseOrder houseOrder = houseOrderService.getById(bookingId);
|
|
|
|
|
+ String liveName = houseOrder.getLiveName();
|
|
|
|
|
+ vo.setName(liveName);
|
|
|
|
|
+ String statusBar = "7,8,9,10,11";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ Date liveTime = houseOrder.getLiveTime();
|
|
|
|
|
+// 入住时间
|
|
|
|
|
+ vo.setLiveTime(liveTime);
|
|
|
|
|
+// 付款
|
|
|
|
|
+ vo.setPayPrice(houseOrder.getPayPrice());
|
|
|
|
|
+// 已入住时间
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ LocalDateTime stateEnd = LocalDateTime.ofInstant(liveTime.toInstant(), ZoneId.systemDefault());
|
|
|
|
|
+ Duration duration = Duration.between(stateEnd, now);
|
|
|
|
|
+ long l = duration.toMinutes();
|
|
|
|
|
+ Double m = Double.valueOf(l);
|
|
|
|
|
+ Integer days = (int) (m / (60 * 24)); //天
|
|
|
|
|
+ Integer hours = (int) (m / (60) - days * 24); //小时
|
|
|
|
|
+ Integer minutes = (int) (m - hours * 60 - days * 24 * 60); //分钟
|
|
|
|
|
+ String checkTime = days + "天" + hours + "小时" + minutes + "分钟";
|
|
|
|
|
+ vo.setCheckTime(checkTime);
|
|
|
|
|
+// 电起码,水起码
|
|
|
|
|
+ LambdaQueryWrapper<HouseOrderBill> wrapperHOB = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperHOB.eq(HouseOrderBill::getHotelOrderId, houseOrder.getId());
|
|
|
|
|
+ HouseOrderBill houseOrderBill = houseOrderBillService.getOne(wrapperHOB);
|
|
|
|
|
+ String startOfWater = houseOrderBill.getStartOfWater();
|
|
|
|
|
+ vo.setStartWater(startOfWater);
|
|
|
|
|
+ String startOfElectric = houseOrderBill.getStartOfElectric();
|
|
|
|
|
+ vo.setStartElectric(startOfElectric);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (status1 == 4) {
|
|
|
|
|
+// 脏房
|
|
|
|
|
+ String statusBar = "11,12";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ } else if (status1 == 5) {
|
|
|
|
|
+// 锁定
|
|
|
|
|
+ String statusBar = "6,11";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ } else if (status1 == 6) {
|
|
|
|
|
+// 维修
|
|
|
|
|
+ String statusBar = "5,11";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ String startTime = houseNumberState.getStartTime();
|
|
|
|
|
+ String endTime = houseNumberState.getEndTime();
|
|
|
|
|
+// 开始时间,结束时间
|
|
|
|
|
+ vo.setStateTime(startTime);
|
|
|
|
|
+ vo.setEndTime(endTime);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+// 空闲
|
|
|
|
|
+ String statusBar = "1,2,3,4,11,13";
|
|
|
|
|
+ vo.setStatusBar(statusBar);
|
|
|
|
|
+ vo.setHouseStatus(status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+// 获取该房间电量
|
|
|
|
|
+ LambdaQueryWrapper<HouseLock> wrapperHL = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperHL.eq(HouseLock::getHouseNumberId, houseNumberId);
|
|
|
|
|
+ HouseLock houseLock = houseLockService.getOne(wrapperHL);
|
|
|
|
|
+ String equipmentType = houseLock.getEquipmentType();
|
|
|
|
|
|
|
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
+ map.put("categoryId", doorLockConfig.getCategoryId());//"d0c248256f8346d2a19afa296562b319");//设备分类ID 所有蓝牙wifi锁默认统一值
|
|
|
|
|
+ map.put("luid", equipmentType);//"047863CA78E0"
|
|
|
|
|
+
|
|
|
|
|
+ String jsonContent = JSONObject.toJSONString(map);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObject = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonObject = queryData(jsonContent, PasswordUrlEnum.Device_Info.getUrl());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
|
+// 电量
|
|
|
|
|
+ String battery = data.getString("battery");
|
|
|
|
|
+ vo.setElectricQuantity(battery + "%");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok(vo);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 请求数据
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param content 请求参数
|
|
|
|
|
+ * @param path 请求接口
|
|
|
|
|
+ */
|
|
|
|
|
+ public JSONObject queryData(String content, String path) throws Exception {
|
|
|
|
|
+ String sign = MD5.getMD5(doorLockConfig.getAppId() + doorLockConfig.getAppSecret());
|
|
|
|
|
+
|
|
|
|
|
+ String appId = doorLockConfig.getAppId();
|
|
|
|
|
+ String jsonStr = AesUtils.encrypt(content, doorLockConfig.getAppSecret());
|
|
|
|
|
+ /*执行请求,使用可以附加token的doPost方*/
|
|
|
|
|
+ HttpClientHelper instance = HttpClientHelper.getInstance();
|
|
|
|
|
+ String result = instance.doPostJson(doorLockConfig.getServiceHost() + (path.startsWith("/") ? path : ("/" + path)), jsonStr, sign, appId);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(result)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*解析数据 start*/
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
|
|
+
|
|
|
|
|
+// System.out.println("jsonObject = " + jsonObject);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return jsonObject;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|