فهرست منبع

大屏数据源:三单和试车

wangxuan 6 ماه پیش
والد
کامیت
3dc850b1b0

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxCommissionCheckDao.java

@@ -3,6 +3,7 @@ package com.rongwei.bscommon.sys.dao;
 import com.rongwei.bsentity.domain.ZhcxCommissionCheckDetailDo;
 import com.rongwei.bsentity.domain.ZhcxCommissionCheckDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwei.bsentity.vo.check.LargeScreenCheckVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.HashMap;
@@ -76,4 +77,10 @@ public interface ZhcxCommissionCheckDao extends BaseMapper<ZhcxCommissionCheckDo
      * @param pid 试车检查主表id
      */
     void deleteTreeByPid(@Param("pid") String pid);
+
+    /**
+     * 获取大屏试车数据
+     * @return
+     */
+    List<LargeScreenCheckVo> getLargeScreenData();
 }

+ 20 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxPmqManagementDao.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwei.bsentity.vo.check.LargeScreenCheckVo;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
@@ -21,4 +22,23 @@ public interface ZhcxPmqManagementDao extends BaseMapper<ZhcxPmqManagementDo> {
 
     @Select("SELECT * FROM ZHCX_PMQ_MANAGEMENT WHERE DELETED = '0' AND CONCAT(ORDERNO, '|-_-|', PROJECTNO, '|-_-|', ORDERTYPE) = #{orderno}")
     List<ZhcxPmqManagementDo> getByCodeUnit(Map<String, String> map);
+
+    @Select("SELECT d.PROJECTID AS projectid,\n" +
+            "       d.PROJECTCODE AS projectcode,\n" +
+            "       d.PROJECTNAME AS projectname,\n" +
+            "       d.MACHINENO AS machineno,\n" +
+            "       d.MACHINEID AS machineno,\n" +
+            "       COALESCE(a.xiafa_count,0) AS denominator,\n" +
+            "       COALESCE(a.finish_count,0) AS molecule\n" +
+            "FROM INCONTROL.ZHCX_SHIP_OFFSHORE_DETAIL d\n" +
+            "LEFT join (SELECT mt.PROJECTNO,\n" +
+            "                      COUNT(mt.PROJECTNO)                                              AS xiafa_count,\n" +
+            "                      SUM(CASE WHEN CLOSESTATUS IN ('已关闭', 'NA') THEN 1 ELSE 0 END) AS finish_count\n" +
+            "      FROM INCONTROL.ZHCX_PMQ_MANAGEMENT mt\n" +
+            "               WHERE mt.DELETED = '0'\n" +
+            "                 AND mt.ORDERTYPE in ('液压修改单', '机械修改单', '电气修改单', '电气工艺修改单')\n" +
+            "    GROUP BY mt.PROJECTNO) a on a.PROJECTNO = d.PROJECTCODE\n" +
+            "WHERE\n" +
+            "    d.DELETED = '0'")
+    List<LargeScreenCheckVo> getLargeScreenData();
 }

+ 5 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxCommissionCheckService.java

@@ -98,4 +98,9 @@ public interface ZhcxCommissionCheckService extends IService<ZhcxCommissionCheck
      * @return
      */
     R wordExportPrj(Map<String, Object> map, HttpServletResponse response);
+
+    /**
+     * 大屏数据源(试车)
+     */
+    void largeScreenData();
 }

+ 4 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxPmqManagementService.java

@@ -13,4 +13,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxPmqManagementService extends IService<ZhcxPmqManagementDo> {
 
+    /**
+     * 大屏数据源(三单)
+     */
+    void largeScreenData();
 }

+ 47 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxCommissionCheckServiceImpl.java

@@ -1,6 +1,7 @@
 package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.aspose.words.*;
@@ -25,10 +26,12 @@ import com.rongwei.bsentity.dto.commission.CopyDetailDto;
 import com.rongwei.bsentity.dto.commission.ImportProjectCheckBO;
 import com.rongwei.bsentity.dto.commission.ImportProjectCheckDto;
 import com.rongwei.bsentity.dto.commission.ParseDocBO;
