监控点信息
This commit is contained in:
parent
f5d127fe66
commit
6a7b2e5be0
|
|
@ -0,0 +1,186 @@
|
||||||
|
package com.dkl.large.utli;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.dkl.common.core.domain.entity.SysDept;
|
||||||
|
import com.dkl.common.utils.StringUtils;
|
||||||
|
import com.dkl.system.service.ISysDeptService;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component("zzjgxxUtil")
|
||||||
|
public class zzjgxxUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
public void getDeptAll() throws IOException {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
// 构建请求体
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
RequestBody body = RequestBody.create(mediaType, "{\n" +
|
||||||
|
" \"jsonObject\": {\n" +
|
||||||
|
" \"key\": \"value\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"method\": \"GET\",\n" +
|
||||||
|
" \"pageNum\": 1,\n" +
|
||||||
|
" \"pageSize\": 1000000,\n" +
|
||||||
|
" \"path\": \"/edataservice/api/zzjgxx\",\n" +
|
||||||
|
" \"secret\": \"7231958b69385ff66a1900584a72c0b85dbc0b602d54ec7a23f9ccdeeb17018c\",\n" +
|
||||||
|
" \"sortParam\": \"zzjgdm\",\n" +
|
||||||
|
" \"sortType\": \"ASC\"\n" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
// 构建请求
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("http://10.22.245.216:29999/jeecg-data-service/edataservice/api/")
|
||||||
|
.post(body)
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 执行请求并处理响应
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
// System.out.println("Response Code: " + response.code());
|
||||||
|
// System.out.println("Response Body: " + response.body().string());
|
||||||
|
String jsonString = response.body().string();
|
||||||
|
// 创建ObjectMapper实例
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
// 解析JSON字符串为JsonNode对象
|
||||||
|
JsonNode rootNode = objectMapper.readTree(jsonString);
|
||||||
|
|
||||||
|
// 获取code字段的值
|
||||||
|
String code = rootNode.get("code").asText();
|
||||||
|
System.out.println("Code: " + code);
|
||||||
|
|
||||||
|
// 获取success字段的值
|
||||||
|
boolean success = rootNode.get("success").asBoolean();
|
||||||
|
System.out.println("Success: " + success);
|
||||||
|
|
||||||
|
// 获取data字段的值(是一个数组)
|
||||||
|
JsonNode dataNode = rootNode.get("result");
|
||||||
|
JsonNode dataList= dataNode.get("records");
|
||||||
|
// 遍历data数组中的每个元素
|
||||||
|
for (JsonNode deptNode : dataList) {
|
||||||
|
//获取所有部门
|
||||||
|
SysDept sysDept =new SysDept();
|
||||||
|
//如果组织机构机构代码不为空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zzjgdm").asText())){
|
||||||
|
SysDept gainfo = deptService.selectDeptBygajgjgdm(deptNode.get("zzjgdm").asText());
|
||||||
|
//部门是空
|
||||||
|
if (gainfo == null) {
|
||||||
|
//创建
|
||||||
|
//上级组织机构不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("sjzzjg").asText())){
|
||||||
|
SysDept info = deptService.selectDeptBysjgajgjgdm(deptNode.get("sjzzjg").asText());
|
||||||
|
//如果上级机构存在
|
||||||
|
if (info != null) {
|
||||||
|
//部门名称 = 对接组织机构名称 zzjgmc
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zzjgmc").asText())){
|
||||||
|
sysDept.setDeptName(deptNode.get("zzjgmc").asText());
|
||||||
|
}
|
||||||
|
sysDept.setParentId(info.getDeptId());
|
||||||
|
|
||||||
|
//显示顺序 = 对接显示顺序 xssx
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("xssx").asText())){
|
||||||
|
sysDept.setOrderNum(Integer.valueOf(deptNode.get("xssx").asText()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//单位类别
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("dwlb").asText())){
|
||||||
|
sysDept.setDwlb(deptNode.get("dwlb").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//组织机构单位性质类别 zzjgdwxzlbdm
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zzjgdwxzlbdm").asText())){
|
||||||
|
sysDept.setGajgbmlbdm(deptNode.get("zzjgdwxzlbdm").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//单位级别
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("dwjb").asText())){
|
||||||
|
sysDept.setGajgbmlbdm(deptNode.get("dwjb").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//组织机构代码
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zzjgdm").asText())){
|
||||||
|
sysDept.setGajgjgdm(deptNode.get("zzjgdm").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//上级组织机构不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("sjzzjg").asText())){
|
||||||
|
sysDept.setSjgajgjgdm(deptNode.get("sjzzjg").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//组织机构简称不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zzjgjc").asText())){
|
||||||
|
sysDept.setZzjgjc(deptNode.get("zzjgjc").asText());
|
||||||
|
}
|
||||||
|
//行政区划代码不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("xzqhdm").asText())){
|
||||||
|
sysDept.setXzqhdm(deptNode.get("xzqhdm").asText());
|
||||||
|
}
|
||||||
|
//单位类型不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("dwlx").asText())){
|
||||||
|
sysDept.setDwlx(deptNode.get("dwlx").asText());
|
||||||
|
}
|
||||||
|
//派出所类型代码不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("pcslxdm").asText())){
|
||||||
|
sysDept.setDwlb(deptNode.get("pcslxdm").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//联系人不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("lxr").asText())){
|
||||||
|
sysDept.setLeader(deptNode.get("lxr").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//联系电话不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("lxdh").asText())){
|
||||||
|
sysDept.setPhone(deptNode.get("lxdh").asText());
|
||||||
|
}
|
||||||
|
//值班电话不能不空
|
||||||
|
if(StringUtils.isNotEmpty( deptNode.get("zbdh").asText())){
|
||||||
|
sysDept.setZbdh(deptNode.get("zbdh").asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
//帐号状态(0正常 1停用)
|
||||||
|
sysDept.setStatus("0");
|
||||||
|
//删除状态
|
||||||
|
sysDept.setDelFlag("0");
|
||||||
|
//创建时间
|
||||||
|
sysDept.setCreateTime(new Date());
|
||||||
|
//创建人
|
||||||
|
sysDept.setCreateBy("admin");
|
||||||
|
//修改时间
|
||||||
|
sysDept.setUpdateTime(new Date());
|
||||||
|
//修改人
|
||||||
|
sysDept.setUpdateBy("admin");
|
||||||
|
deptService.insertDept(sysDept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(dataList);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue