Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

hym 4 tahun lalu
induk
melakukan
23ee866fd1

+ 60 - 0
src/main/java/com/zoniot/ccrc/commom/utils/SendWechatPush.java

@@ -0,0 +1,60 @@
+package com.zoniot.ccrc.commom.utils;
+
+import java.io.IOException;
+
+/**
+ * 微信公众号消息推送
+ */
+public class SendWechatPush {
+
+
+    /**
+     * 统一消息发送异常通知(微信公众号和小程序)
+     */
+    public static String sendAbnormalNotice(String accessToken,String oa_appid, String openId, String url,String weapp_appid, String pagepath, String first, String keyword1, String keyword2, String keyword3, String remark) {
+        if (accessToken != null && !"".equals(accessToken)) {
+            String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" + accessToken;
+            String json = "{\n" +
+                    "  \"touser\": \""+openId+"\",\n" +
+                    "  \"mp_template_msg\": {\n" +
+                    "    \"appid\": \""+oa_appid +"\",\n" +
+                    "    \"template_id\": \"r8mtd2mgMt8w-sNgHsJ4deoD2bfq-0RyK9lCY3WEoxI\",\n" +
+                    "    \"url\": \""+url+"\",\n" +
+                    "    \"miniprogram\": {\n" +
+                    "      \"appid\": \""+weapp_appid+"\",\n" +
+                    "      \"path\": \""+pagepath+"\"\n" +
+                    "    },\n" +
+                    "    \"data\": {\n" +
+                    "      \"first\": {\n" +
+                    "        \"value\": \""+first+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword1\": {\n" +
+                    "        \"value\": \""+keyword1+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword2\": {\n" +
+                    "        \"value\": \""+keyword2+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword3\": {\n" +
+                    "        \"value\": \""+keyword3+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"remark\": {\n" +
+                    "        \"value\": \""+remark+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      }\n" +
+                    "    }\n" +
+                    "  }\n" +
+                    "}";
+            try {
+                return HttpRequest.doPost(sendUrl, json);
+            } catch (IOException e) {
+                return null;
+            }
+        } else {
+            return "accessToken不存在";
+        }
+    }
+}

+ 32 - 1
src/main/java/com/zoniot/ccrc/controller/common/CommonController.java

@@ -14,18 +14,26 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.client.RestTemplate;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.time.LocalDateTime;
 import java.util.List;
 
 @Controller