+import com.rongwei.bsentity.dto.project.indicator.DelPhysicalParam;
 import com.rongwei.bsentity.vo.FormDataCheckVO;
 import com.rongwei.bsentity.vo.ImportCheckBaseInfoDetailVo;
 import com.rongwei.bsentity.vo.ZhcxCommissionCheckDetailStandardWordVO;
 import com.rongwei.bsentity.vo.ZhcxCommissionCheckDetailWordVO;
+import com.rongwei.bsentity.vo.check.LargeScreenCheckVo;
 import com.rongwei.rwadmincommon.system.domain.SysDictDo;
 import com.rongwei.rwadmincommon.system.service.SysDictService;
 import com.rongwei.rwcommon.base.R;
@@ -128,6 +131,9 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
     @Autowired
     private SysDictService sysDictService;
 
+    @Autowired
+    private ZhcxProjectDeviceIndicatorService projectDeviceIndicatorService;
+
     @PostConstruct
     public void info() {
         commonFeginClient = autoCommonFeginClient;
@@ -2227,4 +2233,45 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
             }
         }
     }
+
+
+    @Override //大屏数据源(试车)
+    public void largeScreenData() {
+        // 删除大屏试车数据
+        DelPhysicalParam param = DelPhysicalParam.builder()
+                .type("check_test")
+                .build();
+        projectDeviceIndicatorService.delPhysical(param);
+
+        // 获取试车数据
+        List<LargeScreenCheckVo> list = baseMapper.getLargeScreenData();
+        log.info("获取的大屏试车数据源:{}",list.size());
+        List<ZhcxProjectDeviceIndicatorDo> resultList = new ArrayList<>();
+        for (LargeScreenCheckVo largeScreenCheckVo : list) {
+            ZhcxProjectDeviceIndicatorDo indicator = new ZhcxProjectDeviceIndicatorDo();
+            indicator.setId(SecurityUtil.getUUID());
+            indicator.setDate(new Date());
+            indicator.setDeleted("0");
+            indicator.setProjectid(largeScreenCheckVo.getProjectid());
+            indicator.setProjectcode(largeScreenCheckVo.getProjectcode());
+            indicator.setProjectname(largeScreenCheckVo.getProjectname());
+            indicator.setMachineid(largeScreenCheckVo.getMachinenoid());
+            indicator.setMachineno(largeScreenCheckVo.getMachineno());
+            indicator.setDisplayboard("紫");
+            indicator.setIndicatorname("试车检查情况");
+            indicator.setType("check_test");
+            indicator.setSort(4);
+            // 分子
+            indicator.setCompleted(Integer.valueOf(largeScreenCheckVo.getMolecule()));
+            // 分母
+            indicator.setTotal(Integer.valueOf(largeScreenCheckVo.getDenominator()));
+            // 百分比
+            indicator.setCompletionrate( Convert.toBigDecimal(largeScreenCheckVo.getQaprogress()));
+            resultList.add(indicator);
+        }
+        if(!resultList.isEmpty()){
+            projectDeviceIndicatorService.saveBatch(resultList);
+        }
+        log.info("大屏数据源(试车)存储结束");
+    }
 }

+ 67 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPmqManagementServiceImpl.java

@@ -1,11 +1,24 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.rongwei.bscommon.sys.service.ZhcxProjectDeviceIndicatorService;
 import com.rongwei.bsentity.domain.ZhcxPmqManagementDo;
 import com.rongwei.bscommon.sys.dao.ZhcxPmqManagementDao;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.domain.ZhcxProjectDeviceIndicatorDo;
+import com.rongwei.bsentity.dto.project.indicator.DelPhysicalParam;
+import com.rongwei.bsentity.vo.check.LargeScreenCheckVo;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 三单管理(Integrated Management of Production Orders, Material Documents, and Quality Records in Manufacturing) 服务实现类
@@ -14,7 +27,61 @@ import org.springframework.stereotype.Service;
  * @author wm
  * @since 2024-10-30
  */
