lin 4 lat temu
rodzic
commit
1aa74dc85f
31 zmienionych plików z 459 dodań i 29 usunięć
  1. 2 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/Application.java
  2. 19 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dao/ConfigMapper.java
  3. 9 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/ConfigDataDto.java
  4. 5 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/ValveControlDataDto.java
  5. 45 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/entity/Config.java
  6. 15 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/ConfigService.java
  7. 33 0
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/ConfigServiceImpl.java
  8. 37 4
      smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceV2Impl.java
  9. 1 0
      smart-city-intf/src/main/resources/application-dev.properties
  10. 1 0
      smart-city-intf/src/main/resources/application-prd.properties
  11. 1 0
      smart-city-intf/src/main/resources/application-sit.properties
  12. 1 0
      smart-city-intf/src/main/resources/application-uat.properties
  13. 45 0
      smart-city-intf/src/main/resources/mapper/ConfigMapper.xml
  14. 41 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  15. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/ExternalApiController.java
  16. 2 10
      smart-city-platform/src/main/java/com/bz/smart_city/controller/RealTimeMonitorController.java
  17. 18 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/BuildingController.java
  18. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java
  19. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java
  20. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/ValveControlDataDto.java
  21. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  22. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  23. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/ValveService.java
  24. 10 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  25. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CustomerServiceImpl.java
  26. 66 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  27. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DimensionServiceImpl.java
  28. 39 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ValveServiceImpl.java
  29. 1 1
      smart-city-platform/src/main/resources/mapper/AlarmStatMapper.xml
  30. 49 0
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  31. 3 0
      smart-city-platform/src/main/resources/mapper/CustomerMapper.xml

+ 2 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/Application.java

@@ -6,9 +6,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.annotation.EnableCaching;
 
 @Slf4j
 @SpringBootApplication
