Pārlūkot izejas kodu

添加本地文件

lixinru 4 gadi atpakaļ
vecāks
revīzija
af122700c0
40 mainītis faili ar 3804 papildinājumiem un 0 dzēšanām
  1. 377 0
      src/main/java/com/usky/controller/HtController.java
  2. 11 0
      src/main/java/com/usky/controller/LoraRegistController.java
  3. 7 0
      src/main/java/com/usky/dao/BaseDao.java
  4. 29 0
      src/main/java/com/usky/dao/Impl/BaseDaoImpl.java
  5. 50 0
      src/main/java/com/usky/entity/OnlinrType.java
  6. 398 0
      src/main/java/com/usky/entity/Sp_Iw2017.java
  7. 108 0
      src/main/java/com/usky/entity/Sp_Lora_Device.java
  8. 252 0
      src/main/java/com/usky/entity/Sp_Lora_WAN.java
  9. 40 0
      src/main/java/com/usky/entity/Yt_Lora_Data.java
  10. 269 0
      src/main/java/com/usky/entity/Yt_T_Lrdevice.java
  11. 8 0
      src/main/java/com/usky/service/BaseServie.java
  12. 37 0
      src/main/java/com/usky/service/HtService.java
  13. 22 0
      src/main/java/com/usky/service/Impl/BaseServieImpl.java
  14. 605 0
      src/main/java/com/usky/service/Impl/HtServiceImpl.java
  15. 68 0
      src/main/java/com/usky/service/Impl/NBServiceImpl.java
  16. 69 0
      src/main/java/com/usky/service/Impl/SearchertypeTaskImpl.java
  17. 198 0
      src/main/java/com/usky/service/Impl/SendWXServiceImpl.java
  18. 170 0
      src/main/java/com/usky/service/Impl/aaaServiceImpl.java
  19. 65 0
      src/main/java/com/usky/service/Impl/bbbServiceImpl.java
  20. 12 0
      src/main/java/com/usky/service/NBService.java
  21. 16 0
      src/main/java/com/usky/service/SendWXService.java
  22. 27 0
      src/main/java/com/usky/service/aaaService.java
  23. 21 0
      src/main/java/com/usky/service/bbbService.java
  24. 12 0
      src/main/java/com/usky/service/test.java
  25. 29 0
      src/main/java/com/usky/utils/ApplicationContextUtil.java
  26. 53 0
      src/main/java/com/usky/utils/BeanHelp.java
  27. 151 0
      src/main/java/com/usky/utils/HttpClientUtilWX.java
  28. 138 0
      src/main/java/com/usky/utils/HttpClientUtils.java
  29. 37 0
      src/main/java/com/usky/utils/ListUtil.java
  30. 99 0
      src/main/java/com/usky/utils/MD5Util.java
  31. 19 0
      src/main/java/com/usky/utils/NFDFlightDataTaskListener.java
  32. 40 0
      src/main/java/com/usky/utils/NFDFlightDataTimerTask.java
  33. 38 0
      src/main/java/com/usky/utils/SpringTask.java
  34. 51 0
      src/main/java/com/usky/utils/TimerManager.java
  35. 4 0
      src/main/resources/jdbc.properties
  36. 24 0
      src/main/resources/log4j.properties
  37. 143 0
      src/main/resources/spring/applicationContext.xml
  38. 27 0
      src/main/resources/spring/springmvc-servlet.xml
  39. 70 0
      src/main/webapp/WEB-INF/web.xml
  40. 10 0
      src/main/webapp/index.html

+ 377 - 0
src/main/java/com/usky/controller/HtController.java