+@Slf4j
 @Service
 public class ZhcxPmqManagementServiceImpl extends ServiceImpl<ZhcxPmqManagementDao, ZhcxPmqManagementDo> implements ZhcxPmqManagementService {
 
+    @Autowired
+    private ZhcxProjectDeviceIndicatorService projectDeviceIndicatorService;
+
+    @Override
+    public void largeScreenData() {
+        // 删除大屏试车数据
+        DelPhysicalParam param = DelPhysicalParam.builder()
+                .type("pmq_management")
+                .build();
+        projectDeviceIndicatorService.delPhysical(param);
+
+        // 获取三单数据
+        List<LargeScreenCheckVo> list =baseMapper.getLargeScreenData();
+        log.info("获取的大屏试车数据源:{}",list.size());
+        List<ZhcxProjectDeviceIndicatorDo> resultList = new ArrayList<>();
+        for (LargeScreenCheckVo largeScreenCheckVo : list) {
+            ZhcxProjectDeviceIndicatorDo indicator = new ZhcxProjectDeviceIndicatorDo();
+            indicator.setId(SecurityUtil.getUUID());
+            indicator.setDate(new Date());
+            indicator.setDeleted("0");
+            indicator.setProjectid(largeScreenCheckVo.getProjectid());
+            indicator.setProjectcode(largeScreenCheckVo.getProjectcode());
+            indicator.setProjectname(largeScreenCheckVo.getProjectname());
+            indicator.setMachineid(largeScreenCheckVo.getMachinenoid());
+            indicator.setMachineno(largeScreenCheckVo.getMachineno());
+            indicator.setDisplayboard("绿");
+            indicator.setIndicatorname("三单完成情况");
+            indicator.setType("pmq_management");
+            indicator.setSort(5);
+            // 分子
+            int molecule = Integer.parseInt(largeScreenCheckVo.getMolecule());
+            indicator.setCompleted(molecule);
+            // 分母
+            int denominator = Integer.parseInt(largeScreenCheckVo.getDenominator());
+            indicator.setTotal(denominator);
+            // 百分比
+            BigDecimal result;
+            if (denominator == 0) {
+                // 分母为 0 时,根据实际情况设置为 0 或抛出异常
+                result = BigDecimal.ZERO;
+            } else {
+                BigDecimal bdMolecule = BigDecimal.valueOf(molecule);
+                BigDecimal bdDenominator = BigDecimal.valueOf(denominator);
+                result = bdMolecule.divide(bdDenominator, 2, RoundingMode.HALF_UP);
+            }
+            indicator.setCompletionrate(result);
+            resultList.add(indicator);
+        }
+        if(!resultList.isEmpty()){
+            projectDeviceIndicatorService.saveBatch(resultList);
+        }
+        log.info("大屏数据源(三单)存储结束");
+    }
 }

+ 47 - 0
business-common/src/main/resources/mybatis/business/ZhcxCommissionCheckDao.xml

@@ -112,4 +112,51 @@
         WHERE row_num = 1
         ORDER BY MODIFYDATE DESC
     </select>