+@EnableCaching  //开启缓存
 public class Application implements CommandLineRunner {
 
 	public static void main(String[] args) {

+ 19 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dao/ConfigMapper.java

@@ -0,0 +1,19 @@
+package com.zcxk.smartcity.data.access.dao;
+
+
+import com.zcxk.smartcity.data.access.dto.ConfigDataDto;
+import com.zcxk.smartcity.data.access.entity.Config;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface ConfigMapper {
+
+
+    List<ConfigDataDto> findByParentId(@Param("parentId") int parentId);
+
+    Config findByName(@Param("name") String name);
+
+}

+ 9 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/ConfigDataDto.java

@@ -0,0 +1,9 @@
+package com.zcxk.smartcity.data.access.dto;
+
+import lombok.Data;
+
+@Data
+public class ConfigDataDto {
+    private String name;
+    private String value;
+}

+ 5 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/ValveControlDataDto.java

@@ -5,6 +5,11 @@ import lombok.Data;
 
 @Data
 public class ValveControlDataDto {
+    @ApiModelProperty(value = "active")
+    private String active;
+
+    @ApiModelProperty(value = "客户id")
+    private Integer customerId;
 
     @ApiModelProperty("水表表号")
     private String meterNo;

+ 45 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/entity/Config.java

@@ -0,0 +1,45 @@
+package com.zcxk.smartcity.data.access.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+* Created by Mybatis Generator 2018/12/29
+*/
+@ApiModel(value="配置")
+@Data
+public class Config {
+
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    @ApiModelProperty(value="")
+    private String configName;
+
+    @ApiModelProperty(value="")
+    private String configValue;
+
+    @ApiModelProperty(value="")
+    private String configDesc;
+
+    @ApiModelProperty(value="")
+    private Integer parentId;
+
+    @ApiModelProperty(value="")
+    private Boolean status;
+
+    @ApiModelProperty(value="")
+    private String createBy;
+
+    @ApiModelProperty(value="")
+    private String updateBy;
+
+    @ApiModelProperty(value="")
+    private Date dateCreate;
+
+    @ApiModelProperty(value="")
+    private Date dateUpdate;
+}

+ 15 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/ConfigService.java

@@ -0,0 +1,15 @@
+package com.zcxk.smartcity.data.access.service;
+
+
+
+import com.zcxk.smartcity.data.access.dto.ConfigDataDto;
+
+import java.util.List;
+
+public interface ConfigService {
+
+
+
+    List<ConfigDataDto> getConfigData(String type);
+
+}

+ 33 - 0
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/ConfigServiceImpl.java

@@ -0,0 +1,33 @@
+package com.zcxk.smartcity.data.access.service.impl;
+
+import com.zcxk.smartcity.data.access.dao.ConfigMapper;
+import com.zcxk.smartcity.data.access.dto.ConfigDataDto;
+import com.zcxk.smartcity.data.access.entity.Config;
+import com.zcxk.smartcity.data.access.service.ConfigService;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+@Service
+public class ConfigServiceImpl implements ConfigService {
+
+    @Resource
+    private ConfigMapper configMapper;
+
+
+    @Override
+    @Cacheable(value = "CacheConfigData", key = "#type",unless = "#result == null")
+    public List<ConfigDataDto> getConfigData(String type) {
+        Config config = configMapper.findByName(type);
+        List<ConfigDataDto> list = newArrayList();
+        if (config != null) {
+            list = configMapper.findByParentId(config.getId());
+        }
+        return list;
+    }
+
+}

+ 37 - 4
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/service/impl/DeviceDataServiceV2Impl.java

@@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.zcxk.smartcity.data.access.common.RedisUtil;
 import com.zcxk.smartcity.data.access.dao.*;
+import com.zcxk.smartcity.data.access.dto.ConfigDataDto;
 import com.zcxk.smartcity.data.access.dto.UdipUnitDataDTO;
 import com.zcxk.smartcity.data.access.dto.ValveControlDataDto;
 import com.zcxk.smartcity.data.access.entity.*;
 import com.zcxk.smartcity.data.access.protocol.model.MeasuringData;
+import com.zcxk.smartcity.data.access.service.ConfigService;
 import com.zcxk.smartcity.data.access.service.DeviceDataServiceV2;
+import com.zcxk.smartcity.data.access.util.JacksonUtil;
 import com.zcxk.smartcity.data.access.util.MapTransformUtils;
 import com.zcxk.smartcity.data.access.util.SnowflakeIdWorker;
 import lombok.extern.slf4j.Slf4j;
@@ -68,6 +71,15 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
     @Autowired
     private KafkaTemplate<String, Object> kafkaTemplate;
 
+    @Autowired
+    private ConfigService configService;
+
+    @Value("${spring.profiles.active}")
+    private String active;
+    @Value("${com.zcxk.kafka.accept_valve_state.topic}")
+    private String acceptValveStateTopic;
+
+
     @Override
     public int savaDeviceData(Device device, UdipUnitDataDTO unitData) {
         log.info("begin savaDeviceData,device = {} ,data = {}" , JSON.toJSONString(device) ,JSON.toJSONString(unitData));
@@ -187,10 +199,19 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
                         record.setValveStatus(0);
                     }
                     //推送阀门状态至抄表平台
-                    if (device.getCustomerId() != null && device.getCustomerId() == 129) {
-                        ValveControlDataDto valveControlData = new ValveControlDataDto();
-                        valveControlData.setMeterNo(device.getWaterMeterNo());
-                        valveControlData.setValve(record.getValveStatus().toString());
+
+
+                    if (device.getCustomerId() != null) {
+                        if(this.matches(device.getCustomerId())){
+                            ValveControlDataDto valveControlData = new ValveControlDataDto();
+                            valveControlData.setActive(active);
+                            valveControlData.setCustomerId(device.getCustomerId());
+                            valveControlData.setMeterNo(device.getWaterMeterNo());
+                            valveControlData.setValve(record.getValveStatus().toString());
+                            // 改为推送到kafka消息队列
+                            String json = JacksonUtil.obj2String(valveControlData);
+                            kafkaTemplate.send(acceptValveStateTopic, json);
+                        }
                     }
                 }
                 record.setStatus(1);
@@ -216,6 +237,18 @@ public class DeviceDataServiceV2Impl implements DeviceDataServiceV2 {
         return i;
     }
 
+    private boolean matches(Integer customerId) {
+        List<ConfigDataDto> configDataList = configService.getConfigData("push_valve_config");
+        if (configDataList != null && configDataList.size() > 0) {
+            for (ConfigDataDto configDataDto : configDataList) {
+                if(StringUtils.equals(configDataDto.getValue(),customerId.toString())){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     /**
      * 判断设备是否报警,并产生报警记录
      */

+ 1 - 0
smart-city-intf/src/main/resources/application-dev.properties

@@ -53,6 +53,7 @@ spring.kafka.consumer.auto-offset-reset=latest
 spring.kafka.consumer.enable-auto-commit=true
 com.zcxk.kafka.single.data.topic=sc_single_data_topic_dev
 com.zcxk.kafka.multi.data.topic=sc_multi_data_topic_dev
+com.zcxk.kafka.accept_valve_state.topic=sc_accept_valve_state_topic_dev
 #阿里云网管平台配置项
 aliyun.nms.topic=zoniot-aliyun-ns-test-topic
 aliyun.nms.access.key=LTAI9bq4vr6ClPGW

+ 1 - 0
smart-city-intf/src/main/resources/application-prd.properties

@@ -48,6 +48,7 @@ spring.kafka.producer.batch-size=4096
 spring.kafka.producer.buffer-memory=40960
 com.zcxk.kafka.alarm.topic=sc_alarm_topic
 com.zcxk.kafka.card.topic=sc_card_topic
+com.zcxk.kafka.accept_valve_state.topic=sc_accept_valve_state_topic
 #kafka consumer config
 spring.kafka.consumer.group-id=iot-hub-prd
 spring.kafka.consumer.auto-offset-reset=latest

+ 1 - 0
smart-city-intf/src/main/resources/application-sit.properties

@@ -56,6 +56,7 @@ spring.kafka.consumer.auto-offset-reset=latest
 spring.kafka.consumer.enable-auto-commit=true
 com.zcxk.kafka.single.data.topic=sc_single_data_topic_sit
 com.zcxk.kafka.multi.data.topic=sc_single_data_topic_sit
+com.zcxk.kafka.accept_valve_state.topic=sc_accept_valve_state_topic_sit
 #\u963F\u91CC\u4E91\u7F51\u7BA1\u5E73\u53F0\u914D\u7F6E\u9879
 aliyun.nms.topic=zoniot-aliyun-ns-test-topic
 aliyun.nms.access.key=LTAI9bq4vr6ClPGW

+ 1 - 0
smart-city-intf/src/main/resources/application-uat.properties

@@ -47,6 +47,7 @@ spring.kafka.producer.batch-size=4096
 spring.kafka.producer.buffer-memory=40960
 com.zcxk.kafka.alarm.topic=sc_alarm_topic_uat
 com.zcxk.kafka.card.topic=sc_card_topic_uat
+com.zcxk.kafka.accept_valve_state.topic=sc_accept_valve_state_topic_uat
 #kafka consumer config
 spring.kafka.consumer.group-id=iot-hub-uat
 spring.kafka.consumer.auto-offset-reset=latest

+ 45 - 0
smart-city-intf/src/main/resources/mapper/ConfigMapper.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.zcxk.smartcity.data.access.dao.ConfigMapper">
+    <!--auto generated Code-->
+    <resultMap id="BaseResultMap" type="com.zcxk.smartcity.data.access.entity.Config">
+        <result column="id" property="id" jdbcType="INTEGER"/>
+        <result column="config_name" property="configName" jdbcType="VARCHAR"/>
+        <result column="config_value" property="configValue" jdbcType="VARCHAR"/>
+        <result column="config_desc" property="configDesc" jdbcType="VARCHAR"/>
+        <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
+        <result column="status" property="status" jdbcType="TINYINT"/>
+        <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
+        <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
+        <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
+        <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <!--auto generated Code-->
+    <sql id="Base_Column_List">
+        id,
+        config_name,
+        config_value,
+        config_desc,
+        parent_id,
+        status,
+        create_by,
+        update_by,
+        date_create,
+        date_update
+    </sql>
+
+
+
+    <select id="findByParentId" resultType="com.zcxk.smartcity.data.access.dto.ConfigDataDto">
+        select config_name as `name`,config_value as `value`
+        from sc_config_t where status = 1 and parent_id = #{parentId} order by config_value asc
+    </select>
+
+    <select id="findByName" resultMap="BaseResultMap">
+        select <include refid="Base_Column_List"/> from sc_config_t
+        where status = 1 and config_name = #{name}
+    </select>
+
+</mapper>
+

+ 41 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -135,6 +135,47 @@ public class DeviceController {
 
     }
 
+    @GetMapping("/v2/getDeviceListExcel")
+    @ApiOperation(value = "导出设备列表excel")
+    public void getDeviceListExcelV2(
+            @ApiParam(value = "系统id", required = true) @RequestParam(required = true) Integer sysId,
+            @ApiParam(value = "建筑id", required = false) @RequestParam(required = false) Integer buildingId,
+            @ApiParam(value = "设备编号", required = false) @RequestParam(required = false) String deviceNo,
+            @ApiParam(value = "状态  1:正常 2:故障 3:无 4: 预警 5:未启用", required = false) @RequestParam(required = false) Integer status,
+            @ApiParam(value = "厂商id", required = false) @RequestParam(required = false) Integer manufacturerId,
+            @ApiParam(value = "系列", required = false) @RequestParam(required = false) String equipmentType,
+            @ApiParam(value = "型号", required = false) @RequestParam(required = false) String model,
+            @ApiParam(value = "是否标记 0:未标记 1:已标记", required = false) @RequestParam(required = false) Integer isTag,
+            @ApiParam(value = "楼层", required = false) @RequestParam(required = false) Integer floor,
+            @ApiParam(value = "位置描述", required = false) @RequestParam(required = false) String locDesc,
+            @ApiParam(value = "省", required = false) @RequestParam(required = false) Integer province,
+            @ApiParam(value = "市", required = false) @RequestParam(required = false) Integer city,
+            @ApiParam(value = "区", required = false) @RequestParam(required = false) Integer region,
+            @ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer community,
+            @ApiParam(value = "集中器编号", required = false) @RequestParam(required = false) String concentratorNo,
+            @ApiParam(value = "采集器编号", required = false) @RequestParam(required = false) String collectorNo,
+            @ApiParam(value = "故障类型", required = false) @RequestParam(required = false) String errorType,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
+            @ApiParam(value = "连续故障天数", required = false) @RequestParam(required = false) Integer days,
+            @ApiParam(value = "连续故障开始天数", required = false) @RequestParam(required = false) Integer startDays,
+            @ApiParam(value = "连续故障结束天数", required = false) @RequestParam(required = false) Integer endDays,
+            @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
+            @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
+            @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
+            @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus,
+            @ApiParam(value = "同步状态 0:未同步 1:已同步", required = false) @RequestParam(required = false) Integer syncStatus,
+            @ApiParam(value = "开始当前读数", required = false) @RequestParam(required = false) Double startReading,
+            @ApiParam(value = "结束当前读数", required = false) @RequestParam(required = false) Double endReading,
+            @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false,defaultValue = "sd.date_create") String sortColumn,
+            @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false,defaultValue = "DESC") String sortOrder,
+            HttpServletResponse httpServletResponse
+    ) {
+        deviceService.getDeviceListExcelV2(sysId, buildingId, StringUtils.trim(deviceNo), status, manufacturerId, StringUtils.trim(equipmentType), StringUtils.trim(model), isTag,
+                floor, StringUtils.trim(locDesc), province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading, sortColumn, sortOrder, httpServletResponse);
+
+    }
+
     @GetMapping("/exportDeviceListAsXML")
     @ApiOperation(value = "导出设备列表XML")
     public void exportDeviceListAsXML(

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/ExternalApiController.java

@@ -28,8 +28,8 @@ public class ExternalApiController {
     public AjaxMessage valveState(
             @ApiParam(value = "水表表号", required = true) @RequestParam(required = true) String meterNo
     ) {
-        valveService.valveState(meterNo);
-        return new AjaxMessage(ResultStatus.OK);
+        ;
+        return new AjaxMessage(ResultStatus.OK,valveService.valveState(meterNo));
     }
 
     @ResponseBody

+ 2 - 10
smart-city-platform/src/main/java/com/bz/smart_city/controller/RealTimeMonitorController.java

@@ -72,18 +72,10 @@ public class RealTimeMonitorController {
         if (loginUser != null && loginUser.getIsSuperAdmin() != 1) {
             siteId = loginUser.getSiteId();
         }
-        List<ProgramItem> programItems = newArrayList();
-        if (loginUser.getSiteList() != null) {
-            loginUser.getSiteList().forEach(site -> {
-                List<ProgramItem> programItemsTem = loginUser.getDataPermissionMap().get(site.getId());
-                if (programItemsTem != null) {
-                    programItems.addAll(programItemsTem);
-                }
-            });
-        }
+
         // 2,服务查询
         CommonQueryCondition condition = new CommonQueryCondition();
-        condition.setProgramItems(programItems);
+        condition.setProgramItems(UserUtil.getCurrentSiteProgramItems(loginUser));
         condition.setSiteId(siteId);
         condition.setChannelId(system);
         condition.setBuildingId(building);

+ 18 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/BuildingController.java

@@ -233,7 +233,7 @@ public class BuildingController {
 
     @ResponseBody
     @GetMapping("/getBuildingPage")
-    @ApiOperation(value = "查询建筑分页")
+    @ApiOperation(value = "查询建筑分页(实时监控)")
     public AjaxMessage<Pagination<BuildingInfoListDto>> getBuildingPage(
             @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
             @ApiParam(value = "建筑名称", required = false) @RequestParam(required = false) String buildingName,
@@ -248,6 +248,23 @@ public class BuildingController {
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
+    @ResponseBody
+    @GetMapping("/v2/getBuildingPage")
+    @ApiOperation(value = "查询建筑分页")
+    public AjaxMessage<Pagination<BuildingInfoListDto>> getBuildingPageV2(
+            @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
+            @ApiParam(value = "建筑名称", required = false) @RequestParam(required = false) String buildingName,
+            @ApiParam(value = "省", required = false) @RequestParam(required = false) Integer province,
+            @ApiParam(value = "市", required = false) @RequestParam(required = false) Integer city,
+            @ApiParam(value = "区", required = false) @RequestParam(required = false) Integer region,
+            @ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer community,
+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
+    ) {
+        Pagination<BuildingInfoListDto> pageInfo = buildingService.getBuildingPage(sysId, StringUtils.trim(buildingName), province, city, region, community, pageNum, pageSize);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
     @ResponseBody
     @GetMapping("/getAllBuildingList")
     @ApiOperation(value = "查询全部建筑列表(设备数统计)")

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java

@@ -36,6 +36,8 @@ public interface BuildingMapper {
 
     List<BuildingInfoListDto> getBuildingList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingName") String buildingName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("customerIds") List<Integer> customerIds);
 
+    List<BuildingInfoListDto> getBuildingListV2(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingName") String buildingName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("customerIds") List<Integer> customerIds);
+
     List<FloorDto> queryFloor(@Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId);
 
     int deleteQuery(@Param("buildingId") Integer buildingId);

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java

@@ -24,7 +24,7 @@ public interface CustomerMapper {
 
     Customer findCustWithCode(@Param("code") String code);
 
-    List<CustomerDto> getCustomerList(@Param("siteId") Integer siteId, @Param("customerName") String customerName);
+    List<CustomerDto> getCustomerList(@Param("siteId") Integer siteId, @Param("customerName") String customerName, @Param("customerIds") List<Integer> customerIds);
 
     int findByNameUnique(@Param("siteId") Integer siteId, @Param("id") Integer id, @Param("customerName") String customerName);
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/ValveControlDataDto.java

@@ -9,6 +9,6 @@ public class ValveControlDataDto {
     @ApiModelProperty("水表表号")
     private String meterNo;
 
-    @ApiModelProperty("阀门操作,0 关,1 开")
+    @ApiModelProperty("阀门操作,0 关,1 开 2 无阀")
     private String valve;
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java

@@ -41,6 +41,8 @@ public interface BuildingService{
 
     Pagination<BuildingInfoListDto> getBuildingPage(Integer sysId, String buildingName, Integer province, Integer city, Integer region, Integer community, int pageNum, int pageSize);
 
+    Pagination<BuildingInfoListDto> getBuildingPageV2(Integer sysId, String buildingName, Integer province, Integer city, Integer region, Integer community, int pageNum, int pageSize);
+
     List<FloorDto> queryFloor(Integer sysId, Integer buildingId);
 
     List<BuildingInfoListDto> getAllList(Integer sysId);

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -47,6 +47,10 @@ public interface DeviceService{
                             String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
                             Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
+    void getDeviceListExcelV2(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
+                            String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
+                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
+
 
     void exportDeviceListAsXML(Integer sysId,
                                Integer buildingId,

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/ValveService.java

@@ -3,7 +3,7 @@ package com.bz.smart_city.service;
 import com.bz.smart_city.dto.ValveControlDataDto;
 
 public interface ValveService {
-    void valveState(String meterNo);
+    ValveControlDataDto valveState(String meterNo);
 
     void valveControl(ValveControlDataDto result);
 }

+ 10 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java

@@ -967,6 +967,16 @@ public class BuildingServiceImpl implements BuildingService {
         //return null;
     }
 
+    @Override
+    public Pagination<BuildingInfoListDto>
+    getBuildingPageV2(Integer sysId, String buildingName, Integer province, Integer city, Integer region, Integer community, int pageNum, int pageSize) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        PageHelper.startPage(pageNum, pageSize);
+        List<BuildingInfoListDto> list = buildingMapper.getBuildingList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingName, province, city, region, community, UserUtil.getCustomerIds());
+        return new Pagination<>(list);
+    }
+
     @Override
     //@Cacheable(value = "buildingInfoListDtoCache", key = "#loginUser.id.toString() + #loginUser.siteId + #sysId + #buildingId + #buildingName", unless = "#buildingId != null || #buildingName != null")
     public List<BuildingInfoListDto> getAllBuildingList(LoginUser loginUser, Integer sysId, String buildingId, String buildingName, Integer province, Integer city, Integer region) {

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CustomerServiceImpl.java

@@ -109,7 +109,7 @@ public class CustomerServiceImpl implements CustomerService {
     public Pagination<CustomerDto> getCustomerPage(String customerName, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum, pageSize);
-        List<CustomerDto> list = customerMapper.getCustomerList(loginUser.getSiteId(), customerName);
+        List<CustomerDto> list = customerMapper.getCustomerList(loginUser.getSiteId(), customerName, UserUtil.getCustomerIds());
         return new Pagination<>(list);
     }
 
@@ -212,7 +212,7 @@ public class CustomerServiceImpl implements CustomerService {
 
     @Override
     public List<CustomerDto> findSiteCustomer() {
-        return customerMapper.getCustomerList(1,null);
+        return customerMapper.getCustomerList(1,null, UserUtil.getCustomerIds());
     }
 
     @Override

+ 66 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -231,7 +231,7 @@ public  class DeviceServiceImpl implements DeviceService {
                 }
             }else {
                 DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-                String[] rowsName = new String[]{"序号", "设备状态", "设备编号", "水表档案编号", "水表电子号", "集中器编码", "采集器编码", "水表厂商", "客户", "小区", "建筑", "安装地址", "故障类型", "连续故障天数", "水表当前读数", "最后一次更新时间","阀门控制","出厂时间","安装时间","验收时间"};
+                String[] rowsName = new String[]{"序号", "设备状态", "设备编号", "水表档案编号", "水表电子号", "集中器编码", "采集器编码", "设备型号", "客户", "小区", "建筑", "安装地址", "告警类型", "连续故障天数", "当前读数", "最后上报时间","阀门控制","出厂时间","创建时间","验收时间"};
                 List<Object[]> dataList = newArrayList();
                 Object[] objs = null;
                 for (int i = 0; i < list.size(); i++) {
@@ -244,7 +244,7 @@ public  class DeviceServiceImpl implements DeviceService {
                     objs[4] = deviceDto.getWaterMeterNo();
                     objs[5] = deviceDto.getConcentratorName();
                     objs[6] = deviceDto.getCollectorName();
-                    objs[7] = deviceDto.getManufacturerName();
+                    objs[7] = deviceDto.getManufacturerName()+"/"+deviceDto.getEquipmentType()+"/"+deviceDto.getManufacturerName();
                     objs[8] = deviceDto.getCustomerName();
                     objs[9] = deviceDto.getCommunityName();
                     objs[10] = deviceDto.getBuildingName();
@@ -293,6 +293,70 @@ public  class DeviceServiceImpl implements DeviceService {
         }
     }
 
+
+    @Override
+    public void getDeviceListExcelV2(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
+                equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
+                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
+        String title = "设备列表";
+        //判断是否是水表场景
+        WMeterType wMeterType = wMeterTypeMapper.getChannelIdAndLevel(sysId, 2);
+        Channel channel = channelMapper.findById(sysId);
+        if (wMeterType != null || sysId == -99) {
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            String[] rowsName = new String[]{"序号", "设备编号", "水表电子号", "设备型号", "建筑", "安装地址", "设备状态", "当前读数", "最后上报时间"};
+            List<Object[]> dataList = newArrayList();
+            Object[] objs = null;
+            for (int i = 0; i < list.size(); i++) {
+                DeviceDto deviceDto = list.get(i);
+                objs = new Object[rowsName.length];
+                objs[0] = i;
+                objs[1] = deviceDto.getDeviceNo();
+                objs[2] = deviceDto.getWaterMeterNo();
+                objs[3] = deviceDto.getManufacturerName()+"/"+deviceDto.getEquipmentType()+"/"+deviceDto.getManufacturerName();
+                objs[4] = deviceDto.getBuildingName();
+                objs[5] = deviceDto.getLocDesc();
+                objs[6] = this.getDeviceStatusName(deviceDto.getDeviceStatus());
+                objs[7] = deviceDto.getMeterReading();
+                objs[8] = deviceDto.getLastReceiveTime()!=null?deviceDto.getLastReceiveTime().format(df):null;
+                dataList.add(objs);
+            }
+            ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+            try {
+                excelUtil.export(httpServletResponse);
+            } catch (Exception e) {
+                throw new ServiceException(-900, "导出异常");
+            }
+        } else {
+            String[] rowsName = new String[]{"序号", "状态", "编号", "系列", "型号", "厂商", "所属建筑", "楼层", "位置"};
+            List<Object[]> dataList = newArrayList();
+            Object[] objs = null;
+            for (int i = 0; i < list.size(); i++) {
+                DeviceDto deviceDto = list.get(i);
+                objs = new Object[rowsName.length];
+                objs[0] = i;
+                objs[1] = this.getDeviceStatusName(deviceDto.getDeviceStatus());
+                objs[2] = deviceDto.getDeviceNo();
+                objs[3] = deviceDto.getEquipmentType();
+                objs[4] = deviceDto.getModel();
+                objs[5] = deviceDto.getManufacturerName();
+                objs[6] = deviceDto.getBuildingName();
+                objs[7] = deviceDto.getFloor();
+                objs[8] = deviceDto.getLocDesc();
+                dataList.add(objs);
+            }
+            ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+            try {
+                excelUtil.export(httpServletResponse);
+            } catch (Exception e) {
+                throw new ServiceException(-900, "导出异常");
+            }
+        }
+    }
+
     protected String getIssueStatusName(Integer issueStatus){
         String issueStatusName = "未下发";
         if (issueStatus != null) {

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DimensionServiceImpl.java

@@ -200,7 +200,7 @@ public class DimensionServiceImpl implements DimensionService{
             });
         }
         //客户
-        List<CustomerDto> customerDtos = customerMapper.getCustomerList(loginUser.getSiteId(),null);
+        List<CustomerDto> customerDtos = customerMapper.getCustomerList(loginUser.getSiteId(),null,UserUtil.getCustomerIds());
         if (customerDtos != null && customerDtos.size() > 0) {
             customerDtos.forEach(customerDto -> {
                 DimensionDataItemDto build = new DimensionDataItemDto();

+ 39 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ValveServiceImpl.java

@@ -3,7 +3,12 @@ package com.bz.smart_city.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.dao.DeviceMapper;
+import com.bz.smart_city.dao.DeviceTypeMapper;
+import com.bz.smart_city.dao.WaterMeterErrorDaysMapper;
+import com.bz.smart_city.dto.DeviceTypeDto;
 import com.bz.smart_city.dto.ValveControlDataDto;
+import com.bz.smart_city.entity.Device;
+import com.bz.smart_city.entity.WaterMeterErrorDays;
 import com.bz.smart_city.service.DeviceService;
 import com.bz.smart_city.service.ValveService;
 import lombok.extern.slf4j.Slf4j;
@@ -12,6 +17,7 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 @Slf4j
@@ -22,11 +28,41 @@ public class ValveServiceImpl implements ValveService {
     private DeviceMapper deviceMapper;
     @Autowired
     private DeviceService deviceService;
+    @Resource
+    private DeviceTypeMapper deviceTypeMapper;
+    @Resource
+    private WaterMeterErrorDaysMapper waterMeterErrorDaysMapper;
 
     @Override
-    public void valveState(String meterNo) {
-        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-        System.out.println(authentication);
+    public ValveControlDataDto valveState(String meterNo) {
+        List<Long> list = deviceMapper.findDeviceIdByWaterMeterNo(null,meterNo);
+        if (list == null || list.size() == 0) {
+            throw new ServiceException(-900,"该水表表号不存在");
+        }
+        if (list.size() > 1) {
+            throw new ServiceException(-900,"该水表表号出现重复");
+        }
+        Long deviceId = list.get(0);
+        Device device =  deviceMapper.findByDeviceId(deviceId);
+        DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(device.getDeviceType());
+        ValveControlDataDto data = new ValveControlDataDto();
+        data.setMeterNo(meterNo);
+
+        if (deviceTypeDto != null && deviceTypeDto.getIsValve() != null && deviceTypeDto.getIsValve() == 1) {
+            WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceId);
+            if (waterMeterErrorDays != null) {
+                if (waterMeterErrorDays.getValveStatus() != null) {
+                    data.setValve(waterMeterErrorDays.getValveStatus().toString());;
+                }else {
+                    data.setValve("1");
+                }
+            }else {
+                data.setValve("1");
+            }
+        }else {
+            data.setValve("2");
+        }
+        return data;
     }
 
     @Override

+ 1 - 1
smart-city-platform/src/main/resources/mapper/AlarmStatMapper.xml

@@ -294,7 +294,7 @@
 		SELECT
 			t1.device_status as statusCode,
 			t2.config_name as statusName,
-			COUNT(t1.device_no) as numberOfDevice
+			COUNT(1) as numberOfDevice
 		FROM
 			sc_device t1
 			LEFT JOIN sc_config_t t2 ON ( t1.device_status = t2.config_value AND t2.parent_id = 7 )

+ 49 - 0
smart-city-platform/src/main/resources/mapper/BuildingMapper.xml

@@ -788,6 +788,55 @@
         <if test="region != null"> AND sb.region = #{region}</if>
     </select>-->
 
+
+    <select id="getBuildingListV2" resultType="com.bz.smart_city.dto.BuildingInfoListDto">
+        select
+        sb.id as building_id,
+        sb.name as building_name,
+        sb.address ,
+        sau.fire_resp_name,
+        sau.fire_resp_phone,
+        sb.province,
+        sb.city,
+        sb.region,
+        sb.community,
+        sa1.name as province_name,
+        sa2.name as city_name,
+        sa3.name as region_name,
+        sc.name as community_name,
+        sb.latitude,
+        sb.longitude,
+        (SELECT
+        count(1) as device_count
+        from sc_device sd
+        <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
+        WHERE sd.status = 1 and sd.sys_id != -99 and sd.building_id = sb.id
+        <if test="programItems != null and programItems.size() != 0"> and
+            <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+                sdd.${item.dimensionCode} = #{item.dimensionValue}
+            </foreach>
+        </if>
+        ) as device_count
+        from sc_building sb
+        left join sc_access_unit sau on sau.id = sb.access_unit_id and sau.status = 1
+        left join sc_area sa1 on sa1.id = sb.province
+        left join sc_area sa2 on sa2.id = sb.city
+        left join sc_area sa3 on sa3.id = sb.region
+        left join sc_community sc on sc.id = sb.community
+        where sb.status = 1
+        <if test="siteId != null"> and sb.site_id = #{siteId}</if>
+        <if test="sysId != null"> and temp.sys_id = #{sysId} </if>
+        <if test="buildingName != null and buildingName != ''"> AND sb.name LIKE concat('%',#{buildingName},'%')</if>
+        <if test="province != null"> AND sb.province = #{province}</if>
+        <if test="city != null"> AND sb.city = #{city}</if>
+        <if test="region != null"> AND sb.region = #{region}</if>
+        <if test="community != null"> AND sb.community = #{community}</if>
+        <if test="customerIds != null and customerIds.size() != 0">
+            and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
+        order by sb.create_date desc
+    </select>
+
     <select id="queryFloor" resultType="com.bz.smart_city.dto.FloorDto">
         select
         sbf.floor_no as floor,

+ 3 - 0
smart-city-platform/src/main/resources/mapper/CustomerMapper.xml

@@ -253,6 +253,9 @@
         where status = 1
         <if test="siteId != null"> and site_id = #{siteId} </if>
         <if test="customerName != null and customerName != ''"> and customer_name like concat('%',#{customerName} ,'%')</if>
+        <if test="customerIds != null and customerIds.size() != 0">
+            and id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
         order by date_create desc
     </select>
     <select id="findByNameUnique" resultType="int">