Browse Source

生物防控人员2

523096025 1 tháng trước cách đây
mục cha
commit
f42855d940

+ 5 - 10
huimv-admin/src/main/java/com/huimv/admin/HuimvAdminApplication.java

@@ -1,16 +1,10 @@
 package com.huimv.admin;
 
-import org.apache.catalina.Context;
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.descriptor.web.SecurityCollection;
-import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
-import org.apache.tomcat.util.http.LegacyCookieProcessor;
+import com.huimv.admin.server.EnvInputServer;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.web.client.RestTemplate;
@@ -20,8 +14,9 @@ import org.springframework.web.client.RestTemplate;
 @EnableScheduling
 //@EnableDiscoveryClient
 public class HuimvAdminApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(HuimvAdminApplication.class, args);
+    public static void main(String[] args) throws InterruptedException {
+        ConfigurableApplicationContext run = SpringApplication.run(HuimvAdminApplication.class, args);
+        run.getBean(EnvInputServer.class).run();
     }
     @Bean
     public static RestTemplate getRestTemplate(){

+ 4 - 0
huimv-admin/src/main/java/com/huimv/admin/controller/ProtDataController.java

@@ -32,6 +32,10 @@ public class ProtDataController {
     public Result list(HttpServletRequest httpServletRequest, @RequestBody Map<String,String> paramsMap) {
         return protDataService.list(httpServletRequest,paramsMap);
     }
+    @RequestMapping("/listFlowScreen")
+    public Result listScreen(HttpServletRequest httpServletRequest, @RequestBody Map<String,String> paramsMap) {
+        return protDataService.listFlowScreen(httpServletRequest,paramsMap);
+    }
 
     @RequestMapping("/listWarning")
     public Result listWarning(HttpServletRequest httpServletRequest, @RequestBody Map<String,String> paramsMap) {

+ 74 - 0
huimv-admin/src/main/java/com/huimv/admin/server/EnvInputServer.java

@@ -0,0 +1,74 @@
+package com.huimv.admin.server;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class EnvInputServer {
+    @Autowired
+    private EnvInputServerHandler serverHandler;
+    //监听端口
+    private int port = 3728;
+    //创建构造方法
+    public EnvInputServer(){
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EnvInputServer().run();
+    }
+/**
+ *
+ * 功能描述: 启动方法前台多个服务  处理多个线程
+ *
+ * @param:
+ * @return:
+ * @auther: LiGang
+ * @date: 2019/3/26 11:31
+ */
+    /**
+     * 启动流程
+     */
+    public void run() throws InterruptedException {
+        //配置服务端线程组
+        EventLoopGroup bossGroup=new NioEventLoopGroup();
+        EventLoopGroup workGroup=new NioEventLoopGroup();
+
+        try{
+            //引导整个server的启动
+            ServerBootstrap serverBootstrap = new ServerBootstrap();
+            serverBootstrap.group(bossGroup,workGroup)
+                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
+                    .childHandler(new ChannelInitializer<SocketChannel>() {
+                        @Override
+                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            socketChannel.pipeline().addLast(serverHandler);
+                        }
+                    });
+            System.out.println("# 耳标及采集器设备数据接收服务器已经启动,监听端口(Port):"+port);
+            System.out.println("# 准备接收数据:");
+            //绑定端口,同步等待成功
+            ChannelFuture cf = serverBootstrap.bind(port).sync();
+            // 等待服务端监听端口关闭
+            cf.channel().closeFuture().sync();
+        }finally {
+            //优雅的退出
+            bossGroup.shutdownGracefully();
+            workGroup.shutdownGracefully();
+        }
+    }
+}

+ 378 - 0
huimv-admin/src/main/java/com/huimv/admin/server/EnvInputServerHandler.java

@@ -0,0 +1,378 @@
+package com.huimv.admin.server;
+
+import com.alibaba.fastjson.JSONArray;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ChannelHandler.Sharable
+@Component
+@Slf4j
+public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
+    private StringBuilder askTextSb = null;
+
+    //
+    public void appendClientAsk(String text) {
+        if (this.askTextSb == null) {
+            askTextSb = new StringBuilder();
+        }
+        askTextSb.append(text);
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf data = (ByteBuf) msg;
+        String clientAskText = data.toString(CharsetUtil.UTF_8);
+        //保存实例内的客户端请求
+        appendClientAsk(clientAskText);
+        //临时写入耳标数据到文件
+//        writeTxt(clientAskText,"all");
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+//        if (askTextSb.toString().indexOf("end") != -1) {
+            // {处理客户端消息}
+            handleClientAskCmd(askTextSb.toString(), ctx);
+            //清空重置;
+            askTextSb.delete(0, askTextSb.length());
+//        }
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        if (cause.getMessage().indexOf("Connection reset") != -1) {
+            log.info("相关采集器设备正在重启:" + cause.toString());
+        }
+//        cause.printStackTrace();
+        ctx.close();
+    }
+
+    /**
+     * @Method : handleClientAskCmd
+     * @Description : 处理请求小心
+     * @Params : [clientAskText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/28
+     * @Time : 17:36
+     */
+
+
+    private void handleClientAskCmd(String clientAskText, ChannelHandlerContext ctx) throws ParseException, IOException {
+
+        System.out.println("接收到消息: " + clientAskText + "  时间: " + System.currentTimeMillis());
+
+        askTextSb.delete(0, askTextSb.length());
+    }
+
+    /**
+     * @Method : askCmdActuator
+     * @Description :
+     * @Params : [askText, ctx]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/3/23
+     * @Time : 18:08
+     */
+    private void askCmdActuator(String askText, ChannelHandlerContext ctx) throws ParseException, IOException {
+        System.out.println("======>接收设备请求:" + askText);
+        String[] dataArray = askText.split("\\+");
+        String cmdHeader = dataArray[0];
+        if (!cmdHeader.trim().equalsIgnoreCase("hm")) {
+            log.info("当前命令是非hm命令[" + askText + "]");
+            return;
+        }
+        //芯片id/设备编码
+        String idCode = dataArray[1];
+        String cmd = dataArray[2];
+        Map map = new HashMap();
+        map.put("askText", askText);
+//        rawDataService.insert(idCode,askText);
+        switch (cmd) {
+//            case "1":
+//                //获取远程设备编码
+//                getDeviceCode(askText, idCode, ctx);
+//                break;
+//            case "2":
+//                //同步时间
+//                getServerTime(askText, idCode, ctx);
+//                break;
+//            case "3":
+//                //日龄上传
+//                uploadDayAge(askText, idCode, ctx);
+//                break;
+//            case "4":
+//                //通风等级
+//                uploadFeng(askText, idCode, ctx);
+//                break;
+//            case "5":
+//                //室外温度
+//                uploadOutTemp(askText, idCode, ctx);
+//                break;
+//            case "6":
+//                //室内温度 平均温度
+//                uploadInTemp(askText, idCode, ctx);
+//                break;
+//            case "7":
+//                //目标温度
+//                uploadTargetnTemp(askText, idCode, ctx);
+//                break;
+//            case "8":
+//                //水暖温度
+//                uploadShuiNuanTemp(askText, idCode, ctx);
+//                break;
+//            case "9":
+//                //水暖温度
+//                uploadWeiZhiTemp(askText, idCode, ctx);
+//                break;
+//            case "21":
+//                //温度
+//                uploadTemp(askText, idCode, ctx);
+//                break;
+//            case "22":
+//                //湿度
+//                uploadHumi(askText, idCode, ctx);
+//                break;
+//            case "23":
+//                //co2
+//                uploadCo2(dataArray,askText, idCode, ctx);
+//                break;
+//            case "24":
+//                //压力
+//                uploadYaLi(dataArray,askText, idCode, ctx);
+//                break;
+//            case "31":
+//                //水表
+//                uploadShuiBiao(dataArray,askText, idCode, ctx);
+//                break;
+//            case "32":
+//                //电表
+//                uploadDianBiao(dataArray,askText, idCode, ctx);
+//                break;
+//            case "41":
+//                //报警
+//                uploadWarning(askText, idCode, ctx);
+//                break;
+//            case "42":
+//                //报警
+//                uploadStatusWaraning(askText, idCode, ctx);
+//                break;
+//            case "61":
+//                //风机状态
+//                uploadFengStatus(askText, idCode, ctx);
+//                break;
+//            case "62":
+//                //湿帘状态
+//                uploadShiLianStatus(askText, idCode, ctx);
+//                break;
+//            case "63":
+//                //喷雾状态
+//                uploadPengWuStatus(askText, idCode, ctx);
+//                break;
+//            case "64":
+//                //加热器状态
+//                uploadJiaReQiStatus(askText, idCode, ctx);
+//                break;
+//            case "65":
+//                //小窗状态
+//                uploadXiaoChuangStatus(askText, idCode, ctx);
+//                break;
+//            case "66":
+//                //导流板状态
+//                uploadDaoLiuBanStatus(askText, idCode, ctx);
+//                break;
+//            case "67":
+//                //照明状态
+//                uploadZhaoMingStatus(askText, idCode, ctx);
+//                break;
+//            case "81":
+//                //日龄配置
+//                uploadDayAgePeizhiuStatus(askText, idCode, ctx);
+//                break;
+//            case "82":
+//                //通风级别配置
+//                uploadTongFengPeizhiuStatus(askText, idCode, ctx);
+//                break;
+//            case "91":
+//                //通获取日龄配置
+//                uploadGainDayAgePeizhiuStatus(dataArray,askText, idCode, ctx);
+//                break;
+//            case "92":
+//                //通风级别配置
+//                uploadGainTongFengPeizhiuStatus(dataArray,askText, idCode, ctx);
+//                break;
+//            default:
+//                System.out.println("==>未知命令");
+//                log.error(">>当前数据为非法数据-未知命令>>" + askText);
+        }
+    }
+//
+//    private void uploadZhaoMingStatus(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#照明状态上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+67+0+4+end";
+//        log.info(">>照明状态上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        producer.sendZhaoMingStatus(askText);
+//    }
+//
+//    private void uploadDaoLiuBanStatus(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#导流板状态上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+66+0+4+end";
+//        log.info(">>导流板状态上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        producer.sendDaoLiuStatus(askText);
+//    }
+//
+//    private void uploadXiaoChuangStatus(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#小窗状态上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+65+0+4+end";
+//        log.info(">>小窗状态上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendXiaoChuangStatus(askText);
+//    }
+//
+//    private void uploadJiaReQiStatus(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#加热状态上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+64+0+4+end";
+//        log.info(">>加热温度上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendJiaReStatus(askText);
+//    }
+//
+//    private void uploadDianBiao(String[] dataArray, String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#电表上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+32+0+4+end";
+//        log.info(">>电表上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendDianBiaoData(askText);
+//    }
+//
+//    private void uploadShuiBiao(String[] dataArray, String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("#水表上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+31+0+4+end";
+//        log.info(">>水表温度上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendShuiBiaoData(askText);
+//    }
+//    private void uploadWeiZhiTemp(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("##位置温度上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+9+0+4+end";
+//        log.info(">>位置温度上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendWeiZhi(askText);
+//    }
+//
+//    private void uploadShuiNuanTemp(String askText, String idCode, ChannelHandlerContext ctx) {
+//
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("##水暖上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+8+0+4+end";
+//        log.info(">>水暖上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendShuiNuan(askText);
+//    }
+//
+//    private void uploadStatusWaraning(String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("##状态报警上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+42+0+2+end";
+//        log.info(">>状态报警上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendWarning(askText);
+//    }
+//
+//    private void uploadYaLi(String[] dataArray, String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("##压力 上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        String answerText = "hm+24+0+8+end";
+//        log.info(">>压力  等级上传请求-应答数据>>" + answerText);
+//        answerCmd(answerText, ctx);
+//        //发送湿度请求到消息队列
+//        producer.sendYaLi(askText);
+//    }
+//
+//    private void uploadCo2(String[] dataArray, String askText, String idCode, ChannelHandlerContext ctx) {
+//        if (!cmdProService.isEffectiveDevice(idCode)) {
+//            System.out.println("##CO2 上传请求-未注册设备 idCode=" + idCode);
+//            return;
+//        }
+//        //TODO
+//        String answerText = "hm+23+0+8+end";
+
+//    //拆分粘包数据
+    public JSONArray parseAskCmdPackage(String text) {
+        String key = "end";
+        Pattern pattern = Pattern.compile(key);
+        Matcher matcher = pattern.matcher(text);
+        int count = 0;
+        while (matcher.find()) {
+            count++;
+        }
+        JSONArray dataJa = new JSONArray();
+        if (count == 1) {
+            dataJa.add(text);
+        } else {
+            for (int a = 0; a < count; a++) {
+                int p1 = text.indexOf("end");
+                dataJa.add(text.substring(0, p1 + 3));
+                text = text.substring(p1 + 3, text.length());
+            }
+        }
+        return dataJa;
+    }
+}

+ 4 - 0
huimv-admin/src/main/java/com/huimv/admin/service/IProtDataService.java

@@ -26,4 +26,8 @@ public interface IProtDataService extends IService<ProtData> {
 
     /*大屏环保监测*/
     Result listScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+
+    Result listFlowScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+
+//    Result listFlowScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
 }

+ 56 - 0
huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtDataServiceImpl.java

@@ -1075,5 +1075,61 @@ public class ProtDataServiceImpl extends ServiceImpl<ProtDataMapper, ProtData> i
         return new Result(ResultCode.SUCCESS, jsonObject);
     }
 
+    @Override
+    public Result listFlowScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+        String farmId = paramsMap.get("farmId");
+
+        QueryWrapper<ProtData> protDataQueryWrapper = new QueryWrapper<>();
+        ArrayList<Map> maps = new ArrayList<>();
+        Date now = new Date();
+        for (int i = 0; i < 8; i++) {
+            DateTime dateTime = DateUtil.offsetDay(now, -i);
+            HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
+            ProtData protData = getListFlowScreenWrapper(protDataQueryWrapper,1,dateTime,farmId);
+            objectObjectHashMap.put("createDate",protData.getCreateDate());
+            ProtData protData2 = getListFlowScreenWrapper(protDataQueryWrapper,2,dateTime,farmId);
+            ProtData protData3 = getListFlowScreenWrapper(protDataQueryWrapper,3,dateTime,farmId);
+            objectObjectHashMap.put("in",ObjectUtil.isEmpty(protData) ? "0": protData.getFlow());
+            objectObjectHashMap.put("deal",ObjectUtil.isEmpty(protData) ? "0": protData2.getFlow());
+            objectObjectHashMap.put("out",ObjectUtil.isEmpty(protData) ? "0": protData3.getFlow());
+           maps.add(objectObjectHashMap);
+        }
+        return new Result(ResultCode.SUCCESS,maps);
+    }
+
+    private ProtData getListFlowScreenWrapper(QueryWrapper<ProtData> protDataQueryWrapper, int loctionType ,DateTime dateTime,String farmId) {
+        protDataQueryWrapper.clear();
+        protDataQueryWrapper.eq("farm_id",farmId);
+        protDataQueryWrapper.between("create_date",DateUtil.beginOfDay(dateTime),DateUtil.endOfDay(dateTime));
+        protDataQueryWrapper.eq("loction_type",loctionType);
+        protDataQueryWrapper.orderByDesc("id").last("limit 1");
+        return   this.getOne(protDataQueryWrapper);
+    }
+
+//    @Override
+//    public Result listFlowScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+//        QueryWrapper<ProtData> queryWrapper = new QueryWrapper<>();
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
+//        Date dateTime = calendar.getTime();
+//
+//        queryWrapper.ge("create_date", dateTime);
+//        queryWrapper.eq("loction_type", 1);
+//        List<ProCountVo> protData1 = protDataMapper.listFlow(queryWrapper);
+//        proCountDto.setInList(protData1);
+//
+//        QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
+//        queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
+//        queryWrapper2.eq("loction_type", 2);
+//        List<ProCountVo> protData2 = protDataMapper.listFlow(queryWrapper2);
+//        proCountDto.setDealList(protData2);
+//
+//        QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
+//        queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
+//        queryWrapper3.eq("loction_type", 3);
+//        List<ProCountVo> protData3 = protDataMapper.listFlow(queryWrapper3);
+//        proCountDto.setOutList(protData3);
+//    }
+
 
 }

