Selaa lähdekoodia

Merge branch 'master' of https://e.coding.net/chuanghaikeji/smartCampus/backend_code

溪鸭夏 2 vuotta sitten
vanhempi
commit
d9912f5b1a

+ 32 - 0
src/main/java/com/template/api/DriverStockControllerAPI.java

@@ -29,4 +29,36 @@ public interface DriverStockControllerAPI {
     @ResponseBody
     public CommonResult getEnergyTjAvg();
 
+    @RequestMapping(value = "/getEnergyMonth")
+    @ResponseBody
+    public CommonResult getEnergyMonth(Integer type);
+
+    @RequestMapping(value = "/getDeviceT")
+    @ResponseBody
+    public CommonResult getDeviceT();
+
+    @RequestMapping(value = "/getMeterPage")
+    @ResponseBody
+    public CommonResult getMeterPage(int currentPage, int pageCount,Integer meterType);
+
+    @RequestMapping(value = "/getUserComp")
+    @ResponseBody
+    public CommonResult getUserComp();
+
+    @RequestMapping(value = "/getUserPage")
+    @ResponseBody
+    public CommonResult getUserPage(int currentPage, int pageCount,String key,Integer identityId);
+
+    @RequestMapping(value = "/getScorePer")
+    @ResponseBody
+    public CommonResult getScorePer(String examName,String updateUser);
+
+    @RequestMapping(value = "/getExamName")
+    @ResponseBody
+    public CommonResult getExamName();
+
+    @RequestMapping(value = "/getTeacherExam")
+    @ResponseBody
+    public CommonResult getTeacherExam(String cardNo);
+
 }

+ 97 - 2
src/main/java/com/template/controller/DriverStockController.java

@@ -1,24 +1,32 @@
 package com.template.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.template.annotation.DESRespondSecret;
 import com.template.annotation.PassToken;
 import com.template.api.DriverStockControllerAPI;
+import com.template.common.utils.TimeExchange;
 import com.template.model.pojo.SmartUser;
 import com.template.model.pojo.SmartWarning;
 import com.template.model.result.CommonResult;
 import com.template.model.result.PageUtils;
-import com.template.model.tongji.Tj;
-import com.template.model.tongji.TjFloat;
+import com.template.model.tongji.*;
 import com.template.services.DriverStockService;
 import com.template.services.SmartUserService;
 import com.template.services.SmartWarningService;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 
 @Controller
