Forráskód Böngészése

大屏-外部报验情况

wangming 6 hónapja
szülő
commit
add44009e1

+ 25 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxItpProjectNodesDao.java

@@ -3,6 +3,7 @@ package com.rongwei.bscommon.sys.dao;
 import com.alibaba.fastjson.JSONObject;
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwei.bsentity.vo.project.ShipOffStoreNodeTotal;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -104,4 +105,28 @@ public interface ZhcxItpProjectNodesDao extends BaseMapper<ZhcxItpProjectNodesDo
             "WHERE " +
             " zii.DELETED = '0'")
     List<JSONObject> getDeletedNodeProject();
+
+    /**
+     * 离岸项目的报验点数量
+     *
+     * @return
+     */
+    @Select("SELECT " +
+            " n.PROJECTID , " +
+            " count(n.ID) AS total " +
+            "FROM " +
+            " ZHCX_ITP_PROJECT_NODES n " +
+            "WHERE " +
+            " n.ISNEEDOUT= 'true' " +
+            " and EXISTS ( " +
+            " SELECT " +
+            "  * " +
+            " FROM " +
+            "  ZHCX_SHIP_OFFSHORE_DETAIL d " +
+            " WHERE " +
+            "  d.PROJECTID = n.PROJECTID " +
+            "  AND n.MACHINENAME LIKE CONCAT('%', d.MACHINENO, '%') " +
+            "   AND d.DELETED = '0') " +
+            "   GROUP BY n.PROJECTID ")
+    List<ShipOffStoreNodeTotal> getShipOffStoreNodeTotal();
 }

+ 16 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxOutsideInspectionItpDao.java

@@ -5,6 +5,7 @@ import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwei.bsentity.dto.OutsideInspactionSyncDto;
 import com.rongwei.bsentity.dto.OutsideInspactionSyncReqquest;
+import com.rongwei.bsentity.vo.outside.OutsideInspectionVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -89,4 +90,19 @@ public interface ZhcxOutsideInspectionItpDao extends BaseMapper<ZhcxOutsideInspe
             "WHERE " +
             " zii.DELETED = '0' AND zii.PROJECTID = #{projectId}")
     List<JSONObject> getDeletedNodeInspection(@Param("projectId") String projectId);
+
+    /**
+     * 获取离岸项目报验单
+     *
+     * @return
+     */
+    @Select("SELECT " +
+            " DISTINCT i.*,d.MACHINEID as shipMachineNoId, d.MACHINENO as  shipMachineNo" +
+            " FROM " +
+            " ZHCX_OUTSIDE_INSPECTION_ITP i " +
+            "JOIN ZHCX_OUTSIDE_INSPECTION_ITP_SUPERVISION_DISPATCH sd ON sd.ITPID = i.ID " +
+            "JOIN ZHCX_SHIP_OFFSHORE_DETAIL d ON d.PROJECTID = i.PROJECTID AND (i.MACHINENO LIKE CONCAT('%', d.MACHINENO, '%') OR i.STRUCTUREMACHINENO LIKE CONCAT('%', d.MACHINENO, '%')) AND d.DELETED = '0' " +
+            "WHERE " +
+            " sd.INSPECTIONCONCLUSION IN ('10', '30') AND i.DELETED = '0' AND sd.DELETED = '0'")
+    List<OutsideInspectionVo> getShipInspectionDisplay();
 }

+ 8 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxItpProjectNodesService.java

@@ -5,6 +5,7 @@ import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.OutsideInspectionProjectPointDto;
 import com.rongwei.bsentity.vo.CopyNodeVo;
+import com.rongwei.bsentity.vo.project.ShipOffStoreNodeTotal;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -52,4 +53,11 @@ public interface ZhcxItpProjectNodesService extends IService<ZhcxItpProjectNodes
      */
     List<JSONObject> getPrjNode(String projectId);
 
+    /**
+     * 离岸各个项目报验点数量
+     *
+     * @return
+     */
+    List<ShipOffStoreNodeTotal> getShipOffStoreNodeTotal();
+
 }

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxOutsideInspectionItpService.java

@@ -89,5 +89,11 @@ public interface ZhcxOutsideInspectionItpService extends IService<ZhcxOutsideIns
      * @return
      */
     List<JSONObject> getDeletedNodeProject();
