Browse Source

毛高接口修改

wukai 1 ngày trước cách đây
mục cha
commit
06e7c81933

+ 23 - 0
jjt-biz/src/main/java/com/jjt/biz/controller/ApiController.java

@@ -4,6 +4,7 @@ import com.jjt.biz.domain.TwinDevice;
 import com.jjt.biz.service.ITwinDeviceService;
 import com.jjt.biz.vo.*;
 import com.jjt.calc.domain.TwinCalcDay;
+import com.jjt.calc.domain.TwinCalcHourSpec;
 import com.jjt.calc.service.ITwinCalcDayService;
 import com.jjt.calc.service.ITwinCalcHourSpecService;
 import com.jjt.calc.vo.SpecVO;
@@ -224,6 +225,28 @@ public class ApiController extends BaseController {
         }
     }
 
+    @ApiOperation("配方月统计")
+    @GetMapping("/api/formula/calc/{month}")
+    @CrossOrigin(origins = "*")
+    public R formulaDetail(@PathVariable String month) {
+        Map<String, Object> result = new HashMap<>();
+        List<SpecVO> specs = specService.selectSpec(month, null);
+        specs.forEach(spec -> spec.setHeight(spec.getHeight().stripTrailingZeros()));
+        Map<String, List<SpecVO>> specsGroup = specs.stream().collect(Collectors.groupingBy(s -> s.getHeight().stripTrailingZeros().toPlainString(), LinkedHashMap::new, Collectors.toList()));
+        result.put("trend", specsGroup);
+        TwinCalcHourSpec hour = new TwinCalcHourSpec();
+        Map<String, Object> params = new HashMap<>(16);
+        params.put("month", month);
+        hour.setParams(params);
+        List<TwinCalcHourSpec> list = specService.selectTwinCalcHourSpecList(hour);
+        List<String> specsList = list.stream()
+                .map(s -> s.getHeight().stripTrailingZeros().toPlainString())
+                .collect(Collectors.toList());
+        result.put("height", specsList);
+        return R.success(result);
+    }
+
+
     @ApiOperation("导出当前停机明细")
     @GetMapping("/api/view/stop")
     @CrossOrigin(origins = "*")

+ 1 - 1
jjt-biz/src/main/java/com/jjt/calc/vo/SpecVO.java

@@ -18,7 +18,7 @@ import java.util.Date;
 @Data
 public class SpecVO {
     @ApiModelProperty("时间")
-    @JsonFormat(pattern = "yyyy-MM-dd hh")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date time;
     @ApiModelProperty("毛高")
     private BigDecimal height;

+ 13 - 4
jjt-biz/src/main/resources/mapper/calc/TwinCalcHourSpecMapper.xml

@@ -49,7 +49,12 @@
             <if test="params.sTime != null and params.eTime != null">
                 and DATEADD(hour, HOUR, DATA_DATE) between #{params.sTime} and #{params.eTime}
             </if>
+            <if test="params.month != null and params.month!=''">
+                and FORMAT(DATEADD(hour, HOUR - 7, DATA_DATE), 'yyyy-MM') = #{params.month}
+                and hour=7
+            </if>
         </where>
+        order by DATEADD(hour, HOUR, DATA_DATE)
     </select>
 
     <select id="selectTwinCalcHourSpecById" parameterType="Long" resultMap="TwinCalcHourSpecResult">
@@ -58,10 +63,14 @@
     </select>
     <select id="selectSpec" resultType="com.jjt.calc.vo.SpecVO">
         select t.time, t.height, count(DISTINCT device_id) num
-        from (select DATEADD(hour, HOUR, DATA_DATE) time, HEIGHT, device_id
-              from TWIN_CALC_HOUR_SPEC
-              where HEIGHT = #{height}
-                and FORMAT(DATEADD(hour, HOUR - 7, DATA_DATE), 'yyyy-MM') = #{month}) t
+        from (select DATA_DATE time, HEIGHT, device_id
+        from TWIN_CALC_HOUR_SPEC
+        <where>
+            <if test="height!=null">and HEIGHT =#{height}</if>
+            and FORMAT(DATEADD(hour, HOUR - 7, DATA_DATE), 'yyyy-MM') = #{month}
+            and hour=7
+        </where>
+        ) t
         group by t.time, t.height
         order by time
     </select>