Ver Fonte

AI工艺对比修改

wukai há 1 mês atrás
pai
commit
4e64c9b7a6

+ 86 - 39
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiYrServiceImpl.java

@@ -1,6 +1,8 @@
 package com.jjt.biz.service.impl;
 
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
 import com.jjt.biz.service.IApiYrService;
 import com.jjt.biz.vo.*;
 import com.jjt.calc.domain.TwinCalcDayYhj;
@@ -31,6 +33,9 @@ import java.time.ZoneOffset;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 /**
@@ -391,18 +396,82 @@ public class ApiYrServiceImpl implements IApiYrService {
             para.setName(item.getDeviceName());
             para.setPara(map);
             if ("Forward".equals(item.getWsName())) {
-                qzProcessor(qz, item, flag, para);
+                qzProcessor(qz, item, para);
             } else if ("Back".equals(item.getWsName())) {
-                hzProcessor(hz, item, flag, para);
+                hzProcessor(hz, item, para);
             } else {
                 //留给烘固机
-                yrProcessor(yr, item, flag, para);
+                yrProcessor(yr, item, para);
             }
         });
+        calcAvg(vo, flag);
         return vo;
     }
 
-    private void qzProcessor(CompareVO.Qz qz, TwinCalcHourRz item, boolean flag, CompareVO.Para para) {
+    private void calcAvg(CompareVO vo, boolean flag) {
+        // 提取公用方法
+        Function<Map.Entry<String, Object>, BigDecimal> valueExtractor = entry -> {
+            JSONObject jsonObject = JSONObject.parseObject(entry.getValue().toString());
+            JSONArray array = jsonObject.getJSONArray("act");
+            return array != null && !array.isEmpty() ? array.getJSONObject(0).getBigDecimal("value") : BigDecimal.ZERO;
+        };
+
+        // 计算平均值的方法
+        BiFunction<List<CompareVO.Para>, Predicate<Map.Entry<String, Object>>, BigDecimal> calculateAvg = (list, filter) ->
+            list.stream()
+                .flatMap(item -> item.getPara().entrySet().stream())
+                .filter(filter)
+                .map(valueExtractor)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        // 前整车间计算
+        List<CompareVO.Para> qzDx = vo.getQz().getDxPara();
+        List<CompareVO.Para> qzTg = vo.getQz().getTgPara();
+
+        vo.getQz().setHxAvgTemp(qzDx.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(qzDx, entry -> entry.getKey().contains("烘箱温度"))
+                .divide(new BigDecimal(qzDx.size() * 4), 2, RoundingMode.HALF_UP));
+
+        vo.getQz().setTgAvgTemp(qzTg.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(qzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
+                .divide(new BigDecimal(qzTg.size() * 2), 2, RoundingMode.HALF_UP));
+
+        vo.getQz().setTgAvgSpeed(qzTg.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(qzTg, entry -> entry.getKey().contains("走布速度"))
+                .divide(new BigDecimal(qzTg.size()), 2, RoundingMode.HALF_UP));
+
+        // 后整车间计算
+        List<CompareVO.Para> hzDx = vo.getHz().getDxPara();
+        List<CompareVO.Para> hzTg = vo.getHz().getTgPara();
+
+        vo.getHz().setHxAvgTemp(hzDx.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(hzDx, entry -> entry.getKey().contains("烘箱温度"))
+                .divide(new BigDecimal(hzDx.size() * 4), 2, RoundingMode.HALF_UP));
+
+        vo.getHz().setTgAvgTemp(hzTg.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(hzTg, entry -> entry.getKey().contains("烫辊") && entry.getKey().contains("温度"))
+                .divide(new BigDecimal(hzTg.size() * 2), 2, RoundingMode.HALF_UP));
+
+        vo.getHz().setTgAvgSpeed(hzTg.isEmpty() ? BigDecimal.ZERO :
+            calculateAvg.apply(hzTg, entry -> entry.getKey().contains("走布速度"))
+                .divide(new BigDecimal(hzTg.size()), 2, RoundingMode.HALF_UP));
+
+        if (!flag) {
+            vo.getQz().setDxPara(null);
+            vo.getQz().setGsPara(null);
+            vo.getQz().setSmPara(null);
+            vo.getQz().setTgPara(null);
+            vo.getHz().setDxPara(null);
+            vo.getHz().setGsPara(null);
+            vo.getHz().setQmPara(null);
+            vo.getHz().setSmPara(null);
+            vo.getHz().setTgPara(null);
+            vo.getHz().setTjPara(null);
+            vo.getYr().setHgPara(null);
+        }
+    }
+
+    private void qzProcessor(CompareVO.Qz qz, TwinCalcHourRz item, CompareVO.Para para) {
         //前整
         switch (item.getTypeId()) {
             case 2:
@@ -410,51 +479,41 @@ public class ApiYrServiceImpl implements IApiYrService {
                 if ("Y".equals(item.getOnline())) {
                     qz.setDx(qz.getDx() + 1);
                 }
-                if (flag) {
-                    qz.addDxPara(para);
-                }
+                qz.addDxPara(para);
                 break;
             case 3:
                 //双棍烫光机
                 if ("Y".equals(item.getOnline())) {
                     qz.setTg(qz.getTg() + 1);
                 }
-                if (flag) {
-                    qz.addTgPara(para);
-                }
+                qz.addTgPara(para);
                 break;
             case 4:
                 //高梳机
                 if ("Y".equals(item.getOnline())) {
                     qz.setGs(qz.getGs() + 1);
                 }
-                if (flag) {
-                    qz.addGsPara(para);
-                }
+                qz.addGsPara(para);
                 break;
             case 5:
                 //双棍刷毛
                 if ("Y".equals(item.getOnline())) {
                     qz.setSm(qz.getSm() + 1);
                 }
-                if (flag) {
-                    qz.addSmPara(para);
-                }
+                qz.addSmPara(para);
                 break;
             default:
                 break;
         }
     }
 
-    private void yrProcessor(CompareVO.Yr yr, TwinCalcHourRz item, boolean flag, CompareVO.Para para) {
+    private void yrProcessor(CompareVO.Yr yr, TwinCalcHourRz item, CompareVO.Para para) {
         if (8 == item.getTypeId()) {
-            if (flag) {
-                yr.addHgPara(para);
-            }
+            yr.addHgPara(para);
         }
     }
 
-    private void hzProcessor(CompareVO.Hz hz, TwinCalcHourRz item, boolean flag, CompareVO.Para para) {
+    private void hzProcessor(CompareVO.Hz hz, TwinCalcHourRz item, CompareVO.Para para) {
         //后整
         switch (item.getTypeId()) {
             case 6:
@@ -462,54 +521,42 @@ public class ApiYrServiceImpl implements IApiYrService {
                 if ("Y".equals(item.getOnline())) {
                     hz.setDx(hz.getDx() + 1);
                 }
-                if (flag) {
-                    hz.addDxPara(para);
-                }
+                hz.addDxPara(para);
                 break;
             case 3:
                 //双棍烫光机
                 if ("Y".equals(item.getOnline())) {
                     hz.setTg(hz.getTg() + 1);
                 }
-                if (flag) {
-                    hz.addTgPara(para);
-                }
+                hz.addTgPara(para);
                 break;
             case 4:
                 //高梳机
                 if ("Y".equals(item.getOnline())) {
                     hz.setGs(hz.getGs() + 1);
                 }
-                if (flag) {
-                    hz.addGsPara(para);
-                }
+                hz.addGsPara(para);
                 break;
             case 5:
                 //双棍刷毛
                 if ("Y".equals(item.getOnline())) {
                     hz.setSm(hz.getSm() + 1);
                 }
-                if (flag) {
-                    hz.addSmPara(para);
-                }
+                hz.addSmPara(para);
                 break;
             case 7:
                 //起毛机
                 if ("Y".equals(item.getOnline())) {
                     hz.setQm(hz.getQm() + 1);
                 }
-                if (flag) {
-                    hz.addQmPara(para);
-                }
+                hz.addQmPara(para);
                 break;
             case 9:
                 //烫剪机
                 if ("Y".equals(item.getOnline())) {
                     hz.setTj(hz.getTj() + 1);
                 }
-                if (flag) {
-                    hz.addTjPara(para);
-                }
+                hz.addTjPara(para);
                 break;
             default:
                 break;

+ 6 - 6
jjt-biz/src/main/java/com/jjt/inventory/controller/TwinCalcHourBpController.java

@@ -41,7 +41,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 查询白坯仓库小时数据列表
      */
     @ApiOperation("查询白坯仓库小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:list')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:list')")
     @GetMapping("/list")
     public TableDataInfo list(TwinCalcHourBp twinCalcHourBp)
     {
@@ -54,7 +54,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 导出白坯仓库小时数据列表
      */
     @ApiOperation("导出白坯仓库小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:export')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:export')")
     @Log(title = "白坯仓库小时数据", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TwinCalcHourBp twinCalcHourBp)
@@ -68,7 +68,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 获取白坯仓库小时数据详细信息
      */
     @ApiOperation("获取白坯仓库小时数据详细信息")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:query')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -79,7 +79,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 新增白坯仓库小时数据
      */
     @ApiOperation("新增白坯仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:add')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:add')")
     @Log(title = "白坯仓库小时数据", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TwinCalcHourBp twinCalcHourBp)
@@ -91,7 +91,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 修改白坯仓库小时数据
      */
     @ApiOperation("修改白坯仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:edit')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:edit')")
     @Log(title = "白坯仓库小时数据", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TwinCalcHourBp twinCalcHourBp)
@@ -103,7 +103,7 @@ public class TwinCalcHourBpController extends BaseController{
      * 删除白坯仓库小时数据
      */
     @ApiOperation("删除白坯仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:bpHour:remove')")
+    //@PreAuthorize("@ss.hasPermi('inventory:bpHour:remove')")
     @Log(title = "白坯仓库小时数据", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 6 - 6
jjt-biz/src/main/java/com/jjt/inventory/controller/TwinCalcHourBpOutController.java

@@ -41,7 +41,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 查询白坯投放量小时数据列表
      */
     @ApiOperation("查询白坯投放量小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:out:list')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:list')")
     @GetMapping("/list")
     public TableDataInfo list(TwinCalcHourBpOut twinCalcHourBpOut)
     {
@@ -54,7 +54,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 导出白坯投放量小时数据列表
      */
     @ApiOperation("导出白坯投放量小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:out:export')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:export')")
     @Log(title = "白坯投放量小时数据", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TwinCalcHourBpOut twinCalcHourBpOut)
@@ -68,7 +68,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 获取白坯投放量小时数据详细信息
      */
     @ApiOperation("获取白坯投放量小时数据详细信息")
-    @PreAuthorize("@ss.hasPermi('inventory:out:query')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -79,7 +79,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 新增白坯投放量小时数据
      */
     @ApiOperation("新增白坯投放量小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:out:add')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:add')")
     @Log(title = "白坯投放量小时数据", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TwinCalcHourBpOut twinCalcHourBpOut)
@@ -91,7 +91,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 修改白坯投放量小时数据
      */
     @ApiOperation("修改白坯投放量小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:out:edit')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:edit')")
     @Log(title = "白坯投放量小时数据", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TwinCalcHourBpOut twinCalcHourBpOut)
@@ -103,7 +103,7 @@ public class TwinCalcHourBpOutController extends BaseController{
      * 删除白坯投放量小时数据
      */
     @ApiOperation("删除白坯投放量小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:out:remove')")
+    //@PreAuthorize("@ss.hasPermi('inventory:out:remove')")
     @Log(title = "白坯投放量小时数据", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 6 - 6
jjt-biz/src/main/java/com/jjt/inventory/controller/TwinCalcHourPtController.java

@@ -41,7 +41,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 查询盘头仓库小时数据列表
      */
     @ApiOperation("查询盘头仓库小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:list')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:list')")
     @GetMapping("/list")
     public TableDataInfo list(TwinCalcHourPt twinCalcHourPt)
     {
@@ -54,7 +54,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 导出盘头仓库小时数据列表
      */
     @ApiOperation("导出盘头仓库小时数据列表")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:export')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:export')")
     @Log(title = "盘头仓库小时数据", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TwinCalcHourPt twinCalcHourPt)
@@ -68,7 +68,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 获取盘头仓库小时数据详细信息
      */
     @ApiOperation("获取盘头仓库小时数据详细信息")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:query')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -79,7 +79,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 新增盘头仓库小时数据
      */
     @ApiOperation("新增盘头仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:add')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:add')")
     @Log(title = "盘头仓库小时数据", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TwinCalcHourPt twinCalcHourPt)
@@ -91,7 +91,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 修改盘头仓库小时数据
      */
     @ApiOperation("修改盘头仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:edit')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:edit')")
     @Log(title = "盘头仓库小时数据", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TwinCalcHourPt twinCalcHourPt)
@@ -103,7 +103,7 @@ public class TwinCalcHourPtController extends BaseController{
      * 删除盘头仓库小时数据
      */
     @ApiOperation("删除盘头仓库小时数据")
-    @PreAuthorize("@ss.hasPermi('inventory:ptHour:remove')")
+    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:remove')")
     @Log(title = "盘头仓库小时数据", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 12 - 1
jjt-biz/src/main/java/com/jjt/rz/vo/CompareVO.java

@@ -43,7 +43,6 @@ public class CompareVO {
     private Integer length;
     @ApiModelProperty("白坯投放量")
     private Integer bp;
-
     @Data
     public static class Qz {
         @ApiModelProperty("定型次数")
@@ -66,6 +65,12 @@ public class CompareVO {
         private BigDecimal elect;
         @ApiModelProperty("热油")
         private BigDecimal oil;
+        @ApiModelProperty("烘箱平均温度")
+        private BigDecimal hxAvgTemp;
+        @ApiModelProperty("烫辊平均温度")
+        private BigDecimal tgAvgTemp;
+        @ApiModelProperty("烫光平均速度")
+        private BigDecimal tgAvgSpeed;
 
         public Qz() {
             this.elect = BigDecimal.ZERO;
@@ -144,6 +149,12 @@ public class CompareVO {
         private BigDecimal elect;
         @ApiModelProperty("热油")
         private BigDecimal oil;
+        @ApiModelProperty("烘箱平均温度")
+        private BigDecimal hxAvgTemp;
+        @ApiModelProperty("烫辊平均温度")
+        private BigDecimal tgAvgTemp;
+        @ApiModelProperty("烫光平均速度")
+        private BigDecimal tgAvgSpeed;
 
         public Hz() {
             this.elect = BigDecimal.ZERO;

+ 1 - 0
jjt-biz/src/main/resources/mapper/inventory/TwinCalcHourBpMapper.xml

@@ -74,6 +74,7 @@
             <if test="updatedTime != null ">and UPDATED_TIME = #{updatedTime}</if>
             <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
         </where>
+        ORDER BY DATA_DATE DESC,HOUR DESC
     </select>
 
     <select id="selectTwinCalcHourBpById" parameterType="Long" resultMap="TwinCalcHourBpResult">

+ 1 - 1
jjt-biz/src/main/resources/mapper/inventory/TwinCalcHourBpOutMapper.xml

@@ -32,7 +32,7 @@
                 and DATEADD(hour, HOUR, DATA_DATE) between #{params.sTime} and #{params.eTime}
             </if>
         </where>
-        order by ID desc
+        ORDER BY DATA_DATE DESC,HOUR DESC
     </select>
 
     <select id="selectTwinCalcHourBpOutById" parameterType="Long" resultMap="TwinCalcHourBpOutResult">

+ 1 - 0
jjt-biz/src/main/resources/mapper/inventory/TwinCalcHourPtMapper.xml

@@ -53,6 +53,7 @@
             <if test="updatedTime != null ">and UPDATED_TIME = #{updatedTime}</if>
             <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
         </where>
+        ORDER BY DATA_DATE DESC,HOUR DESC
     </select>
 
     <select id="selectTwinCalcHourPtById" parameterType="Long" resultMap="TwinCalcHourPtResult">