|
|
|
@ -13,7 +13,6 @@ import com.example.zxweb.entity.ZxDevice;
|
|
|
|
|
import com.example.zxweb.entity.ZxDeviceMethod;
|
|
|
|
|
import com.example.zxweb.exception.BusinessException;
|
|
|
|
|
import com.example.zxweb.mapper.ZxCelueMapper;
|
|
|
|
|
import com.example.zxweb.mapper.ZxDeviceMethodMapper;
|
|
|
|
|
import com.example.zxweb.service.IZxCelueService;
|
|
|
|
|
import com.example.zxweb.service.IZxDeviceService;
|
|
|
|
|
import com.example.zxweb.utils.AssertUtils;
|
|
|
|
@ -23,8 +22,6 @@ import com.example.zxweb.vo.AddZxCeluePVO;
|
|
|
|
|
import com.example.zxweb.vo.QueryCelueVO;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
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.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -32,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -61,6 +55,12 @@ public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> impl
|
|
|
|
|
AssertUtils.hasSize(addZxCeluePVO.getDevidList(),"请选择[设备]");
|
|
|
|
|
try {
|
|
|
|
|
BeanUtils.copyProperties(addZxCeluePVO,zxCelue);
|
|
|
|
|
String celueid = addZxCeluePVO.getCelueid();
|
|
|
|
|
if(StringUtils.isNotBlank(celueid)){
|
|
|
|
|
zxCelue.setCelueid(celueid);
|
|
|
|
|
}else{
|
|
|
|
|
zxCelue.setCelueid(time+"");
|
|
|
|
|
}
|
|
|
|
|
/*if (StringUtils.isBlank(zxCelue.getStartTime())) {
|
|
|
|
|
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())) {
|
|
|
|
|
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());
|
|
|
|
|
zxCelue.setTriggereTime(cron);
|
|
|
|
|
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 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.replace("%celueid", zxCelue.getCelueid());
|
|
|
|
|
requestBodyJson.replace("%name",zxCelue.getName());
|
|
|
|
|
requestBodyJson.replace("%cron",cron);
|
|
|
|
|
requestBodyJson.replace("%action",action);
|
|
|
|
|
requestBodyJson.replace("%startDate",StringUtils.isNotBlank(addZxCeluePVO.getStartTime())?addZxCeluePVO.getStartTime():null);
|
|
|
|
|
requestBodyJson.replace("%endDate",StringUtils.isNotBlank(addZxCeluePVO.getEndTime())?addZxCeluePVO.getEndTime():null);
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%serial",gateway_5lqh);
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%celueid", zxCelue.getCelueid());
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%name",zxCelue.getName());
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%cron",cron);
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%action",action.toString().replace("\"","\\\""));
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%startDate",StringUtils.isNotBlank(addZxCeluePVO.getStartTime())?addZxCeluePVO.getStartTime():"");
|
|
|
|
|
requestBodyJson=requestBodyJson.replace("%endDate",StringUtils.isNotBlank(addZxCeluePVO.getEndTime())?addZxCeluePVO.getEndTime():"");
|
|
|
|
|
JSONObject requestBody = JSONObject.parseObject(requestBodyJson);
|
|
|
|
|
IotUtils.celueSet(requestBody);
|
|
|
|
|
save(zxCelue);
|
|
|
|
|
if (active) {
|
|
|
|
|
IotUtils.celueSet(requestBody);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(celueid)) {
|
|
|
|
|
updateById(zxCelue);
|
|
|
|
|
}else{
|
|
|
|
|
save(zxCelue);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new BusinessException(e);
|
|
|
|
|
}
|
|
|
|
|