LAPTOP-KB9HII50\70708 2 år sedan
förälder
incheckning
08c6b4440f

+ 82 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/statistics/IotStatisticsStockDO.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 大屏-统计-设备库存数据
@ -32,6 +33,15 @@ public class IotStatisticsStockDO extends UuidIdentityEntityWithCreateTime {
    private Long diseasePatientUseCount;//慢病患者设备使用数
    private Long faultCount;//设备故障数
    private String iotRate;//设备物联率
    private String lostRate;//设备失联率
    private String interveneRate;//干预指导率
    private String issueRate;//设备发放率
    private String bindingRate;//设备绑定率
    private String diseasePatientDeviceRate;//慢病患者设备覆盖率
    private String diseasePatientUseRate;//慢病患者设备使用率
    private String faultRate;//设备故障率
    @Column(name = "name")
    public String getName() {
        return name;
@ -184,4 +194,76 @@ public class IotStatisticsStockDO extends UuidIdentityEntityWithCreateTime {
    public void setFaultCount(Long faultCount) {
        this.faultCount = faultCount;
    }
    @Transient
    public String getIotRate() {
        return iotRate;
    }
    public void setIotRate(String iotRate) {
        this.iotRate = iotRate;
    }
    @Transient
    public String getLostRate() {
        return lostRate;
    }
    public void setLostRate(String lostRate) {
        this.lostRate = lostRate;
    }
    @Transient
    public String getInterveneRate() {
        return interveneRate;
    }
    public void setInterveneRate(String interveneRate) {
        this.interveneRate = interveneRate;
    }
    @Transient
    public String getIssueRate() {
        return issueRate;
    }
    public void setIssueRate(String issueRate) {
        this.issueRate = issueRate;
    }
    @Transient
    public String getBindingRate() {
        return bindingRate;
    }
    public void setBindingRate(String bindingRate) {
        this.bindingRate = bindingRate;
    }
    @Transient
    public String getDiseasePatientDeviceRate() {
        return diseasePatientDeviceRate;
    }
    public void setDiseasePatientDeviceRate(String diseasePatientDeviceRate) {
        this.diseasePatientDeviceRate = diseasePatientDeviceRate;
    }
    @Transient
    public String getDiseasePatientUseRate() {
        return diseasePatientUseRate;
    }
    public void setDiseasePatientUseRate(String diseasePatientUseRate) {
        this.diseasePatientUseRate = diseasePatientUseRate;
    }
    @Transient
    public String getFaultRate() {
        return faultRate;
    }
    public void setFaultRate(String faultRate) {
        this.faultRate = faultRate;
    }
}

+ 20 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -862,6 +862,26 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        return success(monitorPlatformService.getEquipmentStatistics(deviceType, monitorPlatformService.getDeviceNameByRequestParam(deviceName), showLevel));
    }
    @GetMapping(value = "/onboardingDeviceManagement")
    @ApiOperation("入驻设备管理")
    public Envelop onboardingDeviceManagement(@RequestParam(value = "type", required = false)
                                              @ApiParam(name = "type", value = "设备通用名code", required = false) String type,
                                              @RequestParam(value = "town", required = false)
                                              @ApiParam(name = "town", value = "地区code", required = false) String town) {
        try {
            if(StringUtils.isBlank(type)){
                type = "0";
            }
            if(StringUtils.isBlank(town)){
                town = "350200";
            }
            return success(monitorPlatformService.onboardingDeviceManagement(type,town));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/getEquipmentStock")
    @ApiOperation("设备库存、使用中、总备案")
    public Envelop getEquipmentStock() {

+ 5 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/statistics/IotStatisticsStockDao.java

@ -2,11 +2,16 @@ package com.yihu.iot.dao.statistics;
import com.yihu.jw.entity.iot.statistics.IotStatisticsStockDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2023/5/6.
 */
public interface IotStatisticsStockDao extends PagingAndSortingRepository<IotStatisticsStockDO,String>,
        JpaSpecificationExecutor<IotStatisticsStockDO> {
    @Query("from IotStatisticsStockDO w where w.parentType =?1 and w.town=?2 ")
    List<IotStatisticsStockDO> findByParentTypeAndTown(String parentType,String town);
}

+ 66 - 8
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -6,12 +6,12 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.dao.statistics.IotStatisticsCommonDao;
import com.yihu.iot.dao.statistics.IotStatisticsStockDao;
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
import com.yihu.iot.service.analyzer.WlyyIotTzDictDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
import com.yihu.iot.service.label.FigureLabelSerachService;
import com.yihu.iot.service.platform.IotInterfaceLogService;
import com.yihu.iot.util.conceal.ConcealUtil;
import com.yihu.iot.util.excel.HibenateUtils;
@ -19,6 +19,7 @@ import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO;
import com.yihu.jw.entity.iot.statistics.IotStatisticsCommonDO;
import com.yihu.jw.entity.iot.statistics.IotStatisticsRealtimeDO;
import com.yihu.jw.entity.iot.statistics.IotStatisticsStockDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.common.LatitudeUtils;
@ -70,7 +71,7 @@ public class MonitorPlatformService {
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    @Autowired
    private FigureLabelSerachService figureLabelSerachService;
    private IotStatisticsStockDao iotStatisticsStockDao;
    @Autowired
    private IotEqtDetailService iotEqtDetailService;
    @Autowired
@ -1249,16 +1250,73 @@ public class MonitorPlatformService {
    }
    //入驻设备管理
    public JSONObject onboardingDeviceManagement(String parentType){
        JSONObject result = new JSONObject();
    public IotStatisticsStockDO onboardingDeviceManagement(String type,String town){
        IotStatisticsStockDO stockDO;
        try {
            String sql = "select sum(total) total,sum(useing) useing,SUM(stock) stock,SUM(iot_count) iot_count,SUM(lost_count) lost_count, " +
                    "SUM(intervene_count) intervene_count,SUM(issue_count) issue_count,SUM(binding_count) binding_count,SUM(disease_patient_count) disease_patient_count, " +
                    "SUM(disease_patient_device_count) disease_patient_device_count,SUM(disease_patient_use_count) disease_patient_use_count, " +
                    "SUM(fault_count) fault_count from iot_statistics_stock WHERE parent_type = '"+type+"' and town = '"+town+"'";
            List<IotStatisticsStockDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(IotStatisticsStockDO.class));
            if(list.size()>0){
                stockDO = list.get(0);
                stockDO.setBindingRate(rateLong(stockDO.getBindingCount(),stockDO.getTotal()));
                stockDO.setDiseasePatientDeviceRate(rateLong(stockDO.getDiseasePatientDeviceCount(),stockDO.getDiseasePatientCount()));
                stockDO.setDiseasePatientUseRate(rateLong(stockDO.getDiseasePatientUseCount(),stockDO.getDiseasePatientDeviceCount()));
                stockDO.setFaultRate(rateLong(stockDO.getFaultCount(),stockDO.getTotal()));
                stockDO.setInterveneRate(rateLong(stockDO.getInterveneCount(),stockDO.getTotal()));
                stockDO.setIotRate(rateLong(stockDO.getIotCount(),stockDO.getIssueCount()));
                stockDO.setIssueRate(rateLong(stockDO.getIssueCount(),stockDO.getTotal()));
                stockDO.setLostRate(rateLong(stockDO.getLostCount(),stockDO.getIssueCount()));
                return stockDO;
            }else {
                stockDO = new IotStatisticsStockDO();
                stockDO.setBindingRate("0.00%");
                stockDO.setDiseasePatientDeviceRate("0.00%");
                stockDO.setDiseasePatientUseRate("0.00%");
                stockDO.setFaultRate("0.00%");
                stockDO.setInterveneRate("0.00%");
                stockDO.setIotRate("0.00%");
                stockDO.setIssueRate("0.00%");
                stockDO.setLostRate("0.00%");
                stockDO.setTotal(0l);//总数
                stockDO.setUseing(0l);//使用数
                stockDO.setStock(0l);//库存数
                stockDO.setIotCount(0l);//物联数
                stockDO.setLostCount(0l);//失联数
                stockDO.setInterveneCount(0l);//干预数
                stockDO.setIssueCount(0l);//发放数
                stockDO.setBindingCount(0l);//绑定数
                stockDO.setDiseasePatientCount(0l);//慢病患者数
                stockDO.setDiseasePatientDeviceCount(0l);//慢病患者设备数
                stockDO.setDiseasePatientUseCount(0l);//慢病患者设备使用数
                stockDO.setFaultCount(0l);//设备故障数
            }
        }catch (Exception e){
            e.printStackTrace();
            stockDO = new IotStatisticsStockDO();
        }
        return result;
        return stockDO;
    }
    /**
     * 计算百分比
     * @param molecule 分子
     * @param denominator 分母
     */
    public String rateLong(Long molecule,Long denominator){
        if(molecule==null||denominator==null){
            return "0.00%";
        }
        if (denominator == 0 && molecule > 0) {
            return "100%";
        } else if (molecule == 0 && denominator == 0) {
            return "0.00%";
        }
        float size = (float) (molecule * 100) / denominator;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
    //设备库存、使用中、总备案、物联率、失联率