+ 12 - 0
huimv-admin/src/main/java/com/huimv/admin/timer/WaterAndElcTimer.java

@@ -2701,6 +2701,7 @@ public class WaterAndElcTimer {
                   energyScreen.setDayDifference(day4);
                   energyScreen.setWeekDifference(week3);
                   energyScreen.setMonthDifference(month3);
+                  energyScreen.setBuildName(envDevice.getUnitName());
               } else if ("3".equals(envDevice.getRemark())) {
                   //用料
                   energyScreen.setCreateDate(new Date());
@@ -2723,6 +2724,7 @@ public class WaterAndElcTimer {
                   String month3 = def.format(month1 - month2);
                   energyScreen.setDayDifference(day4);
                   energyScreen.setWeekDifference(week3);
+                  energyScreen.setBuildName(envDevice.getUnitName());
                   energyScreen.setMonthDifference(month3);
               } else {
 
@@ -2735,6 +2737,7 @@ public class WaterAndElcTimer {
                   energyScreen.setLastWeekConsume(dataScreenVo.getElectricityValueLastWeekUsage());
                   energyScreen.setMonthConsume(dataScreenVo.getElectricityValueThisMonthUsage());
                   energyScreen.setLastMonthConsume(dataScreenVo.getElectricityValueLastMonthUsage());
+                  energyScreen.setBuildName(envDevice.getUnitName());
                   double day2 = Double.parseDouble(dataScreenVo.getElectricityValueTodayUsage());
                   double day3 = Double.parseDouble(dataScreenVo.getElectricityValueYesterdayUsage());
                   double week1 = Double.parseDouble(dataScreenVo.getElectricityValueThisWeekUsage());
@@ -2884,6 +2887,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getWaterValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getWaterValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getWaterValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getWaterValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getWaterValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getWaterValueThisWeekUsage());
@@ -2907,6 +2911,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getFeedValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getFeedValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getFeedValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getFeedValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getFeedValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getFeedValueThisWeekUsage());
@@ -2930,6 +2935,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getElectricityValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getElectricityValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getElectricityValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getElectricityValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getElectricityValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getElectricityValueThisWeekUsage());
@@ -3079,6 +3085,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getWaterValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getWaterValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getWaterValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getWaterValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getWaterValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getWaterValueThisWeekUsage());
@@ -3108,6 +3115,7 @@ public class WaterAndElcTimer {
                     double week2 = Double.parseDouble(dataScreenVo.getFeedValueLastWeekUsage());
                     double month1 = Double.parseDouble(dataScreenVo.getFeedValueThisMonthUsage());
                     double month2 = Double.parseDouble(dataScreenVo.getFeedValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     DecimalFormat def = new DecimalFormat("0.00");
                     String day4 = def.format(day2 - day3);
                     String week3 = def.format(week1 - week2);
@@ -3131,6 +3139,7 @@ public class WaterAndElcTimer {
                     double week2 = Double.parseDouble(dataScreenVo.getElectricityValueLastWeekUsage());
                     double month1 = Double.parseDouble(dataScreenVo.getElectricityValueThisMonthUsage());
                     double month2 = Double.parseDouble(dataScreenVo.getElectricityValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     DecimalFormat def = new DecimalFormat("0.00");
                     String day4 = def.format(day2 - day3);
                     String week3 = def.format(week1 - week2);
@@ -3280,6 +3289,7 @@ public class WaterAndElcTimer {
                     double week2 = Double.parseDouble(dataScreenVo.getWaterValueLastWeekUsage());
                     double month1 = Double.parseDouble(dataScreenVo.getWaterValueThisMonthUsage());
                     double month2 = Double.parseDouble(dataScreenVo.getWaterValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     DecimalFormat def = new DecimalFormat("0.00");
                     String day4 = def.format(day2 - day3);
                     String week3 = def.format(week1 - week2);
@@ -3297,6 +3307,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getFeedValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getFeedValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getFeedValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getFeedValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getFeedValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getFeedValueThisWeekUsage());
@@ -3320,6 +3331,7 @@ public class WaterAndElcTimer {
                     energyScreen.setLastWeekConsume(dataScreenVo.getElectricityValueLastWeekUsage());
                     energyScreen.setMonthConsume(dataScreenVo.getElectricityValueThisMonthUsage());
                     energyScreen.setLastMonthConsume(dataScreenVo.getElectricityValueLastMonthUsage());
+                    energyScreen.setBuildName(envDevice.getUnitName());
                     double day2 = Double.parseDouble(dataScreenVo.getElectricityValueTodayUsage());
                     double day3 = Double.parseDouble(dataScreenVo.getElectricityValueYesterdayUsage());
                     double week1 = Double.parseDouble(dataScreenVo.getElectricityValueThisWeekUsage());

+ 5 - 35
huimv-receive/src/main/java/com/huimv/receive/ReceiveApplication.java

@@ -1,49 +1,19 @@
 package com.huimv.receive;
 
-import org.apache.catalina.Context;
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.descriptor.web.SecurityCollection;
-import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
+import org.springframework.context.ConfigurableApplicationContext;
 
 @SpringBootApplication
 @MapperScan("com.huimv.receive.mapper")
 public class ReceiveApplication {
 
     public static void main(String[] args) {
-        SpringApplication.run(ReceiveApplication.class, args);
+        ConfigurableApplicationContext run = SpringApplication.run(ReceiveApplication.class, args);
+
+//        ApplicationContext applicationContext = SpringApplication.run(ReceiveApplication.class, args);
+
     }
 
-//    @Bean
-//    public TomcatServletWebServerFactory servletContainer() {
-//        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
-//            @Override
-//            protected void postProcessContext(Context context) {
-//                SecurityConstraint constraint = new SecurityConstraint();
-//                constraint.setUserConstraint("CONFIDENTIAL");
-//                SecurityCollection collection = new SecurityCollection();
-//                collection.addPattern("/*");
-//                constraint.addCollection(collection);
-//                context.addConstraint(constraint);
-//            }
-//        };
-//        tomcat.addAdditionalTomcatConnectors(httpConnector());
-//        return tomcat;
-//    }
-//
-//    @Bean
-//    public Connector httpConnector() {
-//        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
-//        connector.setScheme("http");
-//        //Connector监听的http的默认端口号
-//        connector.setPort(8014);
-//        connector.setSecure(false);
-//        //监听到http的端口号后转向到的https的端口号,也就是项目配置的port
-//        connector.setRedirectPort(8015);
-//        return connector;
-//    }
 }

+ 2 - 2
huimv-receive/src/main/java/com/huimv/receive/controller/SysUserController.java

@@ -182,7 +182,7 @@ public class SysUserController {
             if (!PhoneNumberValidator.isValidPhoneNumber(userPhone)) {
                 return new Result(10001,"手机号格式不正确",false);
             }
-            int count = sysUserService.count(new QueryWrapper<SysUser>().eq("user_phone", userPhone)) ;
+            int count = sysUserService.count(new QueryWrapper<SysUser>().eq("user_phone", userPhone).ne("id",sysUser.getId())) ;
             if (count >0) {
                 return new Result(10001,"手机号已存在",false);
             }
@@ -191,7 +191,7 @@ public class SysUserController {
             if (StringUtils.isNotBlank(cardNum) && "身份证".equals(cardType) && !IDCardValidator.isValidIDCard(cardNum)) {
                 return new Result(10001,"身份证格式不正确",false);
             }
-            int countUserPhone = sysUserService.count(new QueryWrapper<SysUser>().eq("card_type", cardType).eq("card_num", cardNum));
+            int countUserPhone = sysUserService.count(new QueryWrapper<SysUser>().eq("card_type", cardType).eq("card_num", cardNum).ne("id",sysUser.getId()));
             if (countUserPhone >0) {
                 return new Result(10001,"身份证已存在",false);
             }