From 228d1be133e0fd2f1f46a29af8bc9cbda3d18d74 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期一, 14 三月 2022 17:11:31 +0800
Subject: [PATCH] 熙讯接口新增
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java | 69 +++++++++++++++++++++++-----------
1 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
index 6acaf6d..e090934 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
@@ -3,7 +3,11 @@
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
+import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.param.LEDScheduleParam_xixun;
@@ -38,32 +42,32 @@
public boolean insert(LEDScheduleParam_xixun ledEntity) {
LedScheduleEntity ledScheduleEntity = new LedScheduleEntity();
- BeanUtil.copyProperties(ledEntity,ledScheduleEntity);
+ BeanUtil.copyProperties(ledEntity, ledScheduleEntity);
ledScheduleEntity.setUserId(SecurityUtils.getClientId());
Schedules schedules = new Schedules();
Task task = new Task();
TaskSchedules taskSchedules = new TaskSchedules();
- if(ledEntity.getStartTime() =="" || ledEntity.getEndTime() == "" || ledEntity.getStartTime() == null || ledEntity.getEndTime() ==null ){
+ if (ledEntity.getStartTime() == "" || ledEntity.getEndTime() == "" || ledEntity.getStartTime() == null || ledEntity.getEndTime() == null) {
schedules.setTimeType("All");
- }else {
+ } else {
schedules.setTimeType("Range");
schedules.setStartTime(ledEntity.getStartTime());
schedules.setEndTime(ledEntity.getEndTime());
}
- if(ledEntity.getStartDate() =="" || ledEntity.getEndDate() == "" || ledEntity.getStartDate() == null || ledEntity.getEndDate() ==null ){
+ if (ledEntity.getStartDate() == "" || ledEntity.getEndDate() == "" || ledEntity.getStartDate() == null || ledEntity.getEndDate() == null) {
schedules.setDateType("All");
- }else {
+ } else {
schedules.setDateType("Range");
schedules.setStartDate(ledEntity.getStartDate());
schedules.setEndDate(ledEntity.getEndDate());
}
- if(ledEntity.getWeek().length != 0){
+ if (ledEntity.getWeek().length != 0) {
schedules.setFilterType("Week");
schedules.setWeekFilter(ledEntity.getWeek());
- }else {
+ } else {
schedules.setFilterType("None");
}
- List list =new ArrayList();
+ List list = new ArrayList();
list.add(schedules);
task.setSchedules(list);
task.setCreateDate(ledEntity.getCreateDate());
@@ -79,12 +83,13 @@
String json = JSON.toJSONString(taskSchedules, SerializerFeature.WriteMapNullValue);
// String json = new Gson().toJson(taskSchedules);
ledScheduleEntity.setSchedule(json);
- return this.save(ledScheduleEntity);
+ return this.save(ledScheduleEntity);
}
/**
* 瀹氭椂鎺ㄩ��
+ *
* @param scheduleId
* @param lightemitIds
*/
@@ -96,38 +101,56 @@
// String json = new Gson().toJson(sendCommand);
Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds));
- if(poleLightemitEntities != null){
- for (PoleLightemitEntity entity: poleLightemitEntities) {
+ if (poleLightemitEntities != null) {
+ for (PoleLightemitEntity entity : poleLightemitEntities) {
lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), ledScheduleEntity.getSchedule());
}
}
}
- public boolean updateSchedule(LEDScheduleParam_xixun paramXixun){
- if(paramXixun.getId()==null){
+ public boolean updateSchedule(LEDScheduleParam_xixun paramXixun) {
+ if (paramXixun.getId() == null) {
throw new BusinessException("鍙傛暟閿欒");
}
LedScheduleEntity byId = getById(paramXixun.getId());
- if(byId==null){
+ if (byId == null) {
throw new BusinessException("鏈壘鍒拌瀹氭椂鏁版嵁");
}
- boolean result=false;
- if( removeById(paramXixun.getId())){
- result = insert(paramXixun);
- }
- return result;
+ boolean result = false;
+ if (removeById(paramXixun.getId())) {
+ result = insert(paramXixun);
+ }
+ return result;
}
- public LedScheduleEntity getSchedule(Integer id){
- if(id==null){
+ public LedScheduleEntity getSchedule(Integer id) {
+ if (id == null) {
throw new BusinessException("鍙傛暟閿欒");
}
LedScheduleEntity byId = getById(id);
- if(byId==null){
+ if (byId == null) {
throw new BusinessException("鏈壘鍒拌瀹氭椂鏁版嵁");
}
- //List<Map> schedule = JSON.parseArray(byId.getSchedule(), List.class);
+ //List<Map> schedule = JSON.parseArray(byId.getSchedule(), List.class);
return byId;
}
+
+ public List listSchedule(BaseConditionVO baseConditionVO, String keyword) {
+ LambdaQueryWrapper<LedScheduleEntity> eq = new LambdaQueryWrapper<>();
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ if (SecurityUtils.getClientId() != null && clientService.findClientId()) {
+ eq = Wrappers.lambdaQuery(LedScheduleEntity.class).eq(LedScheduleEntity::getUserId, SecurityUtils.getUserId());
+ } else if (SecurityUtils.getClientId() != null && !clientService.findClientId()) {
+ eq = Wrappers.lambdaQuery(LedScheduleEntity.class).eq(LedScheduleEntity::getClientId, SecurityUtils.getUserId());
+ } else {
+ eq = Wrappers.lambdaQuery(LedScheduleEntity.class);
+ }
+ if (!keyword.isEmpty()) {
+ eq = eq.like(LedScheduleEntity::getName, keyword);
+ }
+
+ return list(eq);
+ }
+
}
--
Gitblit v1.9.3