ZhuDeKang 3 місяців тому
батько
коміт
fdda9a5695

+ 59 - 2
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/PtServiceLogStatisServiceController.java

@@ -1,19 +1,76 @@
 package com.ruoyi.interfaces.controller;
 
 import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
+import com.ruoyi.interfaces.service.IPtServiceLogService;
 import com.ruoyi.interfaces.service.IPtServiceLogStatisService;
-import org.omg.CORBA.BAD_POLICY;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 @RestController
 @RequestMapping("/service/log/statis")
 public class PtServiceLogStatisServiceController extends BaseController {
 
     @Autowired
-    private IPtServiceLogStatisService serviceLogStatisServices;
+    private IPtServiceLogStatisService logStatisServices;
+
+    @Autowired
+    private IPtServiceLogService logService;
+
+
+    @RequestMapping("/list")
+    public AjaxResult list(PtServiceLogStatis logStatis) {
+
+        List<PtServiceLogStatisVo> ptServiceLogStatis = logStatisServices.selectPtServiceLogStatis(logStatis);
+        return success(ptServiceLogStatis);
+    }
+
+    @RequestMapping("/toDaylist")
+    public AjaxResult toDaylist(PtServiceLogStatis logStatis) {
+        if (StringUtils.isNull(logStatis.getParams().get("beginTime"))) {
+            logStatis.getParams().put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.getDateDD(DateUtils.getNowDate())));
+        }
+        if (StringUtils.isNull(logStatis.getParams().get("endTime"))) {
+            logStatis.getParams().put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,
+                    DateUtils.getDateDD(DateUtils.getLastHourTime(DateUtils.getNowDate(), -24))));
+        }
+        List<PtServiceLogStatisVo> nowList = logService.selectServiceLogStatis(logStatis);
+        return success(nowList);
+    }
 
+    @RequestMapping("/monthList")
+    public AjaxResult monthList(PtServiceLogStatis logStatis) {
+        List<PtServiceLogStatisVo> ptServiceLogStatis = logStatisServices.selectPtServiceLogStatisMonthList(logStatis);
+        return success(ptServiceLogStatis);
+    }
 
+    @RequestMapping("/sum")
+    public AjaxResult sum(PtServiceLogStatis logStatis) {
+        List<PtServiceLogStatisVo> ptServiceLogStatis = logStatisServices.selectPtServiceLogStatis(logStatis);
+        Integer statisNum = 0;
+        for (PtServiceLogStatis ptServiceLogStati : ptServiceLogStatis) {
+            statisNum += ptServiceLogStati.getStatisNum();
+        }
+        return success(statisNum);
+    }
 
+    @RequestMapping("/toDaySum")
+    public AjaxResult toDaySum(PtServiceLogStatis logStatis) {
+        if (StringUtils.isNull(logStatis.getParams().get("beginTime"))) {
+            logStatis.getParams().put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.getDateDD(DateUtils.getNowDate())));
+        }
+        if (StringUtils.isNull(logStatis.getParams().get("endTime"))) {
+            logStatis.getParams().put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,
+                    DateUtils.getDateDD(DateUtils.getLastHourTime(DateUtils.getNowDate(), -24))));
+        }
+        List<PtServiceLogStatisVo> nowList = logService.selectServiceLogStatis(logStatis);
+        return success(nowList.size());
+    }
 }

+ 6 - 4
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/PtServiceLogStatis.java

@@ -1,5 +1,6 @@
 package com.ruoyi.interfaces.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.core.domain.BaseEntity;
 
 import java.util.Date;
