main
周文涛 2 years ago
parent f6c0d4d0de
commit 6758fc5071

@ -8,12 +8,15 @@ import com.example.zxweb.entity.ZxCelue;
import com.example.zxweb.service.IZxCelueService;
import com.example.zxweb.utils.IotUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -29,7 +32,7 @@ public class LoadCelueInit implements ApplicationRunner{
@Override
public void run(ApplicationArguments args) throws Exception {
//获取网关的数据,同步到数据库中
/*String gateway_5lqh = DevConstant.gateway.gateway_5lqh;//5楼网关
String gateway_5lqh = DevConstant.gateway.gateway_5lqh;//5楼网关
String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", gateway_5lqh,gateway_5lqh);
JSONObject requestBody = JSONObject.parseObject(format);
JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody);
@ -40,10 +43,28 @@ public class LoadCelueInit implements ApplicationRunner{
JSONArray list = outputData.getJSONArray("list");
if (!CollectionUtils.isEmpty(list)) {
List<ZxCelue> zxCelues = list.toJavaList(ZxCelue.class);
for (ZxCelue zxCelue : zxCelues) {
List<String> devidList=new ArrayList<>();
String action = zxCelue.getAction();
if (StringUtils.isNotBlank(action)) {
String[] split = action.split("&&");
for (String s : split) {
String[] split1 = s.split("\\.");
String s1 = split1[0];
devidList.add(s1);
}
}
zxCelue.setDevid(String.join(",",devidList));
}
//更新库表
zxCelueService.saveOrUpdateBatch(zxCelues);
}
}
}*/
}
}
public static void main(String[] args) {
ArrayList<String> devidList = new ArrayList<>(Arrays.asList("1,2"));
System.out.println(String.join(",",devidList));;
}
}

@ -119,6 +119,7 @@ public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> impl
@Override
public boolean editStatus(ZxCelue zxCelue) {
String status="0";
AssertUtils.notEmpty(zxCelue.getCelueid(),"当前策略id不可用");
try {
ZxCelue celue = getById(zxCelue.getCelueid());
LambdaUpdateWrapper<ZxCelue> updateWrapper=new LambdaUpdateWrapper<>();

@ -68,6 +68,8 @@ public class IotUtils {
if (code==1) {
return true;
}
}else{
throw new BusinessException(outputData.getString("message"));
}
}
}
@ -97,6 +99,8 @@ public class IotUtils {
Integer code1 = outputData.getInteger("code");
if (code1!=null && 1==code1) {
return true;//更改成功
}else{
throw new BusinessException(outputData.getString("message"));
}
}
}
@ -121,6 +125,8 @@ public class IotUtils {
if (outputData != null) {
Integer code = outputData.getInteger("code");
return code == 1;
}else{
throw new BusinessException(outputData.getString("message"));
}
}
}catch (Exception e){

Loading…
Cancel
Save