瀏覽代碼

修改接口名称

hym 4 年之前
父節點
當前提交
93be0305e7

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/PlatformApiController.java

@@ -27,7 +27,7 @@ public class PlatformApiController {
         platformAapiService.updateMeterNo(meterNo,meterCode,customerNo);
         return new AjaxMessage<>(ResultStatus.OK);
     }
-    @PostMapping ("/sendCommond ")
+    @PostMapping ("/sendCommond")
     @ApiOperation(value = "阀门操作")
     public AjaxMessage sendCommond (
             @ApiParam(value = "客户id", required = true)  @RequestParam String customerNo,

+ 5 - 1
water_query_api/pom.xml

@@ -107,7 +107,11 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 20 - 0
water_query_api/src/main/java/com/zcxk/WaterQueryApiApplication.java

@@ -0,0 +1,20 @@
+package com.zcxk;
+
+import org.springframework.boot.SpringApplication;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+
+
+@SpringBootApplication
+public class WaterQueryApiApplication extends SpringBootServletInitializer {
+
+    public static void main(String[] args) {
+        SpringApplication.run(WaterQueryApiApplication.class, args
+        );
+    }
+
+
+}

+ 72 - 0
water_query_api/src/main/java/com/zcxk/config/SwaggerConfig.java

@@ -0,0 +1,72 @@
+package com.zcxk.config;
+
+import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    @Bean
+    public Docket api() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .ignoredParameterTypes(BasicErrorController.class)
+                .groupName("web")
+                .select()
+                .apis(RequestHandlerSelectors.any())
+                .paths(PathSelectors.any())
+                .build()
+                .apiInfo(apiInfo())
+                .securitySchemes(securitySchemes())
+                .securityContexts(securityContexts());
+    }
+
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("水查查Api")
+                .description("水查查")
+                .version("1.0")
+                .termsOfServiceUrl("Terms of service")
+                .license("测试")
+                .build();
+    }
+
+    private List<ApiKey> securitySchemes() {
+        return newArrayList(
+                new ApiKey("Authorization", "Authorization", "header"));
+    }
+
+    private List<SecurityContext> securityContexts() {
+        return newArrayList(
+                SecurityContext.builder()
+                        .securityReferences(defaultAuth())
+                        .forPaths(PathSelectors.regex("^(?!auth).*$"))
+                        .build()
+        );
+    }
+
+    List<SecurityReference> defaultAuth() {
+        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
+        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+        authorizationScopes[0] = authorizationScope;
+        return newArrayList(
+                new SecurityReference("Authorization", authorizationScopes));
+    }
+
+}

+ 30 - 31
water_query_api/src/main/java/com/zcxk/controller/WaterApiController.java

@@ -45,23 +45,24 @@ public class WaterApiController {
      * @param meterNo 水表档案号
      * @return 单条数据
      */
-    @RequestMapping(value = "getRealTimeUseWater ", method = RequestMethod.POST)
+    @RequestMapping(value = "getRealTimeUseWater", method = RequestMethod.POST)
     @ApiOperation(value = "查询用户用水量")
     public AjaxMessage<List<UseWaterDto>> getRealTimeUseWater(
-            @ApiParam(value = "水表档案号", required = true) String meterNo,
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "查询范围,7:近7日,30:近30日", required = true) Integer period) {
-        List<UseWaterDto>result=  meterReadRecordService.getRealTimeUseWater(meterNo,period);
+            @ApiParam(value = "水表档案号", required = true) @RequestParam String meterNo,
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "查询范围,7:近7日,30:近30日", required = true) @RequestParam Integer period) {
+        List<UseWaterDto>result=  meterReadRecordService.getRealTimeUseWater(meterNo,period,customerNo);
 
 
         return new AjaxMessage<>(ResultStatus.OK,result );
     }