@@ -9,6 +10,7 @@ public class PtServiceLogStatis extends BaseEntity {
     /**
      * 日期 yyyyy-mm-dd,;
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date statisTm;
     /**
      * 模型id,;
@@ -25,7 +27,7 @@ public class PtServiceLogStatis extends BaseEntity {
     /**
      * 数量,;
      */
-    private int statisNum;
+    private Integer statisNum;
 
     public Date getStatisTm() {
         return statisTm;
@@ -59,15 +61,15 @@ public class PtServiceLogStatis extends BaseEntity {
         this.statusCode = statusCode;
     }
 
-    public int getStatisNum() {
+    public Integer getStatisNum() {
         return statisNum;
     }
 
-    public void setStatisNum(int statisNum) {
+    public void setStatisNum(Integer statisNum) {
         this.statisNum = statisNum;
     }
 
-    public PtServiceLogStatis(Date statisTm, String mdId, String serId, String statusCode, int statisNum) {
+    public PtServiceLogStatis(Date statisTm, String mdId, String serId, String statusCode, Integer statisNum) {
         this.statisTm = statisTm;
         this.mdId = mdId;
         this.serId = serId;

+ 41 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/vo/PtServiceLogStatisVo.java

@@ -0,0 +1,41 @@
+package com.ruoyi.interfaces.domain.vo;
+
+import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+
+import java.util.Date;
+
+public class PtServiceLogStatisVo extends PtServiceLogStatis {
+    private String mdName;
+    private String serName;
+
+    public String getMdName() {
+        return mdName;
+    }
+
+    public void setMdName(String mdName) {
+        this.mdName = mdName;
+    }
+
+    public String getSerName() {
+        return serName;
+    }
+
+    public void setSerName(String serName) {
+        this.serName = 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) {
+        super(statisTm, mdId, serId, statusCode, statisNum);
+    }
+}

+ 2 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/mapper/PtServiceLogMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.interfaces.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.interfaces.domain.PtServiceLog;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 
 import java.util.List;
 
@@ -68,5 +69,5 @@ public interface PtServiceLogMapper extends BaseMapper<PtServiceLog>
      * @param serviceLogStatis
      * @return
      */
-    List<PtServiceLogStatis> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+    List<PtServiceLogStatisVo> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis);
 }

+ 6 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/mapper/PtServiceLogStatisMapper.java

@@ -3,14 +3,19 @@ package com.ruoyi.interfaces.mapper;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 @Mapper
 @DataSource(DataSourceType.SLAVE)
 public interface PtServiceLogStatisMapper {
-    PtServiceLogStatis selectPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+    List<PtServiceLogStatisVo> selectPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
 
     int insertPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
 
     int updatePtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+
+    List<PtServiceLogStatisVo> selectPtServiceLogStatisMonthList(PtServiceLogStatis logStatis);
 }

+ 2 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/IPtServiceLogService.java

@@ -3,6 +3,7 @@ package com.ruoyi.interfaces.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.interfaces.domain.PtServiceLog;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 
 import java.util.List;
 
@@ -62,5 +63,5 @@ public interface IPtServiceLogService extends IService<PtServiceLog>
      */
     public int deletePtServiceLogByLogId(Long logId);
 
-    List<PtServiceLogStatis> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+    List<PtServiceLogStatisVo> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis);
 }

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

@@ -1,8 +1,15 @@
 package com.ruoyi.interfaces.service;
 
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
+
+import java.util.List;
 
 public interface IPtServiceLogStatisService {
 
     int insertPtServiceLogStatis(PtServiceLogStatis serviceLogStatis);
+
+    List<PtServiceLogStatisVo> selectPtServiceLogStatis(PtServiceLogStatis logStatis);
+
+    List<PtServiceLogStatisVo> selectPtServiceLogStatisMonthList(PtServiceLogStatis logStatis);
 }

+ 2 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceLogServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.interfaces.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.interfaces.domain.PtServiceLog;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import com.ruoyi.interfaces.mapper.PtServiceLogMapper;
 import com.ruoyi.interfaces.service.IPtServiceLogService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -90,7 +91,7 @@ public class PtServiceLogServiceImpl extends ServiceImpl<PtServiceLogMapper, PtS
     }
 
     @Override
-    public List<PtServiceLogStatis> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis) {
+    public List<PtServiceLogStatisVo> selectServiceLogStatis(PtServiceLogStatis serviceLogStatis) {
         return ptServiceLogMapper.selectServiceLogStatis(serviceLogStatis);
     }
 }

+ 16 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceLogStatisServiceImpl.java

@@ -2,12 +2,16 @@ package com.ruoyi.interfaces.service.impl;
 
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import com.ruoyi.interfaces.mapper.PtServiceLogStatisMapper;
 import com.ruoyi.interfaces.service.IPtServiceLogStatisService;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
