From bfce748e37a753c729e15dd233600379f504d019 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期四, 28 四月 2022 13:59:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java | 147 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 122 insertions(+), 25 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..fbf1548 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,15 +3,22 @@
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;
import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.JsonUtil;
import com.sandu.ximon.admin.utils.LightemitUtils;
import com.sandu.ximon.admin.utils.request.Schedules;
-import com.sandu.ximon.admin.utils.request.Task;
+import com.sandu.ximon.admin.utils.request.requestbody.GetSchedules;
+import com.sandu.ximon.admin.utils.request.requestbody.Task;
import com.sandu.ximon.admin.utils.request.TaskSchedules;
+import com.sandu.ximon.admin.vo.LedScheduleVO;
import com.sandu.ximon.dao.domain.LedScheduleEntity;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.mapper.LedScheduleEntityMapper;
@@ -38,32 +45,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,55 +86,145 @@
String json = JSON.toJSONString(taskSchedules, SerializerFeature.WriteMapNullValue);
// String json = new Gson().toJson(taskSchedules);
ledScheduleEntity.setSchedule(json);
- return this.save(ledScheduleEntity);
+ if (SecurityUtils.getClientId() != null) {
+ ledScheduleEntity.setUserId(SecurityUtils.getUserId());
+ if (clientService.findClientId()) {
+ ledScheduleEntity.setClientId(clientService.getClientId());
+ }
+ }
+ return this.save(ledScheduleEntity);
}
/**
* 瀹氭椂鎺ㄩ��
+ *
* @param scheduleId
* @param lightemitIds
*/
public void ledschedulepush(Integer scheduleId, Long[] lightemitIds) {
- LedScheduleEntity ledScheduleEntity = baseMapper.selectById(scheduleId);
+// LedScheduleEntity ledScheduleEntity = baseMapper.selectById(scheduleId);
+ LedScheduleEntity ledScheduleEntity = getById(scheduleId);
+ if (ledScheduleEntity == null) {
+ throw new BusinessException("璇ュ畾鏃朵换鍔′笉瀛樺湪");
+ }
+// SendCommand sendCommand = new SendCommand();
// SendCommand sendCommand = new SendCommand();
// sendCommand.setTask(ledScheduleEntity.getSchedule());
// 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;
}
+
+ /**
+ * 鎾斁璁″垝鍒楄〃锛堢啓璁級
+ *
+ * @param baseConditionVO
+ * @param keyword
+ * @return
+ */
+ public List listSchedule(BaseConditionVO baseConditionVO, String keyword) {
+ LambdaQueryWrapper<LedScheduleEntity> eq = Wrappers.lambdaQuery(LedScheduleEntity.class);
+ //鐢ㄦ埛绫诲瀷鍒ゆ柇
+ if (SecurityUtils.getClientId() != null) {
+ eq = eq.eq(LedScheduleEntity::getUserId, SecurityUtils.getUserId()).or(w -> {
+ w.eq(LedScheduleEntity::getClientId, SecurityUtils.getUserId());
+ });
+ }
+ //妯$硦鏌ヨ鍏抽敭瀛楀垽鏂�
+ if (keyword != null && !keyword.isEmpty()) {
+ eq = eq.like(LedScheduleEntity::getName, keyword);
+ }
+
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ return list(eq);
+ }
+
+
+ /**
+ * 瀹氭椂鏌ヨ
+ */
+ public LedScheduleVO getledschedules(Long id) {
+
+ PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id);
+
+ String result1 = lightemitUtils.getTimeSchedule(poleLightemitEntity.getLightemitControlCode());
+ if(result1.indexOf("not open")!=-1){
+ LedScheduleVO notOpen = new LedScheduleVO();
+ notOpen.setLedName(poleLightemitEntity.getLightemitName());
+ notOpen.setScheduleName("璁惧鏈紑鍚�");
+ return notOpen;
+ }
+ boolean flag = result1.contains("exist");
+ if(flag!=true) {
+ String result = lightemitUtils.getTimeSchedule(poleLightemitEntity.getLightemitControlCode());
+// if(result !=null){
+ GetSchedules getSchedules = new GetSchedules();
+ try {
+ getSchedules = JsonUtil.convertJsonStringToObject(result, GetSchedules.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ LedScheduleVO ledScheduleVO = new LedScheduleVO();
+ ledScheduleVO.setLedName(poleLightemitEntity.getLightemitName());
+ if (getSchedules.getTask().getName() != null) {
+ ledScheduleVO.setScheduleName(getSchedules.getTask().getName());
+ List<Schedules> list = new ArrayList();
+ list = getSchedules.getTask().getSchedules();
+ for (Schedules schedules : list) {
+
+ ledScheduleVO.setStartTime(schedules.getStartTime());
+ ledScheduleVO.setEndTime(schedules.getEndTime());
+ ledScheduleVO.setStartDate(schedules.getStartDate());
+ ledScheduleVO.setEndDate(schedules.getEndDate());
+ ledScheduleVO.setWeek(schedules.getWeekFilter());
+ }
+ ;
+ } else {
+ ledScheduleVO.setScheduleName("鏃犲畾鏃�");
+ }
+ return ledScheduleVO;
+ }else {
+ LedScheduleVO ledScheduleVO = new LedScheduleVO();
+ ledScheduleVO.setLedName(poleLightemitEntity.getLightemitName());
+ ledScheduleVO.setScheduleName("璁惧鏈紑鍚�");
+ return ledScheduleVO;
+ }
+
+ }
+
}
--
Gitblit v1.9.3