main
周文涛 2 years ago
parent 677f6831ff
commit 2c551f3388

@ -1,9 +1,6 @@
package com.example.zxweb.controller; package com.example.zxweb.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zxweb.common.api.vo.Result; import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.dto.ZxCelueDTO; import com.example.zxweb.dto.ZxCelueDTO;
import com.example.zxweb.entity.ZxCelue; import com.example.zxweb.entity.ZxCelue;
@ -12,12 +9,9 @@ import com.example.zxweb.vo.AddZxCeluePVO;
import com.example.zxweb.vo.QueryCelueVO; import com.example.zxweb.vo.QueryCelueVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* @Description * @Description
@ -59,8 +53,8 @@ public class CelueController {
@ApiOperation(value = "编辑") @ApiOperation(value = "编辑")
@PutMapping @PutMapping
public Result<?>edit(@RequestBody ZxCelue zxCelue){ public Result<?>edit(@RequestBody AddZxCeluePVO editZxCeluePVO){
zxCelueService.updateById(zxCelue); zxCelueService.saveZxCelue(editZxCeluePVO);
return Result.OK("操作成功"); return Result.OK("操作成功");
} }

@ -13,7 +13,6 @@ import com.example.zxweb.entity.ZxDevice;
import com.example.zxweb.entity.ZxDeviceMethod; import com.example.zxweb.entity.ZxDeviceMethod;
import com.example.zxweb.exception.BusinessException; import com.example.zxweb.exception.BusinessException;
import com.example.zxweb.mapper.ZxCelueMapper; import com.example.zxweb.mapper.ZxCelueMapper;
import com.example.zxweb.mapper.ZxDeviceMethodMapper;
import com.example.zxweb.service.IZxCelueService; import com.example.zxweb.service.IZxCelueService;
import com.example.zxweb.service.IZxDeviceService; import com.example.zxweb.service.IZxDeviceService;
import com.example.zxweb.utils.AssertUtils; import com.example.zxweb.utils.AssertUtils;
@ -23,8 +22,6 @@ import com.example.zxweb.vo.AddZxCeluePVO;
import com.example.zxweb.vo.QueryCelueVO; import com.example.zxweb.vo.QueryCelueVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -61,6 +55,12 @@ public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> impl
AssertUtils.hasSize(addZxCeluePVO.getDevidList(),"请选择[设备]"); AssertUtils.hasSize(addZxCeluePVO.getDevidList(),"请选择[设备]");
try { try {
BeanUtils.copyProperties(addZxCeluePVO,zxCelue); BeanUtils.copyProperties(addZxCeluePVO,zxCelue);
String celueid = addZxCeluePVO.getCelueid();
if(StringUtils.isNotBlank(celueid)){
zxCelue.setCelueid(celueid);
}else{
zxCelue.setCelueid(time+"");
}
/*if (StringUtils.isBlank(zxCelue.getStartTime())) { /*if (StringUtils.isBlank(zxCelue.getStartTime())) {
zxCelue.setStartTime(DateFormatUtils.format(date,"yyyy-MM-dd")); zxCelue.setStartTime(DateFormatUtils.format(date,"yyyy-MM-dd"));
} }
@ -70,7 +70,6 @@ public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> impl
if (!CollectionUtils.isEmpty(addZxCeluePVO.getDevidList())) { if (!CollectionUtils.isEmpty(addZxCeluePVO.getDevidList())) {
zxCelue.setDevid(String.join(",", addZxCeluePVO.getDevidList())); zxCelue.setDevid(String.join(",", addZxCeluePVO.getDevidList()));
} }
zxCelue.setCelueid(time+"");
String cron = CronLowUtil.getCron(addZxCeluePVO.getTimeType(), addZxCeluePVO.getExeTime(), addZxCeluePVO.getWeeklyDay(), addZxCeluePVO.getDay(), addZxCeluePVO.getStartTime(), addZxCeluePVO.getEndTime()); String cron = CronLowUtil.getCron(addZxCeluePVO.getTimeType(), addZxCeluePVO.getExeTime(), addZxCeluePVO.getWeeklyDay(), addZxCeluePVO.getDay(), addZxCeluePVO.getStartTime(), addZxCeluePVO.getEndTime());
zxCelue.setTriggereTime(cron); zxCelue.setTriggereTime(cron);
String type = addZxCeluePVO.getType(); String type = addZxCeluePVO.getType();
@ -103,16 +102,22 @@ public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> impl
//String s = "s10001.switch1.controlSwitch1.ctrl_ch0_status=\"1\"&&s10002.switch1.controlSwitch1.ctrl_ch0_status=\"1\""; //String s = "s10001.switch1.controlSwitch1.ctrl_ch0_status=\"1\"&&s10002.switch1.controlSwitch1.ctrl_ch0_status=\"1\"";
} }
String requestBodyJson="{\"serial\":\"%serial\",\"productId\":\"\",\"methodName\":\"celueSet\",\"inputData\":{\"devid\":\"%serial\",\"celueid\":\"%celueid\",\"name\":\"%name\",\"triggereTime\":\"%cron\",\"action\":\"%action\",\"startTime\":\"%startDate\",\"endTime\":\"%endDate\"}}"; String requestBodyJson="{\"serial\":\"%serial\",\"productId\":\"\",\"methodName\":\"celueSet\",\"inputData\":{\"devid\":\"%serial\",\"celueid\":\"%celueid\",\"name\":\"%name\",\"triggereTime\":\"%cron\",\"action\":\"%action\",\"startTime\":\"%startDate\",\"endTime\":\"%endDate\"}}";
requestBodyJson.replace("%serial",gateway_5lqh); requestBodyJson=requestBodyJson.replace("%serial",gateway_5lqh);
requestBodyJson.replace("%celueid", zxCelue.getCelueid()); requestBodyJson=requestBodyJson.replace("%celueid", zxCelue.getCelueid());
requestBodyJson.replace("%name",zxCelue.getName()); requestBodyJson=requestBodyJson.replace("%name",zxCelue.getName());
requestBodyJson.replace("%cron",cron); requestBodyJson=requestBodyJson.replace("%cron",cron);
requestBodyJson.replace("%action",action); requestBodyJson=requestBodyJson.replace("%action",action.toString().replace("\"","\\\""));
requestBodyJson.replace("%startDate",StringUtils.isNotBlank(addZxCeluePVO.getStartTime())?addZxCeluePVO.getStartTime():null); requestBodyJson=requestBodyJson.replace("%startDate",StringUtils.isNotBlank(addZxCeluePVO.getStartTime())?addZxCeluePVO.getStartTime():"");
requestBodyJson.replace("%endDate",StringUtils.isNotBlank(addZxCeluePVO.getEndTime())?addZxCeluePVO.getEndTime():null); requestBodyJson=requestBodyJson.replace("%endDate",StringUtils.isNotBlank(addZxCeluePVO.getEndTime())?addZxCeluePVO.getEndTime():"");
JSONObject requestBody = JSONObject.parseObject(requestBodyJson); JSONObject requestBody = JSONObject.parseObject(requestBodyJson);
IotUtils.celueSet(requestBody); if (active) {
save(zxCelue); IotUtils.celueSet(requestBody);
}
if (StringUtils.isNotBlank(celueid)) {
updateById(zxCelue);
}else{
save(zxCelue);
}
}catch (Exception e){ }catch (Exception e){
throw new BusinessException(e); throw new BusinessException(e);
} }

@ -16,6 +16,8 @@ import java.util.List;
@Data @Data
@ApiModel(value = "新建策略信息对象") @ApiModel(value = "新建策略信息对象")
public class AddZxCeluePVO implements Serializable { public class AddZxCeluePVO implements Serializable {
@ApiModelProperty(value = "策略id")
private String celueid;
@ApiModelProperty(value = "选择设备id集合") @ApiModelProperty(value = "选择设备id集合")
private List<String> devidList; private List<String> devidList;
@ApiModelProperty(value = "策略名称") @ApiModelProperty(value = "策略名称")

@ -84,7 +84,7 @@ mybatis-plus:
table-underline: true table-underline: true
configuration: configuration:
# 这个配置会将执行的sql打印出来在开发或测试的时候可以用 # 这个配置会将执行的sql打印出来在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段 # 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true call-setters-on-nulls: true

@ -539,14 +539,25 @@
startDate=day; startDate=day;
endDate=day; endDate=day;
}else if(timeType==='date'){ }else if(timeType==='date'){
if(checkNull(startDate)){
layer.msg('请选择[策略执行开始日期]', {icon: 0}, function(){
// layer.msg('提示框关闭后的回调');
});
return false;
}
if(checkNull(startDate)&&checkNull(endDate)){ if(checkNull(startDate)&&checkNull(endDate)){
layer.msg('请选择[选择日期]', {icon: 0}, function(){ layer.msg('请选择[策略执行结束日期]', {icon: 0}, function(){
// layer.msg('提示框关闭后的回调'); // layer.msg('提示框关闭后的回调');
}); });
return false; return false;
} }
} }
if (checkNull(exeTime)) {
layer.msg('请选择[执行时段]', {icon: 0}, function(){});
return false;
}
var index = layer.load(0, {shade: false}); var index = layer.load(0, {shade: false});
var obj = { var obj = {
'name':celueName, 'name':celueName,

Loading…
Cancel
Save