+
+    <select id="getLargeScreenData" resultType="com.rongwei.bsentity.vo.check.LargeScreenCheckVo">
+        SELECT MACHINEID   as machinenoid,
+               MACHINENO   as machineno,
+               PROJECTCODE as projectcode,
+               PROJECTID   as projectid,
+               PROJECTNAME as projectname,
+               CASE
+                   WHEN b.qaresult IS NULL THEN '0'
+                   WHEN b.qaresult = 0 THEN '0'
+                   ELSE b.qaresult
+                   END     as molecule,
+               CASE
+                   WHEN b.total IS NULL THEN '0'
+                   WHEN b.total = 0 THEN '0'
+                   ELSE (b.total - b.na2)
+                   END     as denominator,
+               CASE
+                   WHEN b.qaalltesttime_cx IS NULL THEN '0'
+                   WHEN b.qaalltesttime_cx = 0 THEN '0'
+                   WHEN b.qatesttime_cx IS NULL THEN '0'
+                   WHEN b.qatesttime_cx = 0 THEN '0'
+                   ELSE ROUND(b.qatesttime_cx / b.qaalltesttime_cx, 2)
+                   END     AS qaprogress
+        FROM INCONTROL.ZHCX_COMMISSION_CHECK c
+                 LEFT JOIN (SELECT PID,
+                                   count(*)                                               AS total,
+                                   SUM(CASE WHEN det.TESTRESULT = '20' THEN 1 ELSE 0 END) AS na2,
+                                   SUM(CASE WHEN det.TESTRESULT = '30' THEN 1 ELSE 0 END) AS qaresult,
+                                   SUM(CASE
+                                           WHEN (det.TESTRESULT NOT IN ('20') OR det.TESTRESULT IS NULL) AND
+                                                (det.TESTADDRESS = '10' OR det.TESTADDRESS IS NULL) THEN det.TESTTIME
+                                           ELSE 0 END)                                    AS qaalltesttime_cx,
+                                   SUM(CASE
+                                           WHEN det.TESTRESULT = '30' AND (det.TESTADDRESS = '10' OR det.TESTADDRESS IS NULL)
+                                               THEN det.TESTTIME
+                                           ELSE 0 END)                                    AS qatesttime_cx
+                            FROM INCONTROL.ZHCX_COMMISSION_CHECK_DETAIL det
+                            WHERE det.DELETED = '0'
+                            GROUP BY PID) b ON b.PID = c.ID
+        WHERE c.DELETED = '0'
+          and EXISTS (SELECT *
+                      FROM INCONTROL.ZHCX_SHIP_OFFSHORE_DETAIL d
+                      WHERE d.PROJECTID = c.PROJECTID
+                        AND d.MACHINENO = c.MACHINENO
+                        AND d.DELETED = '0')
+    </select>
 </mapper>

+ 44 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/check/LargeScreenCheckVo.java

@@ -0,0 +1,44 @@
+package com.rongwei.bsentity.vo.check;
+
+import lombok.Data;
+
+@Data
+public class LargeScreenCheckVo {
+    /**
+     * 项目id
+     */
+    private String projectid;
+
+    /**
+     * 项目工号
+     */
+    private String projectcode;
+    /**
+     * 项目名称
+     */
+    private String projectname;
+
+    /**
+     * 机号id
+     */
+    private String machinenoid;
+    /**
+     * 机号
+     */
+    private String machineno;
+
+    /**
+     * 分子
+     */
+    private String molecule;
+
+    /**
+     * 分母
+     */
+    private String denominator;
+
+    /**
+     * 试车进度
+     */
+    private String qaprogress;
+}

+ 7 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxCommissionCheckController.java

@@ -133,5 +133,12 @@ public class ZhcxCommissionCheckController {
             return R.error("标准库导入异常");
         }
     }
+
+    @RequestMapping("largeScreenData")
+    @ApiOperation("大屏数据源(试车)")
+    public R largeScreenData() {
+        commissionCheckService.largeScreenData();
+        return R.ok();
+    }
 }
 

+ 11 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxPmqManagementController.java

@@ -4,6 +4,7 @@ package com.rongwei.bsserver.controller;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementDistributionDetailService;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementLogService;
 import com.rongwei.bscommon.sys.service.ZhcxPmqManagementRecoredService;
+import com.rongwei.bscommon.sys.service.ZhcxPmqManagementService;
 import com.rongwei.rwcommon.base.R;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -38,6 +39,9 @@ public class ZhcxPmqManagementController {
     @Autowired
     private ZhcxPmqManagementLogService logService;
 
+    @Autowired
+    private ZhcxPmqManagementService zhcxPmqManagementService;
+
     @PostMapping("/generateDistributionDetail")
     @ApiOperation("第二层生成三单派单数据(左边列表 NA/已关闭)")
     public R generateDistributionDetail(@RequestBody Map<String,Object> map){
@@ -140,5 +144,12 @@ public class ZhcxPmqManagementController {
             return R.error("三单执行页面修改关闭状态");
         }
     }
+
+    @RequestMapping("largeScreenData")
+    @ApiOperation("大屏数据源(三单)")
+    public R largeScreenData() {
+        zhcxPmqManagementService.largeScreenData();
+        return R.ok();
+    }
 }