Kaynağa Gözat

获取容器bean对象空指针问题修改

yejian 3 yıl önce
ebeveyn
işleme
cd943fbfdb

+ 5 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -5,10 +5,12 @@ import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
 import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
+import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.TaskService;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
+import com.github.zuihou.business.productionResourceCenter.service.impl.ZZoneServiceImpl;
 import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
 import org.slf4j.Logger;
@@ -57,14 +59,14 @@ public class MsgUtil implements ApplicationContextAware {
 
     public void pushTask(TTask task) {
         //查出所有的线边库数据
-        StockInfoService stockInfoService = (StockInfoService)getBean("StockInfoServiceImpl");
+        StockInfoService stockInfoService = (StockInfoService)getBean(StockInfoServiceImpl.class);
         Map<String, Map<String, List<Map>>> stockMap = stockInfoService.demoLineAllStock();
         Map<String, Object> pushMap = new HashMap<>();
         pushMap.put("type", WebSocketServer.PUSH_TYPE_STORGE);
         pushMap.put("data", stockMap);
         this.pushTask(task, pushMap);
 
-        ZZoneService zoneService = (ZZoneService)getBean("ZZoneServiceImpl");
+        ZZoneService zoneService = (ZZoneService)getBean(ZZoneServiceImpl.class);
         Map resourceMap = zoneService.demoLineAllResource();
         pushMap.clear();
         pushMap.put("type", WebSocketServer.PUSH_TYPE_RESOURCE);
@@ -134,7 +136,7 @@ public class MsgUtil implements ApplicationContextAware {
     public void pushDetailTask(TTask task) {
         Map<String, Object> rmap = new HashMap<>();
         rmap.put("id", task.getResourceId());
-        TaskService taskService = (TaskService)getBean("TaskService");
+        TaskService taskService = (TaskService)getBean(TaskService.class);
         Map<String, Object> pmap = taskService.getExeTaskByResourceList(rmap);
         try {
             Object o = pmap.get("orderList");