From edbb2fe4eabbb7c526fb2f7313bead37d38928e2 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 15 八月 2022 14:57:16 +0800
Subject: [PATCH] 充电桩上电请求
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java | 92 ++++++++++++++++++++++++++++++++--------------
1 files changed, 64 insertions(+), 28 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
index 402f563..bb04b27 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlayPlanNvService.java
@@ -10,13 +10,10 @@
import com.sandu.ximon.admin.config.VnnoxConstant;
import com.sandu.ximon.admin.dto.PlanDto;
import com.sandu.ximon.admin.dto.SchedulesDTO;
-import com.sandu.ximon.admin.dto.nova.PlayerProgram;
-import com.sandu.ximon.admin.dto.nova.ProgramDto;
-import com.sandu.ximon.admin.dto.nova.ProgramPush;
-import com.sandu.ximon.admin.dto.nova.ProgramSchedule;
-import com.sandu.ximon.admin.entity.Plans;
+import com.sandu.ximon.admin.dto.nova.*;
import com.sandu.ximon.admin.param.PlayPlanParam;
import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.LogUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.VnnoxAPIUtil;
import com.sandu.ximon.admin.utils.VnnoxProgramAPIUtil;
@@ -168,11 +165,21 @@
return removeByIds(ids);
}
+ /**
+ * 鎺ㄩ�佸畾鏃惰妭鐩�
+ *
+ * @param planId
+ * @param nova
+ * @return
+ */
public Map<String, Object> pushToLed(Long planId, List<NovaPushResultVO> nova) {
- if(nova==null){
+ if (nova == null) {
throw new BusinessException("璇烽�夋嫨姝g‘鐨凩ED灞�");
}
PushToLed pushToLed = playPlanMapper.pushToLed(planId);
+ if (pushToLed.getPages() == null) {
+ throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+ }
PlayPlanNv byId = getById(planId);
if (pushToLed == null) {
throw new BusinessException("鏈壘鍒拌鎾斁璁″垝");
@@ -186,24 +193,44 @@
program.setPlayerIds(playerIds);
//鑾峰彇鑺傜洰瀹炰綋
- program.setPages(JSON.parseObject(pushToLed.getPages(), List.class));
+
+ List<PlayerPage> programDtos = JSON.parseArray(pushToLed.getPages(), PlayerPage.class);
+ programDtos.forEach(
+ programDto -> {
+ programDto.getWidgets().forEach(
+ widget -> {
+ if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
+ String url = widget.getUrl();
+ LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
+ if (one == null) {
+ throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
+ }
+ widget.setMd5(one.getMd5());
+ widget.setSize(Long.parseLong(one.getSize()));
+ }
+ }
+ );
+ }
+ );
+
+ program.setPages(programDtos);
//鑾峰彇鑺傜洰瀹氭椂瀹炰綋
- program.setSchedule((JSON.parseObject(pushToLed.getSchedule(), Map.class)));
- Map map = JSON.parseObject(pushToLed.getSchedule(), Map.class);
- map.get("plans");
- List<Plans> plans = JSON.parseArray(map.get("plans").toString(), Plans.class);
- plans.forEach(p -> {
- //鍒犻櫎鍚庝袱浣嶅瓧绗︿覆
- p.setStartTime(p.getStartTime().substring(0, p.getStartTime().length() - 3));
- p.setEndTime(p.getEndTime().substring(0, p.getEndTime().length() - 3));
- });
- System.out.println(plans + "plans11111");
- map.put("plans", plans);
- program.setSchedule(map);
+ PlayerSchedule playerSchedule = JSON.parseObject(pushToLed.getSchedule(), PlayerSchedule.class);
+ //鍒犻櫎鏃堕棿鐨勫悗涓変綅
+ List<PlayerSchedulePlans> plans = playerSchedule.getPlans();
+ plans.forEach(
+ plan -> {
+ plan.setStartTime(plan.getStartTime().substring(0, plan.getStartTime().length() - 3));
+ plan.setEndTime(plan.getEndTime().substring(0, plan.getEndTime().length() - 3));
+ }
+ );
+ program.setSchedule(playerSchedule);
+
program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
+ LogUtils.error("鑺傜洰鍐呭+++++++++++" + JSON.toJSONString(program));
VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.normalProgram(program);
vnnoxAPIUtil.volChange(playerIds, Integer.valueOf(pushToLed.getVolume()).intValue());
@@ -392,6 +419,9 @@
if (ledProgram == null) {
throw new BusinessException("鏈壘鍒拌妭鐩�");
}
+ if (ledProgram.getPages() == null) {
+ throw new BusinessException("鑺傜洰鍐呭涓㈠け");
+ }
if (SecurityUtils.getClientId() != null && !Objects.equals(ledProgram.getClientId(), SecurityUtils.getUserId()) && !Objects.equals(ledProgram.getClientId(), SecurityUtils.getClientId())) {
throw new BusinessException("璇蜂笉瑕佹搷浣滃叾浠栦汉鐨勮妭鐩�");
}
@@ -401,30 +431,35 @@
playerIds.add(n.getPlayerId());
});
- ProgramPush program = new ProgramPush();
- List<ProgramDto> programDtos = JSON.parseArray(pages, ProgramDto.class);
+ PlayerProgram program = new PlayerProgram();
+ List<PlayerPage> programDtos = JSON.parseArray(pages, PlayerPage.class);
programDtos.forEach(
programDto -> {
programDto.getWidgets().forEach(
widget -> {
- String url = widget.getUrl();
- LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
- if (one == null) {
- throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
+ if (PlayerWidgetType.PICTURE.equals(widget.getType()) || PlayerWidgetType.VIDEO.equals(widget.getType())) {
+ String url = widget.getUrl();
+ LEDProgramFile one = fileService.getOne(Wrappers.lambdaQuery(LEDProgramFile.class).eq(LEDProgramFile::getFileUrl, url));
+ if (one == null) {
+ throw new BusinessException("鑺傜洰鏂囦欢宸插け鏁�");
+ }
+ widget.setMd5(one.getMd5());
+ widget.setSize(Long.parseLong(one.getSize()));
}
- widget.setMd5(one.getMd5());
- widget.setSize(one.getSize());
}
);
}
);
-
program.setPlayerIds(playerIds);
//鑾峰彇鑺傜洰瀹炰綋
program.setPages(programDtos);
program.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
VnnoxResultResponse vnnoxResultResponse = vnnoxProgramAPIUtil.pushProgram(program);
+
+ if (vnnoxResultResponse == null || vnnoxResultResponse.getData() == null) {
+ throw new BusinessException("鎺ㄩ�佸け璐�");
+ }
List<String> success = new ArrayList<>();
List<String> fail = new ArrayList<>();
@@ -472,4 +507,5 @@
return result;
}
+
}
--
Gitblit v1.9.3