|
|
@ -1,9 +1,13 @@ |
|
|
|
package com.yxt.supervise.monitor.biz.scheduled; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.yxt.supervise.monitor.api.entity.WareHouse; |
|
|
|
import com.yxt.supervise.monitor.biz.messageInfo.YMessageInfoService; |
|
|
|
import com.yxt.supervise.monitor.biz.task.YTaskService; |
|
|
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
|
|
|
import com.yxt.supervise.monitor.biz.wareHouse.YWareHouseService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
@ -14,6 +18,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Service |
|
|
@ -23,6 +28,9 @@ public class SyncService { |
|
|
|
@Autowired |
|
|
|
YMessageInfoService yMessageInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
YWareHouseService yWareHouseService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
YTaskService yTaskService; |
|
|
|
|
|
|
@ -36,7 +44,7 @@ public class SyncService { |
|
|
|
public static String haiKangMessageConsumer = ""; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void getMessageConsumer() { |
|
|
|
public void initMain() { |
|
|
|
// 先登录
|
|
|
|
String loginUrl = "https://api2.hik-cloud.com/oauth/token"; |
|
|
|
Map<String, Object> tokenParam = new HashMap<>(); |
|
|
@ -63,6 +71,32 @@ public class SyncService { |
|
|
|
System.out.println(message); |
|
|
|
log.error(message); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新仓库列表数据
|
|
|
|
String url = "http://jianguan.yyundong.com/api/portal/v1/flow/storeHouseListPage"; |
|
|
|
String result = ""; |
|
|
|
List<WareHouse> athleteBOIPage = null; |
|
|
|
try { |
|
|
|
Map<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("current", "1"); |
|
|
|
paramMap.put("size", "1000"); |
|
|
|
paramMap.put("params", new Object()); |
|
|
|
String jsonParam = JSONObject.toJSONString(paramMap); |
|
|
|
result = HttpUtils.sendPostJson(url, jsonParam, ""); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
|
JSONObject jsonData = (JSONObject) jsonObject.get("data"); |
|
|
|
String jsonRecords = jsonData.getString("records"); |
|
|
|
athleteBOIPage = JSONArray.parseArray(jsonRecords, WareHouse.class); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println(e); |
|
|
|
athleteBOIPage = null; |
|
|
|
} |
|
|
|
yWareHouseService.remove(new QueryWrapper<>()); |
|
|
|
for (WareHouse wareHouse : athleteBOIPage) { |
|
|
|
wareHouse.setShowStatus(true); |
|
|
|
yWareHouseService.save(wareHouse); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|