@@ -78,4 +86,91 @@ public class DriverStockController implements DriverStockControllerAPI {
         return CommonResult.ok(list);
     }
 
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getEnergyMonth(Integer type) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+        List<JSONObject> jList = new ArrayList<>();
+        for (int i=-5; i<=0; i++) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.add(Calendar.MONTH, i);
+            String date = simpleDateFormat.format(calendar.getTime());
+            List<TjFloat> list = driverStockService.getEnergyMonth(date,type);
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("month", date);
+            jsonObject.put("data", list);
+            jList.add(jsonObject);
+        }
+        return CommonResult.ok(jList);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getDeviceT(){
+        List<JSONObject> list = new ArrayList<>();
+        JSONObject jsonObject1 = new JSONObject();
+        List<TjFloat> allList = driverStockService.getTotalDevice();
+        jsonObject1.put("name", "总设备数");
+        jsonObject1.put("data", allList);
+        list.add(jsonObject1);
+        List<TjFloat> onlineList = driverStockService.getOnlineDevice(TimeExchange.getDate());
+        JSONObject jsonObject2 = new JSONObject();
+        jsonObject2.put("name", "在线设备数");
+        jsonObject2.put("data", onlineList);
+        list.add(jsonObject2);
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getMeterPage(int currentPage, int pageCount,Integer meterType) {
+        PageHelper.startPage(currentPage, pageCount);
+        PageInfo<MeterPage> list = driverStockService.getMeterDetail(meterType);
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getUserComp() {
+        List<Tj> list = driverStockService.getUserComp();
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getUserPage(int currentPage, int pageCount,String key,Integer identityId){
+        PageHelper.startPage(currentPage, pageCount);
+        PageInfo<userPage> list = driverStockService.getUserPage(key,identityId);
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getScorePer(String examName,String updateUser){
+        List<Tj> list = driverStockService.getScorePer(examName,updateUser);
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getExamName(){
+        List<Tj> list = driverStockService.getExamName();
+        return CommonResult.ok(list);
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public CommonResult getTeacherExam(String cardNo){
+        Tj list = driverStockService.getTeacherExam(cardNo);
+        return CommonResult.ok(list);
+    }
+
 }

+ 28 - 2
src/main/java/com/template/mapper/DriverStockMapper.java

@@ -2,8 +2,8 @@ package com.template.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.template.model.pojo.SmartUser;
-import com.template.model.tongji.Tj;
-import com.template.model.tongji.TjFloat;
+import com.template.model.tongji.*;
+import org.apache.ibatis.annotations.Param;
 import org.apache.poi.ss.formula.functions.T;
 import org.springframework.stereotype.Repository;
 
@@ -21,4 +21,30 @@ public interface DriverStockMapper extends BaseMapper<T> {
     // 能耗总量统计
     public List<TjFloat> getEnergyTj();
 
+    // 每栋楼电费月统计
+    public List<TjFloat> getEnergyMonth(@Param("date") String date,@Param("type") Integer type);
+
+    // 总设备数
+    public List<TjFloat> getTotalDevice();
+
+    // 在线设备数
+    public List<TjFloat> getOnlineDevice(@Param("date") String date);
+
+    public List<MeterPage> getMeterDetail(@Param("meterType") Integer meterType);
+
+    // 用户结构
+    public List<Tj> getUserComp();
+
+    // 用户汇总学生
+    public List<userPage> getUserPage(@Param("key") String key,@Param("identityId") Integer identityId);
+
+    // 教学成果
+    public List<Tj> getScorePer(@Param("examName") String examName,@Param("updateUser") String updateUser);
+
+    // 考试名称
+    public List<Tj> getExamName();
+
+    // 教师评分
+    public List<Tj> getTeacherExam(@Param("cardNo") String cardNo);
+
 }

+ 32 - 0
src/main/java/com/template/model/tongji/userPage.java

@@ -0,0 +1,32 @@
+package com.template.model.tongji;
+
+public class userPage {
+
+    public String name;
+    public String cardNo;
+    public String departMent;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    public String getDepartMent() {
+        return departMent;
+    }
+
+    public void setDepartMent(String departMent) {
+        this.departMent = departMent;
+    }
+}

+ 30 - 0
src/main/java/com/template/services/DriverStockService.java

@@ -1,7 +1,11 @@
 package com.template.services;
 
+import com.github.pagehelper.PageInfo;
+import com.template.model.tongji.MeterPage;
 import com.template.model.tongji.Tj;
 import com.template.model.tongji.TjFloat;
+import com.template.model.tongji.userPage;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,4 +20,30 @@ public interface DriverStockService {
     // 能耗总量统计
     public List<TjFloat> getEnergyTj();
 
+    // 每栋楼电费月统计
+    public List<TjFloat> getEnergyMonth(@Param("date") String date, @Param("type") Integer type);
+
+    // 总设备数
+    public List<TjFloat> getTotalDevice();
+
+    // 在线设备数
+    public List<TjFloat> getOnlineDevice(@Param("date") String date);
+
+    public PageInfo<MeterPage> getMeterDetail(@Param("meterType") Integer meterType);
+
+    // 用户结构
+    public List<Tj> getUserComp();
+
+    // 用户汇总学生
+    public PageInfo<userPage> getUserPage(String key,Integer identityId);
+
+    // 教学成果
+    public List<Tj> getScorePer(@Param("examName") String examName,@Param("updateUser") String updateUser);
+
+    // 考试名称
+    public List<Tj> getExamName();
+
+    // 教师评分
+    public Tj getTeacherExam(@Param("cardNo") String cardNo);
+
 }

+ 54 - 2
src/main/java/com/template/services/impl/DriverStockServiceImpl.java

@@ -1,9 +1,10 @@
 package com.template.services.impl;
 
+import com.github.pagehelper.PageInfo;
 import com.template.mapper.DriverStockMapper;
-import com.template.model.tongji.Tj;
-import com.template.model.tongji.TjFloat;
+import com.template.model.tongji.*;
 import com.template.services.DriverStockService;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -31,4 +32,55 @@ public class DriverStockServiceImpl implements DriverStockService {
         return driverStockMapper.getEnergyTj();
     }
 
+    // 每栋楼电费月统计
+    public List<TjFloat> getEnergyMonth(@Param("date") String date,@Param("type") Integer type){
+        return driverStockMapper.getEnergyMonth(date,type);
+    }
+
+    // 总设备数
+    public List<TjFloat> getTotalDevice(){
+        return driverStockMapper.getTotalDevice();
+    }
+
+    // 在线设备数
+    public List<TjFloat> getOnlineDevice(@Param("date") String date){
+        return driverStockMapper.getOnlineDevice(date);
+    }
+
+    public PageInfo<MeterPage> getMeterDetail(@Param("meterType") Integer meterType){
+        List<MeterPage> list = driverStockMapper.getMeterDetail(meterType);
+        PageInfo<MeterPage> meterPageInfo = new PageInfo<>(list);
+        return meterPageInfo;
+    }
+
+    // 用户结构
+    public List<Tj> getUserComp(){
+        return driverStockMapper.getUserComp();
+    }
+
+    // 用户汇总学生
+    public PageInfo<userPage> getUserPage(String key,Integer identityId){
+        List<userPage> list = driverStockMapper.getUserPage(key,identityId);
+        PageInfo<userPage> meterPageInfo = new PageInfo<>(list);
+        return meterPageInfo;
+    }
+
+    // 教学成果
+    public List<Tj> getScorePer(@Param("examName") String examName,@Param("updateUser") String updateUser){
+        return driverStockMapper.getScorePer(examName,updateUser);
+    }
+
+    // 考试名称
+    public List<Tj> getExamName(){
+        return driverStockMapper.getExamName();
+    }
+
+    // 教师评分
+    public Tj getTeacherExam(@Param("cardNo") String cardNo){
+        List<Tj> list = driverStockMapper.getTeacherExam(cardNo);
+        if (!list.isEmpty()){
+            return list.get(0);
+        }
+        return null;
+    }
 }

+ 83 - 0
src/main/resources/mapper/template/DriverStockMapper.xml

@@ -12,6 +12,19 @@
         <result property="num" column="num"/>
     </resultMap>
 
+    <resultMap id="MeterPage" type="com.template.model.tongji.MeterPage">
+        <result property="build" column="build"/>
+        <result property="meterId" column="meter_id"/>
+        <result property="num" column="num"/>
+        <result property="createTime" column="create_time"/>
+    </resultMap>
+
+    <resultMap id="userPage" type="com.template.model.tongji.userPage">
+        <result property="name" column="name"/>
+        <result property="cardNo" column="card_no"/>
+        <result property="departMent" column="depart_ment"/>
+    </resultMap>
+
     <!--年级统计-->
     <select id="getClassTj" resultMap="Tj">
         select `name`, COUNT(*) as num from ( select IFNULL(b.`name`,'未知') `name` from `smart_user` a
@@ -31,4 +44,74 @@
                    group by meter_type
     </select>
 
+    <!--每栋楼电费月统计-->
+    <select id="getEnergyMonth" resultMap="TjF">
+        select b.name, IFNULL(a.num,0) num,#{date} as date from (
+            select name,IFNULL(SUM(num),0) as num from `month_meter_detail`
+            where date=#{date} and type=#{type}
+            group by name ) a right join `smart_build` b on a.name=b.name
+    </select>
+
+    <!--总设备数-->
+    <select id="getTotalDevice" resultMap="TjF">
+        select case meter_type when 1 then '电表' when 0 then '水表' end as `name`,
+               COUNT(*) as num
+        from `smart_build_meter` group by meter_type
+    </select>
+
+    <!--在线设备数-->
+    <select id="getOnlineDevice" resultMap="TjF">
+        select case meter_type when 1 then '电表' when 0 then '水表' end as `name`,
+               COUNT(*) as num from (select * from `smart_meter_detail` where create_time
+           like concat(#{date}, '%') group by meter_id ) a group by meter_type
+    </select>
+
+    <!--设备实时记录数据-->
+    <select id="getMeterDetail" resultMap="MeterPage">
+        select c.meter_id,c.meter_power num,d.`name` build,c.create_time from (select a.`meter_id`,a.`meter_power`,a.`create_time`,
+              b.`build_id` from `smart_meter_detail` a left join `smart_build_meter` b
+              on a.`meter_id`=b.`meter_id` where a.meter_type=#{meterType}) c
+              left join `smart_build` d on c.`build_id`=d.`id` order by create_time desc
+    </select>
+
+    <!--设备实时记录数据-->
+    <select id="getUserComp" resultMap="Tj">
+        select iname as name,COUNT(*) as num from (
+             select a.*,b.name as iname from `smart_user` a left join `smart_identity` b
+             on a.`identity_id`=b.id where a.deleted=0 ) c group by iname
+    </select>
+
+    <!--用户汇总学生-->
+    <select id="getUserPage" resultMap="userPage">
+        select a.name,a.`card_no`,b.`name` as depart_ment from `smart_user` a
+             left join `smart_department` b on a.`department_id`=b.id
+             where a.`deleted`=0 and a.identity_id=#{identityId}
+        <if test="key != null and key != ''">
+            and (a.name like '%' #{key} '%' or a.card_no like '%' #{key} '%')
+        </if>
+    </select>
+
+    <!--教学成果-->
+    <select id="getScorePer" resultMap="Tj">
+        select score as name,COUNT(*) as num from (
+        select case when score <![CDATA[ < ]]> 60 then '60分以下'
+        when score <![CDATA[ >= ]]> 60 and score <![CDATA[ <= ]]> 70 then '60-70'
+        when score <![CDATA[ >= ]]> 71 and score <![CDATA[ <= ]]> 80 then '71-80'
+        when score <![CDATA[ >= ]]> 81 and score <![CDATA[ <= ]]> 90 then '81-90'
+        when score <![CDATA[ >= ]]> 91 and score <![CDATA[ <= ]]> 100 then '91-100'
+        end score,CONCAT(semester,b.name) as exam_name,a.deleted=0,a.update_user from `smart_score` a
+        left join `smart_examtype` b on a.exam_type=b.id ) a
+        where a.exam_name=#{examName} and a.update_user=#{updateUser} group by score
+    </select>
+
+    <!--考试名称-->
+    <select id="getExamName" resultMap="Tj">
+        select distinct(CONCAT(semester,b.name)) as name from `smart_score` a
+              left join `smart_examtype` b on a.exam_type=b.id where a.`deleted`=0
+    </select>
+
+    <!--教师评分-->
+    <select id="getTeacherExam" resultMap="Tj">
+        select evaluate_detail as name from `smart_evaluate_teacher` where card_no=#{cardNo} and deleted=0 order by id desc
+    </select>
 </mapper>