+import java.util.List;
+
 @Service
 public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService {
 
@@ -21,7 +25,7 @@ public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService
                 && StringUtils.isNotNull(serviceLogStatis.getStatisTm())
                 && StringUtils.isNotNull(serviceLogStatis.getStatusCode())
         ) {
-            if (StringUtils.isNull(ptServiceLogStatisMapper.selectPtServiceLogStatis(serviceLogStatis))){
+            if (StringUtils.isEmpty(ptServiceLogStatisMapper.selectPtServiceLogStatis(serviceLogStatis))){
                 return ptServiceLogStatisMapper.insertPtServiceLogStatis(serviceLogStatis);
             }else {
                 return ptServiceLogStatisMapper.updatePtServiceLogStatis(serviceLogStatis);
@@ -29,4 +33,15 @@ public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService
         }
         return 0;
     }
+
+    @Override
+    public List<PtServiceLogStatisVo> selectPtServiceLogStatis(PtServiceLogStatis logStatis) {
+        return ptServiceLogStatisMapper.selectPtServiceLogStatis(logStatis);
+    }
+
+    @Override
+    public List<PtServiceLogStatisVo> selectPtServiceLogStatisMonthList(PtServiceLogStatis logStatis) {
+
+        return ptServiceLogStatisMapper.selectPtServiceLogStatisMonthList(logStatis);
+    }
 }

+ 2 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/snailJob/ServiceLogStatisJob.java

@@ -9,6 +9,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.interfaces.domain.MdAppFlow;
 import com.ruoyi.interfaces.domain.PtServiceLog;
 import com.ruoyi.interfaces.domain.PtServiceLogStatis;
+import com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo;
 import com.ruoyi.interfaces.mapper.MdJobScheduleMapper;
 import com.ruoyi.interfaces.mapper.PtServiceLogMapper;
 import com.ruoyi.interfaces.service.IPtServiceLogService;