@@ -0,0 +1,377 @@
+package com.usky.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.usky.entity.Sp_Lora_WAN;
+import com.usky.service.HtService;
+import com.usky.service.NBService;
+
+import com.usky.service.aaaService;
+import com.usky.service.bbbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.sql.Date;
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+
+@Controller
+@RequestMapping("user")
+public class HtController {
+    private static final Logger LOGGER = Logger.getLogger(HtController.class);
+    @Autowired
+    private HtService htServiceImpl;
+
+    @Autowired
+    private NBService nbServiceImpl;
+
+    @Autowired
+    private aaaService aaaService;
+
+    @Autowired
+    private bbbService bbbService;
+
+    @RequestMapping("demo")
+    @ResponseBody
+    public void demo(HttpServletRequest request) {
+        long startTime = System.currentTimeMillis();
+
+        LOGGER.info("********************************开始接收数据*");
+        HashMap<String, String> map = new HashMap<>();
+        //接收数据
+        String s = null;
+        try {
+            s = htServiceImpl.getStr(request);
+            System.out.println("s = " + s);
+
+//        //判断网关
+//        Sp_Lora_WAN sp_lora_wan = new Sp_Lora_WAN();
+// sp_lora_wan = JSON.parseObject(s, Sp_Lora_WAN.class);
+//        String state = sp_lora_wan.getState();
+//        //设备id
+//        String devid = sp_lora_wan.getDevid();
+//        System.out.println("devid = " + devid);
+//        //设备类型
+//        String l_name = sp_lora_wan.getL_name();
+//        System.out.println("l_name = " + l_name);
+//        String name = l_name.substring(2, 4);
+//        String name1 = String.valueOf(Integer.parseInt(name, 16));
+//        System.out.println("name1 = " + name1);
+//        //项目
+//        String code = l_name.substring(4, l_name.length());
+//        String code1 = String.valueOf(Integer.parseInt(code, 16));
+//        map.put("dwtype",name);
+//        map.put("company",code1);
+//        map.put("deviceid",devid);
+//        //StringBuffer
+//        String tab="yt"+name+code1+"_"+devid;
+//        //String tab1="a";
+//        System.out.println("表名="+tab);
+//        JSONObject jsonObject = JSON.parseObject(state);
+//        JSONObject gwinfo1 = jsonObject.getJSONObject("gwinfo");
+//        System.out.println("gwinfo1 = " + gwinfo1);
+//        //JSONObject payload1 = jsonObject.getJSONObject("payload");
+//        Object payload1 = jsonObject.get("payload");
+//        String payload = String.valueOf(payload1);
+//        //String payload= String.valueOf(jsonObject.getJSONObject("payload"));
+//        System.out.println("payload = " + payload);
+//        //拿到网关id
+//        String wanId = (String)gwinfo1.get("id");
+//        System.out.println("wanId = " + wanId);
+///////////////////////////////////////////////////////////////////////////////////
+
+
+            JSONObject service = JSON.parseObject(s);
+            Object timee = service.get("time");
+            String time = String.valueOf(timee);
+            System.out.println("time = " + time);
+            JSONObject state = service.getJSONObject("state");
+            JSONObject gwinfo1 = state.getJSONObject("gwinfo");
+            Object payload1 = state.get("payload");
+            String payload = String.valueOf(payload1);
+
+
+//设备id
+            String devid = (String) service.get("deveui");
+            //设备类型
+            String l_name = (String) service.get("l_name");
+            System.out.println("l_name = " + l_name);
+            String name = l_name.substring(2, 4);
+            String name1 = String.valueOf(Integer.parseInt(name, 16));
+            System.out.println("name1 = " + name1);
+            //项目
+            String code = l_name.substring(4, l_name.length());
+            String code1 = String.valueOf(Integer.parseInt(code, 16));
+            map.put("dwtype", name);
+            map.put("company", code1);
+            map.put("deviceid", devid);
+
+//拿到网关id
+            String wanId = (String) gwinfo1.get("id");
+
+
+//        //StringBuffer
+            String tab = "yt" + name + code1 + "_" + devid;
+
+
+            //判断是此网关id才保存
+            if (wanId.equals("009D9AFFFE9AE0F7")) {
+                //解析之前存网关表
+                System.out.println("=========== = ");
+                LOGGER.info("********************************解析之前存网关表*");
+                //int id1 = htServiceImpl.saveLora(sp_lora_wan);
+                int id = htServiceImpl.saveLoradata(devid, s);
+                String loraWanId = String.valueOf(id);
+                System.out.println("主键" + loraWanId);
+                //生成唯一标识   存sp_owner和lora设备表
+                //是否新 设备 返回唯一标识
+                String num = htServiceImpl.query(map);
+
+                //解析之后存设备表   需要建表 判断是否为烟感
+                if ("1".equals(name1)) {
+
+                    //解析之后存设备表   需要建表 判断是否为烟感
+                    //建表
+                    htServiceImpl.cretTab1(tab);
+                    //解析烟感保存  需要唯一码
+                    LOGGER.info("********************************解析数据存设备表(烟感)****网关表id:" + id);
+                    htServiceImpl.saveYG(payload, num, tab, loraWanId, devid, time);
+                    //生成设备唯一标识码
+                } else if ("2".equals(name1) || "3".equals(name1)) {
+                    //液位表、压力表
+                    htServiceImpl.cretTab2(tab);
+                    LOGGER.info("********************************解析数据存设备表(水表)****网关表id:" + id);
+                    htServiceImpl.save02and03(payload, num, tab, loraWanId, devid, time);
+
+
+                } else {
+                    System.out.println("未知设备类型");
+                }
+
+
+                System.out.println("结束");
+
+                //mqttUtil.addMqttPayload(lora_wan);
+                //test.cret();
+            } else {
+                System.out.println("非自己网关");
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            LOGGER.error("*****************************解析异常****" + e.getMessage());
+        }
+
+
+        long endTime = System.currentTimeMillis();
+        java.sql.Date date1 = new Date(endTime);
+        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        String dateStr1 = sdf1.format(date1);
+        long usedTime = (endTime - startTime) / 1000;
+        LOGGER.info("********************************解析数据完成*****耗时:" + usedTime + "秒************");
+
+
+        //return s;
+
+
+    }
+
+
+    @RequestMapping("nBdeviceCover")
+    @ResponseBody
+    public String nBdeviceCover(HttpServletRequest request) {
+        long startTime = System.currentTimeMillis();
+        LOGGER.info("********************************开始接收井盖数据*");
+        try {
+            String s = nbServiceImpl.getStr(request);
+            System.out.println("s = " + s);
+            LOGGER.info("********************************开始解析*");
+            nbServiceImpl.saveCover(s);
+        } catch (IOException e) {
+            e.printStackTrace();
+            LOGGER.error("*****************************解析异常****" + e.getMessage());
+        } finally {
+            long endTime = System.currentTimeMillis();
+            long usedTime = (endTime - startTime) / 1000;
+            LOGGER.info("********************************解析数据完成****耗时:" + usedTime + "秒************");
+        }
+        System.out.println("結束");
+        return "200";
+
+    }
+
+
+    @RequestMapping("aaa")
+    @ResponseBody
+    public void a(HttpServletRequest request) {
+
+        LOGGER.info("test接口");
+        LOGGER.debug("debug!!!");
+        // LOGGER.warn("warn!!!");
+        LOGGER.error("error!!!");
+        // LOGGER.fatal("fatal!!!");
+        System.out.println(1 / 0);
+
+        //testimpl.aaa();
+        System.out.println("s = *******************************************");
+        LOGGER.info("test接口====");
+    }
+
+
+    @RequestMapping("test")
+    public void getData(HttpServletRequest request) {
+//        LOGGER.info("test接口");
+//        LOGGER.debug("debug!!!");
+//        // LOGGER.warn("warn!!!");
+//        LOGGER.error("error!!!");
+//        // LOGGER.fatal("fatal!!!");
+//        System.out.println("s = *******************************************" );
+//        LOGGER.info("test接口====");
+        long startTime = System.currentTimeMillis();
+        try {
+            for (int i = 1; i <= 2; i++) {
+                aaaService.doTaskOne();
+                aaaService.doTaskTwo();
+                aaaService.doTaskThree();
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        System.out.println("usedTime = " + usedTime);
+    }
+
+    @RequestMapping("test1")
+    public void getData1(HttpServletRequest request) {
+        LOGGER.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+        long startTime = System.currentTimeMillis();
+        try {
+            for (int i = 1; i <= 2; i++) {
+                bbbService.doTaskOne();
+                bbbService.doTaskTwo();
+                bbbService.doTaskThree();
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        long endTime = System.currentTimeMillis();
+        long usedTime = (endTime - startTime) / 1000;
+        System.out.println("usedTime1 = " + usedTime);
+        LOGGER.info("==============================================================");
+
+    }
+
+
+    @RequestMapping("te")
+    public void getD(HttpServletRequest request) {
+
+        long startTime = System.currentTimeMillis();
+
+
+        try {
+            aaaService.abb();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        System.out.println("usedTime = " + usedTime);
+    }
+
+
+    @RequestMapping("loralogin")
+    public String loralogin(HttpServletRequest request,
+                            @RequestParam(value = "username", required = true) String username,
+                            @RequestParam(value = "password", required = true) String password
+
+    ) {
+
+        long startTime = System.currentTimeMillis();
+
+
+        String s = aaaService.loralogin(request, username, password);
+
+
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        System.out.println("usedTime = " + usedTime);
+        return s;
+    }
+
+    @RequestMapping("loradelogin")
+    public String loradevicelogin(HttpServletRequest request,
+                                  @RequestParam(value = "pno", required = true) String pno,
+                                  @RequestParam(value = "dno", required = true) String dno,
+                                  @RequestParam(value = "profile", required = true) String profile,
+                                  @RequestParam(value = "dev_addr", required = true) String dev_addr,
+                                  @RequestParam(value = "nwk_skey", required = true) String nwk_skey,
+                                  @RequestParam(value = "app_skey", required = true) String app_skey,
+                                  @RequestParam(value = "device_type", required = true) String device_type) {
+        HttpSession session = request.getSession();
+        Object token = session.getAttribute("token");
+        System.out.println("seesion==============" + token.toString());
+        long startTime = System.currentTimeMillis();
+        JSONObject json = new JSONObject();
+        json.put("pno", pno);
+        json.put("dno", dno);
+        json.put("profile", profile);
+        json.put("dev_addr", dev_addr);
+        json.put("nwk_skey", nwk_skey);
+        json.put("app_skey", app_skey);
+        json.put("device_type", device_type);
+
+        String s = aaaService.loradevicelogin(json);
+
+
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        System.out.println("usedTime = " + usedTime);
+        return s;
+    }
+
+
+    @RequestMapping("delet")
+    public void delet(HttpServletRequest request) {
+        bbbService.delet();
+
+
+    }
+
+
+}
+
+
+

+ 11 - 0
src/main/java/com/usky/controller/LoraRegistController.java

@@ -0,0 +1,11 @@
+package com.usky.controller;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public class LoraRegistController {
+}

+ 7 - 0
src/main/java/com/usky/dao/BaseDao.java

@@ -0,0 +1,7 @@
+package com.usky.dao;
+
+import org.hibernate.Session;
+
+public interface BaseDao {
+    public Session getSession();
+}

+ 29 - 0
src/main/java/com/usky/dao/Impl/BaseDaoImpl.java

@@ -0,0 +1,29 @@
+package com.usky.dao.Impl;
+
+import com.usky.dao.BaseDao;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/2/20 16:37
+ * @description TODO
+ **/
+@Repository
+@Transactional
+public class BaseDaoImpl implements BaseDao {
+    @Autowired
+    @Qualifier("sessionFactory")
+    private SessionFactory sessionFactory;
+    @Override
+    public Session getSession() {
+        // 事务必须是开启的(Required),否则获取不到
+        //return sessionFactory.openSession();
+        return sessionFactory.getCurrentSession();
+    }
+}

+ 50 - 0
src/main/java/com/usky/entity/OnlinrType.java

@@ -0,0 +1,50 @@
+package com.usky.entity;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public class OnlinrType {
+
+    private String id;
+    private String devicecode;
+    private String eventtime;
+
+    public OnlinrType() {
+    }
+
+
+    public OnlinrType(String id, String devicecode, String eventtime) {
+        this.id = id;
+        this.devicecode = devicecode;
+        this.eventtime = eventtime;
+    }
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getDevicecode() {
+        return devicecode;
+    }
+
+    public void setDevicecode(String devicecode) {
+        this.devicecode = devicecode;
+    }
+
+    public String getEventtime() {
+        return eventtime;
+    }
+
+    public void setEventtime(String eventtime) {
+        this.eventtime = eventtime;
+    }
+}

+ 398 - 0
src/main/java/com/usky/entity/Sp_Iw2017.java

@@ -0,0 +1,398 @@
+package com.usky.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Entity
+@Table(name = "sp_iw2017")
+public class Sp_Iw2017 implements Serializable {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "port")
+    private String port;
+
+    @Column(name = "device_code")
+    private String device_code;//设备编号
+
+    @Column(name = "time")
+    private String time;//告警发生时间
+
+    @Column(name = "address")
+    private String address;//地址ip
+
+    @Column(name = "device_status")
+    private String status;//状态(开关状态)
+
+    @Column(name = "rssi")
+    private String rssi;//    '信号强度'
+
+    @Column(name = "isRecover")
+    private String isRecover;//'是否重发数据
+
+    @Column(name = "voltage")
+    private String voltage;//			//当前电压值
+
+    @Column(name = "temp")
+    private String temp;//			温度值
+
+    @Column(name = "hum")
+    private String hum;//			湿度值
+
+    @Column(name = "angle")
+    private String angle;//			倾斜角度
+
+    @Column(name = "angleSensorStatus")
+    private String angleSensorStatus;//	角度传感器状态
+
+    @Column(name = "tempSensorStatus")
+    private String tempSensorStatus;//	湿度传感器状态
+
+    @Column(name = "isRetrans")
+    private String isRetrans;//       是否重发
+
+    @Column(name = "snr")
+    private String snr;//				信噪比
+
+    @Column(name = "rsrp")
+    private String rsrp;//			参考信号接收功率
+
+
+    @Column(name = "ncmd")
+    private String ncmd;//'命令码'
+
+    @Column(name = "data1")
+    private String data1;//'备用字段'
+
+    @Column(name = "data2")
+    private String data2;//'类型
+
+    @Column(name = "data3")
+    private String data3;//'详情
+
+    @Column(name = "data4")
+    private String data4;//'回路地址'
+
+    @Column(name = "data5")
+    private String data5;//'部件位置信息'
+
+    @Column(name = "cllx")
+    private String cllx;//'处理类型
+
+    @Column(name = "clsj")
+    private String clsj;//'处理时间
+
+    @Column(name = "clr")
+    private String clr;//'处理人'
+
+    @Column(name = "clnr")
+    private String clnr;//'处理内容'
+
+    @Column(name = "clwb")
+    private String clwb;//'处理误报'
+
+    @Column(name = "cllxr")
+    private String cllxr;//'联系人
+
+    @Column(name = "cldh")
+    private String cldh;//'联系电话'
+
+    @Column(name = "clzt")
+    private Integer clzt;//'处理状态'
+
+
+    public Sp_Iw2017() {
+    }
+
+    public Sp_Iw2017(String port, String device_code, String time, String address, String status, String rssi, String isRecover, String voltage, String temp, String hum, String angle, String angleSensorStatus, String tempSensorStatus, String isRetrans, String snr, String rsrp, String ncmd, String data1, String data2, String data3, String data4, String data5, String cllx, String clsj, String clr, String clnr, String clwb, String cllxr, String cldh, Integer clzt) {
+        this.port = port;
+        this.device_code = device_code;
+        this.time = time;
+        this.address = address;
+        this.status = status;
+        this.rssi = rssi;
+        this.isRecover = isRecover;
+        this.voltage = voltage;
+        this.temp = temp;
+        this.hum = hum;
+        this.angle = angle;
+        this.angleSensorStatus = angleSensorStatus;
+        this.tempSensorStatus = tempSensorStatus;
+        this.isRetrans = isRetrans;
+        this.snr = snr;
+        this.rsrp = rsrp;
+        this.ncmd = ncmd;
+        this.data1 = data1;
+        this.data2 = data2;
+        this.data3 = data3;
+        this.data4 = data4;
+        this.data5 = data5;
+        this.cllx = cllx;
+        this.clsj = clsj;
+        this.clr = clr;
+        this.clnr = clnr;
+        this.clwb = clwb;
+        this.cllxr = cllxr;
+        this.cldh = cldh;
+        this.clzt = clzt;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getDevice_code() {
+        return device_code;
+    }
+
+    public void setDevice_code(String device_code) {
+        this.device_code = device_code;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getRssi() {
+        return rssi;
+    }
+
+    public void setRssi(String rssi) {
+        this.rssi = rssi;
+    }
+
+    public String getIsRecover() {
+        return isRecover;
+    }
+
+    public void setIsRecover(String isRecover) {
+        this.isRecover = isRecover;
+    }
+
+    public String getVoltage() {
+        return voltage;
+    }
+
+    public void setVoltage(String voltage) {
+        this.voltage = voltage;
+    }
+
+    public String getTemp() {
+        return temp;
+    }
+
+    public void setTemp(String temp) {
+        this.temp = temp;
+    }
+
+    public String getHum() {
+        return hum;
+    }
+
+    public void setHum(String hum) {
+        this.hum = hum;
+    }
+
+    public String getAngle() {
+        return angle;
+    }
+
+    public void setAngle(String angle) {
+        this.angle = angle;
+    }
+
+    public String getAngleSensorStatus() {
+        return angleSensorStatus;
+    }
+
+    public void setAngleSensorStatus(String angleSensorStatus) {
+        this.angleSensorStatus = angleSensorStatus;
+    }
+
+    public String getTempSensorStatus() {
+        return tempSensorStatus;
+    }
+
+    public void setTempSensorStatus(String tempSensorStatus) {
+        this.tempSensorStatus = tempSensorStatus;
+    }
+
+    public String getIsRetrans() {
+        return isRetrans;
+    }
+
+    public void setIsRetrans(String isRetrans) {
+        this.isRetrans = isRetrans;
+    }
+
+    public String getSnr() {
+        return snr;
+    }
+
+    public void setSnr(String snr) {
+        this.snr = snr;
+    }
+
+    public String getRsrp() {
+        return rsrp;
+    }
+
+    public void setRsrp(String rsrp) {
+        this.rsrp = rsrp;
+    }
+
+    public String getNcmd() {
+        return ncmd;
+    }
+
+    public void setNcmd(String ncmd) {
+        this.ncmd = ncmd;
+    }
+
+    public String getData1() {
+        return data1;
+    }
+
+    public void setData1(String data1) {
+        this.data1 = data1;
+    }
+
+    public String getData2() {
+        return data2;
+    }
+
+    public void setData2(String data2) {
+        this.data2 = data2;
+    }
+
+    public String getData3() {
+        return data3;
+    }
+
+    public void setData3(String data3) {
+        this.data3 = data3;
+    }
+
+    public String getData4() {
+        return data4;
+    }
+
+    public void setData4(String data4) {
+        this.data4 = data4;
+    }
+
+    public String getData5() {
+        return data5;
+    }
+
+    public void setData5(String data5) {
+        this.data5 = data5;
+    }
+
+    public String getCllx() {
+        return cllx;
+    }
+
+    public void setCllx(String cllx) {
+        this.cllx = cllx;
+    }
+
+    public String getClsj() {
+        return clsj;
+    }
+
+    public void setClsj(String clsj) {
+        this.clsj = clsj;
+    }
+
+    public String getClr() {
+        return clr;
+    }
+
+    public void setClr(String clr) {
+        this.clr = clr;
+    }
+
+    public String getClnr() {
+        return clnr;
+    }
+
+    public void setClnr(String clnr) {
+        this.clnr = clnr;
+    }
+
+    public String getClwb() {
+        return clwb;
+    }
+
+    public void setClwb(String clwb) {
+        this.clwb = clwb;
+    }
+
+    public String getCllxr() {
+        return cllxr;
+    }
+
+    public void setCllxr(String cllxr) {
+        this.cllxr = cllxr;
+    }
+
+    public String getCldh() {
+        return cldh;
+    }
+
+    public void setCldh(String cldh) {
+        this.cldh = cldh;
+    }
+
+    public Integer getClzt() {
+        return clzt;
+    }
+
+    public void setClzt(Integer clzt) {
+        this.clzt = clzt;
+    }
+}

+ 108 - 0
src/main/java/com/usky/entity/Sp_Lora_Device.java

@@ -0,0 +1,108 @@
+package com.usky.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Entity
+@Table(name = "sp_lora_device")
+public class Sp_Lora_Device implements Serializable{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "dwtype")
+    private String dwtype;
+
+    @Column(name = "company")
+    private String company;
+
+    @Column(name = "number")
+    private String number;
+
+    @Column(name = "creat_time")
+    private String creat_time;
+
+    @Column(name = "owner_code")
+    private String owner_code;
+
+    @Column(name = "deviceid")
+    private String deviceid;
+
+
+    public Sp_Lora_Device() {
+    }
+
+    public Sp_Lora_Device(String dwtype, String company, String number, String creat_time, String owner_code, String deviceid) {
+        this.dwtype = dwtype;
+        this.company = company;
+        this.number = number;
+        this.creat_time = creat_time;
+        this.owner_code = owner_code;
+        this.deviceid = deviceid;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getDwtype() {
+        return dwtype;
+    }
+
+    public void setDwtype(String dwtype) {
+        this.dwtype = dwtype;
+    }
+
+    public String getCompany() {
+        return company;
+    }
+
+    public void setCompany(String company) {
+        this.company = company;
+    }
+
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
+    public String getCreat_time() {
+        return creat_time;
+    }
+
+    public void setCreat_time(String creat_time) {
+        this.creat_time = creat_time;
+    }
+
+    public String getOwner_code() {
+        return owner_code;
+    }
+
+    public void setOwner_code(String owner_code) {
+        this.owner_code = owner_code;
+    }
+
+    public String getDeviceid() {
+        return deviceid;
+    }
+
+    public void setDeviceid(String deviceid) {
+        this.deviceid = deviceid;
+    }
+}

+ 252 - 0
src/main/java/com/usky/entity/Sp_Lora_WAN.java

@@ -0,0 +1,252 @@
+package com.usky.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Entity
+@Table(name = "sp_lora_wan")
+public class Sp_Lora_WAN{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "a_name")
+    private String a_name;
+
+    @Column(name = "b_name")
+    private String b_name;
+
+    @Column(name = "deveui")
+    private String deveui;
+
+    @Column(name = "devid")
+    private String devid;
+
+    @Column(name = "devtype")
+    private String devtype;
+
+    @Column(name = "dir")
+    private int dir;
+
+    @Column(name = "direct")
+    private int direct;
+
+    @Column(name = "l_name")
+    private String l_name;
+
+    @Column(name = "lat")
+    private double lat;
+
+    @Column(name = "lng")
+    private double lng;
+
+    @Column(name = "method")
+    private String method;
+
+    @Column(name = "pid")
+    private String pid;
+
+    @Column(name = "plugin")
+    private String plugin;
+
+    @Column(name = "pname")
+    private String pname;
+
+    @Column(name = "product_type")
+    private int product_type;
+
+    @Column(name = "time")
+    private String time;
+
+    @Column(name = "version")
+    private int version;
+
+    @Column(name = "state")
+    private String state;
+
+
+    public Sp_Lora_WAN() {
+    }
+
+    public Sp_Lora_WAN(String a_name, String b_name, String deveui, String devid, String devtype, int dir, int direct, String l_name, double lat, double lng, String method, String pid, String plugin, String pname, int product_type, String time, int version, String state) {
+        this.a_name = a_name;
+        this.b_name = b_name;
+        this.deveui = deveui;
+        this.devid = devid;
+        this.devtype = devtype;
+        this.dir = dir;
+        this.direct = direct;
+        this.l_name = l_name;
+        this.lat = lat;
+        this.lng = lng;
+        this.method = method;
+        this.pid = pid;
+        this.plugin = plugin;
+        this.pname = pname;
+        this.product_type = product_type;
+        this.time = time;
+        this.version = version;
+        this.state = state;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getA_name() {
+        return a_name;
+    }
+
+    public void setA_name(String a_name) {
+        this.a_name = a_name;
+    }
+
+    public String getB_name() {
+        return b_name;
+    }
+
+    public void setB_name(String b_name) {
+        this.b_name = b_name;
+    }
+
+    public String getDeveui() {
+        return deveui;
+    }
+
+    public void setDeveui(String deveui) {
+        this.deveui = deveui;
+    }
+
+    public String getDevid() {
+        return devid;
+    }
+
+    public void setDevid(String devid) {
+        this.devid = devid;
+    }
+
+    public String getDevtype() {
+        return devtype;
+    }
+
+    public void setDevtype(String devtype) {
+        this.devtype = devtype;
+    }
+
+    public int getDir() {
+        return dir;
+    }
+
+    public void setDir(int dir) {
+        this.dir = dir;
+    }
+
+    public int getDirect() {
+        return direct;
+    }
+
+    public void setDirect(int direct) {
+        this.direct = direct;
+    }
+
+    public String getL_name() {
+        return l_name;
+    }
+
+    public void setL_name(String l_name) {
+        this.l_name = l_name;
+    }
+
+    public double getLat() {
+        return lat;
+    }
+
+    public void setLat(double lat) {
+        this.lat = lat;
+    }
+
+    public double getLng() {
+        return lng;
+    }
+
+    public void setLng(double lng) {
+        this.lng = lng;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getPid() {
+        return pid;
+    }
+
+    public void setPid(String pid) {
+        this.pid = pid;
+    }
+
+    public String getPlugin() {
+        return plugin;
+    }
+
+    public void setPlugin(String plugin) {
+        this.plugin = plugin;
+    }
+
+    public String getPname() {
+        return pname;
+    }
+
+    public void setPname(String pname) {
+        this.pname = pname;
+    }
+
+    public int getProduct_type() {
+        return product_type;
+    }
+
+    public void setProduct_type(int product_type) {
+        this.product_type = product_type;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public int getVersion() {
+        return version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+}

+ 40 - 0
src/main/java/com/usky/entity/Yt_Lora_Data.java

@@ -0,0 +1,40 @@
+package com.usky.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+
+
+
+@Entity
+@Table(name = "yt_lora_data")
+@Data
+public class Yt_Lora_Data implements Serializable{
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "device_code")
+    private String device_code;
+
+    @Column(name = "Service")
+    private String Service;
+
+
+
+    @Column(name = "Eventtime")
+    private String Eventtime;
+
+
+}

+ 269 - 0
src/main/java/com/usky/entity/Yt_T_Lrdevice.java

@@ -0,0 +1,269 @@
+package com.usky.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Entity
+@Table(name = "yt_t_lrdevice")
+@Data
+public class Yt_T_Lrdevice implements Serializable {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id")
+    private Integer id;
+
+    @Column(name = "device_id")
+    private Integer deviceId;
+
+    @Column(name = "company_code")
+    private String companyCode;
+
+    @Column(name = "transmission_mode")
+    private Integer transmissionMode;
+
+    @Column(name = "device_type")
+    private String deviceType;
+    @Column(name = "device_model")
+    private String deviceModel;
+    @Column(name = "data")
+    private String data;
+    @Column(name = "number")
+    private Integer number;
+    @Column(name = "owner_code")
+    private String ownerCode;
+    @Column(name = "lora_type")
+    private String loraType;
+    @Column(name = "goods_type")
+    private String goodsType;
+    @Column(name = "profile")
+    private String profile;
+    @Column(name = "device_code")
+    private String deviceCode;
+    @Column(name = "dev_addr")
+    private String devAddr;
+    @Column(name = "nwk_skey")
+    private String nwkSkey;
+    @Column(name = "app_skey")
+    private String appSkey;
+
+    @Column(name = "app_key")
+    private String appKey;
+    @Column(name = "app_eui")
+    private String appEui;
+    @Column(name = "bind_address")
+    private String bindAddress;
+
+    @Column(name = "l_name")
+    private String lName;
+
+
+
+    @Column(name = "creat_time")
+    private String creatTime;
+
+
+    public Yt_T_Lrdevice() {
+    }
+
+
+    public Yt_T_Lrdevice(Integer deviceId, String companyCode, Integer transmissionMode, String deviceType, String deviceModel, String data, Integer number, String ownerCode, String loraType, String goodsType, String profile, String deviceCode, String devAddr, String nwkSkey, String appSkey, String appKey, String appEui, String bindAddress, String lName, String creatTime) {
+        this.deviceId = deviceId;
+        this.companyCode = companyCode;
+        this.transmissionMode = transmissionMode;
+        this.deviceType = deviceType;
+        this.deviceModel = deviceModel;
+        this.data = data;
+        this.number = number;
+        this.ownerCode = ownerCode;
+        this.loraType = loraType;
+        this.goodsType = goodsType;
+        this.profile = profile;
+        this.deviceCode = deviceCode;
+        this.devAddr = devAddr;
+        this.nwkSkey = nwkSkey;
+        this.appSkey = appSkey;
+        this.appKey = appKey;
+        this.appEui = appEui;
+        this.bindAddress = bindAddress;
+        this.lName = lName;
+        this.creatTime = creatTime;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(Integer deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getCompanyCode() {
+        return companyCode;
+    }
+
+    public void setCompanyCode(String companyCode) {
+        this.companyCode = companyCode;
+    }
+
+    public Integer getTransmissionMode() {
+        return transmissionMode;
+    }
+
+    public void setTransmissionMode(Integer transmissionMode) {
+        this.transmissionMode = transmissionMode;
+    }
+
+    public String getDeviceType() {
+        return deviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        this.deviceType = deviceType;
+    }
+
+    public String getDeviceModel() {
+        return deviceModel;
+    }
+
+    public void setDeviceModel(String deviceModel) {
+        this.deviceModel = deviceModel;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public String getOwnerCode() {
+        return ownerCode;
+    }
+
+    public void setOwnerCode(String ownerCode) {
+        this.ownerCode = ownerCode;
+    }
+
+    public String getLoraType() {
+        return loraType;
+    }
+
+    public void setLoraType(String loraType) {
+        this.loraType = loraType;
+    }
+
+    public String getGoodsType() {
+        return goodsType;
+    }
+
+    public void setGoodsType(String goodsType) {
+        this.goodsType = goodsType;
+    }
+
+    public String getProfile() {
+        return profile;
+    }
+
+    public void setProfile(String profile) {
+        this.profile = profile;
+    }
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDevAddr() {
+        return devAddr;
+    }
+
+    public void setDevAddr(String devAddr) {
+        this.devAddr = devAddr;
+    }
+
+    public String getNwkSkey() {
+        return nwkSkey;
+    }
+
+    public void setNwkSkey(String nwkSkey) {
+        this.nwkSkey = nwkSkey;
+    }
+
+    public String getAppSkey() {
+        return appSkey;
+    }
+
+    public void setAppSkey(String appSkey) {
+        this.appSkey = appSkey;
+    }
+
+    public String getAppKey() {
+        return appKey;
+    }
+
+    public void setAppKey(String appKey) {
+        this.appKey = appKey;
+    }
+
+    public String getAppEui() {
+        return appEui;
+    }
+
+    public void setAppEui(String appEui) {
+        this.appEui = appEui;
+    }
+
+    public String getBindAddress() {
+        return bindAddress;
+    }
+
+    public void setBindAddress(String bindAddress) {
+        this.bindAddress = bindAddress;
+    }
+
+    public String getlName() {
+        return lName;
+    }
+
+    public void setlName(String lName) {
+        this.lName = lName;
+    }
+
+    public String getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(String creatTime) {
+        this.creatTime = creatTime;
+    }
+}

+ 8 - 0
src/main/java/com/usky/service/BaseServie.java

@@ -0,0 +1,8 @@
+package com.usky.service;
+
+import org.hibernate.Session;
+
+public interface BaseServie {
+    public Session getSession();
+
+}

+ 37 - 0
src/main/java/com/usky/service/HtService.java

@@ -0,0 +1,37 @@
+package com.usky.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.usky.entity.Sp_Lora_WAN;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Timestamp;
+import java.util.HashMap;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public interface HtService{
+
+
+    int saveLora(Sp_Lora_WAN sp_lora_wan);
+
+    void cretTab1(String tab);
+    void cretTab2(String tab);
+    void saveYG(String payload,String num,String tab,String loraWanId,String devid,String time);
+
+    String getStr(HttpServletRequest request)throws Exception ;
+
+    String query(HashMap<String, String> map);
+
+    String saveLoraDev(HashMap<String, String> map);
+
+    void save02and03(String payload, String num, String tab, String loraWanId, String devid,String time);
+
+    void YGsendWX(String devid, String loraWanId, String timeStamep, String evt);
+
+    int saveLoradata(String devid, String s);
+}

+ 22 - 0
src/main/java/com/usky/service/Impl/BaseServieImpl.java

@@ -0,0 +1,22 @@
+package com.usky.service.Impl;
+
+import com.usky.dao.BaseDao;
+import com.usky.service.BaseServie;
+import org.hibernate.Session;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/2/19 17:42
+ * @description TODO
+ **/
+public class BaseServieImpl implements BaseServie {
+    @Autowired
+    private BaseDao baseDaoImpl;
+    @Override
+    public Session getSession() {
+        return baseDaoImpl.getSession();
+    }
+
+}

+ 605 - 0
src/main/java/com/usky/service/Impl/HtServiceImpl.java

@@ -0,0 +1,605 @@
+package com.usky.service.Impl;
+
+import com.usky.controller.HtController;
+import com.usky.entity.Sp_Lora_Device;
+import com.usky.entity.Sp_Lora_WAN;
+import com.usky.entity.Yt_Lora_Data;
+import com.usky.service.HtService;
+import com.usky.service.SendWXService;
+import com.usky.utils.HttpClientUtilWX;
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.log4j.Logger;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedInputStream;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Service
+@Transactional
+public class HtServiceImpl extends BaseServieImpl implements HtService {
+    private static final Logger LOGGER = Logger.getLogger(HtServiceImpl.class);
+
+    @Autowired
+    private SendWXService sendWXService;
+
+    @Override
+    public int saveLora(Sp_Lora_WAN sp_lora_wan) {
+        int i = (int) getSession().save(sp_lora_wan);
+        return i;
+    }
+
+    /**
+     * @return void
+     * @Author zhangzilong
+     * @Description //烟感
+     * @Date 10:24 2020/3/13
+     * @Param * @param tab
+     */
+    @Override
+    public void cretTab1(String tab) {
+        System.out.println("创建表明" + tab);
+
+        String sql = "CREATE TABLE IF NOT EXISTS `" + tab + "` (`id` int(25) NOT NULL AUTO_INCREMENT,`wan_id` int(25) NOT NULL COMMENT '网关表主键id',`device_id` varchar(50) NOT NULL COMMENT '设备编号',`owner_code` varchar(50) NOT NULL DEFAULT '' COMMENT '设备唯一标识',`version` varchar(11) NOT NULL DEFAULT '' COMMENT '协议版本',`frame` varchar(11) NOT NULL DEFAULT '' COMMENT '发送失败帧计算',`smog` varchar(11) NOT NULL DEFAULT '' COMMENT '烟雾浓度',`battery` varchar(11) NOT NULL DEFAULT '' COMMENT '电量',`TData` varchar(11) NOT NULL DEFAULT '' COMMENT '温度',`event_time` varchar(50) NOT NULL COMMENT '数据上报时间',`status` varchar(11) NOT NULL DEFAULT '' COMMENT '设备状态;0:设备心跳。1:设备自检。2:火灾报警。3:温度报警。4:烟感电量低。5:防拆报警。6:发射电路故障。',`time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT '入库时间',PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8;";
+        SQLQuery qry = this.getSession().createSQLQuery(sql);
+
+        int i = qry.executeUpdate();
+        System.out.println("创建表返回值" + i);
+    }
+
+    /**
+     * @return void
+     * @Author zhangzilong
+     * @Description //液位
+     * @Date 10:24 2020/3/13
+     * @Param * @param tab
+     */
+    @Override
+    public void cretTab2(String tab) {
+        System.out.println("创建表明" + tab);
+
+        String sql = "CREATE TABLE IF NOT EXISTS `" + tab + "` (`id` int(25) NOT NULL AUTO_INCREMENT,`wan_id` int(25) NOT NULL COMMENT '网关表主键id',`device_id` varchar(50) NOT NULL COMMENT '设备编号',`owner_code` varchar(50) NOT NULL COMMENT '设备唯一编号',`length` varchar(11) NOT NULL COMMENT '长度',`device_type` varchar(11) NOT NULL COMMENT '设备类型。0:未知设备。1:无线智能消防栓监测终端。2:无线远程压力采集终端。3:无线远程液位采集终端',`send_freq` varchar(11) NOT NULL COMMENT '发送频率',`update_time` varchar(11) NOT NULL COMMENT '设置时间更新。0:关闭时间更新。1:开启时间更新',`device_status` varchar(11) NOT NULL COMMENT '设备状态。0:未知设备状态。1:设备状态正常。2:设备倾斜,可能被撞。3:设备有加速度,可能被盗。',`battery_level` varchar(11) NOT NULL COMMENT '电池电量',`battery_status` varchar(11) NOT NULL COMMENT '电池状态。1:电量过低。2:电量正常。',`value_status` varchar(11) NOT NULL COMMENT '数值状态。0:数值正常。1:低压超限。2:高压超限。3:波动变化超限。4:设备故障。',`value_unit` varchar(11) NOT NULL COMMENT '数值单位',`event_time` varchar(50) NOT NULL COMMENT '数据上报时间',`sample_value` varchar(11) NOT NULL COMMENT '结果值',`time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT '时间',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
+        SQLQuery qry = this.getSession().createSQLQuery(sql);
+        int i = qry.executeUpdate();
+        System.out.println("创建表返回值" + i);
+    }
+
+    @Override
+    public void saveYG(String payload, String num, String tab, String loraWanId, String devid,String time) {
+
+        //协议版本
+        String version = payload.substring(2, 4);
+       // String head = payload.substring(0, 24);
+        //消息体
+        String str = payload.substring(24, 58);
+        String end = payload.substring(58, payload.length());
+
+
+        System.out.println((str.length() / 2));
+        //告警识别
+        String type = "0";
+        //wx
+        String evt = "";
+        int count = 0;
+        int a = 0;
+        int b = 0;
+        //key名称
+        String info = "";
+        Map<String, String> map = new HashMap<>();
+        map.put("status", "0");
+        map.put("frame", "0");
+        map.put("smog", "0");
+        map.put("battery", "0");
+        map.put("TData", "0");
+        for (int i = 0; i <= str.length(); i++) {
+            for (int j = 1; j <= 3; j++) {
+                if (j == 1) {
+                    String s = str.substring(a, a + 2);
+                    if (s.equals("17")) {
+                        info = "17";
+                    } else if (s.equals("14")) {
+                        info = "14";
+                    } else if (s.equals("0B")) {
+                        info = "0B";
+                    } else if (s.equals("24")) {
+                        info = "24";
+                    } else if (s.equals("01")) {
+                        info = "01";
+                    } else if (s.equals("02")) {
+                        info = "02";
+                    } else if (s.equals("19")) {
+                        info = "19";
+                    } else {
+                        info = "未知状态";
+                    }
+                    str = str.substring(a + 2, str.length());
+                } else if (j == 2) {
+                    if (str.length() < (a + 2)) {
+                        System.out.println("???????????????" + "未知的类型");
+                    } else {
+                        String s = str.substring(a, a + 2);
+                        if (s.equals("01")) {
+                            b = 2;
+                        } else {
+                            b = 4;
+                        }
+                        str = str.substring(a + 2, str.length());
+                    }
+                } else {
+                    if (str.length() < (a + b)) {
+                        System.out.println("???????????????" + "未知的类型");
+                    } else {
+
+                        String s = str.substring(a, a + b);
+                        if (info.equals("17")) {
+                            //失败帧
+                            String s1 = String.valueOf(Integer.parseInt(s, 16));
+                            map.put("frame", s1);
+                        } else if (info.equals("14")) {
+                            //烟雾浓度
+                            String s1 = String.valueOf(Integer.parseInt(s, 16));
+                            map.put("smog", s1);
+                        } else if (info.equals("0B")) {
+                            //温度值
+                            String s1 = String.valueOf(Integer.parseInt(s, 16));
+                            map.put("TData", s1);
+                        } else if (info.equals("19")) {
+                            type = "1";
+                            //设备自检
+                            String s1 = String.valueOf(Integer.parseInt(s, 16));
+                            map.put("status", "1");
+                            evt = "y12";
+                        } else if (info.equals("24")) {
+                            //设备电量
+                            String s1 = String.valueOf(Integer.parseInt(s, 16));
+                            map.put("battery", s1);
+                        } else if (info.equals("01")) {
+                            type = "1";
+                            //火灾报警
+                            if (s.equals("01")) {
+                                //火灾
+                                map.put("status", "2");
+                                evt = "y07";
+                            } else if (s.equals("02")) {
+                                //温度
+                                map.put("status", "3");
+                                evt = "y08";
+                            }
+                        } else if (info.equals("02")) {
+                            type = "1";
+                            //告警
+                            if (s.equals("02")) {
+                                //电量低
+                                map.put("status", "4");
+                                evt = "y09";
+                            } else if (s.equals("03")) {
+                                //防拆报警
+                                map.put("status", "5");
+                                evt = "y10";
+                            } else if (s.equals("07")) {
+                                //发射电路故障
+                                map.put("status", "6");
+                                evt = "y11";
+                            }
+                        } else {
+                            System.out.println("!!!!!未知参数");
+                        }
+                        str = str.substring(a + b, str.length());
+                    }
+                }
+            }
+        }
+
+
+        Date date = new Date();
+        Timestamp timeStamep = new Timestamp(date.getTime());
+//保存设备表
+        String sql = "INSERT INTO `" + tab + "` VALUES (null," + loraWanId + ",'" + devid + "','" + num + "','" + version + "','" + map.get("frame") + "','" + map.get("smog") + "','" + map.get("battery") + "','" + map.get("TData") + "','" + time+ "','" + map.get("status") + "',null)";
+        SQLQuery qry = getSession().createSQLQuery(sql);
+        int i = qry.executeUpdate();
+
+
+//保存告警表
+        if ("1".equals(type)) {
+            LOGGER.info("********************************告警数据上传告警表sp_yj2017*" );
+            String sql1 = "INSERT INTO `sp_yj2017` VALUES (null, 'jindun fume','" + devid + "', '" + timeStamep + "', '', '', '00', '" + map.get("status") + "', '" + map.get("smog") + "', '', '" + map.get("battery") + "', '" + map.get("TData") + "', '', '0000-00-00 00:00:00', '', '', '', '', '', 0, '');";
+            SQLQuery qry1 = getSession().createSQLQuery(sql1);
+            int i1 = qry1.executeUpdate();
+            System.out.println("保存告警表");
+            sendWXService.YGsendWX(devid, loraWanId, timeStamep.toString(), evt);
+            //this.YGsendWX(devid, loraWanId, timeStamep.toString(), evt);
+        }
+
+
+    }
+
+    @Override
+    public void YGsendWX(String devid, String loraWanId, String timeStamep, String evt) {
+        LOGGER.info("********************************告警数据上传微信*" );
+        List<NameValuePair> nameValuePairsList = new ArrayList<>();
+        StringBuffer sb = new StringBuffer();
+        String sql="SELECT company FROM sp_owner where owner_code='"+devid+"'";
+        SQLQuery query = getSession().createSQLQuery(sql);
+        List list = query.list();
+        Object o = list.get(0);
+        for (Object b : list) {
+            System.out.println("b = " + b.toString());
+        }
+        String s = o.toString();
+        String sql1="SELECT phone from sp_owner_phone  where data2 like'%6%' and owner_code='"+s+"'";
+        Query query1 = getSession().createSQLQuery(sql1);
+        List list1 = query1.list();
+//        for (Object b : list1) {
+//            System.out.println("b111 = " + b.toString());
+//        }
+        if (list1 != null && list1.size()>0){
+            for (Object sp : list1) {
+                sb.append(sp);
+                sb.append(",");
+               // System.out.println("sp = " + sp);
+            }
+        }
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String time = df.format(new Date());
+        BasicNameValuePair basicNameValuePair1 = new BasicNameValuePair("IMEI",devid);
+        // BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone",sb.toString());
+        BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone",sb.toString());
+        BasicNameValuePair basicNameValuePair3 = new BasicNameValuePair("insert_id",loraWanId);
+        BasicNameValuePair basicNameValuePair4 = new BasicNameValuePair("time",time);
+        BasicNameValuePair  basicNameValuePair = new BasicNameValuePair("evt",evt);
+        nameValuePairsList.add(basicNameValuePair);
+        nameValuePairsList.add(basicNameValuePair1);
+        nameValuePairsList.add(basicNameValuePair2);
+        nameValuePairsList.add(basicNameValuePair3);
+        nameValuePairsList.add(basicNameValuePair4);
+
+        String url ="http://iot.usky.cn/jdxf/wxapp2.php/Home/Waterwarn/bj";
+        HttpClientUtilWX.doFromPost(url,null,nameValuePairsList);
+        System.out.println("发送微信");
+        LOGGER.info("********************************告警数据上传微信完成*" );
+
+    }
+
+    @Override
+    public int saveLoradata(String devid, String s) {
+        Yt_Lora_Data lr = new Yt_Lora_Data();
+        lr.setDevice_code(devid);
+        lr.setService(s);
+        int i = (int)getSession().save(lr);
+        System.out.println("i = " + i);
+        return i;
+
+    }
+
+    @Override
+    public String getStr(HttpServletRequest request)throws Exception {
+        //解析数据
+        StringBuffer str = new StringBuffer();
+
+            BufferedInputStream in = new BufferedInputStream(request.getInputStream());
+            int i;
+            char c;
+            while ((i = in.read()) != -1) {
+                c = (char) i;
+                str.append(c);
+            }
+
+        //数据体
+        String s = str.toString();
+        return s;
+    }
+
+    /**
+     * @return void
+     * @Author zhangzilong
+     * @Description //查询是否存在设备表  不在则为新注册  需生成唯一标识保存sp_owner
+     * @Date 10:09 2020/3/12
+     * @Param * @param map
+     */
+    @Override
+    public String query(HashMap<String, String> map) {
+//根据类型和设备id判断是否为新设备
+        String sql = "SELECT owner_code FROM sp_lora_device where dwtype ='" + map.get("dwtype") + "' and deviceid='" + map.get("deviceid") + "' and company=" + map.get("company") + "";
+        SQLQuery qry = this.getSession().createSQLQuery(sql);
+        List list = qry.list();
+        //新设备要注册
+        if (CollectionUtils.isEmpty(list)) {
+            //新设备 注册
+            String s = this.saveLoraDev(map);
+
+            return s;
+        } else {
+            String o = String.valueOf(list.get(0));
+            //已注册设备不管   返回唯一码
+            return o;
+        }
+
+
+    }
+
+    /**
+     * @return void
+     * @Author zhangzilong
+     * @Description 新注册
+     * @Date 10:50 2020/3/12
+     * @Param * @param map
+     */
+    @Override
+    public String saveLoraDev(HashMap<String, String> map) {
+        //根据类型和单位 查询num
+        String num;
+        String sql = "SELECT max(number) FROM sp_lora_device where dwtype ='" + map.get("dwtype") + "' and company='" + map.get("company") + "'";
+        SQLQuery qry = this.getSession().createSQLQuery(sql);
+        List list = qry.list();
+        //此单位此设备类型第一个
+        Object o = list.get(0);
+        if (o == null) {
+            num = "10000001";
+        } else {
+
+
+            int i = Integer.parseInt(o.toString());
+
+            num = String.valueOf(i + 1);
+
+        }
+
+
+        String company = map.get("company");
+        String dwtype = map.get("dwtype");
+        // String deviceid = map.get("deviceid");
+        Sp_Lora_Device device = new Sp_Lora_Device();
+        device.setCompany(company);
+        device.setDwtype(dwtype);
+        device.setDeviceid(map.get("deviceid"));
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        device.setCreat_time(df.format(new Date()));
+        device.setNumber(num);
+        String code = "yt" + dwtype + company+"_" + num;
+        device.setOwner_code(code);
+        getSession().save(device);
+
+
+        //存入sp_owner
+
+
+        return code;
+    }
+
+    /**
+     * @param num
+     * @param tab
+     * @param loraWanId
+     * @param devid
+     * @return void
+     * @Author zhangzilong
+     * @Description //解析液位和压力
+     * @Date 13:14 2020/3/13
+     * @Param * @param payload
+     */
+    @Override
+    public void save02and03(String payload, String num, String tab, String loraWanId, String devid,String time) {
+
+        Map<String, String> map = new HashMap<>();
+        Map<String, String> map1 = new HashMap<>();
+//        map.put("Sample_Value", s2);
+//        map.put("Value_Unit", "M");
+//        map1.put("Value_Status", "LL4");
+//        map.put("Battery_Level", s);
+//        map.put("Device_Status", "0");
+//        map.put("Update_Time", "0");
+//        map.put("Send_Freq", "未知时间");
+//        map.put("Device_Type", "0");
+//        map.put("length", s1);
+        //告警状态
+        String status="0";
+
+        //长度
+        String length = payload.substring(0, 2);
+        ;
+        String s1 = String.valueOf(Integer.parseInt(length, 16));
+        map.put("length", s1);
+        //设备类型
+        String Device_Type = payload.substring(2, 4);
+        //发送频率
+        String Send_Freq = payload.substring(4, 6);
+        //时间更新
+        String Update_Time = payload.substring(6, 8);
+        //设备状态
+        String Device_Status = payload.substring(8, 10);
+        //电池电量
+        String Battery_Level = payload.substring(10, 12);
+        //电池状态
+        String Battery_Status = payload.substring(12, 14);
+        //数值状态
+        String Value_Status = payload.substring(14, 15);
+        //数值单位
+        String Value_Unit = payload.substring(15, 16);
+        //小数位数
+        String Decimal_Digits = payload.substring(16, 17);
+        //采样数值
+        String Sample_Value = payload.substring(17, payload.length());
+
+        //设备类型
+        if ("01".equals(Device_Type)) {
+            map.put("Device_Type", "1");
+        } else if ("02".equals(Device_Type)) {
+            map.put("Device_Type", "2");
+        } else if ("03".equals(Device_Type)) {
+            map.put("Device_Type", "3");
+        } else {
+            map.put("Device_Type", "0");
+        }
+
+        //发送频率保存
+        if (Send_Freq.equals("0A")) {
+            map.put("Send_Freq", "10min");
+        } else if (Send_Freq.equals("14")) {
+            map.put("Send_Freq", "20min");
+        } else if (Send_Freq.equals("1E")) {
+            map.put("Send_Freq", "30min");
+        } else if (Send_Freq.equals("3C")) {
+            map.put("Send_Freq", "1h");
+        } else if (Send_Freq.equals("78")) {
+            map.put("Send_Freq", "2h");
+        } else if (Send_Freq.equals("B4")) {
+            map.put("Send_Freq", "3h");
+        } else {
+            map.put("Send_Freq", "未知时间");
+        }
+
+        //时间更新Update_Time    暂未使用
+        if ("01".equals(Update_Time)) {
+            map.put("Update_Time", "1");
+        } else {
+            map.put("Update_Time", "0");
+        }
+
+        //设备状态保存
+        if (Device_Status.equals("01")) {
+            map.put("Device_Status", "1");
+        } else if (Device_Status.equals("02")) {
+            map.put("Device_Status", "2");
+            status="1";
+        } else if (Device_Status.equals("03")) {
+            map.put("Device_Status", "3");
+            status="1";
+        } else {
+            map.put("Device_Status", "0");
+        }
+
+
+        //Battery_Level电池状态保存   进制换算
+        String s = String.valueOf(Integer.parseInt(Battery_Level, 16));
+        map.put("Battery_Level", s);
+
+        //电池状态暂未使用Battery_Status
+        if (Battery_Status.equals("01")) {
+            map.put("Battery_Status", "1");
+            status="1";
+        } else if (Battery_Status.equals("02")) {
+            map.put("Battery_Status", "2");
+        }
+
+
+        //数值状态保存
+        if (Value_Status.equals("0")) {
+            map.put("Value_Status", "0");
+
+            if ("02".equals(Device_Type)) {
+                map1.put("Value_Status", "WP0");
+            } else if ("03".equals(Device_Type)) {
+                map1.put("Value_Status", "LL0");
+            }
+
+        } else if (Value_Status.equals("1")) {
+            status="1";
+            map.put("Value_Status", "1");
+            //压力
+            if ("02".equals(Device_Type)) {
+                map1.put("Value_Status", "WP1");
+            } else if ("03".equals(Device_Type)) {
+                map1.put("Value_Status", "LL1");
+            }
+        } else if (Value_Status.equals("2")) {
+            status="1";
+            map.put("Value_Status", "2");
+
+            if ("02".equals(Device_Type)) {
+                map1.put("Value_Status", "WP2");
+            } else if ("03".equals(Device_Type)) {
+                map1.put("Value_Status", "LL2");
+            }
+        } else if (Value_Status.equals("3")) {
+            status="1";
+            map.put("Value_Status", "3");
+
+            if ("02".equals(Device_Type)) {
+                map1.put("Value_Status", "WP3");
+            } else if ("03".equals(Device_Type)) {
+                map1.put("Value_Status", "LL3");
+            }
+        } else if (Value_Status.equals("4")) {
+            status="1";
+            map.put("Value_Status", "4");
+
+            if ("02".equals(Device_Type)) {
+                map1.put("Value_Status", "WP4");
+            } else if ("03".equals(Device_Type)) {
+                map1.put("Value_Status", "LL4");
+            }
+        }
+
+
+        //数值单位保存
+        if (Value_Unit.equals("1")) {
+            map.put("Value_Unit", "MPa");
+        } else if (Value_Unit.equals("2")) {
+            map.put("Value_Unit", "Bar");
+        } else if (Value_Unit.equals("3")) {
+            map.put("Value_Unit", "KPa");
+        } else if (Value_Unit.equals("4")) {
+            map.put("Value_Unit", "M");
+        }
+
+        //采样数值
+        BigDecimal maxlng1 = new BigDecimal(Sample_Value);
+
+        double minlat = maxlng1.doubleValue();
+        double a = 0;
+        //小数位数
+        if (Decimal_Digits.equals("1")) {
+            a = minlat / 10;
+        } else if (Decimal_Digits.equals("2")) {
+            a = minlat / 100;
+        } else if (Decimal_Digits.equals("3")) {
+            a = minlat / 1000;
+        } else if (Decimal_Digits.equals("4")) {
+            a = minlat / 10000;
+        }
+        //四舍五入保留三位保存数值
+        double result = new BigDecimal(a).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+        //System.out.println("result="+result);
+        String s2 = String.valueOf(result);
+        map.put("Sample_Value", s2);
+
+//更新时间
+        Date date = new Date();
+        Timestamp timeStamep = new Timestamp(date.getTime());
+//保存
+        String sql = "INSERT INTO `" + tab + "` VALUES (null, '" + loraWanId + "', '" + devid + "','" + num + "', '" + map.get("length") + "', '" + map.get("Device_Type") + "', '" + map.get("Send_Freq") + "', '" + map.get("Update_Time") + "', '" + map.get("Device_Status") + "', '" + map.get("Battery_Level") + "', '" + map.get("Battery_Status") + "', '" + map.get("Value_Status") + "', '" + map.get("Value_Unit") + "', '" + time + "', '" + map.get("Sample_Value") + "', null);";
+        SQLQuery qry = getSession().createSQLQuery(sql);
+        int i = qry.executeUpdate();
+
+
+//保存到sp_sj2017
+        if ("1".equals(status)) {
+            LOGGER.info("********************************告警数据上传告警表sp_sj2017*" );
+            System.out.println("有告警信息");
+            String sql1 = "INSERT INTO `sp_sj2017` VALUES (null, 'tp_water_pressure','" + devid + "', '" + timeStamep + "', '', '', '', '" + map1.get("Value_Status") + "', '" + map.get("Battery_Level") + "', '', '" + map.get("Sample_Value") + "', '', '', '0000-00-00 00:00:00', '', '', '', '', '0', '', '');";
+            SQLQuery qry1 = getSession().createSQLQuery(sql1);
+            int i1 = qry1.executeUpdate();
+        }
+
+
+    }
+
+
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 68 - 0
src/main/java/com/usky/service/Impl/NBServiceImpl.java


+ 69 - 0
src/main/java/com/usky/service/Impl/SearchertypeTaskImpl.java

@@ -0,0 +1,69 @@
+package com.usky.service.Impl;
+
+import com.usky.service.test;
+import org.apache.log4j.Logger;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Service
+@Transactional
+public class SearchertypeTaskImpl extends BaseServieImpl implements test {
+    private static final Logger LOGGER = Logger.getLogger(NBServiceImpl.class);
+    @Override
+    public void task1() {
+        String sql="SELECT addtime from sp_iw863434046496870 where id=(SELECT max(id) from sp_iw863434046496870);";
+        SQLQuery query = getSession().createSQLQuery(sql);
+        List list = query.list();
+        String date = String.valueOf(list.get(0));
+
+        System.out.println("o = " + date);
+
+        Date time = null;
+        try {
+            time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        System.out.println("time = " + time);
+        long time1 = time.getTime();
+        System.out.println("time1 = " + time1);
+
+        long startTime =  System.currentTimeMillis();
+        System.out.println("startTime = " + startTime);
+        long usedTime1 = (startTime-time1);
+        System.out.println("usedTime = " + usedTime1+"毫秒");
+        long usedTime = (startTime-time1)/1000;
+        System.out.println("usedTime = " + usedTime+"秒");
+        long usedTime2 = (startTime-time1)/1000/60;
+        System.out.println("usedTime = " + usedTime2+"分钟");
+        long usedTime3 = (startTime-time1)/1000/60/60;
+        System.out.println("usedTime = " + usedTime3+"小时");
+
+       long s= startTime-time1;
+                //一小时判断
+                if ((1000*60*60*8)<s){
+                    LOGGER.info("==========井盖离线啦");
+                    System.out.println("井盖离线啦");
+                }else {
+                    LOGGER.info("==========井盖没离线呢");
+                    System.out.println("井盖还在线呢");
+
+                }
+
+
+
+    }
+}

+ 198 - 0
src/main/java/com/usky/service/Impl/SendWXServiceImpl.java

@@ -0,0 +1,198 @@
+package com.usky.service.Impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.usky.service.SendWXService;
+import com.usky.utils.HttpClientUtilWX;
+import com.usky.utils.HttpClientUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.log4j.Logger;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Service
+@Transactional
+public class SendWXServiceImpl extends BaseServieImpl implements SendWXService {
+    private static final Logger LOGGER = Logger.getLogger(HtServiceImpl.class);
+
+    @Override
+    @Async
+    public void YGsendWX(String devid, String loraWanId, String timeStamep, String evt) {
+        long startTime = System.currentTimeMillis();
+        LOGGER.info("++++++++++++++++++++++++++++++++告警数据上传微信++");
+        List<NameValuePair> nameValuePairsList = new ArrayList<>();
+        StringBuffer sb = new StringBuffer();
+        String sql = "SELECT company FROM sp_owner where owner_code='" + devid + "'";
+        SQLQuery query = getSession().createSQLQuery(sql);
+        List list = query.list();
+        Object o = list.get(0);
+        for (Object b : list) {
+            System.out.println("b = " + b.toString());
+        }
+        String s = o.toString();
+        String sql1 = "SELECT phone from sp_owner_phone  where data2 like'%6%' and owner_code='" + s + "'";
+        Query query1 = getSession().createSQLQuery(sql1);
+        List list1 = query1.list();
+//        for (Object b : list1) {
+//            System.out.println("b111 = " + b.toString());
+//        }
+        if (list1 != null && list1.size() > 0) {
+            for (Object sp : list1) {
+                sb.append(sp);
+                sb.append(",");
+                // System.out.println("sp = " + sp);
+            }
+        }
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String time = df.format(new Date());
+        BasicNameValuePair basicNameValuePair1 = new BasicNameValuePair("IMEI", devid);
+        // BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone",sb.toString());
+        BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone", sb.toString());
+        BasicNameValuePair basicNameValuePair3 = new BasicNameValuePair("insert_id", loraWanId);
+        BasicNameValuePair basicNameValuePair4 = new BasicNameValuePair("time", time);
+        BasicNameValuePair basicNameValuePair = new BasicNameValuePair("evt", evt);
+        nameValuePairsList.add(basicNameValuePair);
+        nameValuePairsList.add(basicNameValuePair1);
+        nameValuePairsList.add(basicNameValuePair2);
+        nameValuePairsList.add(basicNameValuePair3);
+        nameValuePairsList.add(basicNameValuePair4);
+
+        String url = "http://iot.usky.cn/jdxf/wxapp2.php/Home/Waterwarn/bj";
+        HttpClientUtilWX.doFromPost(url, null, nameValuePairsList);
+        System.out.println("发送微信");
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        LOGGER.info("++++++++++++++++++++++++++++++++告警数据上传微信完成++++耗时:" + usedTime + "秒+++++++++");
+
+    }
+
+
+    //发送微信
+    @Override
+    @Async
+    public void CoversendWX(String imei, String id, String time, String evtname, String deviceStatus) {
+        long startTime = System.currentTimeMillis();
+        LOGGER.info("++++++++++++++++++++++++++++++++告警数据开始上传微信*");
+
+//        String hql = "from sp_iw2017 t where t.Id=" + id;
+//        Query q = getSession().createQuery(hql);
+//        List list2 = q.list();
+        // String time1 = tRoleList.getTime();
+        //System.out.println("time1 = " + time1);
+
+        List<NameValuePair> nameValuePairsList = new ArrayList<>();
+        StringBuffer sb = new StringBuffer();
+        String sql = "SELECT company FROM sp_owner where owner_code='" + imei + "'";
+        SQLQuery query = getSession().createSQLQuery(sql);
+        List list = query.list();
+        Object o = list.get(0);
+        for (Object b : list) {
+            System.out.println("b = " + b.toString());
+        }
+        String s = o.toString();
+        String sql1 = "SELECT phone from sp_owner_phone  where data2 like'%6%' and owner_code='" + s + "'";
+        Query query1 = getSession().createSQLQuery(sql1);
+        List list1 = query1.list();
+        for (Object b : list1) {
+            System.out.println("b111 = " + b.toString());
+        }
+        if (list1 != null && list1.size() > 0) {
+            for (Object sp : list1) {
+                sb.append(sp);
+                sb.append(",");
+            }
+        }
+        BasicNameValuePair basicNameValuePair1 = new BasicNameValuePair("device_code", imei);
+        // BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone",sb.toString());
+        BasicNameValuePair basicNameValuePair2 = new BasicNameValuePair("phone", sb.toString());
+        BasicNameValuePair basicNameValuePair3 = new BasicNameValuePair("insert_id", id);
+        BasicNameValuePair basicNameValuePair4 = new BasicNameValuePair("time", time);
+        BasicNameValuePair basicNameValuePair = new BasicNameValuePair("evt", evtname);
+        nameValuePairsList.add(basicNameValuePair);
+        nameValuePairsList.add(basicNameValuePair1);
+        nameValuePairsList.add(basicNameValuePair2);
+        nameValuePairsList.add(basicNameValuePair3);
+        nameValuePairsList.add(basicNameValuePair4);
+if (!"0".equals(deviceStatus)){
+    String url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/ManholeCoverwarn/message_manhole_cover";
+    HttpClientUtilWX.doFromPost(url, null, nameValuePairsList);
+}
+
+        LOGGER.info("********************************告警数据上传微信完成*");
+        JSONObject cObj = new JSONObject();
+        /*SubType: 设备类型,井盖(不含液位),140
+DeviceId: 设备编号,sp_owner表中的owner_code
+InsertId: 告警报告列表的ID
+Confirmed: 告警确认标识,0
+CompanyCode: 单位编号,sp_owner表中的company字段
+evt_name: 告警名称,例如井盖打开
+evt: 告警编号,等下发你
+alarm_time: 告警时间,yyyy-MM-dd HH:mm:ss*/
+       /* 53 打开
+        54 关闭*/
+if (StringUtils.isNotEmpty(deviceStatus)){
+
+    cObj.put("SubType", "140");
+    cObj.put("DeviceId", imei);
+    cObj.put("InsertId", id);
+    cObj.put("Confirmed", "0");
+    cObj.put("CompanyCode", o);
+
+    if ("54".equals(deviceStatus)){
+        cObj.put("evt_name", "井盖关闭");
+        cObj.put("evt", "54");
+    }else if ("53".equals(deviceStatus)){
+        cObj.put("evt_name", "井盖开启");
+        cObj.put("evt", "53");
+    }else if ("0".equals(deviceStatus)){
+        cObj.remove("InsertId");
+        cObj.put("sig",evtname);
+        cObj.put("bat",id);
+    }
+
+    cObj.put("alarm_time", time);
+
+    final String curl = "http://47.98.201.73:55125/report";
+    HttpClientUtils.doPostJson(curl,cObj.toJSONString());
+}
+
+
+
+
+     //发送到c程序
+        JSONObject js = new JSONObject();
+        js.put("SubType", "128");
+        js.put("DeviceId", imei);
+        js.put("InsertId", id);
+        js.put("Confirmed", "false");
+        LOGGER.info("********************************告警数据开始上传C程序完成*");
+
+
+        HttpClientUtils.doPostJson("http://47.98.201.187:55335/report", js.toJSONString());
+
+        long endTime = System.currentTimeMillis();
+
+        long usedTime = (endTime - startTime) / 1000;
+        LOGGER.info("++++++++++++++++++++++++++++++++告警数据上传C程序完成++++耗时:" + usedTime + "秒+++++++++");
+
+    }
+
+
+}

+ 170 - 0
src/main/java/com/usky/service/Impl/aaaServiceImpl.java

@@ -0,0 +1,170 @@
+package com.usky.service.Impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.usky.entity.Yt_T_Lrdevice;
+import com.usky.service.aaaService;
+import com.usky.utils.HttpClientUtils;
+import com.usky.utils.MD5Util;
+import netscape.javascript.JSObject;
+import org.hibernate.SQLQuery;
+import org.springframework.stereotype.Service;
+import sun.misc.Request;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.transaction.Transactional;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Service
+@Transactional
+public class aaaServiceImpl extends BaseServieImpl implements aaaService {
+    @Override
+    public void doTaskOne() throws Exception {
+        System.out.println("开始做任务一");
+        long start = System.currentTimeMillis();
+        Thread.sleep(2000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务一,耗时:" + (end - start) + "毫秒");
+    }
+
+    @Override
+    public void doTaskTwo() throws Exception {
+        System.out.println("开始做任务二");
+        long start = System.currentTimeMillis();
+        Thread.sleep(3000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务二,耗时:" + (end - start) + "毫秒");
+    }
+
+    @Override
+    public void doTaskThree() throws Exception {
+        System.out.println("开始做任务三");
+        long start = System.currentTimeMillis();
+        Thread.sleep(4000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务三,耗时:" + (end - start) + "毫秒");
+    }
+
+    public static <T> List<T> castList(Object obj, Class<T> clazz) {
+        List<T> result = new ArrayList<T>();
+        if (obj instanceof List<?>) {
+            for (Object o : (List<?>) obj) {
+                result.add(clazz.cast(o));
+            }
+            return result;
+        }
+        return null;
+
+    }
+
+
+    /**
+     * @Author zhangzilong
+     * @Description //TODO   多设备定时查询是否离线
+     * @Date 11:30 2020/4/29
+     * @Param  * @param
+     * @return void
+     */
+    @Override
+    public void abb() throws Exception {
+
+
+        String sql = "SELECT max(eventtime) FROM yt_lora_data GROUP BY device_code;";
+        SQLQuery query = getSession().createSQLQuery(sql);
+        List list = query.list();
+
+        for (Object o : list) {
+            System.out.println("o = " + o.toString());
+
+            String sql1 = "SELECT device_code FROM yt_lora_data where eventtime='"+o+"';";
+            SQLQuery query1 = getSession().createSQLQuery(sql1);
+            List list1 = query1.list();
+            for (Object o1 : list1) {
+                System.out.println("o1 = " + o1.toString());
+                //todo 时间判断  修改状态
+            }
+
+
+        }
+
+
+            }
+
+    @Override
+    public String loralogin(HttpServletRequest request,String username, String password) {
+        HttpSession session = request.getSession();
+
+        String url="http://dc.turboes.com/Tbsapi/v1/login";
+        JSONObject json = new JSONObject();
+        String s1 = MD5Util.md5Encrypt32Lower(password);
+        //登录
+        json.put("username",username);
+        json.put("password",s1);
+        System.out.println(json.toString());
+        String s = HttpClientUtils.doPostJson(url, json.toJSONString());
+        JSONObject jsonObject = JSON.parseObject(s);
+        String code = jsonObject.get("code").toString();
+        System.out.println("code = " + code);
+        if ("1".equals(code)){
+            JSONObject data = jsonObject.getJSONObject("data");
+            Object a = data.get("token");
+            String token = String.valueOf(a);
+            System.out.println("登录成功");
+            System.out.println("token = " + token);
+            session.setAttribute("token",token);
+            //todo    token需要保存
+            Yt_T_Lrdevice lr = new Yt_T_Lrdevice();
+
+            return s;
+        }else {
+            //todo    登录失败   需要联系管理员
+
+            System.out.println("登录失败");
+            return s;
+        }
+    }
+
+    @Override
+    public String loradevicelogin(JSONObject json) {
+
+        //todo url需要拼接token
+        String url="http://dc.turboes.com/Tbsapi/v1/device_add?token=059521958a384af84185ec114359b67e";
+        JSONObject js = new JSONObject();
+        js.put("aid","318");
+        js.put("bid","496");
+        js.put("lname","yt01271a");
+        json.put("bind_address",js);
+        String s = HttpClientUtils.doPostJson(url, json.toJSONString());
+        JSONObject jsonObject = JSON.parseObject(s);
+        Object a = jsonObject.get("code");
+        String code = String.valueOf(a);
+        System.out.println("code = " + code);
+        System.out.println("发送数据"+json.toString());
+        if ("1".equals(code)){
+           //todo    注册成功保存到设备表   先主表返回主键
+
+            System.out.println("注册成功");
+            return s;
+        }else {
+            //todo    注册失败
+            System.out.println("注册失败");
+            Object a1 = jsonObject.get("info");
+            String info = String.valueOf(a1);
+
+            System.out.println("info = " + info);
+            return info;
+        }
+    }
+}
+
+
+

+ 65 - 0
src/main/java/com/usky/service/Impl/bbbServiceImpl.java

@@ -0,0 +1,65 @@
+package com.usky.service.Impl;
+
+import com.usky.service.aaaService;
+import com.usky.service.bbbService;
+import org.hibernate.Query;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+@Service
+@Transactional
+public class bbbServiceImpl extends BaseServieImpl implements bbbService {
+
+
+    @Override
+    @Async
+    public void doTaskOne() throws Exception {
+        System.out.println("开始做任务一bbbbb");
+        long start = System.currentTimeMillis();
+        Thread.sleep(2000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务一,耗时:" + (end - start) + "毫秒");
+    }
+    @Override
+    @Async
+    public void doTaskTwo() throws Exception {
+        System.out.println("开始做任务二bbbbb");
+        long start = System.currentTimeMillis();
+        Thread.sleep(3000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务二,耗时:" + (end - start) + "毫秒");
+    }
+    @Override
+    @Async
+    public void doTaskThree() throws Exception {
+        System.out.println("开始做任务三bbbbb");
+        long start = System.currentTimeMillis();
+        Thread.sleep(4000);
+        long end = System.currentTimeMillis();
+        System.out.println("完成任务三,耗时:" + (end - start) + "毫秒");
+    }
+
+    @Override
+    public void delet() {
+        String sql1="select a_name from  sp_lora_wan where id=3893";
+        Query query = getSession().createSQLQuery(sql1);
+        List list = query.list();
+        Object o = list.get(0);
+        System.out.println("id"+o.toString());
+        String sql="delete from sp_lora_wan where 1=1;";
+        int i = getSession().createSQLQuery(sql).executeUpdate();
+        System.out.println("i = " + i);
+
+    }
+}
+

+ 12 - 0
src/main/java/com/usky/service/NBService.java

@@ -0,0 +1,12 @@
+package com.usky.service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+public interface NBService {
+    void saveCover(String s);
+
+    String getStr(HttpServletRequest request) throws IOException;
+
+    void CoversendWX(String imei, String id,String time,String evtname);
+}

+ 16 - 0
src/main/java/com/usky/service/SendWXService.java

@@ -0,0 +1,16 @@
+package com.usky.service;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public interface SendWXService {
+
+    void YGsendWX(String devid, String loraWanId, String timeStamep, String evt);
+
+    void CoversendWX(String imei, String id, String time, String evtname, String deviceStatus);
+
+}

+ 27 - 0
src/main/java/com/usky/service/aaaService.java

@@ -0,0 +1,27 @@
+package com.usky.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public interface aaaService {
+    void doTaskOne() throws Exception;
+
+
+    void doTaskTwo() throws Exception;
+
+    void doTaskThree() throws Exception;
+
+    void abb() throws Exception;
+
+    String loralogin(HttpServletRequest request,String username, String password);
+
+    String loradevicelogin(JSONObject json);
+}

+ 21 - 0
src/main/java/com/usky/service/bbbService.java

@@ -0,0 +1,21 @@
+package com.usky.service;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public interface bbbService {
+
+    void doTaskOne() throws Exception;
+
+
+    void doTaskTwo() throws Exception;
+
+    void doTaskThree() throws Exception;
+
+
+    void delet();
+}

+ 12 - 0
src/main/java/com/usky/service/test.java

@@ -0,0 +1,12 @@
+package com.usky.service;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public interface test {
+    void task1();
+}

+ 29 - 0
src/main/java/com/usky/utils/ApplicationContextUtil.java

@@ -0,0 +1,29 @@
+package com.usky.utils;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class ApplicationContextUtil implements ApplicationContextAware {
+    private static ApplicationContext applicationContext;
+
+    public static ApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) {
+        ApplicationContextUtil.applicationContext = applicationContext;
+    }
+
+    public static Object getBean(String beanName) {
+        return applicationContext.getBean(beanName);
+    }
+
+}

+ 53 - 0
src/main/java/com/usky/utils/BeanHelp.java

@@ -0,0 +1,53 @@
+package com.usky.utils;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.BeanUtils;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/3/9 12:49
+ * @description TODO
+ **/
+
+public class BeanHelp {
+    private Logger logger = Logger.getLogger(BeanHelp.class);
+    public static <T> T copyProperties(Object source, Class<T> target){
+        try {
+            T t = target.newInstance();
+            BeanUtils.copyProperties(source, t);
+            return t;
+        } catch (Exception e) {
+           /* logger.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);*/
+            //logger.error();
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+    public static <T> List<T> copyWithCollection(List<?> sourceList, Class<T> target){
+        try {
+            return sourceList.stream().map(s -> copyProperties(s, target)).collect(Collectors.toList());
+        } catch (Exception e) {
+           // log.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+    public static <T> Set<T> copyWithCollection(Set<?> sourceList, Class<T> target){
+        try {
+            return sourceList.stream().map(s -> copyProperties(s, target)).collect(Collectors.toSet());
+        } catch (Exception e) {
+           // log.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+
+}

+ 151 - 0
src/main/java/com/usky/utils/HttpClientUtilWX.java

@@ -0,0 +1,151 @@
+package com.usky.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @Author zhangzilong
+ * @Description //TODO
+ * @Date $ $
+ * @Param $
+ * @return $
+ */
+public class HttpClientUtilWX {
+
+    //private static Logger logger = Logger.getLogger(HttpClientUtils.class);// 日志方便打印
+
+
+    /**
+     *  * post请求  * @param url  * @param authorValue  * @param json  * @return  
+     */
+    public static JSONObject doPost(String url, String authorValue, JSONObject json) {
+        DefaultHttpClient client = new DefaultHttpClient();
+        HttpPost post = new HttpPost(url);
+        if (StringUtils.isNotEmpty(authorValue)) {
+            post.setHeader("Authorization",authorValue);
+        }
+        JSONObject response = null;
+        try {
+            response = getJsonObject(json, client, post);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return response;
+    }
+
+    public static JSONObject doPost(String url, String authorValue, Map map) {
+        DefaultHttpClient client = new DefaultHttpClient();
+        HttpPost post = new HttpPost(url);
+        if (StringUtils.isNotEmpty(authorValue)) {
+            post.setHeader("Authorization", authorValue);
+        }
+        JSONObject response = null;
+        String result = "";
+        try {
+            StringEntity s = new StringEntity(map.toString());
+            s.setContentEncoding("UTF-8");
+            s.setContentType("application/json");// 发送json数据需要设置contentType
+            post.setEntity(s);
+
+            HttpResponse res = client.execute(post);
+            HttpEntity entity = res.getEntity();
+            result = EntityUtils.toString(entity);// 返回json格式:
+            response = JSONObject.parseObject(result);
+        } catch (Exception e) {
+            //logger.error("doPost 请求解析失败 result = " + result);
+            throw new RuntimeException(e);
+        }
+        return response;
+    }
+
+    private static JSONObject getJsonObject(JSONObject json, DefaultHttpClient client,
+                                            HttpEntityEnclosingRequestBase base) throws IOException {
+        JSONObject response;
+        StringEntity s = new StringEntity(json.toString());
+        s.setContentEncoding("UTF-8");
+        s.setContentType("application/json");// 发送json数据需要设置contentType
+        base.setEntity(s);
+
+        HttpResponse res = client.execute(base);
+        HttpEntity entity = res.getEntity();
+        String result = EntityUtils.toString(entity);// 返回json格式:
+        response = JSONObject.parseObject(result);
+        return response;
+    }
+
+    /**
+     *  * get 请求  * @param url  * @param authorValue  * @param para  * @return  
+     */
+    public static JSONObject doGet(String url, String authorValue, Map<String, String> para) {
+        JSONObject response = null;
+        String result = "";
+        try {
+            DefaultHttpClient client = new DefaultHttpClient();
+            URIBuilder builder = new URIBuilder(url);
+            Set<String> set = para.keySet();
+            for (String key : set) {
+                builder.setParameter(key, para.get(key));
+            }
+            HttpGet request = new HttpGet(builder.build());
+            if (StringUtils.isNotEmpty(authorValue)) {
+                request.setHeader("Authorization", authorValue);
+            }
+            request.setHeader("ContentTye", "application/json");
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(6000).setConnectTimeout(6000)
+                    .setConnectionRequestTimeout(6000).build();
+            request.setConfig(requestConfig);
+
+            HttpResponse res = client.execute(request);
+            // if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
+            result = EntityUtils.toString(res.getEntity());// 返回json格式:
+            response = JSONObject.parseObject(result);
+            // }
+        } catch (Exception e) {
+            //logger.error("doGet 请求解析失败 result = " + result);
+            throw new RuntimeException(e);
+        }
+        return response;
+    }
+    public static String doFromPost(String url, String authorValue, List list) {
+        HttpClient client = new DefaultHttpClient(); //客户端对象
+        HttpPost post = new HttpPost(url);             //请求对象
+        HttpEntity entity = null;//模拟form进行表单提交
+        try {
+            entity = new UrlEncodedFormEntity(list);
+            post.setEntity(entity);
+            HttpResponse response = client.execute(post);//连接服务器
+            if (response.getStatusLine().getStatusCode() == 200) {
+                HttpEntity entit = response.getEntity();//获取内容
+                return EntityUtils.toString(entit, "utf-8");
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return url;
+    }
+
+
+}

+ 138 - 0
src/main/java/com/usky/utils/HttpClientUtils.java

@@ -0,0 +1,138 @@
+package com.usky.utils;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.http.Consts;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+
+
+public class HttpClientUtils {
+
+	public static String doGet(String url, Map<String, String> param) {
+
+		// 创建Httpclient对象
+		CloseableHttpClient httpclient = HttpClients.createDefault();
+
+		String resultString = "";
+		CloseableHttpResponse response = null;
+		try {
+			// 创建uri
+			URIBuilder builder = new URIBuilder(url);
+			if (param != null) {
+				for (String key : param.keySet()) {
+					builder.addParameter(key, param.get(key));
+				}
+			}
+			URI uri = builder.build();
+			// 创建http GET请求
+			HttpGet httpGet = new HttpGet(uri);
+			// 执行请求
+			response = httpclient.execute(httpGet);
+			// 判断返回状态是否为200
+			if (response.getStatusLine().getStatusCode() == 200) {
+				resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (response != null) {
+					response.close();
+				}
+				httpclient.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return resultString;
+	}
+
+	public static String doGet(String url) {
+		return doGet(url, null);
+	}
+
+	public static String doPost(String url, Map<String, String> param) {
+		// 创建Httpclient对象
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		CloseableHttpResponse response = null;
+		String resultString = "";
+		try {
+			// 创建Http Post请求
+			HttpPost httpPost = new HttpPost(url);
+			// 创建参数列表
+			if (param != null) {
+				List<NameValuePair> paramList = new ArrayList<>();
+				for (String key : param.keySet()) {
+					paramList.add(new BasicNameValuePair(key, param.get(key)));
+				}
+				// 模拟表单
+				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+				httpPost.setEntity(entity);
+			}
+			// 执行http请求
+			response = httpClient.execute(httpPost);
+			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				response.close();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+		return resultString;
+	}
+
+	public static String doPost(String url) {
+		return doPost(url, null);
+	}
+
+	public static String doPostJson(String url, String json) {
+		// 创建Httpclient对象
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		CloseableHttpResponse response = null;
+		String resultString = "";
+		try {
+			// 创建Http Post请求
+			HttpPost httpPost = new HttpPost(url);
+			// 创建请求内容
+			StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
+			httpPost.setEntity(entity);
+			// 执行http请求
+			response = httpClient.execute(httpPost);
+			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				response.close();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+
+		return resultString;
+	}
+
+
+	
+	
+}

+ 37 - 0
src/main/java/com/usky/utils/ListUtil.java

@@ -0,0 +1,37 @@
+package com.usky.utils;
+
+import java.util.List;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/2/22 15:41
+ * @description 集合判断工具类
+ **/
+public class ListUtil {
+    /**
+     * 判断集合是否为空
+     * @param list
+     * @return
+     */
+    public static boolean isNotBlank(List list) {
+        if (list == null || list.isEmpty()) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     *
+     * @param list
+     * @return
+     */
+    public static boolean isBlank(List list) {
+        if (list == null || list.isEmpty()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

+ 99 - 0
src/main/java/com/usky/utils/MD5Util.java

@@ -0,0 +1,99 @@
+package com.usky.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class MD5Util {
+ 
+    /**
+     * MD5加密字符串(32位大写)
+     *
+     * @param string 需要进行MD5加密的字符串
+     * @return 加密后的字符串(大写)
+     */
+    public static String md5Encrypt32Upper(String string) {
+        byte[] hash;
+        try {
+            //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位
+            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("Huh, MD5 should be supported?", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Huh, UTF-8 should be supported?", e);
+        }
+ 
+        //转换为十六进制字符串
+        StringBuilder hex = new StringBuilder(hash.length * 2);
+        for (byte b : hash) {
+            if ((b & 0xFF) < 0x10) {hex.append("0");}
+            hex.append(Integer.toHexString(b & 0xFF));
+        }
+        return hex.toString().toUpperCase();
+    }
+ 
+    /**
+     * MD5加密字符串(32位小写)
+     *
+     * @param string 需要进行MD5加密的字符串
+     * @return 加密后的字符串(小写)
+     */
+    public static String md5Encrypt32Lower(String string) {
+        byte[] hash;
+        try {
+            //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位
+            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("Huh, MD5 should be supported?", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Huh, UTF-8 should be supported?", e);
+        }
+ 
+        //转换为十六进制字符串
+        StringBuilder hex = new StringBuilder(hash.length * 2);
+        for (byte b : hash) {
+            if ((b & 0xFF) < 0x10) {hex.append("0");}
+            hex.append(Integer.toHexString(b & 0xFF));
+        }
+        return hex.toString().toLowerCase();
+    }
+ 
+    /**
+     * 将二进制字节数组转换为十六进制字符串
+     *
+     * @param bytes 二进制字节数组
+     * @return 十六进制字符串
+     */
+    public static String bytesToHex(byte[] bytes) {
+        StringBuffer hexStr = new StringBuffer();
+        int num;
+        for (int i = 0; i < bytes.length; i++) {
+            num = bytes[i];
+            if (num < 0) {
+                num += 256;
+            }
+            if (num < 16) {
+                hexStr.append("0");
+            }
+            hexStr.append(Integer.toHexString(num));
+        }
+        return hexStr.toString().toUpperCase();
+    }
+ 
+    /**
+     * Unicode中文编码转换成字符串
+     */
+    public static String unicodeToString(String str) {
+        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
+        Matcher matcher = pattern.matcher(str);
+        char ch;
+        while (matcher.find()) {
+            ch = (char) Integer.parseInt(matcher.group(2), 16);
+            str = str.replace(matcher.group(1), ch + "");
+        }
+        return str;
+    }
+
+}

+ 19 - 0
src/main/java/com/usky/utils/NFDFlightDataTaskListener.java

@@ -0,0 +1,19 @@
+package com.usky.utils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+ 
+ 
+public class NFDFlightDataTaskListener implements  ServletContextListener {
+ 
+    @Override
+    public void contextInitialized(ServletContextEvent sce) {
+         new TimerManager();
+    }
+    @Override
+    public void contextDestroyed(ServletContextEvent sce) {
+        // TODO Auto-generated method stub
+         
+    }
+ 
+}

+ 40 - 0
src/main/java/com/usky/utils/NFDFlightDataTimerTask.java

@@ -0,0 +1,40 @@
+package com.usky.utils;
+ 
+import com.usky.service.Impl.SearchertypeTaskImpl;
+import org.aspectj.weaver.ast.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimerTask;
+ 
+/**
+ * 在 TimerManager 这个类里面,大家一定要注意 时间点的问题。如果你设定在凌晨2点执行任务。但你是在2点以后
+ *发布的程序或是重启过服务,那这样的情况下,任务会立即执行,而不是等到第二天的凌晨2点执行。为了,避免这种情况
+ *发生,只能判断一下,如果发布或重启服务的时间晚于定时执行任务的时间,就在此基础上加一天。
+ * @author wls
+ *
+ */
+
+public class NFDFlightDataTimerTask extends TimerTask {
+
+
+
+    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    @Override
+    public void run() {
+        try {
+             //在这里写你要执行的内容
+            System.out.println("执行当前时间"+formatter.format(Calendar.getInstance().getTime()));
+            SearchertypeTaskImpl springTask = (SearchertypeTaskImpl)ApplicationContextUtil.getBean("SearchertypeTaskImpl");
+            springTask.task1();
+
+        } catch (Exception e) {
+            System.out.println("-------------解析信息发生异常--------------");
+        }
+    }
+     
+}

+ 38 - 0
src/main/java/com/usky/utils/SpringTask.java

@@ -0,0 +1,38 @@
+package com.usky.utils;
+import com.usky.service.Impl.BaseServieImpl;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class SpringTask extends BaseServieImpl {
+    private static final Logger log = LoggerFactory.getLogger(SpringTask.class);
+
+
+    public void aaa() {
+        String sql = "SELECT addtime from sp_iw863434046496870 where id=(SELECT max(id) from sp_iw863434046496870);";
+        SQLQuery query = this.getSession().createSQLQuery(sql);
+        List list = query.list();
+        String o = String.valueOf(list.get(0));
+
+        System.out.println("o = " + o);
+    }
+//    @Scheduled(cron = "1/5 * * * * *")
+//    public void task1(){
+//        log.info("springtask 定时任务!");
+//        System.out.println("定时任务执行");
+//    }
+//
+//	@Scheduled(initialDelay = 1000,fixedRate = 1*1000)
+//    public void task2(){
+//        log.info("springtask 定时任务!");
+//    }
+}

+ 51 - 0
src/main/java/com/usky/utils/TimerManager.java

@@ -0,0 +1,51 @@
+package com.usky.utils;
+
+
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Timer;
+
+/**
+ * java定时任务,每天定时执行任务
+ * @author wls
+ *
+ */
+public class TimerManager {
+    //时间间隔
+     private static final long PERIOD_DAY = 24 * 60 * 60 * 1000;
+     public TimerManager() {
+          Calendar calendar = Calendar.getInstance(); 
+                 
+          /*** 定制每日2:00执行方法 ***/
+ 
+          calendar.set(Calendar.HOUR_OF_DAY, 9);
+          calendar.set(Calendar.MINUTE, 30);
+          calendar.set(Calendar.SECOND, 0);
+           
+          Date date=calendar.getTime(); //第一次执行定时任务的时间
+          System.out.println(date);
+          System.out.println("before 方法比较:"+date.before(new Date()));
+          //如果第一次执行定时任务的时间 小于 当前的时间
+          //此时要在 第一次执行定时任务的时间 加一天,以便此任务在下个时间点执行。如果不加一天,任务会立即执行。循环执行的周期则以当前时间为准
+          if (date.before(new Date())) {
+              date = this.addDay(date, 1);
+              System.out.println(date);
+          }
+
+          Timer timer = new Timer();
+
+          NFDFlightDataTimerTask task = new NFDFlightDataTimerTask();
+
+         //安排指定的任务在指定的时间开始进行重复的固定延迟执行。
+          timer.schedule(task,date,PERIOD_DAY);
+         }
+ 
+         // 增加或减少天数
+         public Date addDay(Date date, int num) {
+          Calendar startDT = Calendar.getInstance();
+          startDT.setTime(date);
+          startDT.add(Calendar.DAY_OF_MONTH, num);
+          return startDT.getTime();
+         }
+}

+ 4 - 0
src/main/resources/jdbc.properties

@@ -0,0 +1,4 @@
+jdbc.driverClassName=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://47.98.201.187:3306/jdxf?useUnicode=true&amp&characterEncoding=UTF-8&amp&autoReconnect=true&amp&autoReconnectForPools=true&amp&zeroDateTimeBehavior=convertToNull
+jdbc.username=root
+jdbc.password=Yt2018IoT

+ 24 - 0
src/main/resources/log4j.properties

@@ -0,0 +1,24 @@
+### \u8BBE\u7F6E###
+log4j.rootLogger = INFO,stdout,D,E
+
+### \u8F93\u51FA\u4FE1\u606F\u5230\u63A7\u5236\u62AC ###
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target = System.out
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
+
+### \u8F93\u51FADEBUG \u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7\u5230=D://logs/MQTT/log.log ###${catalina.base}/logs/MQTT/log.log   /var/tomcat/webapps/test
+log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
+log4j.appender.D.Threshold = INFO,console
+log4j.appender.D.File = D://logs/MQTT/log.log
+log4j.appender.D.Append = true
+log4j.appender.D.layout = org.apache.log4j.PatternLayout
+log4j.appender.D.layout.ConversionPattern = %d{yyyy/MM/dd HH:mm:ss} %-5p [%c{1}] - %m%n
+
+### \u8F93\u51FAERROR \u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7\u5230=D://logs/MQTT/error.log  ###${catalina.base}/logs/MQTT/error.log   /var/tomcat/webapps/logs/MQTT/error.log
+log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
+log4j.appender.E.File = D://logs/MQTT/error.log
+log4j.appender.E.Append = true
+log4j.appender.E.Threshold = ERROR
+log4j.appender.E.layout = org.apache.log4j.PatternLayout
+log4j.appender.E.layout.ConversionPattern = %d{yyyy/MM/dd HH:mm:ss} %-5p [%c{1}] - %m%n

+ 143 - 0
src/main/resources/spring/applicationContext.xml

@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:task="http://www.springframework.org/schema/task"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/task
+        http://www.springframework.org/schema/task/spring-task-4.3.xsd
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd
+        http://www.springframework.org/schema/aop
+        http://www.springframework.org/schema/aop/spring-aop.xsd">
+
+
+    <!--<task:annotation-driven/>-->
+    <!-- 给@Async指定线程池 -->
+    <task:annotation-driven executor="asyncExecutor" />
+    <!-- 线程池中最小线程数为20,最大数为150, 队列的capacity数为10,任务完成后,线程池中保留最小线程数20,超出的在10s内未使用将被结束掉,当使用的线程数超出线程池最大线程数且队列也已满时,由调用者所在线程来执行相应任务 -->
+    <task:executor id="asyncExecutor" pool-size="20-150"
+                   queue-capacity="10" keep-alive="10" rejection-policy="CALLER_RUNS" />
+
+    <!--定时任务-->
+    <!--<task:executor id="executor" pool-size="10" />-->
+    <!--<task:scheduler id="scheduler" pool-size="10" />-->
+    <!--<task:annotation-driven executor="executor" scheduler="scheduler" />-->
+    <!--&lt;!&ndash;开启注解扫描&ndash;&gt;-->
+    <!--<context:component-scan base-package="com.usky.service"></context:component-scan>-->
+    <!--在扫描时排除Controller-->
+    <context:component-scan base-package="com.usky.service"/>
+    <context:component-scan base-package="com.usky.dao"/>
+    <!--加载外部资源文件-->
+    <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
+    <!--动态代理方式 自动-->
+    <aop:aspectj-autoproxy proxy-target-class="true"/>
+    <!--装配dataSource-->
+    <!--<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">-->
+    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
+        <property name="sessionFactory">
+            <ref bean="sessionFactory"/>
+        </property>
+    </bean>
+    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
+        <property name="driverClass" value="${jdbc.driverClassName}"></property>
+        <property name="jdbcUrl" value="${jdbc.url}"></property>
+        <property name="user" value="${jdbc.username}"></property>
+        <property name="password" value="${jdbc.password}"></property>
+        <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 1 -->
+        <property name="acquireIncrement" value="1">
+        </property>
+        <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
+        <property name="initialPoolSize" value="3">
+        </property>
+        <!--最大空闲时间,30秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
+        <property name="maxIdleTime" value="30"></property>
+        <!--连接池中保留的最大连接数。Default: 15 -->
+        <property name="maxPoolSize" value="10"></property>
+        <!--连接池中保留的最小连接数。Default: 3 -->
+        <property name="minPoolSize" value="3"></property>
+        <!--两次连接中间隔时间,单位毫秒。Default: 1000 -->
+        <property name="acquireRetryDelay" value="1000"></property>
+        <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
+        <property name="acquireRetryAttempts" value="30"></property>
+        <!--获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效 保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试
+            获取连接失败后该数据源将申明已断开并永久关闭。Default: false -->
+
+        <property name="breakAfterAcquireFailure" value="false"></property>
+        <!-- 设定数据库连接超时时间,以秒为单位。如果连接池中某个数据库连接处于空闲状态且超过timeout秒时,就会从连接池中移除-->
+        <!--<property name="hibernate.c3p0.timeout">120</property>-->
+        <!--&lt;!&ndash; 设置数据库 &ndash;&gt;-->
+        <!--<property name="hibernate.c3p0.idle_test_period">3000</property>-->
+
+
+        <!--checkoutTimeout从池中拿未使用的连接,超时设置,如果没有设置,就不超时. -->
+        <property name="checkoutTimeout" value="30000"></property>
+        <property name="maxStatements" value="0"></property>
+        <!--每18000秒检查所有连接池中的空闲连接。Default: 0 -->
+        <property name="idleConnectionTestPeriod" value="18000"></property>
+        <!--testConnectionOnCheckout:如果设置为true,每次从池中取一个连接,将做一下测试,使用automaticTestTable 或者 preferredTestQuery,做一条查询语句.看看连接好不好用,不好用,就关闭它,重新从池中拿一个. -->
+        <property name="testConnectionOnCheckout" value="true"></property>
+
+    </bean>
+    <!-- 配置SessionFactory -->
+    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
+        <!-- 注入连接池 -->
+        <property name="dataSource" ref="dataSource"/>
+        <!-- 配置Hibernate的相关属性 -->
+
+        <property name="hibernateProperties">
+            <props>
+                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
+                <prop key="hibernate.show_sql">true</prop>
+                <prop key="hibernate.format_sql">true</prop>
+                <prop key="hibernate.hbm2ddl.auto">update</prop>
+                <prop key="hibernate.autoReconnect">true</prop>
+                <prop key="hibernate.connection.autoReconnect">true</prop>
+                <prop key="connection.autoReconnectForPools">true</prop>
+                <prop key="connection.is-connection-validation-required">true</prop>
+
+                <!--新增-->
+                <!-- 数据库连接池的使用 -->
+                <!-- 选择使用C3P0连接池 -->
+                <!--连接池中最小连接数 -->
+                <!--<prop key="hibernate.c3p0.min_size">5</prop>-->
+                <!--&lt;!&ndash; 连接池中最大连接数 &ndash;&gt;-->
+                <!--<prop key="hibernate.c3p0.max_size">20</prop>-->
+                <!--&lt;!&ndash; 设定数据库连接超时时间,以秒为单位。如果连接池中某个数据库连接处于空闲状态且超过timeout秒时,就会从连接池中移除&ndash;&gt;-->
+                <!--<prop key="hibernate.c3p0.timeout">120</prop>-->
+                <!--&lt;!&ndash; 设置数据库 &ndash;&gt;-->
+                <!--<prop key="hibernate.c3p0.idle_test_period">3000</prop>-->
+                <!--<prop key="c3p0.max_statement">100</prop>-->
+                <!--<prop key="c3p0.validate">true</prop>-->
+            </props>
+
+        </property>
+        <!--新增-->
+
+
+        <property name="packagesToScan"><!-- 扫描基于JPA注解的PO类目录-->
+            <list>
+                <value>com.usky.entity</value>
+            </list>
+        </property>
+    </bean>
+    <!--开启注解AOP-->
+    <!--  <aop:aspectj-autoproxy></aop:aspectj-autoproxy>-->
+    <!-- 事物管理器配置  -->
+    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
+        <property name="sessionFactory" ref="sessionFactory" />
+    </bean>
+    <tx:annotation-driven transaction-manager="transactionManager" />
+
+
+    <bean  id ="applicationContextUtil"  class ="com.usky.utils.ApplicationContextUtil" ></bean >
+    <bean  id ="SearchertypeTaskImpl"  class ="com.usky.service.Impl.SearchertypeTaskImpl" ></bean >
+    <!--<bean  id ="BaseDaoImpl"  class ="com.usky.dao.Impl.BaseDaoImpl" ></bean >-->
+
+</beans>

+ 27 - 0
src/main/resources/spring/springmvc-servlet.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:beans="http://www.springframework.org/schema/c"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+	http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/mvc
+        http://www.springframework.org/schema/mvc/spring-mvc.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context.xsd">
+    <!--开启注解扫描-->
+    <context:component-scan base-package="com.usky.controller"></context:component-scan>
+
+    <!--配置视图解析器-->
+    <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
+        <!--<property name="prefix" value="/WEB-INF/views/"></property>-->
+        <!--<property name="suffix" value=".jsp"></property>-->
+    <!--</bean>-->
+
+    <!--注解驱动-->
+    <mvc:annotation-driven></mvc:annotation-driven>
+
+
+
+
+</beans>

+ 70 - 0
src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+		  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+    <!--配置Post请求乱码过滤器-->
+    <!--<filter>-->
+        <!--<filter-name>postEncodingFilter</filter-name>-->
+        <!--<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>-->
+        <!--<init-param>-->
+            <!--<param-name>encoding</param-name>-->
+            <!--<param-value>utf-8</param-value>-->
+        <!--</init-param>-->
+    <!--</filter>-->
+    <!--<filter-mapping>-->
+        <!--<filter-name>postEncodingFilter</filter-name>-->
+        <!--<url-pattern>/</url-pattern>-->
+    <!--</filter-mapping>-->
+    <filter>
+        <filter-name>encodingFilter</filter-name>
+        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
+        <async-supported>true</async-supported>
+        <init-param>
+            <param-name>encoding</param-name>
+            <param-value>UTF-8</param-value>
+        </init-param>
+        <init-param>
+            <param-name>forceEncoding</param-name>
+            <param-value>true</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>encodingFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>classpath:spring/applicationContext*.xml</param-value>
+    </context-param>
+    <!--NFDFlightDataTaskListener 监听器-->
+    <listener>
+        <listener-class>com.usky.utils.NFDFlightDataTaskListener</listener-class>
+    </listener>
+    <!--配置spring的监听器-->
+    <listener>
+        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
+
+    </listener>
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+    <!--配置前端控制器-->
+    <servlet>
+        <servlet-name>sringmvc</servlet-name>
+        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+        <init-param>
+            <param-name>contextConfigLocation</param-name>
+            <param-value>classpath:spring/springmvc-servlet.xml</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>sringmvc</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+    <welcome-file-list>
+        <welcome-file>index.html</welcome-file>
+    </welcome-file-list>
+</web-app>

+ 10 - 0
src/main/webapp/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>测试首页</title>
+</head>
+<body>
+
+</body>
+</html>

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels