ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -154,9 +154,9 @@ @AnonymousAccess @PostMapping("/poleReset/{poleId}") public ResponseVO<Object> poleReset(@PathVariable Long poleId) { // if (!permissionConfig.check(MenuEnum.POLE_REAL_RESET.getCode())) { // return ResponseUtil.fail("缺少对应用户权限"); // } if (!permissionConfig.check(MenuEnum.POLE_REAL_RESET.getCode())) { return ResponseUtil.fail("缺少对应用户权限"); } return ResponseUtil.success(poleService.poleReset(poleId)); } @@ -271,9 +271,9 @@ @AnonymousAccess @PostMapping("/listStatusByDeviceCode") public ResponseVO<Object> getStatusById(@RequestBody String[] deviceCodeList) { // if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) { // return ResponseUtil.fail("缺少对应用户权限"); // } if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) { return ResponseUtil.fail("缺少对应用户权限"); } for (String s : deviceCodeList) { if (s == null) { return ResponseUtil.fail("参数不能为空"); @@ -297,9 +297,9 @@ @AnonymousAccess @PostMapping("/isRegisterByCode") public ResponseVO<Object> getStatusByCode() { // if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) { /*// if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) { // return ResponseUtil.fail("缺少对应用户权限"); // } // }*/ ArrayList<String> deviceCodeList = new ArrayList<>(); deviceCodeList.add("baseDevice01"); deviceCodeList.add("baseDevice02"); @@ -353,7 +353,7 @@ /** * 查找自己拥有的灯杆 * 查找拥有的灯杆 */ @PostMapping("/getOwnerPole/{cilentId}") public ResponseVO<Object> getOwnerPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mChargingChargeService.java
@@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.stream.Collectors; /** * @Author liuhaonan @@ -209,42 +210,93 @@ */ public BigDecimal getchargeDecimalByC3id(Long c3Id) { List<C3mChargingCharge> list = list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3Id)); //只有一条费率时,直接返回 if (list.size() == 1) { return BigDecimal.valueOf(list.get(0).getCharge()); } else {//费率大于一条时候,计算费率 //排序费率(根据时间排序) List<C3mChargingCharge> collect = list.stream().sorted(Comparator.comparing(C3mChargingCharge::getHour).thenComparing(C3mChargingCharge::getMin)).collect(Collectors.toList()); System.out.println("----- " + collect); //获取当前时间 LocalTime localTime = LocalTime.now(); //遍历费率集合 判断当前时间是否在费率时间段内 LocalTime startTime; LocalTime endTime; //默认费率 Double charge = 8.8; if (list.size() > 1) { //费率条数大于1时,遍历费率集合 获取当前时间段的费率 for (int i = 0; i < list.size(); i++) { //获取费率时间段 转化为LocalTime startTime = LocalTime.of(list.get(i).getHour(), list.get(i).getMin()); endTime = LocalTime.of(list.get(i + 1).getHour(), list.get(i + 1).getMin()); if (i == list.size()) { startTime = LocalTime.of(list.get(i).getHour(), list.get(i).getMin()); endTime = LocalTime.of(list.get(0).getHour(), list.get(0).getMin()); // LocalTime localTime = LocalTime.now(); LocalTime localTime = LocalTime.of(0, 0); System.out.println(localTime); C3mChargingCharge temp1 = collect.get(collect.size() - 1); if (localTime.isAfter(LocalTime.of(temp1.getHour(), temp1.getMin()))) { return BigDecimal.valueOf(temp1.getCharge()); } //判断当前时间是否在费率时间段内 C3mChargingCharge temp2= collect.get(0); if (localTime.isBefore(LocalTime.of(temp2.getHour(), temp2.getMin()))) { return BigDecimal.valueOf(temp1.getCharge()); } for (int i = 0; i < collect.size(); i++) { int x = i; int y = i + 1; if (y == collect.size()) { y = 0; } LocalTime startTime = LocalTime.of(collect.get(x).getHour(), collect.get(x).getMin()); LocalTime endTime = LocalTime.of(collect.get(y).getHour(), collect.get(y).getMin()); //当前时间等于费率时间段的开始时间 if (localTime.equals(startTime)) { return BigDecimal.valueOf(collect.get(x).getCharge()); } //当前时间在费率时间段内 if (localTime.isAfter(startTime) && localTime.isBefore(endTime)) { //获取费率 charge = list.get(i).getCharge(); return BigDecimal.valueOf(collect.get(x).getCharge()); } } } } } else if (list.size() == 1) { //只有一条费率时,直接获取费率 charge = list.get(0).getCharge(); } else { //其他费率时,获取默认费率 charge = 8.8; } //charge转化为BigDecimal //double直接使用 new BigDecimal()时会出现精度问题,所以需要使用BigDecimal.valueOf()方法 并设置精度为2位小数 BigDecimal chargeDecimal = BigDecimal.valueOf(charge).setScale(2, BigDecimal.ROUND_HALF_UP); return chargeDecimal; // // //获取当前时间 // LocalTime localTime = LocalTime.now(); // //遍历费率集合 判断当前时间是否在费率时间段内 // LocalTime startTime; // LocalTime endTime; // //默认费率 // Double charge = 8.8; // if (list.size() > 1) { // //费率条数大于1时,遍历费率集合 获取当前时间段的费率 // for (int i = 0; i < list.size(); i++) { // //获取费率时间段 转化为LocalTime // startTime = LocalTime.of(list.get(i).getHour(), list.get(i).getMin()); // endTime = LocalTime.of(list.get(i + 1).getHour(), list.get(i + 1).getMin()); // if (i == list.size()) { // startTime = LocalTime.of(list.get(i).getHour(), list.get(i).getMin()); // endTime = LocalTime.of(list.get(0).getHour(), list.get(0).getMin()); // } // //判断当前时间是否在费率时间段内 // if (localTime.isAfter(startTime) && localTime.isBefore(endTime)) { // //获取费率 // charge = list.get(i).getCharge(); // } // // } // } else if (list.size() == 1) { // //只有一条费率时,直接获取费率 // charge = list.get(0).getCharge(); // } else { // //其他费率时,获取默认费率 // charge = 8.8; // } // // //charge转化为BigDecimal // //double直接使用 new BigDecimal()时会出现精度问题,所以需要使用BigDecimal.valueOf()方法 并设置精度为2位小数 // BigDecimal chargeDecimal = BigDecimal.valueOf(charge).setScale(2, BigDecimal.ROUND_HALF_UP); // // return chargeDecimal; return BigDecimal.valueOf(99); } } ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -243,6 +243,12 @@ } PageHelper.startPage(conditionVO.getPageNo(), conditionVO.getPageSize()); List<LightReportData> list = list(Wrappers.lambdaQuery(LightReportData.class).eq(LightReportData::getDeviceCode, macCode)); list.forEach( lightReportData -> { lightReportData.setCreateTime(lightReportData.getCreateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); lightReportData.setUpdateTime(lightReportData.getUpdateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); } ); return list; } } ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
@@ -284,6 +284,54 @@ return map; } // 批量截屏 public Map<String, String> getScreenShotUrl(List<String> playerIds) { Map<String, String> map = new HashMap(); playerIds.forEach( playId->{ try { redisUtils.delete(VnnoxConstant.REDIS_SCREEN_SHOT + playId); } catch (Exception e) { } } ); VnnoxResult vnnoxResult = vnnoxAPIUtil.screenShot(playerIds); if (null == vnnoxResult) { map.put("code", "500"); map.put("msg", "设备已下线"); return map; } if (vnnoxResult.getSuccess().size() == 0) { map.put("code", "500"); map.put("msg", "获取缩略图失败!"); return map; } String url = null; Integer checkCount = 0; while (checkCount < 10) { url = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + playerIds.get(0)); if (null != url) { break; } try { Thread.sleep(2000); checkCount = checkCount + 1; } catch (InterruptedException e) { e.printStackTrace(); } } map.put("url", url); map.put("code", "200"); return map; } // //重启 // public VnnoxResult reboot(List<LedPlayerEntity> playerList) { // return vnnoxAPIUtil.reboot( ximon-admin/src/main/java/com/sandu/ximon/admin/utils/VnnoxAPIUtil.java
@@ -205,6 +205,30 @@ return response.getData(); } /** * 批量屏幕截图 * * @param players * @return */ public VnnoxResult screenShot(List<String> players) { VnnoxBaseRequest request = new VnnoxBaseRequest(); request.setPlayerIds(players); request.setNoticeUrl(VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); String result = VnnoxRequestUtil.PostWithHeader( VnnoxUrl.getUrl(VnnoxUrl.SCREEN_SHOT), request.toJson(), new CommonHeader(CommonHeader.JSON, true) ); VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); return response.getData(); } /** * 设备重启 *