|
|
@@ -6,12 +6,16 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.zuihou.base.request.PageParams;
|
|
|
+import com.github.zuihou.business.centralToolMagazine.dao.ToolCostomAddressMapper;
|
|
|
+import com.github.zuihou.business.centralToolMagazine.entity.ToolCostomAddress;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Order;
|
|
|
@@ -28,6 +32,7 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.impl.ZZoneServiceImpl;
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.business.websocket.WebSocketServer;
|
|
|
+import com.github.zuihou.common.constant.CacheKey;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
import com.github.zuihou.context.BaseContextConstants;
|
|
|
import com.github.zuihou.context.BaseContextHandler;
|
|
|
@@ -91,6 +96,9 @@ public class DashboardJob {
|
|
|
@Autowired
|
|
|
private AAutoNodeLogMapper aAutoNodeLogMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ToolCostomAddressMapper toolCostomAddressMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TokenUtil tokenUtil;
|
|
|
|
|
|
@@ -100,6 +108,7 @@ public class DashboardJob {
|
|
|
@Value("${zuihou.database.tenantDatabasePrefix}")
|
|
|
private String database;
|
|
|
|
|
|
+
|
|
|
private static Logger logger = LoggerFactory.getLogger(DashboardJob.class);
|
|
|
|
|
|
@Scheduled(cron="0 0/1 * * * ?")
|
|
|
@@ -314,4 +323,43 @@ public class DashboardJob {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //成航发
|
|
|
+ //机床报警信息数据采集
|
|
|
+ @Scheduled(cron = "*/2 * * * * ?")
|
|
|
+ public void toolWarinCJ() {
|
|
|
+ try{
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ logger.info("成航发机床报警信息数据采集——开始:"+l);
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
+ Object map = msgUtil.redis_get(CacheKey.TOOL_COSTOM_ADDRESS);
|
|
|
+ List<String> addressList=new ArrayList<>();
|
|
|
+ List<ToolCostomAddress> list=null;
|
|
|
+ if(map == null){
|
|
|
+ list = toolCostomAddressMapper.getAddressList();
|
|
|
+ addressList=list.stream().map(ToolCostomAddress::getAddress).collect(Collectors.toList());
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String addressListJson = objectMapper.writeValueAsString(addressList);
|
|
|
+ msgUtil.redis_set(CacheKey.TOOL_COSTOM_ADDRESS , addressListJson);
|
|
|
+ }else{
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ JavaType type = objectMapper.getTypeFactory().constructCollectionType(List.class, String.class);
|
|
|
+ addressList = objectMapper.readValue(map.toString(), type);
|
|
|
+ }
|
|
|
+ String httpserverUrl="http://127.0.0.1:8010/opcua/";
|
|
|
+ JSONObject jsonParam = new JSONObject();
|
|
|
+ jsonParam.put("ServerUrl","opc.tcp://10.161.30.246:4840");
|
|
|
+ jsonParam.put("Type","Collect");
|
|
|
+ jsonParam.put("UserName","OpcUaClient");
|
|
|
+ jsonParam.put("Password","12345678");
|
|
|
+ //jsonParam.put("Addresses",addressList);
|
|
|
+ logger.info("成航发机床报警信息数据采集,已请求");
|
|
|
+ String resultData = msgUtil.httpForPost(httpserverUrl, jsonParam.toString());
|
|
|
+ logger.info(resultData);
|
|
|
+ long l1 = System.currentTimeMillis() - l;
|
|
|
+ logger.info("成航发机床报警信息数据采集——结束,采集时长:"+l1);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|