|
|
|
@ -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));;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|