Procházet zdrojové kódy

楼宇中控数据同步及前端调用接口
后勤资产--典型场景应用率接口(返回数据调整)

zhanghao před 2 měsíci
rodič
revize
15efaaad86

+ 67 - 0
project-zcustom/src/main/java/com/project/zcustom/controller/build/PlatBuildControlController.java

@@ -0,0 +1,67 @@
+package com.project.zcustom.controller.build;
+
+import com.project.common.core.domain.AjaxResult;
+import com.project.common.utils.poi.ExcelUtil;
+import com.project.zcustom.domain.addional.LargeCamera;
+import com.project.zcustom.service.smart.IPlatBuildingService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+@RestController
+@RequestMapping("/large/third")
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+public class PlatBuildControlController {
+    @Autowired
+    private IPlatBuildingService platBuildingService;
+
+    @PostMapping("/updateAirNum")
+    public AjaxResult updateAirNum(@RequestBody Long num) {
+        return AjaxResult.success("查询成功", platBuildingService.updateAirNum(num));
+    }
+
+    /*楼宇本周用电量*/
+    @GetMapping("/thisWeekElectricity")
+    public AjaxResult getThisWeekElectricity() {
+        return AjaxResult.success("查询成功", platBuildingService.getThisWeekElectricity());
+    }
+
+    /*楼宇今日总用电量*/
+    @GetMapping("/todayElectricity")
+    public AjaxResult getTodayElectricity() {
+        return AjaxResult.success("查询成功", platBuildingService.getTodayElectricity());
+    }
+
+    /*楼宇每月用电量*/
+    @GetMapping("/monthElectricity")
+    public AjaxResult getMonthElectricity() {
+        return AjaxResult.success("查询成功", platBuildingService.getMonthElectricity());
+    }
+
+    /*配电室重要回路负荷情况*/
+    @GetMapping("/roomLoad")
+    public AjaxResult getRoomLoad() {
+        return AjaxResult.success("查询成功", platBuildingService.getRoomLoad());
+    }
+
+    /*楼宇中当前告警的设备*/
+    @GetMapping("/warnDevice")
+    public AjaxResult getWarnDevice() {
+        return AjaxResult.success("查询成功", platBuildingService.getWarnDevice());
+    }
+
+    /*告警事件的历史统计*/
+    @GetMapping("/warnEvent")
+    public AjaxResult getWarnEvent() {
+        return AjaxResult.success("查询成功", platBuildingService.getWarnEvent());
+    }
+
+    /*水箱的水位情况*/
+    @GetMapping("/waterState")
+    public AjaxResult getWarnState() {
+        return AjaxResult.success("查询成功", platBuildingService.getWarnState());
+    }
+}

+ 16 - 16
project-zcustom/src/main/java/com/project/zcustom/domain/addional/LargeBuildingControl.java

