Browse Source

全厂孪生 关于经编的数据

wukai 2 tháng trước cách đây
mục cha
commit
fa844037ae

+ 1 - 16
jjt-biz/src/main/java/com/jjt/biz/controller/ApiAllController.java

@@ -1,10 +1,7 @@
 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.common.constant.CacheConstants;
 import com.jjt.common.core.controller.BaseController;
 import com.jjt.common.core.domain.R;
 import com.jjt.common.core.redis.RedisCache;
@@ -17,8 +14,6 @@ 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 用户测试方法
@@ -42,20 +37,10 @@ public class ApiAllController extends BaseController {
         TwinAllVO vo = new TwinAllVO();
         vo.setStock(service.stock());
         vo.setAvgMonth(service.avgMonth());
-        CurrYieldVO currYieldVO = service.currYield();
-        vo.setCurrYield(currYieldVO);
+        vo.setCurrYield(service.currYield());
         vo.setProdTrade(service.prodTrade());
         vo.setEnergyTrade(service.energyTrade());
 
-        IndexData indexData = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
-        currYieldVO.getJb().setOpenRatio(BigDecimal.valueOf(indexData.getDevice().getRunningRatio()).setScale(0, RoundingMode.HALF_UP));
-        IndexData indexData1 = redisCache.getCacheObject(CacheConstants.INDEX_ALARM);
-        currYieldVO.getJb().setYield(BigDecimal.valueOf(indexData.getEfficiency().getTotalLength()).setScale(0, RoundingMode.HALF_UP));
-        currYieldVO.getJb().setYieldMax(BigDecimal.valueOf(50000));
-        BigDecimal jdl = BigDecimal.valueOf(indexData.getEfficiency().getAEfficiency() + indexData.getEfficiency().getBEfficiency()).divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP);
-        currYieldVO.getJb().setJdl(jdl);
-        currYieldVO.getJb().setOpenNum(indexData1.getDevice().getOnline());
-        currYieldVO.getJb().setTotalNum(indexData1.getDevice().getTotal());
         return R.ok(vo);
     }
 

+ 1 - 1
jjt-biz/src/main/java/com/jjt/biz/controller/ApiYrController.java

@@ -36,7 +36,7 @@ public class ApiYrController extends BaseController {
     @Resource
     private RedisCache redisCache;
 
-    @ApiOperation("全厂数字孪生")
+    @ApiOperation("染整线数字孪生")
     @GetMapping("/api/yr/data")
     @CrossOrigin(origins = "*")
     @ResponseBody

+ 27 - 6
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiAllServiceImpl.java

@@ -1,16 +1,15 @@
 package com.jjt.biz.service.impl;
 
 import com.jjt.biz.service.IApiAllService;
-import com.jjt.biz.vo.AvgMonthVO;
-import com.jjt.biz.vo.CurrYieldVO;
-import com.jjt.biz.vo.EnergyTradeVO;
-import com.jjt.biz.vo.ProdTradeVO;
+import com.jjt.biz.vo.*;
 import com.jjt.common.constant.CacheConstants;
 import com.jjt.common.core.redis.RedisCache;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.List;
@@ -60,6 +59,15 @@ public class ApiAllServiceImpl implements IApiAllService {
     public CurrYieldVO currYield() {
         CurrYieldVO vo = new CurrYieldVO();
         vo.mock();
+        IndexData indexData = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
+        vo.getJb().setOpenRatio(BigDecimal.valueOf(indexData.getDevice().getRunningRatio()).setScale(0, RoundingMode.HALF_UP));
+        IndexData indexData1 = redisCache.getCacheObject(CacheConstants.INDEX_ALARM);
+        vo.getJb().setYield(BigDecimal.valueOf(indexData.getEfficiency().getTotalLength()).setScale(0, RoundingMode.HALF_UP));
+        vo.getJb().setYieldMax(BigDecimal.valueOf(50000));
+        BigDecimal jdl = BigDecimal.valueOf(indexData.getEfficiency().getAEfficiency() + indexData.getEfficiency().getBEfficiency()).divide(BigDecimal.valueOf(2), 0, RoundingMode.HALF_UP);
+        vo.getJb().setJdl(jdl);
+        vo.getJb().setOpenNum(indexData1.getDevice().getOnline());
+        vo.getJb().setTotalNum(indexData1.getDevice().getTotal());
         redisCache.setCacheObject(CacheConstants.CURR_YIELD, vo);
         return redisCache.getCacheObject(CacheConstants.CURR_YIELD);
     }
@@ -71,8 +79,21 @@ public class ApiAllServiceImpl implements IApiAllService {
      */
     @Override
     public List<ProdTradeVO> prodTrade() {
-        redisCache.setCacheObject(CacheConstants.PROD_TRADE, mockProd());
-        return redisCache.getCacheObject(CacheConstants.PROD_TRADE);
+        List<ProdTradeVO> list = new ArrayList<>();
+        IndexData id = redisCache.getCacheObject(CacheConstants.INDEX_CALC);
+        List<WeekData> weekDataList = id.getWeekData();
+        for (WeekData wd : weekDataList) {
+            ProdTradeVO vo = new ProdTradeVO();
+            vo.mock();
+            vo.setJbLength(wd.getLength());
+            vo.setJbWeight(wd.getWeight());
+            LocalDate localDate = LocalDate.parse(wd.getTime());
+            vo.setDate(week(localDate));
+            vo.setTips(localDate.toString());
+            list.add(vo);
+        }
+
+        return list;
     }
 
     /**

+ 10 - 0
jjt-biz/src/main/java/com/jjt/biz/vo/WeekData.java

@@ -38,6 +38,13 @@ public class WeekData {
     private BigDecimal aKwh;
     @ApiModelProperty("B班电量")
     private BigDecimal bKwh;
+    @ApiModelProperty("总米长")
+    private BigDecimal length;
+    @ApiModelProperty("A班米长")
+    private BigDecimal lengthA;
+    @ApiModelProperty("B班米长")
+    private BigDecimal lengthB;
+
     @ApiModelProperty("A班停经片停机")
     private Long stop1A;
     @ApiModelProperty("A班CCD停机")
@@ -71,6 +78,9 @@ public class WeekData {
 
         this.aKwh = day.getKwhA();
         this.bKwh = day.getKwhB();
+
+        this.lengthA = day.getLengthA();
+        this.lengthB = day.getLengthB();
     }
 
 }

+ 7 - 3
jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcDay.java

@@ -310,9 +310,13 @@ public class TwinCalcDay extends BaseEntity {
      */
     public void calcDays(List<TwinCalcDay> days) {
         days.forEach(day -> {
-            this.weight = weight.add(day.getLength());
-            this.weightA = weightA.add(day.getLengthA());
-            this.weightB = weightB.add(day.getLengthB());
+            this.weight = weight.add(day.getWeight());
+            this.weightA = weightA.add(day.getWeightA());
+            this.weightB = weightB.add(day.getWeightB());
+
+            this.length = length.add(day.getLength()).setScale(2, RoundingMode.HALF_UP);
+            this.lengthA = lengthA.add(day.getLengthA()).setScale(2, RoundingMode.HALF_UP);
+            this.lengthB = lengthB.add(day.getLengthB()).setScale(2, RoundingMode.HALF_UP);
 
             this.kwh = kwh.add(day.getKwh());
             this.kwhA = kwhA.add(day.getKwhA());