-    @RequestMapping(value = "getThirtyDaysUseWater ", method = RequestMethod.POST)
+    @RequestMapping(value = "getThirtyDaysUseWater", method = RequestMethod.POST)
     @ApiOperation(value = "分析30天用户用水量")
     public AjaxMessage<UseWaterAnalyze> getThirtyDaysUseWater(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "水表档案号", required = true) String meterNo) {
-        UseWaterAnalyze result=meterReadRecordService.getThirtyDaysUseWater(meterNo);
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "水表档案号", required = true) @RequestParam String meterNo) {
+        UseWaterAnalyze result=meterReadRecordService.getThirtyDaysUseWater(meterNo,customerNo);
+
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
     /**
@@ -73,10 +74,10 @@ public class WaterApiController {
     @RequestMapping(value = "getUseWaterAnalyze", method = RequestMethod.POST)
     @ApiOperation(value = "用水分析")
     public AjaxMessage<UseWaterAnalyze> getUseWaterAnalyze(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "水表档案号", required = true) String meterNo) {
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "水表档案号", required = true) @RequestParam String meterNo) {
 
-        UseWaterAnalyze useWaterAnalyze=meterReadRecordService.getUseWaterAnalyze(meterNo);
+        UseWaterAnalyze useWaterAnalyze=meterReadRecordService.getUseWaterAnalyze(meterNo,customerNo);
         return new AjaxMessage<>(ResultStatus.OK, useWaterAnalyze);
     }
 
@@ -89,14 +90,12 @@ public class WaterApiController {
     @RequestMapping(value = "addRule", method = RequestMethod.POST)
     @ApiOperation(value = "添加预警规则")
     public AjaxMessage<Integer> addRule(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天", required = true)
-            @RequestParam(required = true) Integer warningType
-            ,@ApiParam(value = "水表档案号", required = true) String meterNo
-
-            ,@ApiParam(value = "水表档案号", required = true) String userName) {
-         warningRuleService.addRule(warningType,meterNo,userName);
-        return new AjaxMessage<>(ResultStatus.OK, null);
+            @ApiParam(value = "客户id", required = true)  @RequestParam String customerNo,
+            @ApiParam(value = "预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天", required = true)@RequestParam Integer warningType
+            ,@ApiParam(value = "水表档案号", required = true)  @RequestParam String meterNo
+            ,@ApiParam(value = "用户名", required = true)  @RequestParam String userName) {
+        ;
+        return new AjaxMessage<>(ResultStatus.OK,  warningRuleService.addRule(warningType,meterNo,userName,customerNo));
 
     }
 
@@ -109,11 +108,11 @@ public class WaterApiController {
     @RequestMapping(value = "getDateStatus", method = RequestMethod.POST)
     @ApiOperation(value = "查询对应日期预警信息状态")
     public AjaxMessage<List<WarningMessageStatusDto>> getDateStatus(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true) Integer date
-            ,@ApiParam(value = "水表档案号", required = true) String meterNo
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam Integer date
+            ,@ApiParam(value = "水表档案号", required = true) @RequestParam String meterNo
     ) {
-        List<WarningMessageStatusDto>result=warningMessageService.getDateStatus(date,meterNo);
+        List<WarningMessageStatusDto>result=warningMessageService.getDateStatus(date,meterNo,customerNo);
 
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
@@ -126,11 +125,11 @@ public class WaterApiController {
     @RequestMapping(value = "getWariningList", method = RequestMethod.POST)
     @ApiOperation(value = "获取预警信息列表")
     public AjaxMessage<List<WarningMessageDto>> getWariningList(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true) Integer date
-            ,@ApiParam(value = "水表档案号", required = true) String meterNo
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam Integer date
+            ,@ApiParam(value = "水表档案号", required = true) @RequestParam String meterNo
     ) {
-        List<WarningMessageDto> result = warningMessageService.getList(date, meterNo);
+        List<WarningMessageDto> result = warningMessageService.getList(date, meterNo,customerNo);
 
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
@@ -145,9 +144,9 @@ public class WaterApiController {
     @RequestMapping(value = "ruleList", method = RequestMethod.POST)
     @ApiOperation(value = "规则列表")
     public AjaxMessage< List<WarningRule>> ruleList(
-            @ApiParam(value = "客户id", required = true) String customerNo,
-            @ApiParam(value = "水表档案号", required = true) String meterNo) {
-        List<WarningRule>result=warningRuleService.getList(meterNo);
+            @ApiParam(value = "客户id", required = true) @RequestParam String customerNo,
+            @ApiParam(value = "水表档案号", required = true)@RequestParam  String meterNo) {
+        List<WarningRule>result=warningRuleService.getList(meterNo,customerNo);
         return new AjaxMessage<>(ResultStatus.OK, result);
     }
 

+ 4 - 0
water_query_api/src/main/java/com/zcxk/dao/WarningRuleMapper.java

@@ -1,5 +1,6 @@
 package com.zcxk.dao;
 
+import com.zcxk.entity.Device;
 import com.zcxk.entity.WarningRule;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -15,4 +16,7 @@ public interface WarningRuleMapper {
     List<WarningRule> getList(@Param("deviceId") Long deviceId);
 
     int findByWarningTypeUnique(@Param("deviceId") Long deviceId, @Param("warningType") Integer warningType);
+
+    List<Device> findByFileNo(@Param("fileNos") List<String> fileNos,
+                              @Param("customerNo") String customerNo);
 }

+ 120 - 0
water_query_api/src/main/java/com/zcxk/entity/Device.java

@@ -0,0 +1,120 @@
+package com.zcxk.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@ApiModel("设备")
+public class Device {
+    @ApiModelProperty(value = "编号", position = 1)
+    private Long id;
+
+    @ApiModelProperty(value = "设备编号", position = 2)
+    private String deviceNo;
+
+    @ApiModelProperty(value = "设备类型", position = 3)
+    private Integer deviceType;
+
+    @ApiModelProperty(value = "系统id", position = 4)
+    private Integer sysId;
+
+    @ApiModelProperty(value = "系统id数组", position = 4)
+    private List<Integer> sysIds ; 
+    
+    @ApiModelProperty(value = "站点id", position = 4, hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value = "建筑id", position = 5)
+    private Integer buildingId;
+
+    @ApiModelProperty(value = "楼层", position = 6)
+    private Integer floor;
+
+    @ApiModelProperty(value = "位置描述", position = 7)
+    private String locDesc;
+
+    @ApiModelProperty(value = "关联设备", position = 8)
+    private Long relatedDeviceNo;
+
+    @ApiModelProperty(value = "厂商", position = 9)
+    private Integer manufacturerId;
+
+    //@ApiModelProperty(value = "设备状态  1:正常 2:故障 3:无 4: 预警 5:未启用", position = 11, hidden = true)
+    @ApiModelProperty(value = "设备状态  1:正常 2:故障 3:无 4: 预警 5:未启用", position = 11, hidden = true)
+    private Integer deviceStatus;
+
+    @ApiModelProperty(value = "状态 0:删除 1:正常", position = 12, hidden = true)
+    private Integer status;
+
+    @ApiModelProperty(value = "是否已标记 0:未标记 1:已标记", position = 13)
+    private Integer isTag;
+
+    @ApiModelProperty(value = "坐标x", position = 14)
+    private BigDecimal xCoordinates;
+
+    @ApiModelProperty(value = "坐标y", position = 15)
+    private BigDecimal yCoordinates;
+
+    @ApiModelProperty(value = "创建人", hidden = true)
+    private String createBy = "system";
+
+    @ApiModelProperty(value = "更新人", hidden = true)
+    private String updateBy = "system";
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", hidden = true)
+    private LocalDateTime dateCreate;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新时间", hidden = true)
+    private LocalDateTime dateUpdate = LocalDateTime.now();
+
+    @ApiModelProperty(value = "平面图id", position = 16)
+    private Integer planId;
+
+    @ApiModelProperty(value = "水表电子号", position = 17)
+    private String waterMeterNo;
+
+    @ApiModelProperty(value = "水表档案号", position = 18)
+    private String waterMeterFileNo;
+
+
+
+    @ApiModelProperty(value = "参考sc_customer表id", position = 19)
+    private Integer customerId;
+
+    @ApiModelProperty(value = "udip平台id", position = 20)
+    private String udipId;
+
+    @ApiModelProperty(value = "是否注册", position = 20)
+    private Integer registerStatus;
+
+    @ApiModelProperty(value = "同步状态 0:无同步 1:已同步 2:未同步", position = 20)
+    private Integer syncStatus;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "设备最后上报时间", position = 21)
+    private LocalDateTime lastReceiveTime;
+
+    private List<Integer> deviceStatusList;
+
+    @ApiModelProperty(value = "水表档案号", position = 22)
+    private String metercode;
+
+    @ApiModelProperty(value = "客户信息ID", position = 23)
+    private BigInteger accountId;
+
+    @ApiModelProperty(value = "客户编号", position = 24)
+    private String accountnumber;
+
+    @ApiModelProperty(value="铅封号", position = 25)
+    private String sealNo;
+
+}

+ 3 - 3
water_query_api/src/main/java/com/zcxk/service/MeterReadRecordService.java

@@ -6,9 +6,9 @@ import com.zcxk.dto.UseWaterDto;
 import java.util.List;
 
 public interface MeterReadRecordService {
-    List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period);
+    List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period, String customerNo);
 
-    UseWaterAnalyze getThirtyDaysUseWater(String meterNo);
+    UseWaterAnalyze getThirtyDaysUseWater(String meterNo, String customerNo);
 
-    UseWaterAnalyze getUseWaterAnalyze(String meterNo);
+    UseWaterAnalyze getUseWaterAnalyze(String meterNo, String customerNo);
 }

+ 2 - 3
water_query_api/src/main/java/com/zcxk/service/WarningMessageService.java

@@ -2,7 +2,6 @@ package com.zcxk.service;
 
 import com.zcxk.dto.WarningMessageDto;
 import com.zcxk.dto.WarningMessageStatusDto;
-import com.zcxk.entity.WarningMessage;
 
 import java.util.List;
 
@@ -15,6 +14,6 @@ import java.util.List;
  */
 public interface WarningMessageService {
 
-    List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo);
-    List<WarningMessageDto> getList(Integer date, String meterNo);
+    List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo, String customerNo);
+    List<WarningMessageDto> getList(Integer date, String meterNo, String customerNo);
 }