+
+    /**
+     * 添加统计完成指标指标
+     *
+     */
+    void addUpComplateIndicators();
 }
 

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

@@ -16,6 +16,7 @@ import com.rongwei.bsentity.dto.ItpProjectNodeExtVo;
 import com.rongwei.bsentity.dto.ItpProjectNodeL2Vo;
 import com.rongwei.bsentity.dto.OutsideInspectionProjectPointDto;
 import com.rongwei.bsentity.vo.CopyNodeVo;
+import com.rongwei.bsentity.vo.project.ShipOffStoreNodeTotal;
 import com.rongwei.commonservice.service.dao.CommonSqlDao;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.JSONUtils;
@@ -662,4 +663,14 @@ public class ZhcxItpProjectNodesServiceImpl extends ServiceImpl<ZhcxItpProjectNo
     public List<JSONObject> getPrjNode(String projectId) {
         return dao.getPrjNode(projectId);
     }
+
+    /**
+     * 离岸各个项目报验点数量
+     *
+     * @return
+     */
+    @Override
+    public List<ShipOffStoreNodeTotal> getShipOffStoreNodeTotal() {
+        return dao.getShipOffStoreNodeTotal();
+    }
 }

+ 112 - 4
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -4,10 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileNameUtil;
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.core.util.ZipUtil;
+import cn.hutool.core.util.*;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,9 +19,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.dto.outside.OutsideInspectionInsertRequest;
 import com.rongwei.bsentity.dto.outside.OutsideInspectionUpdateRequest;
+import com.rongwei.bsentity.dto.project.indicator.DelPhysicalParam;
 import com.rongwei.bsentity.dto.project.node.ProjectNodeStateBo;
 import com.rongwei.bsentity.dto.project.node.UnItpNodeStateBo;
 import com.rongwei.bsentity.vo.*;
+import com.rongwei.bsentity.vo.outside.OutsideInspectionVo;
+import com.rongwei.bsentity.vo.project.ShipOffStoreNodeTotal;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
@@ -47,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -115,6 +116,9 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
     @Autowired
     private ZhcxInsideInspectionDao insideInspectionDao;
 