@@ -60,7 +61,7 @@ public class ServiceLogStatisJob {
             PtServiceLogStatis serviceLogStatis = new PtServiceLogStatis();
             serviceLogStatis.getParams().put("beginTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date(i)));
             serviceLogStatis.getParams().put("endTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.getLastHourTime(new Date(i), -24)));
-            List<PtServiceLogStatis> ptServiceLogStatis = ptServiceLogService.selectServiceLogStatis(serviceLogStatis);
+            List<PtServiceLogStatisVo> ptServiceLogStatis = ptServiceLogService.selectServiceLogStatis(serviceLogStatis);
             ptServiceLogStatis.forEach(serviceLogStatisService::insertPtServiceLogStatis);
             i = DateUtils.getLastHourTime(new Date(i), -24).getTime();
             if (StringUtils.isEmpty(hashMap))

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

@@ -52,8 +52,17 @@
         <include refid="selectPtServiceLogVo"/>
         where log_id = #{logId}
     </select>
-    <select id="selectServiceLogStatis" resultType="com.ruoyi.interfaces.domain.PtServiceLogStatis">
-        SELECT tm as statis_Tm, MD_ID, SER_ID, STATUS_CODE, count(1) statisNum
+    <select id="selectServiceLogStatis" resultMap="com.ruoyi.interfaces.mapper.PtServiceLogStatisMapper.PtServiceLogStatisMap">
+        select
+            l.STATIS_TM,
+        l.MD_ID,
+        l.SER_ID,
+        l.STATUS_CODE,
+        l.STATIS_NUM,
+        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
         <where>
             tm &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
@@ -61,7 +70,9 @@
         </where>
         )
         GROUP BY tm, MD_ID, SER_ID, STATUS_CODE
-
+        ) l
+        left join md_model_info m on l.MD_ID = m.MDID
+        left join pt_service s on l.MD_ID = s.SRV_ID
     </select>
 
     <insert id="insertPtServiceLog" parameterType="com.ruoyi.interfaces.domain.PtServiceLog" useGeneratedKeys="true"

+ 66 - 9
ruoyi-api-patform/src/main/resources/mapper/interfaces/PtServiceLogStatisMapper.xml

@@ -2,20 +2,27 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.interfaces.mapper.PtServiceLogStatisMapper">
 
-    <resultMap type="com.ruoyi.interfaces.domain.PtServiceLogStatis" id="PtServiceLogStatisMap">
+    <resultMap type="com.ruoyi.interfaces.domain.vo.PtServiceLogStatisVo" id="PtServiceLogStatisMap">
         <result property="statisTm" column="STATIS_TM" jdbcType="DATE"/>
         <result property="mdId" column="MD_ID" jdbcType="VARCHAR"/>
+        <result property="mdName" column="MD_NAME" jdbcType="VARCHAR"/>
         <result property="serId" column="SER_ID" jdbcType="VARCHAR"/>
+        <result property="serName" column="SER_NAME" jdbcType="VARCHAR"/>
         <result property="statusCode" column="STATUS_CODE" jdbcType="VARCHAR"/>
         <result property="statisNum" column="STATIS_NUM" jdbcType="INTEGER"/>
     </resultMap>
     <sql id="selectPtServiceLogStatis">
-        select STATIS_TM,
-               MD_ID,
-               SER_ID,
-               STATUS_CODE,
-               STATIS_NUM
-        from PT_SERVICE_LOG_STATIS
+        select l.STATIS_TM,
+               l.MD_ID,
+               l.SER_ID,
+               l.STATUS_CODE,
+               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
     </sql>
     <insert id="insertPtServiceLogStatis">
         insert into PT_SERVICE_LOG_STATIS
@@ -42,14 +49,22 @@
     <select id="selectPtServiceLogStatis" resultMap="PtServiceLogStatisMap">
         <include refid="selectPtServiceLogStatis"/>
         <where>
+            and m.name is not null
+            and s.name is not null
             <if test="statisTm != null ">
                 and STATIS_TM = #{statisTm}
             </if>
+            <if test="params.beginTime != null">
+                and STATIS_TM &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
+            </if>
+            <if test="params.endTime != null">
+                and STATIS_TM &lt;= to_date(#{params.endTime},'yyyy-mm-dd')
+            </if>
             <if test="mdId != null and mdId != ''">
-                and MD_ID = #{mdId}
+                and l.MD_ID = #{mdId}
             </if>
             <if test="serId != null and serId != ''">
-                and SER_ID = #{serId}
+                and l.SER_ID = #{serId}
             </if>
             <if test="statusCode != null and statusCode != ''">
                 and STATUS_CODE = #{statusCode}
@@ -57,6 +72,48 @@
             <if test="statisNum != null ">
                 and STATIS_NUM = #{statisNum}
             </if>
+
+        </where>
+        ORDER BY STATIS_TM,MD_ID,SER_ID,STATUS_CODE
+    </select>
+    <select id="selectPtServiceLogStatisMonthList"
+            resultMap="PtServiceLogStatisMap">
+        select l.STATIS_TM,
+        l.MD_ID,
+        l.SER_ID,
+        l.STATUS_CODE,
+        l.STATIS_NUM,
+        m.name as MD_NAME,
+        s.name as SER_NAME
+        from (
+        SELECT
+        mmdd AS STATIS_TM ,MD_ID,SER_ID,STATUS_CODE,sum(statis_num) statis_num
+        FROM (
+        SELECT t.*,to_char(STATIS_TM,'yyyy-mm' ) || '-01' mmdd FROM PT_SERVICE_LOG_STATIS t
+        <where>
+            <if test="params.beginTime != null">
+                and STATIS_TM &gt;= to_date(#{params.beginTime},'yyyy-mm-dd')
+            </if>
+            <if test="params.endTime != null">
+                and STATIS_TM &lt;= to_date(#{params.endTime},'yyyy-mm-dd')
+            </if>
+            <if test="mdId != null and mdId != ''">
+                and t.MD_ID = #{mdId}
+            </if>
+            <if test="serId != null and serId != ''">
+                and t.SER_ID = #{serId}
+            </if>
+            <if test="statusCode != null and statusCode != ''">
+                and STATUS_CODE = #{statusCode}
+            </if>
+        </where>
+        ) GROUP BY mmdd,MD_ID,SER_ID,STATUS_CODE
+        ) 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
+        <where>
+            and m.name is not null
+            and s.name is not null
         </where>
     </select>
 </mapper>