-@ResponseBody
 @RequestMapping("common")
 @Api(tags = "公共模块")
 public class CommonController {
@@ -37,10 +45,15 @@ public class CommonController {
     @Autowired
     private AreaMapper areaMapper;
 
+    @Value("${iot.server}")
+    private String server;
+    @Value("${iot.port}")
+    private int port;
 
 
 
 
+    @ResponseBody
     @GetMapping("/getDeviceTypeList")
     @ApiOperation(value = "获取系列(设备类型)列表")
     public AjaxMessage<List<DeviceTypeDto>> getDeviceTypeList(
@@ -51,6 +64,7 @@ public class CommonController {
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 
+    @ResponseBody
     @GetMapping("/getTreeData")
     @ApiOperation(value = "获取厂商/系列/型号树形数据")
     public AjaxMessage<List<TreeDataDto>> getTreeData(
@@ -62,6 +76,7 @@ public class CommonController {
     }
 
 
+    @ResponseBody
     @GetMapping("/getAllArea")
     @ApiOperation(value = "获取所有的省市区")
     public AjaxMessage<List<AreaDto>> getAllArea(
@@ -70,4 +85,20 @@ public class CommonController {
         return new AjaxMessage<>(ResultStatus.OK, TreeUtil.getArea(list, 100000, 1));
     }
 
+    @GetMapping("/getDeviceMeasuringPoint")
+    @ApiOperation(value = "获取设备测点")
+    public void getDeviceMeasuringPoint(
+            @ApiParam(value = "设备类型id", required = true) @RequestParam(required = true) Integer deviceTypeId,
+            HttpServletRequest httpServletRequest,
+            HttpServletResponse httpServletResponse
+    ) throws URISyntaxException, IOException {
+        RestTemplate restTemplate=new RestTemplate();
+        URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
+        ResponseEntity<String> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
+
+        httpServletResponse.setCharacterEncoding("UTF-8");
+        httpServletResponse.setContentType("application/json;charset=utf-8");
+        httpServletResponse.getWriter().write(responseEntity.getBody());
+    }
+
 }

+ 21 - 0
src/main/java/com/zoniot/ccrc/controller/common/TestController.java

@@ -4,6 +4,8 @@ import com.zoniot.ccrc.commom.model.AjaxMessage;
 import com.zoniot.ccrc.commom.model.ResultStatus;
 import com.zoniot.ccrc.commom.utils.ByteArrayUtils;
 import com.zoniot.ccrc.commom.utils.RedisUtil;
+import com.zoniot.ccrc.commom.utils.SendWechatPush;
+import com.zoniot.ccrc.service.AccessTokenService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -25,6 +27,8 @@ public class TestController {
 
     @Value("${files.path}")
     private String filesPath;
+    @Autowired
+    private AccessTokenService accessTokenService;
 
 
     @GetMapping("test")
@@ -60,4 +64,21 @@ public class TestController {
 
 
     }
+
+    @RequestMapping(value = "send", method = RequestMethod.GET)
+    @ApiOperation(value = "测试微信消息推送")
+    public AjaxMessage send(
+            @ApiParam(value = "opendid", required = true) @RequestParam String opendid
+    ) {
+
+        opendid = "o8iCb5HsMBWq-t_iWNVigekPeCP8";
+        String accessToken = accessTokenService.getMpAccessToken();
+        String url = "https://www.zoniot.com";
+        String pagepath = "pages/index/index";
+
+        String result = SendWechatPush.sendAbnormalNotice(accessToken, "wx6b2ce547cd593413", opendid, url, "wx27f831675081e293", pagepath, "用户用水异常", "水量预警", "单日用水量超过2吨",
+                "2021-02-23 17:59:32", "1030844808林家栋13765510000长泽花园2-1-502楼梯间用水量有异常情况,请及时关注用户情况!");
+        log.info(result);
+        return new AjaxMessage(ResultStatus.OK);
+    }
 }

+ 64 - 13
src/main/java/com/zoniot/ccrc/controller/system/DeviceController.java

@@ -12,17 +12,26 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
 @Controller
@@ -32,6 +41,12 @@ public class DeviceController {
     @Autowired
     private DeviceService deviceService;
 
+    @Value("${iot.server}")
+    private String server;
+    @Value("${iot.port}")
+    private int port;
+
+
     @ResponseBody
     @GetMapping("/pageList")
     @ApiOperation(value = "获取设备分页")
@@ -106,8 +121,8 @@ public class DeviceController {
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 
-
-    /*@GetMapping("/getData")
+    @ResponseBody
+    @GetMapping("/getData")
     @ApiOperation(value = "获取设备数据")
     public void getData(
             @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId,
@@ -115,22 +130,58 @@ public class DeviceController {
             @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer endDate,
             HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse
-    ) throws IOException, ServletException {
-        //RequestDispatcher dispatcher = httpServletRequest.getRequestDispatcher("http://114.135.61.188:58088/api/device/getData");
-        //dispatcher.forward(httpServletRequest,httpServletResponse);
-        httpServletResponse.sendRedirect("http://114.135.61.188:58088/api/device/getData");
+    ) throws URISyntaxException, IOException {
+        //http://114.135.61.188:58088/api/device/getData
+        RestTemplate restTemplate=new RestTemplate();
+        URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
+        ResponseEntity<String> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, String.class);
+
+        httpServletResponse.setCharacterEncoding("UTF-8");
+        httpServletResponse.setContentType("application/json;charset=utf-8");
+        httpServletResponse.getWriter().write(responseEntity.getBody());
     }
 
 
+
+
+
+
+
+
     @GetMapping("/getDataExcel")
     @ApiOperation(value = "导出设备数据excel")
     public void getDataExcel(
             @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId,
             @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer startDate,
             @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer endDate,
+            HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse
-    ) throws IOException {
-        httpServletResponse.sendRedirect("/ceng/hello.html");
+    ) throws URISyntaxException, IOException {
+        RestTemplate restTemplate=new RestTemplate();
+        URI uri = new URI("http", null, server, port, httpServletRequest.getRequestURI(), httpServletRequest.getQueryString(), null);
+        ResponseEntity<byte[]> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, byte[].class);
+
+
+        byte[] b=new byte[100];
+        int len;
+
+        ByteArrayInputStream bais=new ByteArrayInputStream(responseEntity.getBody());
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        LocalDateTime date = LocalDateTime.now();
+        String fileName = "历史数据" + "-" + date.format(f) + ".xls";
 
-    }*/
+        String headStr = "attachment;filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8");
+
+        httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
+        httpServletResponse.setHeader("Content-Disposition", headStr);
+        ServletOutputStream out=httpServletResponse.getOutputStream();
+        while((len=bais.read(b))>0){
+            out.write(b,0,len);
+        }
+        out.flush();
+        out.close();
+        bais.close();
+
+
+    }
 }

+ 3 - 0
src/main/java/com/zoniot/ccrc/dao/DeviceMapper.java

@@ -77,5 +77,8 @@ public interface DeviceMapper {
             @Param("longitudeMax") Double longitudeMax,
             @Param("latitudeMin") Double latitudeMin,
             @Param("latitudeMax") Double latitudeMax);
+
     List<PriceInfo> getPriceInfo();
+
+    Device findByDeviceId(@Param("deviceId") Long deviceId);
 }

+ 1 - 1
src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java

@@ -95,5 +95,5 @@ public interface GridManagementMapper {
     List<Device> getDevices(@Param("buildingId") Integer buildingId,
                             @Param("userId") Integer userId, @Param("address") String address);
 
-    GridManagement getByDeviceId(@Param("deviceId") Long deviceId);
+    List<GridManagement> getByDeviceId(@Param("deviceId") Long deviceId);
 }

+ 48 - 7
src/main/java/com/zoniot/ccrc/scheduled/WarningMessageJob.java

@@ -2,15 +2,14 @@ package com.zoniot.ccrc.scheduled;
 
 
 
-import com.zoniot.ccrc.dao.WarningLogMapper;
-import com.zoniot.ccrc.dao.WarningMessageMapper;
-import com.zoniot.ccrc.dao.WarningRuleMapper;
-import com.zoniot.ccrc.entity.WarningLog;
-import com.zoniot.ccrc.entity.WarningMessage;
-import com.zoniot.ccrc.entity.WarningRule;
+import com.zoniot.ccrc.commom.utils.SendWechatPush;
+import com.zoniot.ccrc.dao.*;
+import com.zoniot.ccrc.entity.*;
+import com.zoniot.ccrc.service.AccessTokenService;
 import com.zoniot.ccrc.service.MongoMeterReadRecordService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -37,6 +36,20 @@ public class WarningMessageJob {
     private WarningMessageMapper warningMessageMapper;
     @Autowired
     private MongoMeterReadRecordService mongoMeterReadRecordService;
+    @Resource
+    private DeviceMapper deviceMapper;
+    @Resource
+    private GridManagementMapper gridManagementMapper;
+    @Autowired
+    private AccessTokenService accessTokenService;
+    @Resource
+    private UserMapper userMapper;
+
+    @Value("${wechat.oa.appid}")
+    private String oaAppid;
+
+    @Value("${wechat.mp.appid}")
+    private String mpAppid;
 
 
     /**
@@ -50,7 +63,9 @@ public class WarningMessageJob {
             for (WarningRule warningRule : list) {
                     Boolean flag =  mongoMeterReadRecordService.complyWithWarningRules(warningRule.getDeviceId(),warningRule.getWarningType());
                     if ( flag) {
-                        addMessageInfo(warningRule,"单日用水量超过2吨");
+                        String content =  "单日用水量超过2吨";
+                        addMessageInfo(warningRule,content);
+                        sendWechatMessage(warningRule.getDeviceId(),content);
                 }
 
 
@@ -83,4 +98,30 @@ public class WarningMessageJob {
         warningMessageNew.setDateUpdate(LocalDateTime.now());
         warningMessageMapper.insertSelective(warningMessageNew);
     }
+
+    private void sendWechatMessage(Long deviceId,String content){
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String url = "https://www.zoniot.com";
+        String pagepath = "pages/index/index";
+        Device device = deviceMapper.findByDeviceId(deviceId);
+
+        String accessToken = accessTokenService.getMpAccessToken();
+
+        List<GridManagement> gridManagementList = gridManagementMapper.getByDeviceId(deviceId);
+        if (gridManagementList != null && gridManagementList.size() > 0) {
+            for (GridManagement gridManagement : gridManagementList) {
+                User user = userMapper.findUserById(gridManagement.getUserId());
+
+                if(user != null && user.getOpenid() !=null && !"".equals(user.getOpenid())){
+
+                    String result = SendWechatPush.sendAbnormalNotice(accessToken, oaAppid, user.getOpenid(), url, mpAppid, pagepath, "用户用水异常", "水量预警", content,
+                            LocalDateTime.now().format(df), device.getMeterNo()+gridManagement.getCustomerName()+gridManagement.getCustomerPhone()+device.getLocDesc()+"用水量有异常情况,请及时关注用户情况!");
+                    log.info("sendWechatMessage :"+result);
+                }
+            }
+        }
+
+
+
+    }
 }

+ 54 - 0
src/main/java/com/zoniot/ccrc/service/AccessTokenService.java

@@ -0,0 +1,54 @@
+package com.zoniot.ccrc.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.zoniot.ccrc.commom.utils.HttpRequest;
+import com.zoniot.ccrc.commom.utils.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+@Slf4j
+@Service
+public class AccessTokenService {
+    @Autowired
+    private RedisUtil redisUtil;
+
+
+    @Value("${wechat.mp.appid}")
+    private String mpAppid;
+    @Value("${wechat.mp.app-secret}")
+    private String mpAppSecret;
+
+    /**
+     * 获取微信小程序accessToken
+     * @return
+     */
+    public String getMpAccessToken(){
+        String token = null;
+        token = redisUtil.get("ccrcMpAccessToken");
+        if (token != null) {
+            return token;
+        }else {
+            String tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" +
+                    mpAppid + "&secret=" + mpAppSecret;
+            try {
+                String res = HttpRequest.doGet(tokenUrl);
+                JSONObject jsonObj = (JSONObject) JSONObject.parse(res);
+                log.info(jsonObj.toJSONString());
+                String accessTokenTem = jsonObj.getString("access_token");
+                if (accessTokenTem != null && !"".equals(accessTokenTem)) {
+                    redisUtil.setExpire("ccrcMpAccessToken",accessTokenTem,300);
+                    return accessTokenTem;
+                } else {
+                    log.info("请求token错误");
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return token;
+    }
+}

+ 15 - 5
src/main/resources/application-dev.properties

@@ -69,7 +69,8 @@ files.path=${project.path}/data
 
 #物联网url
 iot.url=http://114.135.61.188:58080
-
+iot.server=114.135.61.188
+iot.port=58088
 
 #########################################Rabbit MQ ����#############################################
 spring.rabbitmq.host=114.135.61.188
@@ -78,18 +79,27 @@ spring.rabbitmq.username=zoniot
 spring.rabbitmq.password=zcxk100
 spring.rabbitmq.virtual-host=/
 spring.rabbitmq.connection-timeout=1000ms
-# ��������ȷ��
+
 spring.rabbitmq.publisher-confirm-type=correlated
-# ��������ʧ���˻�
+
 spring.rabbitmq.publisher-returns=true
 spring.rabbitmq.template.mandatory=true
-# ����ACK
+
 spring.rabbitmq.listener.direct.acknowledge-mode=manual
 spring.rabbitmq.listener.simple.acknowledge-mode=manual
-# �������
+
 spring.rabbitmq.exchange=sync-handler-exchange
 spring.rabbitmq.device.queue=sync-device-handler-queue
 spring.rabbitmq.community.queue=sync-community-handler-queue
 spring.rabbitmq.building.queue=sync-building-handler-queue
 
 
+
+#中城信科公众号
+wechat.oa.appid=wx6b2ce547cd593413
+#小程序水查查服务
+wechat.mp.appid=wx27f831675081e293
+wechat.mp.app-secret=a01d7f75f15e1a6b7fa28a317f97ef1b
+
+
+

+ 33 - 1
src/main/resources/application-prd.properties

@@ -63,4 +63,36 @@ spring.servlet.multipart.location=${project.path}/data
 files.path=${project.path}/data
 
 #物联网url
-iot.url=http://39.108.175.9:8090
+iot.url=http://39.108.175.9:8090
+iot.server=114.135.61.188
+iot.port=58088
+
+#########################################Rabbit MQ ����#############################################
+spring.rabbitmq.host=114.135.61.188
+spring.rabbitmq.port=55672
+spring.rabbitmq.username=zoniot
+spring.rabbitmq.password=zcxk100
+spring.rabbitmq.virtual-host=/
+spring.rabbitmq.connection-timeout=1000ms
+
+spring.rabbitmq.publisher-confirm-type=correlated
+
+spring.rabbitmq.publisher-returns=true
+spring.rabbitmq.template.mandatory=true
+
+spring.rabbitmq.listener.direct.acknowledge-mode=manual
+spring.rabbitmq.listener.simple.acknowledge-mode=manual
+
+spring.rabbitmq.exchange=sync-handler-exchange
+spring.rabbitmq.device.queue=sync-device-handler-queue
+spring.rabbitmq.community.queue=sync-community-handler-queue
+spring.rabbitmq.building.queue=sync-building-handler-queue
+
+
+
+
+#中城信科公众号
+wechat.oa.appid=wx6b2ce547cd593413
+#小程序水查查服务
+wechat.mp.appid=wx27f831675081e293
+wechat.mp.app-secret=a01d7f75f15e1a6b7fa28a317f97ef1b

+ 31 - 0
src/main/resources/application-sit.properties

@@ -65,3 +65,34 @@ files.path=${project.path}/data
 
 #物联网url
 iot.url=http://114.135.61.188:58080
+iot.server=114.135.61.188
+iot.port=58088
+
+#########################################Rabbit MQ ����#############################################
+spring.rabbitmq.host=114.135.61.188
+spring.rabbitmq.port=55672
+spring.rabbitmq.username=zoniot
+spring.rabbitmq.password=zcxk100
+spring.rabbitmq.virtual-host=/
+spring.rabbitmq.connection-timeout=1000ms
+
+spring.rabbitmq.publisher-confirm-type=correlated
+
+spring.rabbitmq.publisher-returns=true
+spring.rabbitmq.template.mandatory=true
+
+spring.rabbitmq.listener.direct.acknowledge-mode=manual
+spring.rabbitmq.listener.simple.acknowledge-mode=manual
+
+spring.rabbitmq.exchange=sync-handler-exchange
+spring.rabbitmq.device.queue=sync-device-handler-queue
+spring.rabbitmq.community.queue=sync-community-handler-queue
+spring.rabbitmq.building.queue=sync-building-handler-queue
+
+
+
+#中城信科公众号
+wechat.oa.appid=wx6b2ce547cd593413
+#小程序水查查服务
+wechat.mp.appid=wx27f831675081e293
+wechat.mp.app-secret=a01d7f75f15e1a6b7fa28a317f97ef1b

+ 4 - 0
src/main/resources/mapper/DeviceMapper.xml

@@ -643,4 +643,8 @@
   <select id="getPriceInfo" resultType="com.zoniot.ccrc.dto.PriceInfo">
     select * from prict_info
   </select>
+
+  <select id="findByDeviceId" resultMap="BaseResultMap">
+    select * from sc_device where status = 1 and id = #{deviceId}
+  </select>
 </mapper>

+ 1 - 1
src/main/resources/mapper/GridManagementMapper.xml

@@ -233,6 +233,6 @@
     </select>
 
     <select id="getByDeviceId" resultMap="GridManagementMap">
-        select * from sc_grid_management where device_id = #{deviceId}
+        select * from sc_grid_management where status = 1 and device_id = #{deviceId}
     </select>
 </mapper>