+    @Autowired
+    private ZhcxProjectDeviceIndicatorService projectDeviceIndicatorService;
+
     /**
      * 保存外部报验单
      *
@@ -1464,6 +1468,110 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         return dao.getInitNodeStateInspection();
     }
 
+    /**
+     * 添加统计完成指标指标
+     *
+     */
+    @Override
+    public void addUpComplateIndicators() {
+        //删除外部报验数据
+        DelPhysicalParam param = DelPhysicalParam.builder()
+                .type("outside_inspection_complate")
+                .build();
+        projectDeviceIndicatorService.delPhysical(param);
+
+
+        final List<ShipOffStoreNodeTotal> nodeTotalList = itpProjectNodesService.getShipOffStoreNodeTotal(); //分母为为空
+        if(ObjectUtil.isEmpty(nodeTotalList)) {
+            return ;
+        }
+
+        //外部报验
+        Map<String, JSONObject> inspectionMap = new HashMap<>();
+        final Map<String, Set<String>> inspectionTolalMap = getInspectionPointTolal(inspectionMap);
+
+        List<ZhcxProjectDeviceIndicatorDo> saveLsit = new ArrayList<>(nodeTotalList.size());
+        for(ShipOffStoreNodeTotal nodeTotal : nodeTotalList) {
+            JSONObject inspection = inspectionMap.get(nodeTotal.getProjectid());
+
+            if(ObjectUtil.isNull(inspection)) {
+                continue;
+            }
+
+            ZhcxProjectDeviceIndicatorDo indicator = new ZhcxProjectDeviceIndicatorDo();
+            indicator.setId(SecurityUtil.getUUID());
+            indicator.setDate(inspection.getDate("inspectionComplateTime"));
+            indicator.setDeleted("0");
+            indicator.setProjectid(inspection.getString("projectId"));
+            indicator.setProjectcode(inspection.getString("projectCode"));
+            indicator.setProjectname(inspection.getString("projectName"));
+            indicator.setProjectshortname(inspection.getString("projectName"));
+            indicator.setMachineid(inspection.getString("machineId"));
+            indicator.setMachineno(inspection.getString("machineNo"));
+            indicator.setDisplayboard("绿");
+            indicator.setIndicatorname("到期检验情况");
+            indicator.setType("outside_inspection_complate");
+            indicator.setSort(1);
+
+            if(ObjectUtil.isEmpty(inspectionTolalMap.get(nodeTotal.getProjectid()))) {
+                indicator.setCompleted(0);
+            } else {
+                indicator.setCompleted(inspectionTolalMap.get(nodeTotal.getProjectid()).size());
+            }
+
+            if(ObjectUtil.isNull(nodeTotal.getTotal())) {
+                indicator.setCompletionrate(BigDecimal.ZERO);
+            } else {
+                indicator.setTotal(nodeTotal.getTotal());
+                Float f = indicator.getCompleted().floatValue() / indicator.getTotal().floatValue() * 100;
+                indicator.setCompletionrate(new BigDecimal(String.format("%.2f", f)));
+            }
+
+            saveLsit.add(indicator);
+        }
+
+        projectDeviceIndicatorService.saveBatch(saveLsit);
+    }
+
+    /**
+     * 获取报验单中所有接收和有条件接收的报验点总和
+     *
+     * @return key:项目id,value:报验点id集合
+     */
+    private Map<String, Set<String>> getInspectionPointTolal(Map<String, JSONObject> inspectionMap) {
+        final List<OutsideInspectionVo> inspectionLst = dao.getShipInspectionDisplay();//接收/有条件接收报验单
+        if(ObjectUtil.isEmpty(inspectionLst)) {
+            return Collections.EMPTY_MAP;
+        }
+
+        Map<String, Set<String>> inspectionNodeMap = new HashMap();
+        for(OutsideInspectionVo outside : inspectionLst) {
+            Set<String> prjNodeSet = inspectionNodeMap.get(outside.getProjectid());
+
+            //报验单
+            final JSONObject inspection = inspectionMap.get(outside.getProjectid());
+            if(ObjectUtil.isNull(inspection)) {
+                JSONObject prjObj = new JSONObject();
+                prjObj.put("projectId", outside.getProjectid());
+                prjObj.put("projectCode", outside.getProjectcode());
+                prjObj.put("projectName", outside.getProjectname());
+                prjObj.put("inspectionComplateTime", outside.getInspectioncomplatetime());
+
+                prjObj.put("machineId", outside.getShipMachineNoId());
+                prjObj.put("machineNo", outside.getShipMachineNo());
+                inspectionMap.put(outside.getProjectid(), prjObj);
+            }
+
+            if(ObjectUtil.isNull(prjNodeSet)) {
+                prjNodeSet = new HashSet<>();
+            }
+            prjNodeSet.add(outside.getInspectioncontentid());
+            inspectionNodeMap.put(outside.getProjectid(), prjNodeSet);
+        }
+
+        return inspectionNodeMap;
+    }
+
     private boolean isWithinAllowedTime() {
         // 获取当前时间
         LocalTime now = LocalTime.now();

+ 12 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/outside/OutsideInspectionVo.java

@@ -0,0 +1,12 @@
+package com.rongwei.bsentity.vo.outside;
+
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
+import lombok.Data;
+
+@Data
+public class OutsideInspectionVo extends ZhcxOutsideInspectionItpDo {
+
+    private String shipMachineNo;
+
+    private String shipMachineNoId;
+}

+ 21 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/project/ShipOffStoreNodeTotal.java

@@ -0,0 +1,21 @@
+package com.rongwei.bsentity.vo.project;
+
+import lombok.*;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ShipOffStoreNodeTotal {
+
+    /**
+     * 项目id
+     */
+    private String projectid;
+
+    /**
+     * 报验点总数
+     */
+    private Integer total;
+}

+ 13 - 4
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxOutsideInspectionItpController.java

@@ -13,10 +13,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import springfox.documentation.annotations.ApiIgnore;
 
 import java.util.Map;
@@ -120,5 +117,17 @@ public class ZhcxOutsideInspectionItpController {
         service.sync2SubmissionPlatform(req);
         return R.ok();
     }
+
+    /**
+     * 添加大屏外部报验
+     *
+     * @return
+     */
+    @PostMapping("/addUpComplateIndicators")
+    @ResponseBody
+    public R addUpComplateIndicators() {
+        service.addUpComplateIndicators();
+        return R.ok();
+    }
 }