+ 3 - 2
water_query_api/src/main/java/com/zcxk/service/WarningRuleService.java

@@ -15,7 +15,8 @@ public interface WarningRuleService {
 
 
 
-    int addRule(Integer warningType, String meterNo,String userName);
+    int addRule(Integer warningType, String meterNo, String userName, String customerNo);
 
-    List<WarningRule> getList(String meterNo);
+    List<WarningRule> getList(String meterNo, String customerNo);
+    long getDeviceId(String meterNo, String customerNo);
 }

+ 11 - 7
water_query_api/src/main/java/com/zcxk/service/impl/MeterReadRecordServiceImpl.java

@@ -4,7 +4,9 @@ import com.zcxk.dao.MeterReadRecordMapper;
 import com.zcxk.dto.UseWaterAnalyze;
 import com.zcxk.dto.UseWaterDto;
 import com.zcxk.service.MeterReadRecordService;
+import com.zcxk.service.WarningRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -14,19 +16,21 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
-
+@Service
 public class MeterReadRecordServiceImpl implements MeterReadRecordService {
     @Autowired
     private MeterReadRecordMapper meterReadRecordMapper;
+    @Autowired
+    private WarningRuleService warningRuleService;
 
     @Override
-    public List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period) {
+    public List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period, String customerNo) {
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
         LocalDateTime startDateTime = LocalDateTime.now().plusDays(-period);
         LocalDateTime endDateTime = LocalDateTime.now().plusDays(-1);
         Integer startDate = Integer.valueOf(startDateTime.format(df));
         Integer endDate = Integer.valueOf(endDateTime.format(df));
-        Long deviceId=0L;
+        Long deviceId=warningRuleService.getDeviceId(meterNo,customerNo);;
         List<UseWaterDto> list =  meterReadRecordMapper.getRealTimeUseWater(deviceId, startDate, endDate);
         //填充缺失月份数据
         fillDataForCertainMonths(period,list,startDateTime,df);
@@ -58,8 +62,8 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
 
     }
     @Override
