Explorar o código

台区管理-增删改查

jichaobo %!s(int64=3) %!d(string=hai) anos
pai
achega
b2e4ee5021

+ 6 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceAnalogVariableListController.java

@@ -81,6 +81,12 @@ public class DeviceAnalogVariableListController {
         return ApiResult.success(deviceAnalogVariableListService.variableList(deviceCode, screen,size,current));
     }
 
+
+    /**
+     * 站点管理-变量列表-列表查询 无分页
+     * @param deviceAnalogVariableListVo
+     * @return
+     */
     @GetMapping("variableListone")
     public ApiResult<CommonPage<DeviceAnalogVariableList>> variableListone(@RequestBody DeviceAnalogVariableListVo deviceAnalogVariableListVo) {
         return ApiResult.success(deviceAnalogVariableListService.variableListone(deviceAnalogVariableListVo));

+ 113 - 3
fiveep-controller/src/main/java/com/bizmatics/controller/web/PlatformAreaController.java

@@ -1,21 +1,131 @@
 package com.bizmatics.controller.web;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.bizmatics.common.core.bean.ApiResult;
+import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.model.DeviceAnalogVariableList;
+import com.bizmatics.model.PlatformArea;
+import com.bizmatics.model.vo.DeviceVo;
+import com.bizmatics.model.vo.PlatformAreaVo;
+import com.bizmatics.model.vo.SiteDeviceList;
+import com.bizmatics.service.PlatformAreaService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 import org.springframework.stereotype.Controller;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author ya
  * @since 2021-09-29
  */
-@Controller
+@RestController
 @RequestMapping("/platformArea")
 public class PlatformAreaController {
 
+    @Autowired
+    private PlatformAreaService platformAreaService;
+
+    /**
+     * 台区管理-新增
+     *
+     * @param platformArea
+     * @return
+     */
+    @GetMapping("platformAreaAdd")
+    public ApiResult<Void> platformAreaAdd(@RequestBody PlatformArea platformArea) {
+        platformAreaService.platformAreaAdd(platformArea);
+        return ApiResult.success();
+    }
+
+    /**
+     * 台区管理-修改
+     *
+     * @param platformArea
+     * @return
+     */
+    @GetMapping("platformAreaUpdate")
+    public ApiResult<Void> platformAreaUpdate(@RequestBody PlatformArea platformArea) {
+        platformAreaService.platformAreaUpdate(platformArea);
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 台区管理-修改回显
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("platformAreaList")
+    public ApiResult<List<Map<String, Object>>> platformAreaList(@RequestParam(value = "id", required = false, defaultValue = "0") int id) {
+        return ApiResult.success(platformAreaService.platformAreaList(id));
+    }
+
+    /**
+     * 台区管理-列表查询
+     *
+     * @param platformAreaName
+     * @return
+     */
+    @GetMapping("platformAreaListOne")
+    public ApiResult<List<PlatformAreaVo>> platformAreaListOne(@RequestParam(required = false) String platformAreaName) {
+        return ApiResult.success(platformAreaService.platformAreaListOne(platformAreaName));
+    }
+
+
+    /**
+     * 台区管路-注销
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("platformAreaDel")
+    public ApiResult<Void> platformAreaDel(@RequestParam int id) {
+        platformAreaService.platformAreaDel(id);
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 台区管路-站点设备列表
+     * @param stationAreaId
+     * @return
+     */
+    @GetMapping("siteDeviceList")
+    public ApiResult<List<SiteDeviceList>> siteDeviceList(@RequestParam int stationAreaId) {
+        return ApiResult.success(platformAreaService.siteDeviceList(stationAreaId));
+    }
+
+    /**
+     * 台区管理-站点设备修改
+     * @param deviceVo
+     * @return
+     */
+    @GetMapping("siteDeviceUpdate")
+    public ApiResult<Void> siteDeviceUpdate(@RequestBody DeviceVo deviceVo) {
+        platformAreaService.siteDeviceUpdate(deviceVo);
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 台区管理-站点设备注销
+     * @param deviceId
+     * @param deviceAttributeId
+     * @return
+     */
+    @GetMapping("siteDeviceDel")
+    public ApiResult<Void> siteDeviceDel(@RequestParam int deviceId,
+                                         @RequestParam int deviceAttributeId) {
+        platformAreaService.siteDeviceDel(deviceId, deviceAttributeId);
+        return ApiResult.success();
+    }
 }
 

+ 26 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/DeviceVo.java

@@ -0,0 +1,26 @@
+package com.bizmatics.model.vo;
+
+import com.bizmatics.model.Device;
+import com.bizmatics.model.DeviceAttribute;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class DeviceVo implements Serializable {
+    private Device device;
+
+    private DeviceAttribute deviceAttribute;
+}

+ 69 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PlatformAreaVo.java

@@ -0,0 +1,69 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.bizmatics.model.Site;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-09-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PlatformAreaVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 台区表主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 台区名称
+     */
+    private String platformAreaName;
+
+    /**
+     * 台区地址
+     */
+    private String platformAreaAddress;
+
+    /**
+     * 台区编号
+     */
+    private String platformAreaCode;
+
+    /**
+     * 使能标识(0 不生效,1 生效)
+     */
+    private Integer enable;
+
+    /**
+     *
+     */
+    private Integer deviceCount;
+
+    /**
+     * 台区下站点总数
+     */
+    private Integer siteCount;
+
+    /**
+     * 台区下站点
+     */
+    private List<Site> site;
+
+}

+ 117 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/SiteDeviceList.java

@@ -0,0 +1,117 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备属性
+ * </p>
+ *
+ * @author ya
+ * @since 2021-09-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SiteDeviceList implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 设备动态属性id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备id
+     */
+    private Integer deviceId;
+
+    /**
+     * 回路表计地址
+     */
+    private Integer loopMeterAddress;
+
+    /**
+     * 额定电压(kv)
+     */
+    private Double ratedVoltage;
+
+    /**
+     * 额定电流(A)
+     */
+    private Double ratedCurrent;
+
+    /**
+     * 电流负载率门限
+     */
+    private Double currentLoadRate;
+
+    /**
+     * 监控设备编号
+     */
+    private String monitoringEquipmentNo;
+
+    /**
+     * 变量列表id
+     */
+    private Integer variableListId;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 电能质量分析
+     */
+    private String qualityAnalysis;
+
+    /**
+     * 1:启用、0:不启用
+     */
+    private Integer enable;
+
+    /**
+     *站点ID
+     */
+    private Integer siteId;
+
+    /**
+     *设备ID
+     */
+    private Integer deviceIdOne;
+
+    /**
+     *设备状态表ID
+     */
+    private Integer deviceStatusId;
+
+    /**
+     *站点名称
+     */
+    private String siteName;
+
+    /**
+     *设备名称
+     */
+    private String deviceName;
+
+    /**
+     * 设备状态
+     */
+    private String deviceStatusr;
+}

+ 12 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PlatformAreaMapper.java

@@ -1,7 +1,12 @@
 package com.bizmatics.persistence.mapper;
 
-import com.bizmatics.model.PlatformArea;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.PlatformArea;
+import com.bizmatics.model.vo.PlatformAreaVo;
+import com.bizmatics.model.vo.SiteDeviceList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,10 @@ import com.bizmatics.common.mvc.base.CrudMapper;
  */
 public interface PlatformAreaMapper extends CrudMapper<PlatformArea> {
 
+    List<PlatformAreaVo> siteCount(@Param("platformAreaName") String platformAreaName);
+
+    List<PlatformAreaVo> deviceCount(@Param("platformAreaName") String platformAreaName);
+
+    List<SiteDeviceList> deviceList(@Param("stationAreaId") int stationAreaId);
+
 }

+ 70 - 5
fiveep-persistence/src/main/resources/mapper/mysql/PlatformAreaMapper.xml

@@ -4,11 +4,76 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.bizmatics.model.PlatformArea">
-        <id column="id" property="id" />
-        <result column="platform_area_name" property="platformAreaName" />
-        <result column="platform_area_address" property="platformAreaAddress" />
-        <result column="platform_area_code" property="platformAreaCode" />
-        <result column="enable" property="enable" />
+        <id column="id" property="id"/>
+        <result column="platform_area_name" property="platformAreaName"/>
+        <result column="platform_area_address" property="platformAreaAddress"/>
+        <result column="platform_area_code" property="platformAreaCode"/>
+        <result column="enable" property="enable"/>
     </resultMap>
+    <select id="siteCount" resultType="com.bizmatics.model.vo.PlatformAreaVo">
+        SELECT
+        a.*, COUNT(b.id) as siteCount
+        FROM
+        platform_area AS a
+        JOIN site AS b ON a.id = b.station_area_id
+        <where>
+            a.enable = 1
+            and b.enable = 1
+            <if test="platformAreaName != null and platformAreaName != ''">
+                and a.platform_area_name LIKE CONCAT(CONCAT('%', #{platformAreaName}), '%')
+            </if>
+        </where>
+    </select>
+
+    <select id="deviceCount" resultType="com.bizmatics.model.vo.PlatformAreaVo">
+        SELECT
+        a.*,
+        COUNT(c.id) AS deviceCount
+        FROM
+        platform_area AS a
+        JOIN site AS b ON a.id = b.station_area_id
+        JOIN device AS c ON b.id = c.site_id
+        <where>
+            a.enable = 1
+            and b.enable = 1
+            and c.enable = 1
+            <if test="platformAreaName != null and platformAreaName != ''">
+                and a.platform_area_name LIKE CONCAT(CONCAT('%', #{platformAreaName}), '%')
+            </if>
+        </where>
+        GROUP BY
+        a.id
+    </select>
+
+
+    <select id="deviceList" resultType="com.bizmatics.model.vo.SiteDeviceList">
+        SELECT
+        a.id AS site_id,
+        a.site_name,
+        b.id AS device_id,
+        b.device_name,
+        IF (
+        d.device_status = 1,
+        '离线',
+        '在线'
+        ) AS device_statusr,
+        c.*,
+        d.id as device_status_id
+        FROM
+        site AS a
+        JOIN device AS b ON a.id = b.site_id
+        JOIN device_attribute AS c ON b.id = c.device_id
+        JOIN device_status AS d ON b.device_code = d.device_code
+        <where>
+            a.enable = 1
+            and b.enable = 1
+            and c.enable = 1
+            <if test="stationAreaId != null and stationAreaId != 0">
+                AND a.station_area_id = #{stationAreaId}
+            </if>
+        </where>
+        GROUP BY
+        a.id
+    </select>
 
 </mapper>

+ 20 - 1
fiveep-service/src/main/java/com/bizmatics/service/PlatformAreaService.java

@@ -2,10 +2,16 @@ package com.bizmatics.service;
 
 import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.model.PlatformArea;
+import com.bizmatics.model.vo.DeviceVo;
+import com.bizmatics.model.vo.PlatformAreaVo;
+import com.bizmatics.model.vo.SiteDeviceList;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author ya
@@ -13,5 +19,18 @@ import com.bizmatics.model.PlatformArea;
  */
 public interface PlatformAreaService extends CrudService<PlatformArea> {
     void platformAreaAdd(PlatformArea platformArea);
+
     void platformAreaUpdate(PlatformArea platformArea);
+
+    List<Map<String, Object>> platformAreaList(int id);
+
+    List<PlatformAreaVo> platformAreaListOne(String platformAreaName);
+
+    void platformAreaDel(int id);
+
+    List<SiteDeviceList> siteDeviceList(int stationAreaId);
+
+    void siteDeviceUpdate(DeviceVo deviceVo);
+
+    void siteDeviceDel(int deviceId, int deviceAttributeId);
 }

+ 1 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAttributeServiceImpl.java

@@ -67,6 +67,7 @@ public class DeviceAttributeServiceImpl extends AbstractCrudService<DeviceAttrib
     @Override
     public void deviceNewsDel(int id) {
         DeviceAttribute deviceAttribute = new DeviceAttribute();
+        deviceAttribute.setId(id);
         deviceAttribute.setEnable(0);
         this.updateById(deviceAttribute);
     }

+ 91 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/PlatformAreaServiceImpl.java

@@ -1,11 +1,22 @@
 package com.bizmatics.service.impl;
 
-import com.bizmatics.model.PlatformArea;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.model.*;
+import com.bizmatics.model.vo.DeviceVo;
+import com.bizmatics.model.vo.PlatformAreaVo;
+import com.bizmatics.model.vo.SiteDeviceList;
 import com.bizmatics.persistence.mapper.PlatformAreaMapper;
 import com.bizmatics.service.PlatformAreaService;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  服务实现类
@@ -17,6 +28,17 @@ import org.springframework.stereotype.Service;
 @Service
 public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMapper, PlatformArea> implements PlatformAreaService {
 
+    @Autowired
+    private SiteServiceImpl siteService;
+    @Autowired
+    private DeviceServiceImpl deviceService;
+
+    @Autowired
+    private DeviceStatusServiceImpl deviceStatusService;
+
+    @Autowired
+    private DeviceAttributeServiceImpl deviceAttributeService;
+
     @Override
     public void platformAreaAdd(PlatformArea platformArea){
         platformArea.setEnable(1);
@@ -28,7 +50,74 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
         this.updateById(platformArea);
     }
 
-    public void platformAreaList(){
+    @Override
+    public List<Map<String, Object>> platformAreaList(int id){
+        LambdaQueryWrapper<PlatformArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PlatformArea::getEnable, 1).eq(PlatformArea::getId, id);
+        List<PlatformArea> platformAreaList = this.list(queryWrapper);
+        PlatformArea platformArea = (PlatformArea)platformAreaList.get(0);
+        LambdaQueryWrapper<Site> siteQueryWrapper = Wrappers.lambdaQuery();
+        siteQueryWrapper.eq(Site::getStationAreaId,platformArea.getId()).eq(Site::getEnable, 1);
+        List<Site> siteList = siteService.list(siteQueryWrapper);
+        int siteCount = siteList.size();
+        LambdaQueryWrapper<Device> deviceQueryWrapper = Wrappers.lambdaQuery();
+        deviceQueryWrapper.in(Device::getSiteId,siteList).eq(Device::getEnable, 1);
+        int deviceCount = deviceService.count(deviceQueryWrapper);
+        PlatformAreaVo platformAreaVo = new PlatformAreaVo();
+        platformAreaVo.setPlatformAreaName(platformArea.getPlatformAreaName());
+        platformAreaVo.setPlatformAreaAddress(platformArea.getPlatformAreaAddress());
+        platformAreaVo.setPlatformAreaCode(platformArea.getPlatformAreaCode());
+        platformAreaVo.setSiteCount(siteCount);
+        platformAreaVo.setDeviceCount(deviceCount);
+        platformAreaVo.setSite(siteList);
+        return (List<Map<String, Object>>) platformAreaVo;
+    }
+
+    @Override
+    public List<PlatformAreaVo> platformAreaListOne(String platformAreaName){
+       List<PlatformAreaVo> PlatformAreaVoSite = baseMapper.siteCount(platformAreaName);
+       List<PlatformAreaVo> PlatformAreaVoDevice =baseMapper.deviceCount(platformAreaName);
+        for (int i = 0; i < PlatformAreaVoSite.size(); i++) {
+            PlatformAreaVo one =(PlatformAreaVo)PlatformAreaVoSite.get(i);
+            for (int j = 0; j < PlatformAreaVoSite.size(); j++) {
+                PlatformAreaVo two =(PlatformAreaVo)PlatformAreaVoDevice.get(j);
+                if (one.getId()==two.getId()){
+                    one.setDeviceCount(two.getDeviceCount());
+                }
+            }
+        }
+        return PlatformAreaVoSite;
+    }
+
+    @Override
+    public void platformAreaDel(int id){
+        PlatformArea platformArea = new PlatformArea();
+        platformArea.setId(id);
+        platformArea.setEnable(0);
+        this.updateById(platformArea);
+    }
+
+    @Override
+    public List<SiteDeviceList> siteDeviceList(int stationAreaId){
+        List<SiteDeviceList> siteDeviceList = baseMapper.deviceList(stationAreaId);
+        return siteDeviceList;
+    }
+
+    @Override
+    public void siteDeviceUpdate (DeviceVo deviceVo){
+        deviceService.updateById(deviceVo.getDevice());
+        deviceAttributeService.updateById(deviceVo.getDeviceAttribute());
+    }
 
+    @Override
+    public void siteDeviceDel(int deviceId,int deviceAttributeId){
+        Device device = new Device();
+        DeviceAttribute deviceAttribute = new DeviceAttribute();
+        device.setId(deviceId);
+        device.setEnable(0);
+        deviceAttribute.setId(deviceAttributeId);
+        deviceAttribute.setEnable(0);
+        deviceService.updateById(device);
+        deviceAttributeService.updateById(deviceAttribute);
     }
 }