wukai 3 mesiacov pred
rodič
commit
f1128940ae

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

@@ -1,9 +1,13 @@
 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;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -13,6 +17,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 用户测试方法
@@ -25,6 +31,8 @@ import javax.annotation.Resource;
 public class ApiAllController extends BaseController {
     @Resource
     private IApiAllService service;
+    @Resource
+    private RedisCache redisCache;
 
     @ApiOperation("全厂数字孪生")
     @GetMapping("/api/all/data")
@@ -34,9 +42,20 @@ public class ApiAllController extends BaseController {
         TwinAllVO vo = new TwinAllVO();
         vo.setStock(service.stock());
         vo.setAvgMonth(service.avgMonth());
-        vo.setCurrYield(service.currYield());
+        CurrYieldVO currYieldVO = service.currYield();
+        vo.setCurrYield(currYieldVO);
         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/resources/mapper/calc/TwinCalcHourEnergyMapper.xml

@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where AUTO_ID = #{autoId}
     </select>
     <select id="lastRecord" resultType="com.jjt.calc.domain.TwinCalcHourEnergy">
-        select top 1 * from TWIN_CALC_HOUR_ENERGY order by id desc
+        select top 1 * from TWIN_CALC_HOUR_ENERGY order by AUTO_ID desc
     </select>
 
     <insert id="insertTwinCalcHourEnergy" parameterType="TwinCalcHourEnergy">