@@ -92,18 +92,6 @@ public class LargeBuildingControl {
     private Long waterDeviceAirNum;
 
     /**
-     * 水箱水位情况json(23层)
-     */
-    @ApiModelProperty("水箱水位情况json(23层)")
-    private String waterStateOne;
-
-    /**
-     * 水箱水位情况json(-2层)
-     */
-    @ApiModelProperty("水箱水位情况json(-2层)")
-    private String waterStateTwo;
-
-    /**
      * 中控水浸正常数
      */
     @ApiModelProperty("中控水浸正常数")
@@ -121,10 +109,23 @@ public class LargeBuildingControl {
     @ApiModelProperty("告警事件的历史统计json")
     private String warnEventStatistics;
 
+    /**
+     * 水箱水位情况json(23层)
+     */
+    @ApiModelProperty("水箱水位情况json(23层)")
+    private String waterStateOne;
+
+    /**
+     * 水箱水位情况json(-2层)
+     */
+    @ApiModelProperty("水箱水位情况json(-2层)")
+    private String waterStateTwo;
+
+
     public LargeBuildingControl() {
     }
 
-    public LargeBuildingControl(String weekElectricity, String roomElectricity, String todayElectricity, String monthElectricityOne, String monthElectricityTwo, String monthElectricityThree, String roomLoadOne, String roomLoadTwo, String roomLoadThree, String warnDevice, Long waterDeviceAirNum, String waterStateOne, String waterStateTwo, Long waterControlNormalNum, Long waterControlAbnormalNum, String warnEventStatistics) {
+    public LargeBuildingControl(String weekElectricity, String roomElectricity, String todayElectricity, String monthElectricityOne, String monthElectricityTwo, String monthElectricityThree, String roomLoadOne, String roomLoadTwo, String roomLoadThree, String warnDevice, Long waterControlNormalNum, Long waterControlAbnormalNum, String warnEventStatistics, String waterStateOne, String waterStateTwo) {
         this.weekElectricity = weekElectricity;
         this.roomElectricity = roomElectricity;
         this.todayElectricity = todayElectricity;
@@ -135,11 +136,10 @@ public class LargeBuildingControl {
         this.roomLoadTwo = roomLoadTwo;
         this.roomLoadThree = roomLoadThree;
         this.warnDevice = warnDevice;
-        this.waterDeviceAirNum = waterDeviceAirNum;
-        this.waterStateOne = waterStateOne;
-        this.waterStateTwo = waterStateTwo;
         this.waterControlNormalNum = waterControlNormalNum;
         this.waterControlAbnormalNum = waterControlAbnormalNum;
         this.warnEventStatistics = warnEventStatistics;
+        this.waterStateOne = waterStateOne;
+        this.waterStateTwo = waterStateTwo;
     }
 }

+ 22 - 0
project-zcustom/src/main/java/com/project/zcustom/mapper/unit/PlatBuildingMapper.java

@@ -1,7 +1,12 @@
 package com.project.zcustom.mapper.unit;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.project.zcustom.domain.addional.LargeBuilding;
+import com.project.zcustom.domain.addional.LargeBuildingControl;
 
+import java.util.Map;
+
+@InterceptorIgnore(blockAttack = "true")
 public interface PlatBuildingMapper {
     public int getCount();
 
@@ -31,6 +36,18 @@ public interface PlatBuildingMapper {
 
 
 
+
+    LargeBuildingControl getThisWeekElectricity();
+    String getTodayElectricity();
+    LargeBuildingControl getMonthElectricity();
+    LargeBuildingControl getRoomLoad();
+    LargeBuildingControl getWarnDevice();
+    String getWarnEvent();
+    LargeBuildingControl getWarnState();
+
+
+
+
     public int updatePowerAndWaterMonth(String res);
 
     public int updateAirCondition(String res);
@@ -57,4 +74,9 @@ public interface PlatBuildingMapper {
 
     public int updateBuilding(LargeBuilding largeBuilding);
     public int insertBuilding(LargeBuilding largeBuilding);
+
+    public int getExist();
+    public int updateAirNum(Long num);
+    public int addBuildingControl(LargeBuildingControl largeBuildingControl);
+    public int updateBuildingControl(LargeBuildingControl largeBuildingControl);
 }

+ 10 - 2
project-zcustom/src/main/java/com/project/zcustom/service/logistics/impl/LargePlatAssetServiceImpl.java

@@ -6,6 +6,7 @@ import com.project.zcustom.service.logistics.ILargePlatAssetService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -58,10 +59,17 @@ public class LargePlatAssetServiceImpl implements ILargePlatAssetService {
     }
 
     public List<LargeLogistics> getSceneRate(int flag){
+        List<LargeLogistics> list;
         if (flag == 0){
-            return platLogisticsMapper.getSceneRateX();
+            list = platLogisticsMapper.getSceneRateX();
         }
-        else return platLogisticsMapper.getSceneRateY();
+        else {
+            list = platLogisticsMapper.getSceneRateY();
+        }
+        for (LargeLogistics it : list){
+            it.setAppName(it.getAppName().substring(2, 4));
+        }
+        return list;
     }
 
     public List<LargeLogistics> getOperation(String appOrg){

+ 16 - 0
project-zcustom/src/main/java/com/project/zcustom/service/smart/IPlatBuildingService.java

@@ -27,4 +27,20 @@ public interface IPlatBuildingService{
     Map<String, Object> patrol();
 
     List<Map<String, Object>> patrolPoint();
+
+    int updateAirNum(Long num);
+
+    Map<String, Object> getThisWeekElectricity();
+
+    List<Map<String, Object>> getTodayElectricity();
+
+    Map<String, Object> getMonthElectricity();
+
+    Map<String, Object> getRoomLoad();
+
+    Map<String, Object> getWarnDevice();
+
+    Map<String, Object> getWarnEvent();
+
+    Map<String, Object> getWarnState();
 }

+ 126 - 0
project-zcustom/src/main/java/com/project/zcustom/service/smart/impl/PlatBuildingServiceImpl.java

@@ -3,6 +3,7 @@ package com.project.zcustom.service.smart.impl;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.project.common.utils.StringUtils;
+import com.project.zcustom.domain.addional.LargeBuildingControl;
 import com.project.zcustom.mapper.unit.PlatBuildingMapper;
 import com.project.zcustom.service.smart.IPlatBuildingService;
 import com.project.zcustom.service.smart.IPlatGreenFoodsService;
@@ -284,4 +285,129 @@ public class PlatBuildingServiceImpl implements IPlatBuildingService {
         }
         return resultList;
     }
+
+    public int updateAirNum(Long num){
+        if (platBuildingMapper.getExist() > 0){
+            platBuildingMapper.updateAirNum(num);
+        }
+        return 0;
+    }
+
+    public Map<String, Object> getThisWeekElectricity(){
+        LargeBuildingControl largeBuildingControl = platBuildingMapper.getThisWeekElectricity();
+        JSONArray weekElectricity = JSONArray.parseArray(largeBuildingControl.getWeekElectricity());
+        JSONArray roomElectricity = JSONArray.parseArray(largeBuildingControl.getRoomElectricity());
+        Map<String, Object> map = new HashMap<>();
+        List<String> weeklist = new ArrayList<>();
+        List<String> roomlist = new ArrayList<>();
+        for (int i = 0; i < weekElectricity.size(); i++) {
+            JSONObject item = weekElectricity.getJSONObject(i);
+            weeklist.add(item.getString("num"));
+        }
+        for (int i = 0; i < roomElectricity.size(); i++) {
+            JSONObject item = roomElectricity.getJSONObject(i);
+            roomlist.add(item.getString("num"));
+        }
+        map.put("total", weeklist);
+        map.put("room", roomlist);
+        return map;
+    }
+
+    public List<Map<String, Object>> getTodayElectricity(){
+        String json = platBuildingMapper.getTodayElectricity();
+        JSONArray jsonArray = JSONArray.parseArray(json);
+        return repeatElectricity(jsonArray);
+    }
+
+    public Map<String, Object> getMonthElectricity(){
+        LargeBuildingControl largeBuildingControl = platBuildingMapper.getMonthElectricity();
+        JSONArray x = JSONArray.parseArray(largeBuildingControl.getMonthElectricityOne());
+        JSONArray y = JSONArray.parseArray(largeBuildingControl.getMonthElectricityTwo());
+        JSONArray z = JSONArray.parseArray(largeBuildingControl.getMonthElectricityThree());
+        List<Map<String, Object>> a = repeatElectricity(x);
+        List<Map<String, Object>> b = repeatElectricity(y);
+        List<Map<String, Object>> c = repeatElectricity(z);
+        Map<String, Object> map = new HashMap<>();
+        map.put("一号配电室", a);
+        map.put("二号配电室", b);
+        map.put("三号配电室", c);
+        return map;
+    }
+
+    public Map<String, Object> getRoomLoad(){
+        LargeBuildingControl largeBuildingControl = platBuildingMapper.getRoomLoad();
+        JSONArray x = JSONArray.parseArray(largeBuildingControl.getRoomLoadOne());
+        JSONArray y = JSONArray.parseArray(largeBuildingControl.getRoomLoadTwo());
+        JSONArray z = JSONArray.parseArray(largeBuildingControl.getRoomLoadThree());
+        List<Map<String, Object>> a = repeatLoad(x);
+        List<Map<String, Object>> b = repeatLoad(y);
+        List<Map<String, Object>> c = repeatLoad(z);
+        Map<String, Object> map = new HashMap<>();
+        map.put("一号配电室", a);
+        map.put("二号配电室", b);
+        map.put("三号配电室", c);
+        return map;
+    }
+
+    public Map<String, Object> getWarnDevice(){
+        LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnDevice();
+        JSONObject jsonObject = JSONObject.parseObject(largeBuildingControl.getWarnDevice());
+        Map<String, Object> map = new HashMap<>();
+        JSONObject water = jsonObject.getJSONObject("水浸");
+        water.put("正常点位", largeBuildingControl.getWaterControlNormalNum() + largeBuildingControl.getWaterDeviceAirNum());
+        water.put("air", largeBuildingControl.getWaterDeviceAirNum());
+        water.put("control", largeBuildingControl.getWaterControlNormalNum() + largeBuildingControl.getWaterControlAbnormalNum());
+        map.put("电表", repeatWarnDevice(jsonObject.getJSONObject("电表")));
+        map.put("液位计", repeatWarnDevice(jsonObject.getJSONObject("液位计")));
+        map.put("水浸", repeatWarnDevice(water));
+        map.put("烟雾", repeatWarnDevice(jsonObject.getJSONObject("烟雾")));
+        return map;
+    }
+
+    public Map<String, Object> getWarnEvent(){
+        String json = platBuildingMapper.getWarnEvent();
+        JSONObject jsonObject = JSONObject.parseObject(json);
+        return jsonObject;
+    }
+
+    public Map<String, Object> getWarnState(){
+        LargeBuildingControl largeBuildingControl = platBuildingMapper.getWarnState();
+        Map<String, Object> map = new HashMap<>();
+        map.put("23F", largeBuildingControl.getWaterStateOne());
+        map.put("-2F", largeBuildingControl.getWaterStateTwo());
+        return map;
+    }
+
+
+    private JSONObject repeatWarnDevice(JSONObject jsonObject){
+        jsonObject.put("total", Long.valueOf(jsonObject.getString("正常点位")) + Long.valueOf(jsonObject.getString("异常点位")));
+        return jsonObject;
+    }
+
+    private List<Map<String, Object>> repeatLoad(JSONArray jsonArray){
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject item = jsonArray.getJSONObject(i);
+            Map<String, Object> map = new HashMap<>();
+            map.put("空载", item.getString("空载"));
+            map.put("轻载", item.getString("轻载"));
+            map.put("正常", item.getString("正常"));
+            map.put("重载", item.getString("重载"));
+            map.put("过载", item.getString("过载"));
+            list.add(map);
+        }
+        return list;
+    }
+
+    private List<Map<String, Object>> repeatElectricity(JSONArray jsonArray){
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject item = jsonArray.getJSONObject(i);
+            Map<String, Object> map = new HashMap<>();
+            map.put("time", item.getString("time"));
+            map.put("Kwh", item.getString("Kwh"));
+            list.add(map);
+        }
+        return list;
+    }
 }

+ 26 - 2
project-zcustom/src/main/java/com/project/zcustom/tools/BuildingService.java

@@ -5,6 +5,7 @@ import com.project.common.utils.StringUtils;
 import com.project.common.utils.http.HttpUtils;
 import com.project.zcustom.domain.addional.LargeBuilding;
 import com.project.zcustom.domain.addional.LargeBuildingControl;
+import com.project.zcustom.domain.addional.LargeLogistics;
 import com.project.zcustom.mapper.unit.PlatBuildingMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,8 +26,31 @@ public class BuildingService {
      *  楼宇中控 接口数据同步
      */
     public void getLeftBuildingData(){
-        LargeBuildingControl largeBuildingControl = new LargeBuildingControl();
-        String res = repeat(ApiUrlConfig.getControlEquipment(), null);
+        String controlEquipment = repeat(ApiUrlConfig.getControlEquipment(), null);
+        JSONObject jsonObject = JSONObject.parseObject(controlEquipment);
+        Long normalNum = Long.valueOf(jsonObject.getJSONObject("水浸").getString("正常点位"));
+        Long abnormalNum = Long.valueOf(jsonObject.getJSONObject("水浸").getString("异常点位"));
+        LargeBuildingControl largeBuildingControl = new LargeBuildingControl(
+                repeat(ApiUrlConfig.getControlElectricity(), null),
+                repeat(ApiUrlConfig.getControlElectricityRoom(), null),
+                repeat(ApiUrlConfig.getControlTodaySum(), null),
+                repeat(ApiUrlConfig.getControlMonthSum(), "type=一号配电室"),
+                repeat(ApiUrlConfig.getControlMonthSum(), "type=二号配电室"),
+                repeat(ApiUrlConfig.getControlMonthSum(), "type=三号配电室"),
+                repeat(ApiUrlConfig.getControlImportantSum(), "type=一号配电室"),
+                repeat(ApiUrlConfig.getControlImportantSum(), "type=二号配电室"),
+                repeat(ApiUrlConfig.getControlImportantSum(), "type=三号配电室"),
+                repeat(ApiUrlConfig.getControlEquipment(), null),
+                normalNum,
+                abnormalNum,
+                repeat(ApiUrlConfig.getControlAlarm(), null),
+                repeat(ApiUrlConfig.getControlWater(), "position=23F"),
+                repeat(ApiUrlConfig.getControlWater(), "position=-2F")
+                );
+        if (platBuildingMapper.getExist() > 0){
+            platBuildingMapper.updateBuildingControl(largeBuildingControl);
+        }
+        else platBuildingMapper.addBuildingControl(largeBuildingControl);
     }
 
     /**

+ 118 - 0
project-zcustom/src/main/resources/mapper/zcustom/unit/PlatBuildingMapper.xml

@@ -4,6 +4,26 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.project.zcustom.mapper.unit.PlatBuildingMapper">
 
+    <resultMap type="com.project.zcustom.domain.addional.LargeBuildingControl" id="LargeBuildingControlResult">
+        <result property="id"    column="id"    />
+        <result property="weekElectricity"    column="week_electricity"    />
+        <result property="roomElectricity"    column="room_electricity"    />
+        <result property="todayElectricity"    column="today_electricity"    />
+        <result property="monthElectricityOne"    column="month_electricity_one"    />
+        <result property="monthElectricityTwo"    column="month_electricity_two"    />
+        <result property="monthElectricityThree"    column="month_electricity_three"    />
+        <result property="roomLoadOne"    column="room_load_one"    />
+        <result property="roomLoadTwo"    column="room_load_two"    />
+        <result property="roomLoadThree"    column="room_load_three"    />
+        <result property="warnDevice"    column="warn_device"    />
+        <result property="waterDeviceAirNum"    column="water_device_air_num"    />
+        <result property="waterControlNormalNum"    column="water_control_normal_num"    />
+        <result property="waterControlAbnormalNum"    column="water_control_abnormal_num"    />
+        <result property="warnEventStatistics"    column="warn_event_statistics"    />
+        <result property="waterStateOne"    column="water_state_one"    />
+        <result property="waterStateTwo"    column="water_state_two"    />
+    </resultMap>
+
     <select id="getCount" resultType="int">
         select count(*) from large_plat_building
     </select>
@@ -59,6 +79,37 @@
 
 
 
+    <select id="getThisWeekElectricity" resultMap="LargeBuildingControlResult">
+        select week_electricity, room_electricity from large_plat_building_control
+    </select>
+
+    <select id="getTodayElectricity" resultType="String">
+        select today_electricity from large_plat_building_control
+    </select>
+
+    <select id="getMonthElectricity" resultMap="LargeBuildingControlResult">
+        select month_electricity_one, month_electricity_two, month_electricity_three from large_plat_building_control
+    </select>
+
+    <select id="getRoomLoad" resultMap="LargeBuildingControlResult">
+        select room_load_one, room_load_two, room_load_three from large_plat_building_control
+    </select>
+
+    <select id="getWarnDevice" resultMap="LargeBuildingControlResult">
+        select warn_device, water_device_air_num, water_control_normal_num, water_control_abnormal_num from large_plat_building_control
+    </select>
+
+    <select id="getWarnEvent" resultType="String">
+        select warn_event_statistics from large_plat_building_control
+    </select>
+
+    <select id="getWarnState" resultMap="LargeBuildingControlResult">
+        select water_state_one, water_state_two from large_plat_building_control
+    </select>
+
+
+
+
     <update id="updatePowerAndWaterMonth" parameterType="String">
         update large_plat_building
         set json_power_water_month = #{res}
@@ -171,4 +222,71 @@
         '0', sysdate()
         )
     </insert>
+
+    <select id="getExist" resultType="int">
+        select count(*) from large_plat_building_control
+    </select>
+
+    <update id="updateAirNum" parameterType="Long">
+        update large_plat_building_control
+        set water_device_air_num = #{num}
+    </update>
+
+    <insert id="addBuildingControl" parameterType="LargeBuildingControl">
+        insert into large_plat_building_control (week_electricity,
+                                                 room_electricity,
+                                                 today_electricity,
+                                                 month_electricity_one,
+                                                 month_electricity_two,
+                                                 month_electricity_three,
+                                                 room_load_one,
+                                                 room_load_two,
+                                                 room_load_three,
+                                                 warn_device,
+                                                 water_device_air_num,
+                                                 water_control_normal_num,
+                                                 water_control_abnormal_num,
+                                                 warn_event_statistics,
+                                                 water_state_one,
+                                                 water_state_two)
+        values (
+                   #{weekElectricity},
+                   #{roomElectricity},
+                   #{todayElectricity},
+                   #{monthElectricityOne},
+                   #{monthElectricityTwo},
+                   #{monthElectricityThree},
+                   #{roomLoadOne},
+                   #{roomLoadTwo},
+                   #{roomLoadThree},
+                   #{warnDevice},
+                   #{waterDeviceAirNum},
+                   #{waterControlNormalNum},
+                   #{waterControlAbnormalNum},
+                   #{warnEventStatistics},
+                   #{waterStateOne},
+                   #{waterStateTwo}
+               )
+    </insert>
+
+    <update id="updateBuildingControl" parameterType="LargeBuildingControl">
+        UPDATE large_plat_building_control
+        SET week_electricity = #{weekElectricity},
+            room_electricity = #{roomElectricity},
+            today_electricity = #{todayElectricity},
+            month_electricity_one = #{monthElectricityOne},
+            month_electricity_two = #{monthElectricityTwo},
+            month_electricity_three = #{monthElectricityThree},
+            room_load_one = #{roomLoadOne},
+            room_load_two = #{roomLoadTwo},
+            room_load_three = #{roomLoadThree},
+            warn_device = #{warnDevice},
+            water_device_air_num = #{waterDeviceAirNum},
+            water_control_normal_num = #{waterControlNormalNum},
+            water_control_abnormal_num = #{waterControlAbnormalNum},
+            warn_event_statistics = #{warnEventStatistics},
+            water_state_one = #{waterStateOne},
+            water_state_two = #{waterStateTwo}
+    </update>
+
 </mapper>