-    public UseWaterAnalyze getThirtyDaysUseWater(String meterNo) {
-        List<UseWaterDto> list = getRealTimeUseWater(meterNo, 30);
+    public UseWaterAnalyze getThirtyDaysUseWater(String meterNo, String customerNo) {
+        List<UseWaterDto> list = getRealTimeUseWater(meterNo, 30, customerNo);
         UseWaterAnalyze useWaterAnalyze = new UseWaterAnalyze();
         useWaterAnalyze.setList(list);
         statisticsOnWaterUsage(useWaterAnalyze,list);
@@ -88,8 +92,8 @@ public class MeterReadRecordServiceImpl implements MeterReadRecordService {
 
     }
     @Override
-    public UseWaterAnalyze getUseWaterAnalyze(String meterNo) {
-        Long deviceId=0l;
+    public UseWaterAnalyze getUseWaterAnalyze(String meterNo, String customerNo) {
+        Long deviceId=warningRuleService.getDeviceId(meterNo,customerNo);;
         UseWaterAnalyze useWaterAnalyze = new UseWaterAnalyze();
         //近12月
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");

+ 10 - 5
water_query_api/src/main/java/com/zcxk/service/impl/WarningMessageServiceImpl.java

@@ -3,8 +3,8 @@ package com.zcxk.service.impl;
 import com.zcxk.dao.WarningMessageMapper;
 import com.zcxk.dto.WarningMessageDto;
 import com.zcxk.dto.WarningMessageStatusDto;
-import com.zcxk.entity.WarningMessage;
 import com.zcxk.service.WarningMessageService;
+import com.zcxk.service.WarningRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -18,18 +18,23 @@ import java.util.List;
  */
 @Service("warningMessageService")
 public class WarningMessageServiceImpl implements WarningMessageService {
+    @Autowired
     private WarningMessageMapper warningMessageMapper;
+    @Autowired
+    private WarningRuleService warningRuleService;
 
 
     @Override
-    public List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo) {
-        Long deviceId=0l;
+    public List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo, String customerNo) {
+        Long deviceId=warningRuleService.getDeviceId(meterNo,customerNo);;
         return warningMessageMapper.getDateStatus(deviceId, date);
     }
 
     @Override
-    public List<WarningMessageDto> getList(Integer date, String meterNo) {
-        Long deviceId=0l;
+    public List<WarningMessageDto> getList(Integer date, String meterNo, String customerNo) {
+        Long deviceId=warningRuleService.getDeviceId(meterNo,customerNo);;
         return warningMessageMapper.getList(deviceId, date);
     }
+
+
 }

+ 21 - 9
water_query_api/src/main/java/com/zcxk/service/impl/WarningRuleServiceImpl.java

@@ -1,12 +1,13 @@
 package com.zcxk.service.impl;
 
 import com.zcxk.dao.WarningRuleMapper;
+import com.zcxk.entity.Device;
 import com.zcxk.entity.WarningRule;
 import com.zcxk.service.WarningRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -23,12 +24,12 @@ public class WarningRuleServiceImpl implements WarningRuleService {
 
 
     @Override
-    public int addRule(Integer warningType, String meterNo,String userName) {
-        Long deviceId=0l;
-
+    public int addRule(Integer warningType, String meterNo, String userName, String customerNo) {
+            Long deviceId=getDeviceId(meterNo,customerNo);;
+            int result=0;
             int resultDeviceNo = warningRuleMapper.findByWarningTypeUnique(deviceId, warningType);
             if (resultDeviceNo > 0) {
-                throw new RuntimeException("该预警类型已经存在");
+               result=1;
             }
 
             WarningRule warningRule = new WarningRule();
@@ -41,13 +42,24 @@ public class WarningRuleServiceImpl implements WarningRuleService {
             warningRule.setDateUpdate(new Date());
             warningRuleMapper.insertSelective(warningRule);
 
-        return 0;
+        return result;
     }
 
     @Override
-    public List<WarningRule> getList(String meterNo) {
-        Long deviceId=0l;
+    public List<WarningRule> getList(String meterNo, String customerNo) {
+        Long deviceId=getDeviceId(meterNo,customerNo);
         return warningRuleMapper.getList(deviceId);
     }
-
+    public long getDeviceId(String meterNo, String customerNo){
+        Device device=null;
+        long id=0;
+        List<String>fileNo=new ArrayList<>();
+        fileNo.add(meterNo);
+        List<Device> devices = warningRuleMapper.findByFileNo(fileNo, customerNo);
+        if(devices.size()>0){
+            device=devices.get(0);
+            id=device.getId();
+        }
+        return id;
+    }
 }

+ 37 - 0
water_query_api/src/main/resources/application-dev.properties

@@ -0,0 +1,37 @@
+server.port=8091
+server.servlet.context-path=/api
+
+spring.thymeleaf.prefix=classpath:/templates/
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://10.0.0.161:3306/smart_city_sit_6_10?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+spring.datasource.url=jdbc:mysql://114.135.61.188:33306/smart_city_sit_6_10?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+#spring.datasource.url=jdbc:mysql://47.112.217.10:3306/smart_city?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+spring.datasource.username=root
+spring.datasource.password=100Zone@123
+spring.datasource.hikari.max-lifetime=30000
+# mybatis_config
+mybatis.mapper-locations=classpath*:mapper/*.xml
+mybatis.type-aliases-package=com.zcxk.entity
+mybatis.configuration.map-underscore-to-camel-case=true
+mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+mybatis.configuration.use-column-label=true
+
+spring.jackson.time-zone=GMT+8
+
+
+
+
+spring.servlet.multipart.max-file-size=100MB
+spring.servlet.multipart.max-request-size=100MB
+spring.servlet.multipart.location=e:/test/files
+
+
+
+
+
+
+
+
+
+
+

+ 2 - 0
water_query_api/src/main/resources/application.properties

@@ -0,0 +1,2 @@
+#开发环境:dev  测试环境:sit  线上环境:prd  演示环境:uat
+spring.profiles.active=dev

+ 1 - 1
water_query_api/src/main/resources/mapper/MeterReadRecordMapper.xml

@@ -215,7 +215,7 @@
       </if>
     </trim>
   </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.water.entity.MeterReadRecord">
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.entity.MeterReadRecord">
     <!--@mbg.generated-->
     update sc_meter_read_record
     <set>

+ 9 - 0
water_query_api/src/main/resources/mapper/WarningRuleMapper.xml

@@ -105,4 +105,13 @@
   <select id="findByWarningTypeUnique" resultType="int">
     select count(1) from sc_warning_rule where status = 1 and device_id = #{deviceId} and warning_type = #{warningType}
   </select>
+    <select id="findByFileNo" resultType="com.zcxk.entity.Device">
+      select b.water_meter_file_no ,b.id from sc_customer a left join  sc_device b on a.id=b.customer_id
+      where
+      a.customer_no=#{customerNo}
+      and b.water_meter_file_no in
+      <foreach collection="fileNos" item="item" separator="," open="(" close=")">
+        #{item}
+      </foreach>
+    </select>
 </mapper>