Kaynağa Gözat

模型质量

ZhuDeKang 3 ay önce
ebeveyn
işleme
deef39277d

+ 30 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdQualityController.java

@@ -0,0 +1,30 @@
+package com.ruoyi.interfaces.controller;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.interfaces.domain.MdModelInfo;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
+import com.ruoyi.interfaces.service.IMdEstimateService;
+import com.ruoyi.interfaces.service.IPtServiceLogStatisService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/md/quality")
+public class MdQualityController extends BaseController {
+
+    @Autowired
+    private IPtServiceLogStatisService logStatisService;
+
+    @GetMapping("/list")
+    public AjaxResult list(MdModelInfo modelInfo) {
+        List<PtServiceLogStatisVo> ptServiceLogStatisVos = logStatisService.selectMdQuality(modelInfo);
+
+        return success(ptServiceLogStatisVos);
+    }
+
+}

+ 14 - 7
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/PtServiceLogStatis.java

@@ -29,6 +29,19 @@ public class PtServiceLogStatis extends BaseEntity {
      */
     private Integer statisNum;
 
+    /**
+     * 累计调用耗时(毫秒)
+     */
+    private Long execTm;
+
+    public Long getExecTm() {
+        return execTm;
+    }
+
+    public void setExecTm(Long execTm) {
+        this.execTm = execTm;
+    }
+
     public Date getStatisTm() {
         return statisTm;
     }
@@ -69,13 +82,7 @@ public class PtServiceLogStatis extends BaseEntity {
         this.statisNum = statisNum;
     }
 
-    public PtServiceLogStatis(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum) {
-        this.statisTm = statisTm;
-        this.mdId = mdId;
-        this.serId = serId;
-        this.statusCode = statusCode;
-        this.statisNum = statisNum;
-    }
+
 
     public PtServiceLogStatis() {
     }

+ 39 - 5
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/vo/PtServiceLogStatisVo.java

@@ -7,6 +7,37 @@ import java.util.Date;
 public class PtServiceLogStatisVo extends PtServiceLogStatis {
     private String mdName;
     private String serName;
+    /**
+     * 调用成功数量
+     */
+    private Integer statisNumTrue;
+
+    private Double rate;
+    private String rateLv;
+
+    public String getRateLv() {
+        return rateLv;
+    }
+
+    public void setRateLv(String rateLv) {
+        this.rateLv = rateLv;
+    }
+
+    public Double getRate() {
+        return rate;
+    }
+
+    public void setRate(Double rate) {
+        this.rate = rate;
+    }
+
+    public Integer getStatisNumTrue() {
+        return statisNumTrue;
+    }
+
+    public void setStatisNumTrue(Integer statisNumTrue) {
+        this.statisNumTrue = statisNumTrue;
+    }
 
     public String getMdName() {
         return mdName;
@@ -24,18 +55,21 @@ public class PtServiceLogStatisVo extends PtServiceLogStatis {
         this.serName = serName;
     }
 
-    public PtServiceLogStatisVo(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum, String mdName, String serName) {
+/*    public PtServiceLogStatisVo(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum, String mdName, String serName) {
         super(statisTm, mdId, serId, statusCode, statisNum);
         this.mdName = mdName;
         this.serName = serName;
-    }
-
+    }*/
+/*
     public PtServiceLogStatisVo(String mdName, String serName) {
         this.mdName = mdName;
         this.serName = serName;
-    }
+    }*/
 
-    public PtServiceLogStatisVo(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum) {
+    /*public PtServiceLogStatisVo(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum) {
         super(statisTm, mdId, serId, statusCode, statisNum);
+    }*/
+
+    public PtServiceLogStatisVo() {
     }
 }

+ 5 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/mapper/PtServiceLogStatisMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.interfaces.mapper;
 
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.interfaces.domain.MdModelInfo;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
 import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -11,6 +12,8 @@ import java.util.List;
 @Mapper
 @DataSource(DataSourceType.SLAVE)
 public interface PtServiceLogStatisMapper {
+    PtServiceLogStatisVo getInfoPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+
     List<PtServiceLogStatisVo> selectPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
 
     int insertPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
@@ -24,4 +27,6 @@ public interface PtServiceLogStatisMapper {
     List<PtServiceLogStatisVo> selectPtServiceLogStatisMonthMdList(PtServiceLogStatis logStatis);
 
     List<PtServiceLogStatisVo> selectPtServiceLogStatisYearMdList(PtServiceLogStatis logStatis);
+
+    List<PtServiceLogStatisVo> selectMdQuality(MdModelInfo modelInfo);
 }

+ 3 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/IPtServiceLogStatisService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.interfaces.service;
 
+import com.ruoyi.interfaces.domain.MdModelInfo;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
 import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 
@@ -18,4 +19,6 @@ public interface IPtServiceLogStatisService {
     List<PtServiceLogStatisVo> selectPtServiceLogStatisMonthMdList(PtServiceLogStatis logStatis);
 
     List<PtServiceLogStatisVo> selectPtServiceLogStatisYearMdList(PtServiceLogStatis logStatis);
+
+    List<PtServiceLogStatisVo> selectMdQuality(MdModelInfo modelInfo);
 }

+ 27 - 2
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceLogStatisServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.interfaces.service.impl;
 
+import com.ruoyi.common.utils.Arith;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.interfaces.domain.MdModelInfo;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
 import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import com.ruoyi.interfaces.mapper.PtServiceLogStatisMapper;
@@ -25,9 +27,9 @@ public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService
                 && StringUtils.isNotNull(serviceLogStatis.getStatisTm())
                 && StringUtils.isNotNull(serviceLogStatis.getStatusCode())
         ) {
-            if (StringUtils.isEmpty(ptServiceLogStatisMapper.selectPtServiceLogStatis(serviceLogStatis))){
+            if (StringUtils.isNull(ptServiceLogStatisMapper.getInfoPtServiceLogStatis(serviceLogStatis))) {
                 return ptServiceLogStatisMapper.insertPtServiceLogStatis(serviceLogStatis);
-            }else {
+            } else {
                 return ptServiceLogStatisMapper.updatePtServiceLogStatis(serviceLogStatis);
             }
         }
@@ -59,4 +61,27 @@ public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService
     public List<PtServiceLogStatisVo> selectPtServiceLogStatisYearMdList(PtServiceLogStatis logStatis) {
         return ptServiceLogStatisMapper.selectPtServiceLogStatisYearMdList(logStatis);
     }
+
+    @Override
+    public List<PtServiceLogStatisVo> selectMdQuality(MdModelInfo modelInfo) {
+
+        List<PtServiceLogStatisVo> ptServiceLogStatisVos = ptServiceLogStatisMapper.selectMdQuality(modelInfo);
+
+        ptServiceLogStatisVos.forEach(v -> {
+            if (StringUtils.isNotNull(v.getStatisNum())) {
+                v.setRate(Arith.div(Arith.mul(v.getStatisNumTrue(), 100), v.getStatisNum()));
+                if (v.getRate() >= 90) {
+                    v.setRateLv("优");
+                } else if (v.getRate() >= 80 && v.getRate() < 90) {
+                    v.setRateLv("高");
+                } else if (v.getRate() >= 60 && v.getRate() < 80) {
+                    v.setRateLv("中");
+                } else if (v.getRate() < 60) {
+                    v.setRateLv("差");
+                }
+            }
+        });
+
+        return ptServiceLogStatisVos;
+    }
 }

+ 8 - 10
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceServiceImpl.java

@@ -63,7 +63,7 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
         entity.setRlstm(now);
         entity.setReleaseTime(now);
         entity.setUptm(now);
-        boolean  ret = super.save(entity);
+        boolean ret = super.save(entity);
         if (CollectionUtils.isNotEmpty(entity.getParams())) {
             entity.getParams().forEach(ptServiceParamMapper::insert);
         }
@@ -129,10 +129,10 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
 
 
     @Override
-    public HashMap<String,String> testRun(PtService ptService) throws IOException {
+    public HashMap<String, String> testRun(PtService ptService) throws IOException {
 
         //String url = RuoYiConfig.getGatewayUrl() + ptService.getProxyPath() + ptService.getUrl();
-        String url =  ptService.getUrl();
+        String url = ptService.getUrl();
         HashMap<String, String> headers = new HashMap<>();
         List<PtServiceParam> params = ptService.getParams();
         HttpUtils.setGatewayHeaders(headers);
@@ -141,15 +141,15 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
             case "POST":
                 HashMap<String, Object> parMap = new HashMap<>();
                 for (PtServiceParam param : params) {
-                    parMap.put(param.getParamCode(),param.getParamObject());
+                    parMap.put(param.getParamCode(), param.getParamObject());
                 }
-               return HttpUtils.sendBodyPost(url,parMap,headers);
+                return HttpUtils.sendBodyPost(url, parMap, headers);
             case "GET":
 
                 for (PtServiceParam param : params) {
-                    paramString+=(param.getParamCode()+"="+param.getParamValue())+"&";
+                    paramString += (param.getParamCode() + "=" + param.getParamValue()) + "&";
                 }
-                return HttpUtils.sendHttpGet(url,paramString,headers);
+                return HttpUtils.sendHttpGet(url, paramString, headers);
         }
         return null;
     }
@@ -165,8 +165,6 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
         return ptServiceMapper.updatePtServicePublish(service);
     }
 
-    public void senServiceLog(){
-
-
+    public void senServiceLog() {
     }
 }

+ 4 - 3
ruoyi-api-patform/src/main/resources/mapper/interfaces/PtServiceLogMapper.xml

@@ -54,16 +54,17 @@
     </select>
     <select id="selectServiceLogStatis" resultMap="com.ruoyi.interfaces.mapper.PtServiceLogStatisMapper.PtServiceLogStatisMap">
         select
-            l.STATIS_TM,
+        l.STATIS_TM,
         l.MD_ID,
         l.SER_ID,
         l.STATUS_CODE,
         l.STATIS_NUM,
+        l.EXEC_TM,
         m.name as MD_NAME,
         s.name as SER_NAME
         from (
-        SELECT tm as statis_Tm, MD_ID, SER_ID, STATUS_CODE, count(1) STATIS_NUM
-        FROM (SELECT MD_ID, SER_ID, STATUS_CODE, to_char(tm, 'yyyy-mm-dd') tm from pt_Service_Log
+        SELECT tm as statis_Tm, MD_ID, SER_ID, STATUS_CODE, count(1) STATIS_NUM,SUM(EXEC_TM) EXEC_TM
+        FROM (SELECT MD_ID, SER_ID, STATUS_CODE, to_char(tm, 'yyyy-mm-dd') tm,EXEC_TM from pt_Service_Log
         <where>
             tm &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
             and tm &lt; to_date(#{params.endTime},'yyyy-mm-dd')

+ 43 - 8
ruoyi-api-patform/src/main/resources/mapper/interfaces/PtServiceLogStatisMapper.xml

@@ -10,6 +10,8 @@
         <result property="serName" column="SER_NAME" jdbcType="VARCHAR"/>
         <result property="statusCode" column="STATUS_CODE" jdbcType="VARCHAR"/>
         <result property="statisNum" column="STATIS_NUM" jdbcType="INTEGER"/>
+        <result property="statisNumTrue" column="STATIS_NUM_TRUE" jdbcType="INTEGER"/>
+        <result property="execTm" column="EXEC_TM" jdbcType="BIGINT"/>
     </resultMap>
     <sql id="selectPtServiceLogStatis">
         select l.STATIS_TM,
@@ -19,7 +21,6 @@
                l.STATIS_NUM,
                m.name as MD_NAME,
                s.name as SER_NAME
-
         from PT_SERVICE_LOG_STATIS l
                  left join md_model_info m on l.MD_ID = m.MDID
                  left join pt_service s on l.SER_ID = s.SRV_ID
@@ -39,13 +40,28 @@
     </insert>
     <update id="updatePtServiceLogStatis">
         update PT_SERVICE_LOG_STATIS
-            STATIS_NUM = #{statisNum,jdbcType=INTEGER},
-        where
-            STATIS_TM = #{statisTm,jdbcType=DATE}
+        set STATIS_NUM = #{statisNum,jdbcType=INTEGER},
+            EXEC_TM    = #{execTm,jdbcType=BIGINT}
+        where STATIS_TM = #{statisTm,jdbcType=DATE}
           and MD_ID = #{mdId,jdbcType=VARCHAR}
           and SER_ID = #{serId,jdbcType=VARCHAR}
           and STATUS_CODE = #{statusCode,jdbcType=VARCHAR}
     </update>
+    <select id="getInfoPtServiceLogStatis" resultType="com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo">
+        select l.STATIS_TM,
+        l.MD_ID,
+        l.SER_ID,
+        l.STATUS_CODE,
+        l.STATIS_NUM
+        from PT_SERVICE_LOG_STATIS l
+        <where>
+            and STATIS_TM = #{statisTm}
+            and l.MD_ID = #{mdId}
+            and l.SER_ID = #{serId}
+            and STATUS_CODE = #{statusCode}
+        </where>
+    </select>
+
     <select id="selectPtServiceLogStatis" resultMap="PtServiceLogStatisMap">
         <include refid="selectPtServiceLogStatis"/>
         <where>
@@ -72,7 +88,6 @@
             <if test="statisNum != null ">
                 and STATIS_NUM = #{statisNum}
             </if>
-
         </where>
         ORDER BY STATIS_TM,MD_ID,SER_ID,STATUS_CODE
     </select>
@@ -153,8 +168,6 @@
         <where>
             and m.name is not null
         </where>
-
-
     </select>
     <select id="selectPtServiceLogStatisMonthMdList"
             resultMap="PtServiceLogStatisMap">
@@ -197,7 +210,6 @@
     </select>
     <select id="selectPtServiceLogStatisYearMdList"
             resultMap="PtServiceLogStatisMap">
-
         select l.STATIS_TM,
         l.MD_ID,
         '' as SER_ID,
@@ -235,4 +247,27 @@
         </where>
 
     </select>
+    <select id="selectMdQuality" resultMap="PtServiceLogStatisMap">
+        SELECT m.mdid MD_ID, m.name as MD_NAME, d.STATIS_NUM, d.STATIS_NUM_TRUE
+        FROM md_model_info m
+        LEFT JOIN (SELECT md_id,
+        sum(statis_num) statis_num,
+        SUM(CASE WHEN status_code = '200' THEN statis_num ELSE 0 END) AS statis_num_true
+        FROM (SELECT md_id,
+        status_code,
+        sum(statis_num) statis_num,
+        sum(exec_tm) exec_tm
+        FROM PT_SERVICE_LOG_STATIS
+        WHERE STATIS_TM &gt;= to_date(#{params.beginTime}, 'yyyy-mm-dd')
+        AND STATIS_TM &lt;= to_date(#{params.endTime}, 'yyyy-mm-dd')
+        GROUP BY md_id, status_code)
+        GROUP BY md_id) d ON m.mdid = d.MD_ID
+        <where>
+            <if test="devkind != null and devkind != ''">
+                and devkind = #{devkind}
+            </if>
+        </where>
+        ORDER BY m.sort
+    </select>
+
 </mapper>