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/LightService.java | 86 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
index 57d3220..2f08bb8 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -34,6 +34,7 @@
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
+import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LightMapper;
import com.sandu.ximon.dao.mapper.LightTaskMapper;
import lombok.AllArgsConstructor;
@@ -72,7 +73,7 @@
Boolean hasKey = redisService.hasKey(LightKey.REPORT_MAC.key(deviceName));
if (!hasKey) {
int count = count(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, deviceName));
- log.info("redis鏌ヤ笉鍒拌矾鐏暟鎹畕}={}", count, deviceName);
+ log.info("redis鏌ヤ笉鍒拌矾鐏暟鎹� 鏁伴噺:{}={}", count, deviceName);
// 褰撳墠璺伅琛ㄦ病鏈夊綍鍏ヨ澶囧悧
if (count == 0) {
Light light = new Light();
@@ -80,15 +81,15 @@
light.setLightPercent(heartBeatDataPackage.getLightPercent());
light.setLight2Percent(heartBeatDataPackage.getLight2Percent());
save(light);
+ log.info("鏂板璺伅");
}
redisService.set(LightKey.REPORT_MAC.key(deviceName), 1, LightKey.REPORT_MAC.expireSeconds());
- log.info("鏂板璺伅");
} else {
Light light = new Light();
light.setLightPercent(heartBeatDataPackage.getLightPercent());
light.setLight2Percent(heartBeatDataPackage.getLight2Percent());
- update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, deviceName));
- log.info("鏇存柊璺伅浜害");
+ boolean update = update(light, Wrappers.lambdaUpdate(Light.class).eq(Light::getDeviceCode, deviceName));
+ log.info("鏇存柊璺伅浜害 {}", update);
}
}
@@ -97,10 +98,43 @@
*
* @return 杩斿洖缁勫悎鏁版嵁dto
*/
- public List<LightBo> listLight(int pageNo, int pageSize, String keyword) {
+ public List<LightBo> listLight(int pageNo, int pageSize, String keyword, Integer order, Integer seq) {
Long clientId = SecurityUtils.getClientId();
- PageHelper.startPage(pageNo, pageSize);
+ //鎺掑簭瀛楁
+ String orderByResult = "light_id";
+ //姝e簭銆佸�掑彊
+ String orderBySeq = OrderByEnums.ASC.getCode();
+ if (order != null) {
+ switch (order) {
+ case 1:
+ orderByResult = OrderByEnums.LIGHT_POLE_NAME.getCode();
+ break;
+ case 2:
+ orderByResult = OrderByEnums.LIGHT_UPDATE_TIME.getCode();
+ break;
+ case 3:
+ orderByResult = OrderByEnums.LIGHT_CREATE_TIME.getCode();
+ break;
+ default:
+ }
+ }
+ if (seq != null) {
+ switch (seq) {
+ case 1:
+ orderBySeq = OrderByEnums.ASC.getCode();
+ break;
+ case 2:
+ orderBySeq = OrderByEnums.DESC.getCode();
+ break;
+ default:
+ break;
+ }
+ }
+ //鎺掑簭鏂瑰紡
+ String orderBy = orderByResult + " " + orderBySeq;
+
+ PageHelper.startPage(pageNo, pageSize, orderBy);
List<LightBo> listLight = baseMapper.listLight(clientId, keyword);
@@ -488,9 +522,6 @@
public BigDecimal getlistEnergy(Integer week) {
- Long clientId = SecurityUtils.getClientId();
-// List<LightBo> listLight = baseMapper.listLight(clientId, null);
-// List<String> deviceCodeList = listLight.stream().map(LightBo::getDeviceCode).collect(Collectors.toList());
//鑾峰彇鍒版鍦ㄦ墽琛岀殑浠诲姟鍒楄〃
List<LightTaskDto> lightTaskDtos = SpringContextHolder.getBean(LightTaskService.class).listTask();
@@ -961,16 +992,31 @@
}
/**
+ * 鐢ㄦ埛鎷ユ湁鐨勮矾鐏�(鐢ㄤ簬棣栭〉鏁版嵁缁熻)
+ *
+ * @return
+ */
+ public List<LightBo> listLightOnHome() {
+ List<LightBo> listLight;
+ if (SecurityUtils.getClientId() != null) {
+ listLight = baseMapper.listLight(SecurityUtils.getUserId(), null);
+ } else {
+ listLight = baseMapper.listLight(null, null);
+ }
+ return listLight;
+ }
+
+ /**
* 鑾峰彇鐢ㄦ埛鎵�鏈夌殑璁惧鐮�
*/
- public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode) {
+ public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode,String orderBy) {
List<String> list;
if (SecurityUtils.getClientId() != null) {
PageHelper.startPage(pageNo, pageSize);
list = baseMapper.listCode(SecurityUtils.getUserId(), keyword, deviceCode);
} else {
- PageHelper.startPage(pageNo, pageSize);
+ PageHelper.startPage(pageNo, pageSize,orderBy);
list = baseMapper.listCode(null, keyword, deviceCode);
}
@@ -985,6 +1031,24 @@
lights.forEach(light -> {
light.setPower1(lightPowerSettingParam.getPower1());
light.setPower2(lightPowerSettingParam.getPower2());
+ //瀛樺湪闈�0鍔熺巼 鍗充负瀛樺湪璇ョ伅澶�
+ if (lightPowerSettingParam.getPower1() != null || lightPowerSettingParam.getPower1() != 0) {
+ light.setLight1(1);
+ } else if (lightPowerSettingParam.getPower1() == 0) {
+ //鎵嬪姩璁剧疆鐏ご鍔熺巼涓�0 鍗充笉瀛樺湪璇ョ伅澶�
+ light.setLight1(0);
+ } else {
+ light.setLight1(0);
+ }
+ //瀛樺湪闈�0鍔熺巼 鍗充负瀛樺湪璇ョ伅澶�
+ if (lightPowerSettingParam.getPower2() != null || lightPowerSettingParam.getPower2() != 0) {
+ light.setLight2(1);
+ } else if (lightPowerSettingParam.getPower2() == 0) {
+ //鎵嬪姩璁剧疆鐏ご鍔熺巼涓�0 鍗充笉瀛樺湪璇ョ伅澶�
+ light.setLight2(0);
+ } else {
+ light.setLight2(0);
+ }
light.setLightCount(lightPowerSettingParam.getLightCount());
});
return updateBatchById(lights);
--
Gitblit v1.9.3