Преглед изворни кода

解决数字孪生2个页面数据不同步问题

wukai пре 3 недеља
родитељ
комит
35a39b3a49

+ 33 - 6
jjt-biz/src/main/java/com/jjt/biz/controller/ApiAllController.java

@@ -1,7 +1,10 @@
 package com.jjt.biz.controller;
 
 import com.jjt.biz.service.IApiAllService;
+import com.jjt.biz.vo.CurrYieldVO;
+import com.jjt.biz.vo.IndexData;
 import com.jjt.biz.vo.TwinAllVO;
+import com.jjt.biz.vo.YrTwinVO;
 import com.jjt.common.constant.CacheConstants;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.R;
@@ -15,6 +18,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 /**
  * swagger 用户测试方法
@@ -35,13 +40,35 @@ public class ApiAllController extends BaseController {
     @CrossOrigin(origins = "*")
     @ResponseBody
     public R<?> data() {
-//        TwinAllVO vo = new TwinAllVO();
-//        vo.setStock(service.stock());
-//        vo.setAvgMonth(service.avgMonth());
-//        vo.setCurrYield(service.currYield());
-//        vo.setProdTrade(service.prodTrade());
-//        vo.setEnergyTrade(service.energyTrade());
         TwinAllVO vo = redisCache.getCacheObject(CacheConstants.ALL_MOCK);
+        //处理经编当前数据  --start
+        CurrYieldVO yieldVO = redisCache.getCacheObject(CacheConstants.CURR_YIELD);
+        IndexData todayData = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
+        IndexData currData = redisCache.getCacheObject(CacheConstants.INDEX_ALARM);
+        yieldVO.getJb().setYield(BigDecimal.valueOf(todayData.getEfficiency().getTotalLength()).setScale(0, RoundingMode.HALF_UP));
+        yieldVO.getJb().setYieldMax(BigDecimal.valueOf(50000));
+        BigDecimal jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency() + todayData.getEfficiency().getBEfficiency()).divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP);
+        if (todayData.getEfficiency().getBEfficiency() == 0f) {
+            jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency()).setScale(0, RoundingMode.HALF_UP);
+        }
+        yieldVO.getJb().setJdl(jdl);
+        yieldVO.getJb().setOpenNum(currData.getDevice().getOnline());
+        yieldVO.getJb().setTotalNum(currData.getDevice().getTotal());
+
+        yieldVO.getJb().setOpenRatio(BigDecimal.valueOf(currData.getDevice().getRunningRatio()).setScale(0, RoundingMode.HALF_UP));
+        //处理经编当前数据  --end
+
+        //处理染整当前数据  --start
+        YrTwinVO rzVO = redisCache.getCacheObject(CacheConstants.RZ_MOCK);
+        CurrYieldVO.RZ rz = yieldVO.getRz();
+        rz.setYield(rzVO.getStatus().getLength());
+        rz.setOpenLine(rzVO.getStatus().getOpenProd());
+        rz.setYieldMax(BigDecimal.valueOf(200000));
+        rz.setOpenNum(rzVO.getStatus().getOpen());
+        rz.setTotalNum(rzVO.getStatus().getTotal());
+        rz.setOpenRatio(rzVO.getStatus().getRatio());
+        vo.setCurrYield(yieldVO);
+        //处理染整当前数据  --end
         return R.ok(vo);
     }
 

+ 14 - 24
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiAllServiceImpl.java

@@ -149,20 +149,20 @@ public class ApiAllServiceImpl implements IApiAllService {
     public CurrYieldVO currYield() {
         CurrYieldVO vo = new CurrYieldVO();
         vo.mock();
-        IndexData todayData = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
-        IndexData currData = redisCache.getCacheObject(CacheConstants.INDEX_ALARM);
-        vo.getJb().setYield(BigDecimal.valueOf(todayData.getEfficiency().getTotalLength()).setScale(0, RoundingMode.HALF_UP));
-        vo.getJb().setYieldMax(BigDecimal.valueOf(50000));
-        BigDecimal jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency() + todayData.getEfficiency().getBEfficiency()).divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP);
-        if (todayData.getEfficiency().getBEfficiency() == 0f) {
-            jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency()).setScale(0, RoundingMode.HALF_UP);
-        }
-        vo.getJb().setJdl(jdl);
-//        vo.getJb().setOpen(currData.getDevice().getOnline(),currData.getDevice().getTotal());
-        vo.getJb().setOpenNum(currData.getDevice().getOnline());
-        vo.getJb().setTotalNum(currData.getDevice().getTotal());
-
-        vo.getJb().setOpenRatio(BigDecimal.valueOf(currData.getDevice().getRunningRatio()).setScale(0, RoundingMode.HALF_UP));
+//        IndexData todayData = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
+//        IndexData currData = redisCache.getCacheObject(CacheConstants.INDEX_ALARM);
+//        vo.getJb().setYield(BigDecimal.valueOf(todayData.getEfficiency().getTotalLength()).setScale(0, RoundingMode.HALF_UP));
+//        vo.getJb().setYieldMax(BigDecimal.valueOf(50000));
+//        BigDecimal jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency() + todayData.getEfficiency().getBEfficiency()).divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP);
+//        if (todayData.getEfficiency().getBEfficiency() == 0f) {
+//            jdl = BigDecimal.valueOf(todayData.getEfficiency().getAEfficiency()).setScale(0, RoundingMode.HALF_UP);
+//        }
+//        vo.getJb().setJdl(jdl);
+////        vo.getJb().setOpen(currData.getDevice().getOnline(),currData.getDevice().getTotal());
+//        vo.getJb().setOpenNum(currData.getDevice().getOnline());
+//        vo.getJb().setTotalNum(currData.getDevice().getTotal());
+//
+//        vo.getJb().setOpenRatio(BigDecimal.valueOf(currData.getDevice().getRunningRatio()).setScale(0, RoundingMode.HALF_UP));
         redisCache.setCacheObject(CacheConstants.CURR_YIELD, vo);
         return redisCache.getCacheObject(CacheConstants.CURR_YIELD);
     }
@@ -311,19 +311,9 @@ public class ApiAllServiceImpl implements IApiAllService {
      */
     @Override
     public void mock() {
-        YrTwinVO rzVO = redisCache.getCacheObject(CacheConstants.RZ_MOCK);
         TwinAllVO vo = new TwinAllVO();
         vo.setStock(stock());
         vo.setAvgMonth(avgMonth());
-        CurrYieldVO currYieldVO = currYield();
-        CurrYieldVO.RZ rz = currYieldVO.getRz();
-        rz.setYield(rzVO.getStatus().getLength());
-        rz.setOpenLine(rzVO.getStatus().getOpenProd());
-        rz.setYieldMax(BigDecimal.valueOf(200000));
-        rz.setOpenNum(rzVO.getStatus().getOpen());
-        rz.setTotalNum(rzVO.getStatus().getTotal());
-        rz.setOpenRatio(rzVO.getStatus().getRatio());
-        vo.setCurrYield(currYieldVO);
         vo.setProdTrade(prodTrade());
         vo.setEnergyTrade(energyTrade());
         redisCache.setCacheObject(CacheConstants.ALL_MOCK, vo);