list = new ArrayList<>();
- list.add(new IotSensorInfo(address, 0, x, deviceCode.toString())) ;
- list.add(new IotSensorInfo(address, 1, y, deviceCode.toString())) ;
- list.add(new IotSensorInfo(address, 2, tempure, deviceCode.toString())) ;
- list.add(new IotSensorInfo(address, 3, battery, deviceCode.toString())) ;
- // 上传
- // 放入到线程中走
- MinaServer.threadPool.execute(new Runnable() {
- @Override
- public void run() {
- String body = Util.json.object2Json(list);
- String url = Constants.URL.SENSORS_DATA;
- // 控制状态修改
- HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body);
- }
- });
- }else{
- LOGGER.info("Lora YW 数据不完整,length=" + lenght+ ", datalength=" + data.length );
- }
- }
-
- }catch(Exception e) {
-
- }
- }
-
- /**
- * 心跳包
- */
- @Override
- public void handbert(IoSession session){
- try{
- // 判断session 读写空闲时间 ( 在每种协议中,确认服务端空闲时间,每个的空闲时间不同则行 )
- if( session.containsAttribute(Constants.NODE_INFO) ){
- IotNodeInfoBO nodeBO = (IotNodeInfoBO) session.getAttribute(Constants.NODE_INFO);
- // 如果上传周期配置为0以及以下,则不设置设备离线 ;
- if( nodeBO.getFrequency() <1 ){
- return ;
- }
- if(session.getLastReadTime() + (nodeBO.getFrequency()+60)*1000 < new Date().getTime() ){
- // session 已判断为假死,关闭session
- session.close(true);
- return ;
- }
-
- }else{
- session.close(true);
- }
- }catch(Exception e){
- session.close(true);
- }
- }
-
- /**
- * 动作执行
- * @param session
- * @param data
- * @param msg
- * IOT_SERVER_LPM:TYPE,nodeId,SENSOR_DEVICE_ID,PORT_ID,DATA,FORMULATE
- */
- @Override
- public void execServer(IoSession session, byte[] data, String msg) {
- // IOT_SERVER_LPM:control,device_code,sensor_device_id, subtype
- String subStr = msg.split(":")[1];
- String[] commands = subStr.split(",");
- String type = commands[0];
- String nodeDeviceCode = commands[1];
- String address = commands[2];
- String subType = commands[3] ; // 子类型
-
- byte btype = Byte.parseByte(subType) ;
-
- // 设置绝对零点
- byte[] command = { 0x77 , 0x08 } ;
- command = Util.protocal.append(command,
- Util.protocal.octInt2ByteArray( Integer.parseInt(address) , 4) );
- command = Util.protocal.append(command,
- new byte[]{0x05, btype } );
- byte a = 0 ;
- for(int i=1;i< command.length ;i++){
- a += command[i] ;
- }
- command = Util.protocal.append(command, new byte[]{ a } );
-
- Util.mina.write(Cache.nodeIdsessionMap.get(nodeDeviceCode), command);
- }
-
- @Override
- public boolean match(IoSession session, byte[] data, String msg) {
- return false ;
- }
-
- @Override
- public void logout(IoSession session) {
- IotNodeInfo iotNodeInfo = new IotNodeInfo();
- iotNodeInfo.setDevice_code( session.getAttribute(Constants.DEVICECODE) +""); ;
- iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.offline);
- iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY);
- String body = Util.json.object2Json(iotNodeInfo);
- HttpServiceSender.doPut(Constants.URL.NODE_INFO, Config.IOT_USER_KEY, body);
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java
deleted file mode 100644
index f62d5f6..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.lpro.iot.server;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.mina.core.service.IoAcceptor;
-import org.apache.mina.core.session.ExpiringSessionRecycler;
-import org.apache.mina.core.session.IoSessionConfig;
-import org.apache.mina.filter.executor.ExecutorFilter;
-import org.apache.mina.transport.socket.DatagramSessionConfig;
-import org.apache.mina.transport.socket.SocketSessionConfig;
-import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
-import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.lpro.iot.common.Config;
-import com.lpro.iot.mqtt.MqttService;
-import com.lpro.iot.serviceImpl.MsgHandlerServiceImpl;
-import com.lpro.iot.serviceImpl.TaskServiceImpl;
-
-/**
- * 入口方法
- *
- */
-public class MinaServer {
-
- public static Logger LOGGER = null;
-
- public static ExecutorService threadPool = Executors.newFixedThreadPool(15);
-
- public static void main(String[] args) throws IOException {
- try {
- if (args != null && args.length > 0) {
- // 设置端口参数
- // 端口参数: args[0]
- // LPM key: args[1]
- Config.loadExtenalConfig(args);
- }
- // logger 初始化
- System.setProperty("lpmKey", Config.IOT_LPM_KEY);
- LOGGER = (Logger) LoggerFactory.getLogger(MinaServer.class);
-
- // 根据协议类型,动态加载相应的服务
-
- ServerIoHandler.msgHandlerService = new MsgHandlerServiceImpl();
-
- // 创建一个非阻塞的Server端Socket
- IoAcceptor acceptor = new NioSocketAcceptor();
- // 设置Handler
- acceptor.setHandler(new ServerIoHandler());
-
- IoSessionConfig cfg = acceptor.getSessionConfig();
- if (cfg instanceof SocketSessionConfig) {
- ((SocketSessionConfig) cfg).setReceiveBufferSize(2 * 1024);
- ((SocketSessionConfig) cfg).setReadBufferSize(2 * 1024);
- ((SocketSessionConfig) cfg).setKeepAlive(true);
- ((SocketSessionConfig) cfg).setSoLinger(0);
- ((SocketSessionConfig) cfg).setTcpNoDelay(true);
- ((SocketSessionConfig) cfg).setWriteTimeout(1000 * 5);
- }
- // 绑定监听端口
- acceptor.bind(new InetSocketAddress(Config.IOT_PORT));
-
- // 任务线程池
- threadPool.execute(new TaskServiceImpl());
-
- // mqtt 启动
- MqttService mqtt = new MqttService();
-
- // udp server
- if(Config.IOT_UDP_SWITCH){
- // ** Acceptor设置
- NioDatagramAcceptor acceptorUdp = new NioDatagramAcceptor();
- // 此行代码能让你的程序整体性能提升10倍
- acceptorUdp.getFilterChain()
- .addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));
- // 设置MINA2的IoHandler实现类
- acceptorUdp.setHandler(new UdpSeverHandler());
- // 设置会话超时时间(单位:毫秒),不设置则默认是10秒,请按需设置
- acceptorUdp.setSessionRecycler(new ExpiringSessionRecycler(15 * 1000));
- // ** UDP通信配置
- DatagramSessionConfig dcfg = acceptorUdp.getSessionConfig();
- dcfg.setReuseAddress(true);
- // 设置输入缓冲区的大小,压力测试表明:调整到2048后性能反而降低
- dcfg.setReceiveBufferSize(1024);
- // 设置输出缓冲区的大小,压力测试表明:调整到2048后性能反而降低
- dcfg.setSendBufferSize(1024);
- // ** UDP服务端开始侦听
- acceptorUdp.bind(new InetSocketAddress(Config.IOT_UDP_PORT));
- LOGGER.info("udp server startup listening on port:" + Config.IOT_UDP_PORT);
- }
-
- } catch (Exception e) {
- LOGGER.error("server startup error!" + e.getMessage());
- return;
- }
- LOGGER.info("tcp server startup listening on port:" + Config.IOT_PORT);
- }
-
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java
deleted file mode 100644
index 43c0dce..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.lpro.iot.server;
-
-import org.apache.mina.core.service.IoHandlerAdapter;
-import org.apache.mina.core.session.IdleStatus;
-import org.apache.mina.core.session.IoSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.lpro.iot.service.MsgHandlerService;
-
-
-public class ServerIoHandler extends IoHandlerAdapter
-{
- protected static MsgHandlerService msgHandlerService = null;
-
- public final static Logger LOGGER = (Logger) LoggerFactory.getLogger(ServerIoHandler.class);
-
- //自定义异常处理
- @Override
- public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
- {
- LOGGER.error(cause.getMessage());
- }
-
- //对接收到的消息(已经解码)进行下一步处理
- @Override
- public void messageReceived( IoSession session, Object message ) throws Exception
- {
- try{
- msgHandlerService.MsgHandler(session, message);
- }catch(Exception e){
- e.printStackTrace();
- LOGGER.error(e.getMessage());
- }
- }
- //当Session处于IDLE状态的时候,输出空闲状态次数
- @Override
- public void sessionIdle( IoSession session, IdleStatus status ) throws Exception
- {
- System.out.println( "IDLE Count:" + session.getIdleCount( status ));
- }
-
-
- @Override
- public void sessionOpened(IoSession session) throws Exception {
- String ip = session.getRemoteAddress().toString().split("\\:")[0];
- LOGGER.info(ip+" connection is open!");
- }
-
- @Override
- public void sessionClosed(IoSession session) throws Exception {
- msgHandlerService.sessionClosed(session);
- }
-
-}
\ No newline at end of file
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java
deleted file mode 100644
index bac50e5..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.lpro.iot.server;
-
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.future.WriteFuture;
-import org.apache.mina.core.service.IoHandlerAdapter;
-import org.apache.mina.core.session.IoSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.lpro.iot.protocal.ProtocalFactory;
-import com.lpro.iot.utils.Util;
-
-public class UdpSeverHandler extends IoHandlerAdapter {
- private static Logger logger = (Logger) LoggerFactory.getLogger(UdpSeverHandler.class);
-
- public static final CharsetDecoder decoder = (Charset.forName("UTF-8")).newDecoder();
-
- /**
- * MINA的异常回调方法。
- *
- * 本类中将在异常发生时,立即close当前会话。
- *
- * @param session
- * 发生异常的会话
- * @param cause
- * 异常内容
- * @see IoSession#close(boolean)
- */
- @Override
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
- logger.error("[IMCORE]exceptionCaught捕获到错了,原因是:" + cause.getMessage(), cause);
- session.close(true);
- }
-
- /**
- * MINA框架中收到客户端消息的回调方法。
- *
- * 本类将在此方法中实现完整的即时通讯数据交互和处理策略。
- *
- * 为了提升并发性能,本方法将运行在独立于MINA的IoProcessor之外的线程池中, 详见
- * {@link ServerLauncher#initAcceptor()}中的MINA设置代码 。
- *
- * @param session
- * 收到消息对应的会话引用
- * @param message
- * 收到的MINA的原始消息封装对象,本类中是 {@link IoBuffer}对象
- * @throws Exception
- * 当有错误发生时将抛出异常
- */
- @Override
- public void messageReceived(IoSession session, Object message) throws Exception {
- // *********************************************** 接收数据
- // 读取收到的数据
- IoBuffer ioBuffer = (IoBuffer) message;
- byte[] data = new byte[ioBuffer.limit()];
- ioBuffer.get(data);
- StringBuffer stringBuffer = new StringBuffer();
- for (int i = 0; i < data.length; i++) {
- stringBuffer.append((char) data[i]);
- }
-
- // 注意:当客户使用不依赖于MINA库的情况下,以下官方推
- // 荐的读取方法会在数据首部出现几个字节的未知乱码
- // message.toString()
-
- ServerIoHandler.LOGGER.info("udp orgin byte data: " + Util.binhexoct.bytesToHex(data));
- ServerIoHandler.LOGGER.info("udp orgin String data:" + stringBuffer.toString());
-
-
- }
-
- @Override
- public void sessionOpened(IoSession session) throws Exception {
- String ip = session.getRemoteAddress().toString().split("\\:")[0];
- logger.info(ip+" connection is open!");
- }
-
- @Override
- public void sessionClosed(IoSession session) throws Exception {
- logger.info("session is closed!");
- }
-
-}
\ No newline at end of file
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java
deleted file mode 100644
index f5e2747..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.lpro.iot.service;
-
-import org.apache.mina.core.session.IoSession;
-
-public interface MsgHandlerService {
-
- public void MsgHandler(IoSession session, Object message);
-
- public void sessionClosed(IoSession session);
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java
deleted file mode 100644
index 07a8337..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.lpro.iot.service.impl.task;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TimerTask;
-
-import org.apache.mina.core.session.IoSession;
-
-import com.lpro.iot.common.Cache;
-import com.lpro.iot.common.Constants;
-import com.lpro.iot.mqtt.MqttService;
-import com.lpro.iot.protocal.ProtocalFactory;
-
-
-/**
- * 网关状态请求
- *
- *
- */
-public class NodeHeartTask extends TimerTask {
-
- @Override
- public void run() {
- try {
- // 后面用线程处理业务
- Iterator> entries = Cache.nodeIdsessionMap.entrySet().iterator();
- while(entries.hasNext()){
- Map.Entry entry = entries.next();
- IoSession session = entry.getValue();
- if(session.isConnected() && !session.isClosing()){
- ProtocalFactory.getInstance(entry.getValue().getAttribute(Constants.PROTOCOL_CATEGORY).toString() ).handbert(entry.getValue());
- }else{
- // 关闭连接
-// session.close(true);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java
deleted file mode 100644
index 7e3d468..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.lpro.iot.service.impl.task;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TimerTask;
-
-import com.lpro.iot.common.Cache;
-import com.lpro.iot.mqtt.MqttService;
-import com.lpro.iot.utils.ObjectUtil;
-
-
-/**
- * 系统健康检测
- * 处理mqtt是否处于连接
- *
- *
- */
-public class SysHealthExam extends TimerTask {
-
- @Override
- public void run() {
- try {
- // mqtt 健康检测
- if( ObjectUtil.isNotEmpty(MqttService.client) && ! MqttService.client.isConnected() ){
- MqttService.connect();
- }
-
-
- // 检测过期数据
- Iterator> entries = Cache.deviceMap.entrySet().iterator();
- while(entries.hasNext()){
- Map.Entry entry = entries.next();
- if( entry.getValue() + 3*60*1000 < new Date().getTime() ){
- entries.remove();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java b/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java
deleted file mode 100644
index 076fbb4..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.lpro.iot.serviceImpl;
-
-import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.mina.core.session.IoSession;
-
-import com.lpro.iot.common.Cache;
-import com.lpro.iot.common.Constants;
-import com.lpro.iot.protocal.Protocal;
-import com.lpro.iot.protocal.ProtocalFactory;
-import com.lpro.iot.server.ServerIoHandler;
-import com.lpro.iot.service.MsgHandlerService;
-import com.lpro.iot.utils.ObjectUtil;
-import com.lpro.iot.utils.Util;
-
-public class MsgHandlerServiceImpl implements MsgHandlerService {
-
- @Override
- public void MsgHandler(IoSession session, Object message) {
- IoBuffer ioBuffer = (IoBuffer) message;
- byte[] data = new byte[ioBuffer.limit()];
- String msg = "" ;
- try {
- ioBuffer.get(data);
- StringBuffer stringBuffer = new StringBuffer();
- for (int i = 0; i < data.length; i++) {
- stringBuffer.append((char) data[i]);
- }
- msg = stringBuffer.toString();
-
- if(ObjectUtil.isNotEmpty(msg)){
- if(msg.contains(Constants.IOT_LPM_TYPE)){
- // iot server find LPM
- Protocal.execServer(session,data,msg);
- }else{
- // gateway find LPM
- // 判断网关是否已经登录注册
- if( session.containsAttribute(Constants.DEVICECODE) ){
- // 是否需要转发
- if( session.containsAttribute(Constants.DEVICE_FLAG) ) {
- IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ;
- Util.mina.write(destSession, data);
- }else {
- // 已注册登录
- if(Cache.nodeIdsessionMap.containsKey(session.getAttribute(Constants.DEVICECODE))){
- Protocal.analysisData(session,data,msg);
- }else{
- session.close(true);
- }
- }
- }else if( session.containsAttribute(Constants.DEVICE_TRANSFER)) {
- // 转发
- IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ;
- Util.mina.write(destSession, data);
- }else{
- // 注册登录
- Protocal.loginProtocal(session, data, msg);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void sessionClosed(IoSession session) {
- // 有些没有注册成功的
- if(session.containsAttribute(Constants.DEVICECODE) ){
- // 活跃NodeId Session 去除
- Cache.nodeIdsessionMap.remove(session.getAttribute(Constants.DEVICECODE).toString());
- String deviceCategory = session.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ;
- ProtocalFactory.getInstance(deviceCategory).logout(session);
- session.removeAttribute(Constants.DEVICECODE);
- }
-
- if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_SESSION))) {
- // 转发
- IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ;
- destSession.close(true) ;
- }
-
- }
-
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java b/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java
deleted file mode 100644
index 37b45b2..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.lpro.iot.serviceImpl;
-
-import java.util.Date;
-import java.util.Timer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.lpro.iot.service.impl.task.NodeHeartTask;
-import com.lpro.iot.service.impl.task.SysHealthExam;
-
-
-
-public class TaskServiceImpl implements Runnable {
-
- private static Logger LOGGER = (Logger) LoggerFactory.getLogger(TaskServiceImpl.class);
-
- @Override
- public void run() {
- try {
-
- // 10s 一次心跳
- new Timer().schedule(new NodeHeartTask(), new Date(), 10 * 1000);
-
- new Timer().schedule(new SysHealthExam(),new Date(), 30* 1000);
-
- } catch (Exception e) {
- e.getStackTrace();
- LOGGER.error("timer has error:" + e.getMessage());
- }
-
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java
deleted file mode 100644
index 2596d8b..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.lpro.iot.utils;
-
-public class ArithHelper {
- // 默认除法运算精度
- private static final int DEF_DIV_SCALE = 16;
-
- // 这个类不能实例化
- private ArithHelper() {
- }
-
- /**
- * 提供精确的加法运算。
- *
- * @param v1 被加数
- * @param v2 加数
- * @return 两个参数的和
- */
-
- public static double add(double v1, double v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
- java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
- return b1.add(b2).doubleValue();
- }
-
- public static double add(String v1, String v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
- java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
- return b1.add(b2).doubleValue();
- }
-
- /**
- * 提供精确的减法运算。
- *
- * @param v1 被减数
- * @param v2 减数
- * @return 两个参数的差
- */
-
- public static double sub(double v1, double v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
- java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
- return b1.subtract(b2).doubleValue();
- }
-
- public static double sub(String v1, String v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
- java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
- return b1.subtract(b2).doubleValue();
- }
-
- /**
- * 提供精确的乘法运算。
- *
- * @param v1
- * 被乘数
- * @param v2
- * 乘数
- * @return 两个参数的积
- */
-
- public static double mul(double v1, double v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
- java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
- return b1.multiply(b2).doubleValue();
- }
-
- public static double mul(String v1, String v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
- java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
- return b1.multiply(b2).doubleValue();
- }
-
- /**
- * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
- *
- * @param v1
- * 被除数
- * @param v2
- * 除数
- * @return 两个参数的商
- */
-
- public static double div(double v1, double v2) {
- return div(v1, v2, DEF_DIV_SCALE);
- }
-
- public static double div(String v1, String v2) {
- java.math.BigDecimal b1 = new java.math.BigDecimal(v1);
- java.math.BigDecimal b2 = new java.math.BigDecimal(v2);
- return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
- /**
- * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
- *
- * @param v1 被除数
- * @param v2 除数
- * @param scale 表示表示需要精确到小数点以后几位。
- * @return 两个参数的商
- */
-
- public static double div(double v1, double v2, int scale) {
- if (scale < 0) {
- throw new IllegalArgumentException("The scale must be a positive integer or zero");
- }
- java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1));
- java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2));
- return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
- /**
- * 提供精确的小数位四舍五入处理。
- *
- * @param v 需要四舍五入的数字
- * @param scale 小数点后保留几位
- * @return 四舍五入后的结果
- */
-
- public static double round(double v, int scale) {
- if (scale < 0) {
- throw new IllegalArgumentException("The scale must be a positive integer or zero");
- }
- java.math.BigDecimal b = new java.math.BigDecimal(Double.toString(v));
- java.math.BigDecimal one = new java.math.BigDecimal("1");
- return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
- public static double round(String v, int scale) {
- if (scale < 0) {
- throw new IllegalArgumentException("The scale must be a positive integer or zero");
- }
- java.math.BigDecimal b = new java.math.BigDecimal(v);
- java.math.BigDecimal one = new java.math.BigDecimal("1");
- return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java
deleted file mode 100644
index fd209fa..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.util.Collections;
-import java.util.Stack;
-
-/**
- * 算数表达式求值 直接调用Calculator的类方法conversion() 传入算数表达式,将返回一个浮点值结果 如果计算过程错误,将返回一个NaN
- */
-public class Calculator {
- private Stack postfixStack = new Stack();// 后缀式栈
- private Stack opStack = new Stack();// 运算符栈
- private int[] operatPriority = new int[] { 0, 3, 2, 1, -1, 1, 0, 2 };// 运用运算符ASCII码-40做索引的运算符优先级
-
- public static double conversion(String expression) {
- double result = 0;
- Calculator cal = new Calculator();
- try {
- expression = transform(expression);
- result = cal.calculate(expression);
- } catch (Exception e) {
- // e.printStackTrace();
- // 运算错误返回NaN
- return 0.0 / 0.0;
- }
- // return new String().valueOf(result);
- return result;
- }
-
- public static String conversion2String(String expression) {
- double result = 0;
- Calculator cal = new Calculator();
- try {
- expression = transform(expression);
- result = cal.calculate(expression);
- } catch (Exception e) {
- // e.printStackTrace();
- // 运算错误返回NaN
- return null;
- }
- // return new String().valueOf(result);
- return Double.toString(result);
- }
-
- /**
- * 将表达式中负数的符号更改
- *
- * @param expression
- * 例如-2+-1*(-3E-2)-(-1) 被转为 ~2+~1*(~3E~2)-(~1)
- * @return
- */
- private static String transform(String expression) {
- char[] arr = expression.toCharArray();
- for (int i = 0; i < arr.length; i++) {
- if (arr[i] == '-') {
- if (i == 0) {
- arr[i] = '~';
- } else {
- char c = arr[i - 1];
- if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == 'E' || c == 'e') {
- arr[i] = '~';
- }
- }
- }
- }
- if (arr[0] == '~' || arr[1] == '(') {
- arr[0] = '-';
- return "0" + new String(arr);
- } else {
- return new String(arr);
- }
- }
-
- /**
- * 按照给定的表达式计算
- *
- * @param expression
- * 要计算的表达式例如:5+12*(3+5)/7
- * @return
- */
- public double calculate(String expression) {
- Stack resultStack = new Stack();
- prepare(expression);
- Collections.reverse(postfixStack);// 将后缀式栈反转
- String firstValue, secondValue, currentValue;// 参与计算的第一个值,第二个值和算术运算符
- while (!postfixStack.isEmpty()) {
- currentValue = postfixStack.pop();
- if (!isOperator(currentValue.charAt(0))) {// 如果不是运算符则存入操作数栈中
- currentValue = currentValue.replace("~", "-");
- resultStack.push(currentValue);
- } else {// 如果是运算符则从操作数栈中取两个值和该数值一起参与运算
- secondValue = resultStack.pop();
- firstValue = resultStack.pop();
-
- // 将负数标记符改为负号
- firstValue = firstValue.replace("~", "-");
- secondValue = secondValue.replace("~", "-");
-
- String tempResult = calculate(firstValue, secondValue, currentValue.charAt(0));
- resultStack.push(tempResult);
- }
- }
- return Double.valueOf(resultStack.pop());
- }
-
- /**
- * 数据准备阶段将表达式转换成为后缀式栈
- *
- * @param expression
- */
- private void prepare(String expression) {
- opStack.push(',');// 运算符放入栈底元素逗号,此符号优先级最低
- char[] arr = expression.toCharArray();
- int currentIndex = 0;// 当前字符的位置
- int count = 0;// 上次算术运算符到本次算术运算符的字符的长度便于或者之间的数值
- char currentOp, peekOp;// 当前操作符和栈顶操作符
- for (int i = 0; i < arr.length; i++) {
- currentOp = arr[i];
- if (isOperator(currentOp)) {// 如果当前字符是运算符
- if (count > 0) {
- postfixStack.push(new String(arr, currentIndex, count));// 取两个运算符之间的数字
- }
- peekOp = opStack.peek();
- if (currentOp == ')') {// 遇到反括号则将运算符栈中的元素移除到后缀式栈中直到遇到左括号
- while (opStack.peek() != '(') {
- postfixStack.push(String.valueOf(opStack.pop()));
- }
- opStack.pop();
- } else {
- while (currentOp != '(' && peekOp != ',' && compare(currentOp, peekOp)) {
- postfixStack.push(String.valueOf(opStack.pop()));
- peekOp = opStack.peek();
- }
- opStack.push(currentOp);
- }
- count = 0;
- currentIndex = i + 1;
- } else {
- count++;
- }
- }
- if (count > 1 || (count == 1 && !isOperator(arr[currentIndex]))) {// 最后一个字符不是括号或者其他运算符的则加入后缀式栈中
- postfixStack.push(new String(arr, currentIndex, count));
- }
-
- while (opStack.peek() != ',') {
- postfixStack.push(String.valueOf(opStack.pop()));// 将操作符栈中的剩余的元素添加到后缀式栈中
- }
- }
-
- /**
- * 判断是否为算术符号
- *
- * @param c
- * @return
- */
- private boolean isOperator(char c) {
- return c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')';
- }
-
- /**
- * 利用ASCII码-40做下标去算术符号优先级
- *
- * @param cur
- * @param peek
- * @return
- */
- public boolean compare(char cur, char peek) {// 如果是peek优先级高于cur,返回true,默认都是peek优先级要低
- boolean result = false;
- if (operatPriority[(peek) - 40] >= operatPriority[(cur) - 40]) {
- result = true;
- }
- return result;
- }
-
- /**
- * 按照给定的算术运算符做计算
- *
- * @param firstValue
- * @param secondValue
- * @param currentOp
- * @return
- */
- private String calculate(String firstValue, String secondValue, char currentOp) {
- String result = "";
- switch (currentOp) {
- case '+':
- result = String.valueOf(ArithHelper.add(firstValue, secondValue));
- break;
- case '-':
- result = String.valueOf(ArithHelper.sub(firstValue, secondValue));
- break;
- case '*':
- result = String.valueOf(ArithHelper.mul(firstValue, secondValue));
- break;
- case '/':
- result = String.valueOf(ArithHelper.div(firstValue, secondValue));
- break;
- }
- return result;
- }
-
- public static void main(String[] args) {
- String expression = "(3*(-2.13))+1";
- double result = Calculator.conversion(expression);
- System.out.println(expression + " = " + result);
- System.out.println();
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java
deleted file mode 100644
index b23a2a0..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package com.lpro.iot.utils;
-
-
-
-
-import java.math.BigDecimal;
-
-/**
- * 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具
- */
-public class CoordinateTransformUtil {
-
-// static String BAIDU_GEOCONV_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX";
- static String baiduUrl = "http://api.map.baidu.com/geocoder/v2";
- static int B_DIV_SCALE = 15;
- static BigDecimal x_pi = new BigDecimal("3.14159265358979324").multiply(new BigDecimal("3000")).divide(new BigDecimal("180"), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP);
- // π
- static BigDecimal pi = new BigDecimal("3.1415926535897932384626");
- // 长半轴
- static BigDecimal a = new BigDecimal("6378245");
- // 扁率
- static BigDecimal ee = new BigDecimal("0.00669342162296594323");
- static BigDecimal b_1 = new BigDecimal("-1");
- static BigDecimal b_2 = new BigDecimal("10");
- static BigDecimal b_3 = new BigDecimal("2");
- static BigDecimal b_4 = new BigDecimal("105");
- static BigDecimal b_5 = new BigDecimal("3");
- static BigDecimal b_6 = new BigDecimal("35");
- static BigDecimal b_7 = new BigDecimal("160");
- static BigDecimal b_8 = new BigDecimal("1");
- static BigDecimal b_9 = new BigDecimal("150");
- static BigDecimal b_10 = new BigDecimal("180");
-
- static BigDecimal b_11 = new BigDecimal("0.00002");
- static BigDecimal b_12 = new BigDecimal("0.000003");
- static BigDecimal b_13 = new BigDecimal("0.0065");
- static BigDecimal b_14 = new BigDecimal("0.006");
-
- /**
- * WGS坐标转百度坐标系(BD-09)
- *
- * @param lng WGS84坐标系的经度
- * @param lat WGS84坐标系的纬度
- * @return 百度坐标数组
- */
- public static double[] wgs84tobd09(double lng, double lat) {
- double[] gcj = wgs84togcj02(lng, lat);
- double[] bd09 = gcj02tobd09(gcj[0], gcj[1]);
- return bd09;
- }
-
- /**
- * 火星坐标系(GCJ-02)转百度坐标系(BD-09)
- *
- * @param lng 火星坐标经度
- * @param lat 火星坐标纬度
- * @return 百度坐标数组
- * @see 谷歌、高德——>百度
- */
- public static double[] gcj02tobd09(double lng, double lat) {
- BigDecimal b_lng = new BigDecimal(lng);
- BigDecimal b_lat = new BigDecimal(lat);
- BigDecimal z = new BigDecimal(Math.sqrt(b_lng.multiply(b_lng).add(b_lat.multiply(b_lat)).doubleValue())).add(b_11.multiply(new BigDecimal(Math.sin(b_lat.multiply(x_pi).doubleValue()))));
- BigDecimal theta = new BigDecimal(Math.atan2(b_lat.doubleValue(), b_lng.doubleValue())).add(b_12.multiply(new BigDecimal(Math.cos(b_lng.multiply(x_pi).doubleValue()))));
- BigDecimal bd_lng = z.multiply(new BigDecimal(Math.cos(theta.doubleValue()))).add(b_13);
-// z * Math.cos(theta) + 0.0065;
- BigDecimal bd_lat = z.multiply(new BigDecimal(Math.sin(theta.doubleValue()))).add(b_14);
- return new double[]{bd_lng.doubleValue(), bd_lat.doubleValue()};
- }
-
- /**
- * WGS84转GCJ02(火星坐标系)
- *
- * @param lng WGS84坐标系的经度
- * @param lat WGS84坐标系的纬度
- * @return 火星坐标数组
- */
- public static double[] wgs84togcj02(double lng, double lat) {
- BigDecimal b_lng = new BigDecimal(lng + "");
- BigDecimal b_lat = new BigDecimal(lat + "");
- if (out_of_china(b_lng, b_lat)) {
- return new double[]{b_lng.doubleValue(), b_lat.doubleValue()};
- }
- BigDecimal dlat = transformlat(b_lng.subtract(b_4), b_lat.subtract(b_6));
- BigDecimal dlng = transformlng(b_lng.subtract(b_4), b_lat.subtract(b_6));
- BigDecimal radlat = b_lat.divide(b_10, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi);
- BigDecimal magic = new BigDecimal(Math.sin(radlat.doubleValue()));
- magic = b_8.subtract(ee.multiply(magic).multiply(magic));
- BigDecimal sqrtmagic = new BigDecimal(Math.sqrt(magic.doubleValue()));
- dlat = (dlat.multiply(b_10)).divide((a.multiply(b_8.subtract(ee))).divide((magic.multiply(sqrtmagic)), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP);
- dlng = (dlng.multiply(b_10)).divide((a.divide(sqrtmagic, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.cos(radlat.doubleValue())).multiply(pi))), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP);
- BigDecimal mglat = b_lat.add(dlat);
- BigDecimal mglng = b_lng.add(dlng);
- return new double[]{mglng.doubleValue(), mglat.doubleValue()};
- }
-
- /**
- * 纬度转换
- *
- * @param lng
- * @param lat
- * @return
- */
- public static BigDecimal transformlat(BigDecimal lng, BigDecimal lat) {
- BigDecimal bet = b_1.multiply(b_2).multiply(b_2)
- .add(b_3.multiply(lng))
- .add(b_5.multiply(lat))
- .add(b_3.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lat).multiply(lat))
- .add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lat))
- .add(b_3.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.abs(lng.doubleValue())))));
- bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(b_5).multiply(lng).multiply(pi).doubleValue())))
- .add(b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(lng).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP));
- bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(lat.multiply(pi).doubleValue())))
- .add(b_3.multiply(b_3).multiply(b_2).multiply(new BigDecimal(Math.sin(lat.divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP));
- bet = bet.add((b_7.multiply(new BigDecimal(Math.sin(lat.divide(b_5.multiply(b_3).multiply(b_3), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue())))
- .add(b_7.multiply(b_3).multiply(new BigDecimal(Math.sin(lat.multiply(pi).divide(b_5.multiply(b_2), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP));
- return bet;
- }
-
- /**
- * 经度转换
- *
- * @param lng
- * @param lat
- * @return
- */
- public static BigDecimal transformlng(BigDecimal lng, BigDecimal lat) {
- BigDecimal bet = b_2.multiply(b_2).multiply(b_5).add(lng).add(b_3.multiply(lat)).add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lng))
- .add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lat)).add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.abs(lng.doubleValue())))));
- bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(b_5).multiply(lng).multiply(pi).doubleValue())))
- .add(b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(lng).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP));
- bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(lng.multiply(pi).doubleValue())))
- .add(b_3.multiply(b_3).multiply(b_2).multiply(new BigDecimal(Math.sin(lng.divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP));
- bet = bet.add((b_9.multiply(new BigDecimal(Math.sin(lng.divide(b_3.multiply(b_3).multiply(b_5), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue())))
- .add(b_9.multiply(b_3).multiply(new BigDecimal(Math.sin(lng.divide(b_5.multiply(b_2), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue())))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)));
- return bet;
- }
-
- /**
- * 判断是否在国内,不在国内不做偏移
- *
- * @param lng
- * @param lat
- * @return
- */
- public static boolean out_of_china(BigDecimal lng, BigDecimal lat) {
- if (lng.compareTo(new BigDecimal("73.66")) < 0 || lng.compareTo(new BigDecimal("135.05")) > 0) {
- return true;
- } else if (lat.compareTo(new BigDecimal("3.86")) < 0 || lat.compareTo(new BigDecimal("53.55")) > 0) {
- return true;
- }
- return false;
- }
-
- public static String strwgs2bd(String lonlat){
- String[] lons = lonlat.split(",");
- double[] a = wgs84tobd09( Double.parseDouble(lons[0]) , Double.parseDouble(lons[1]) );
- return String.format("%.4f", a[0]) +","+String.format("%.4f", a[1]) ;
- }
-
- public static void main(String[] args) {
- double[] a =wgs84tobd09(120.01804 , 30.236946 );
- System.out.println(a[0]+","+a[1]);
- }
-}
-
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java
deleted file mode 100644
index 393623f..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java
+++ /dev/null
@@ -1,488 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.apache.commons.lang.StringUtils;
-
-
-public class DateUtils {
-
- /** 年月日时分秒(无下划线) yyyyMMddHHmmss */
- public static final String dtLong = "yyyyMMddHHmmss";
-
- /** 年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS */
- public static final String dtVeryLong = "yyyyMMddHHmmssSSS";
-
- /** 完整时间 yyyy-MM-dd HH:mm */
- public static final String simple = "yyyy-MM-dd HH:mm";
-
- /** 完整时间 yyyy/MM/dd HH:mm:ss */
- public static final String simpleALL = "yyyy/MM/dd HH:mm:ss";
-
- /** 年月日(无下划线) yyyyMMdd */
- public static final String dtSimple = "yyyy-MM-dd";
-
- /** 年月日(无下划线) yyyyMMdd */
- public static final String dtShort = "yyyyMMdd";
-
- /** 年月日 yyyy.MM.dd */
- public static final String dtShortPoint = "yyyy.MM.dd";
- /** 年月日 yyyy.MM.dd HH:mm */
- public static final String dtLongPoint = "yyyy.MM.dd HH:mm";
-
- /**
- * 字符串转日期
- *
- * @param pattern
- * @param text
- * @return
- * @throws ParseException
- */
- public static Date parse(String pattern, String text) {
- try{
- if (StringUtils.isEmpty(text)) {
- return null;
- }
- SimpleDateFormat df = new SimpleDateFormat(pattern);
- return df.parse(text);
- }catch (Exception e) {
- e.printStackTrace();
- return null ;
- }
- }
-
- /**
- * 日期转字符串
- *
- * @param pattern
- * @param date
- * @return
- * @throws ParseException
- */
- public static String format(String pattern, Date date) throws ParseException {
- if (date == null) {
- return "-";
- }
- SimpleDateFormat df = new SimpleDateFormat(pattern);
- return df.format(date);
- }
-
- /**
- * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss
- *
- * @param text
- * @return
- * @throws ParseException
- */
- public static Date parseDtLong(String text) throws ParseException {
- return parse(dtLong, text);
- }
-
- /**
- * 格式:完整时间 yyyy-MM-dd HH:mm:ss
- *
- * @param text
- * @return
- * @throws ParseException
- */
- public static Date parseSimple(String text) throws ParseException {
- return parse(simple, text);
- }
-
- /**
- * 格式:年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS
- *
- * @param date
- * @return
- * @throws ParseException
- */
- public static String formatDtVeryLong(Date date) throws ParseException {
- return format(dtVeryLong, date);
- }
-
- /**
- * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss
- *
- * @param date
- * @return
- * @throws ParseException
- */
- public static String formatDtLong(Date date) throws ParseException {
- return format(dtLong, date);
- }
-
- /**
- * 格式:完整时间 yyyy-MM-dd HH:mm:ss
- *
- * @param date
- * @return
- * @throws ParseException
- */
- public static String formatSimple(Date date) throws ParseException {
- return format(simple, date);
- }
-
- /**
- * 获取当前的时间 格式: 时:分:秒
- *
- * @return
- */
- public static String getNowTimeStr() {
- Calendar calendar = Calendar.getInstance();
- /**
- * 小时
- */
- int hour = calendar.get(Calendar.HOUR_OF_DAY);
- /**
- * 分钟
- */
- int minute = calendar.get(Calendar.MINUTE);
- /**
- * 秒钟
- */
- int second = calendar.get(Calendar.SECOND);
- /**
- * 拼接时间(时分秒)
- */
- String time = (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":"
- + (second < 10 ? "0" + second : second);
- /**
- * 返回时分秒
- */
- return time;
- }
-
- /**
- * 获取当前时间的前一天
- */
- public static Date getBeforeOneDateTime(Date day) {
-
- Calendar calendar = Calendar.getInstance();
-
- calendar.setTime(day);
-
- int dateday = calendar.get(Calendar.DATE);
-
- calendar.set(Calendar.DATE, dateday - 1);
-
- return calendar.getTime();
- }
-
- /**
- * 获取当前时间的后一天
- */
- public static Date getAfterOneDateTime(Date day) {
-
- Calendar calendar = Calendar.getInstance();
-
- calendar.setTime(day);
-
- int dateday = calendar.get(Calendar.DATE);
-
- calendar.set(Calendar.DATE, dateday + 1);
-
- return calendar.getTime();
- }
-
- /**
- * 获取当前的时间毫秒数,格林尼治时间 格式: 时:分:秒
- *
- * @return the number of milliseconds since January 1, 1970, 00:00:00 GMT
- * represented by this date.
- */
- public static long getNowTime() {
- Calendar calendar = Calendar.getInstance();
- /**
- * 小时
- */
- int hour = calendar.get(Calendar.HOUR_OF_DAY) - 8;
- /**
- * 分钟
- */
- int minute = calendar.get(Calendar.MINUTE);
- /**
- * 秒钟
- */
- int second = calendar.get(Calendar.SECOND);
- /**
- * 返回毫秒数
- */
- return (hour * 60 * 60 + minute * 60 + second) * 1000;
- }
-
- /**
- * 获取当前日期
- *
- * @param args
- */
- public static Date getCurrentDate() {
- // 获取当前日期
- Calendar calendar = new GregorianCalendar();
- GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH));
- return today.getTime();
- }
-
- /**
- * 获取当前日期
- *
- * @param args
- */
- public static Date getCurrentDate(long time) {
- // 获取当前日期
- Calendar calendar = new GregorianCalendar();
- calendar.setTimeInMillis(time);
- GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH));
- return today.getTime();
- }
-
- /**
- * 获取日期
- *
- * @param args
- */
- public static Date getDate(long time) {
- // 获取当前日期
- Calendar calendar = new GregorianCalendar();
- calendar.setTimeInMillis(time);
- return calendar.getTime();
- }
-
- public static Boolean getTimeBeforetimes(Date time, Integer minute) {
- Calendar nowTime = Calendar.getInstance();
- nowTime.add(Calendar.MINUTE, -1* minute);
- return nowTime.getTime().getTime() < time.getTime() ;
- }
-
- /**
- * 获取抽象的时间描述
- *
- * @param insert_time
- * @return
- */
- public static String getTimeDesc(Date insert_time) {
- String insert_time_desc = "";
- long inTime = insert_time.getTime();
- long curTime = System.currentTimeMillis();
- // 差值,分钟
- double dValue = Math.ceil((curTime - inTime) / 1000 / 60);
- if (dValue < 1)
- insert_time_desc = "刚刚";
- else if (dValue < 60)
- insert_time_desc = (long) dValue + "分钟前";
- else if (dValue < 60 * 24)
- insert_time_desc = (long) Math.floor(dValue / 60) + "小时前";
- else if (dValue < 60 * 24 * 30)
- insert_time_desc = (long) Math.floor(dValue / 60 / 24) + "天前";
- else if (dValue < 60 * 24 * 365)
- insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 30) + "月前";
- else
- insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 365) + "年前";
- return insert_time_desc;
- }
-
- /**
- *
- * 取得时间
- *
- * @param type
- * @return
- */
- public static Date getDate(int type) {
- Date date = null;
- try {
- switch (type) {
- case 1:
- // 当天12:00
- date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 12:00");
- break;
- case 2:
- // 明天12:00
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, DateUtils.getAfterOneDateTime(new Date())) + " 12:00");
- break;
- case 3:
- // 后天12:00
- date = DateUtils
- .parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple,
- DateUtils.getAfterOneDateTime(DateUtils.getAfterOneDateTime(new Date())))
- + " 12:00");
- break;
- case 4:
- // 当天09:00
- date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 09:00");
- break;
- case 5:
- // 当天00:00
- date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 00:00");
- break;
-
- case 6:
- // 明天00:00
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, DateUtils.getAfterOneDateTime(new Date())) + " 00:00");
- break;
- case 7:
- // 昨天00:00
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, DateUtils.getBeforeOneDateTime(new Date())) + " 00:00");
- break;
- case 8:
- // 本周一00:00
- //
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, getMondayOfThisWeek()) + " 00:00");
- break;
- case 9:
- // 本周日23:59
- //
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, getSundayOfThisWeek()) + " 23:59");
- break;
- case 10:
- // 当天23:59
- //
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, new Date()) + " 23:59");
- break;
- case 11:
- // 当月第1天 00:00
- //
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, getFirstDayOfThisMonth()) + " 00:00");
- break;
- case 12:
- // 当月最后一天 23:59
- //
- date = DateUtils.parse(DateUtils.simple,
- DateUtils.format(DateUtils.dtSimple, getLastDayOfThisMonth()) + " 23:59");
- break;
- case 13:
- // 当天23:59
- date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 23:59");
- break;
- default:
- break;
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- return date;
- }
-
- public static void main(String[] args) {
- getDate(6);
- getDate(7);
- getDate(13);
-
- }
-
- /**
- * 得到本周周一
- *
- * @return yyyy-MM-dd
- */
- public static Date getMondayOfThisWeek() {
- Calendar c = Calendar.getInstance();
- int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
- if (day_of_week == 0)
- day_of_week = 7;
- c.add(Calendar.DATE, -day_of_week + 1);
- return c.getTime();
- }
-
- /**
- * 得到本周周日
- *
- * @return yyyy-MM-dd
- */
- public static Date getSundayOfThisWeek() {
- Calendar c = Calendar.getInstance();
- int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
- if (day_of_week == 0)
- day_of_week = 7;
- c.add(Calendar.DATE, -day_of_week + 7);
- return c.getTime();
- }
-
-
- /**
- * 当月第一天
- * @return
- */
- private static Date getFirstDayOfThisMonth() {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DAY_OF_MONTH, calendar
- .getActualMinimum(Calendar.DAY_OF_MONTH));
-// calendar.setTime(getDate(5));
- return calendar.getTime();
- }
-
- /**
- * 当月最后一天
- * @return
- */
- private static Date getLastDayOfThisMonth() {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DAY_OF_MONTH, calendar
- .getActualMaximum(Calendar.DAY_OF_MONTH));
- return calendar.getTime();
- }
-
- /**
- *
- * 取得时间
- *
- * @param type
- * @return
- */
- public static String getDateStrDt(int type) {
- try {
- return DateUtils.format(DateUtils.dtSimple, getDate(type));
- } catch (Exception e) {
- // TODO: handle exception
- }
- return "";
- }
-
- /**
- * 取得当前时间与参数时间的差额,如果minus不为空的话,则返回当前时间-参数时间-差额时间
- *
- * @param ts
- * @param minus_seconds
- * 差额
- * @return
- */
- public static long getMinusFromCurrent(Timestamp ts, int... minus_seconds) {
- long curTimeMill = System.currentTimeMillis();
- if (minus_seconds.length > 0) {
- return curTimeMill - ts.getTime() - minus_seconds[0] * 1000;
- }
- return System.currentTimeMillis() - ts.getTime();
- }
-
- /**
- * @see getMinusFromCurrent()
- *
- * @param date
- * @param minus_seconds
- * 差额
- * @return
- */
- public static long getMinusFromCurrent(Date date, int... minus_seconds) {
- long curTimeMill = System.currentTimeMillis();
- if (minus_seconds.length > 0) {
- return curTimeMill - date.getTime() - minus_seconds[0] * 1000;
- }
- return curTimeMill - date.getTime();
- }
-}
-
-
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java
deleted file mode 100644
index 3251688..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.lpro.iot.common.Config;
-
-public class HttpServiceSender {
- protected static final Logger LOGGER = LoggerFactory.getLogger(HttpServiceSender.class);
- protected static final int SC_OK = 200;// 请求成功
- protected static final int SC_REDIRECT = 403;// 请求重定向
- protected static final int SC_UNRESOURCE = 404;// 请求失败(找不到对应资源)
- protected static final int SC_SERVER_ERROE = 500;// 请求失败(服务器内部错误)
- protected static final int SC_ERROR_REQUEST = 503;// 请求失败(服务器非请求类型)
-
- /**
- * 普通get请求
- *
- * @param url
- * 请求url
- * @param bodyString
- * 提交参数
- * @return [响应状态头][响应正文]
- */
-// public static String[] doGet(String url) {
-// String[] response = new String[2];
-// response[0] = "-1";
-// HttpClient client = new HttpClient();
-// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);
-// client.getHttpConnectionManager().getParams().setSoTimeout(2000);
-// GetMethod getMethod = new GetMethod(url);
-// getMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
-// getMethod.setRequestHeader("Content-Type", "application/json");
-// try {
-// client.executeMethod(getMethod);
-// response[0] = String.valueOf(getMethod.getStatusCode());
-// if (getMethod.getStatusCode() == SC_OK) {
-// response[1] = new String(getMethod.getResponseBodyAsString());// .getBytes("ISO-8859-1"),"utf-8");
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// } finally {
-// getMethod.releaseConnection();
-// }
-// return response;
-// }
-
- public static String[] doGet(String url,String userKey) {
- String[] response = new String[2];
- response[0] = "-1";
- HttpClient client = new HttpClient();
- client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);
- client.getHttpConnectionManager().getParams().setSoTimeout(2000);
- GetMethod getMethod = new GetMethod(url);
- getMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
- getMethod.setRequestHeader("Content-Type", "application/json");
- if (ObjectUtil.isNotEmpty(userKey)) {
- getMethod.setRequestHeader("USER-KEY", userKey);
- }
- try {
- client.executeMethod(getMethod);
- response[0] = String.valueOf(getMethod.getStatusCode());
- if (getMethod.getStatusCode() == SC_OK) {
-// response[1] = getMethod.getResponseBodyAsString();
- InputStream inputStream = getMethod.getResponseBodyAsStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
- StringBuffer stringBuffer = new StringBuffer();
- String str= "";
- while((str = br.readLine()) != null){
- stringBuffer .append(str );
- }
- response[1] = stringBuffer.toString();
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- getMethod.releaseConnection();
- }
- return response;
- }
-
- /**
- * 普通POST请求
- *
- * @param url
- * 请求url
- * @param bodyString
- * 提交参数
- * @return [响应状态头][响应正文]
- */
- @SuppressWarnings("deprecation")
- public static String[] doPost(String url, String userKey, String bodyString) {
- String[] response = new String[2];
- response[0] = "-1";
- HttpClient client = new HttpClient();
- PostMethod postMethod = new PostMethod(url);
- postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
- postMethod.setRequestHeader("Content-Type", "application/json");
- if (ObjectUtil.isNotEmpty(userKey)) {
- postMethod.setRequestHeader("Authorization", userKey);
- postMethod.setRequestHeader("USER-KEY", userKey);
- }
- postMethod.setRequestBody(bodyString);
- try {
- client.executeMethod(postMethod);
- if (postMethod.getStatusCode() == SC_OK) {
- response[0] = "200";
-// response[1] = postMethod.getResponseBodyAsString();
- InputStream inputStream = postMethod.getResponseBodyAsStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
- StringBuffer stringBuffer = new StringBuffer();
- String str= "";
- while((str = br.readLine()) != null){
- stringBuffer .append(str );
- }
- response[1] = stringBuffer.toString();
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- postMethod.releaseConnection();
- }
- return response;
- }
-
- /**
- * 普通PUT请求
- *
- * @param url
- * @return [响应状态头][响应正文]
- */
- @SuppressWarnings("deprecation")
- public static String[] doPut(String url, String userKey, String bodyString) {
- String[] response = new String[2];
- response[0] = "-1";
- HttpClient client = new HttpClient();
- PutMethod putMethod = new PutMethod(url);
- putMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
- putMethod.setRequestHeader("Content-Type", "application/json");
- if (ObjectUtil.isNotEmpty(userKey)) {
-// putMethod.setRequestHeader("Authorization", userKey);
- putMethod.setRequestHeader("USER-KEY", userKey);
- putMethod.setRequestHeader("CLIENT-KEY", Config.IOT_LPM_KEY);
- }
- putMethod.setRequestBody(bodyString);
- try {
- client.executeMethod(putMethod);
- if (putMethod.getStatusCode() == SC_OK) {
-// response[1] = putMethod.getResponseBodyAsString();
- InputStream inputStream = putMethod.getResponseBodyAsStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
- StringBuffer stringBuffer = new StringBuffer();
- String str= "";
- while((str = br.readLine()) != null){
- stringBuffer .append(str );
- }
- response[1] = stringBuffer.toString();
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- putMethod.releaseConnection();
- }
- return response;
- }
-
- /**
- * 带认证的DELETE请求
- *
- * @param url
- * 请求地址
- * @param iblueyeKey
- * 密钥
- * @return [响应状态头][响应正文]
- */
- public static String[] doDelete(String url) {
- String[] response = new String[2];
- response[0] = "-1";
- HttpClient client = new HttpClient();
- DeleteMethod deleteMethod = new DeleteMethod(url);
- deleteMethod.setRequestHeader("Content-Type", "application/json");
- try {
- client.executeMethod(deleteMethod);
- response[0] = String.valueOf(deleteMethod.getStatusCode());
- if (deleteMethod.getStatusCode() == SC_OK) {
-// response[1] = deleteMethod.getResponseBodyAsString();
- InputStream inputStream = deleteMethod.getResponseBodyAsStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
- StringBuffer stringBuffer = new StringBuffer();
- String str= "";
- while((str = br.readLine()) != null){
- stringBuffer .append(str );
- }
- response[1] = stringBuffer.toString();
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- deleteMethod.releaseConnection();
- }
- return response;
- }
-
- static String body = "";
-
- public static void main(String[] args) {
- Calendar cal = Calendar.getInstance();
- String start = "2012-02-01";
- String end = "2012-03-02";
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Date dBegin;
- Date dEnd;
- List lDate;
- try {
- dBegin = sdf.parse(start);
- dEnd = sdf.parse(end);
- lDate = findDates(dBegin, dEnd);
- for (Date date : lDate) {
- System.out.println(sdf.format(date));
- System.out.println(date);
- }
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
-
- public static List findDates(Date dBegin, Date dEnd) {
- List lDate = new ArrayList();
- lDate.add(dBegin);
- Calendar calBegin = Calendar.getInstance();
- // 使用给定的 Date 设置此 Calendar 的时间
- calBegin.setTime(dBegin);
- Calendar calEnd = Calendar.getInstance();
- // 使用给定的 Date 设置此 Calendar 的时间
- calEnd.setTime(dEnd);
- // 测试此日期是否在指定日期之后
- while (dEnd.after(calBegin.getTime())) {
- // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
- calBegin.add(Calendar.DAY_OF_MONTH, 1);
- lDate.add(calBegin.getTime());
- }
- return lDate;
- }
-
-
- public static String getSpecifiedDayAfter(String specifiedDay) {
- Calendar c = Calendar.getInstance();
- Date date = null;
- try {
- date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- c.setTime(date);
- int day = c.get(Calendar.DATE);
- c.set(Calendar.DATE, day + 1);
-
- String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
- return dayAfter;
- }
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java
deleted file mode 100644
index 5f1f6e3..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.security.MessageDigest;
-
-public class MD5Util {
-
- private static String byteArrayToHexString(byte b[]) {
- StringBuffer resultSb = new StringBuffer();
- for (int i = 0; i < b.length; i++)
- resultSb.append(byteToHexString(b[i]));
-
- return resultSb.toString();
- }
-
- private static String byteToHexString(byte b) {
- int n = b;
- if (n < 0)
- n += 256;
- int d1 = n / 16;
- int d2 = n % 16;
- return hexDigits[d1] + hexDigits[d2];
- }
-
- public static String MD5Encode(String origin, String charsetname) {
- String resultString = null;
- try {
- resultString = new String(origin);
- MessageDigest md = MessageDigest.getInstance("MD5");
- if (charsetname == null || "".equals(charsetname))
- resultString = byteArrayToHexString(md.digest(resultString
- .getBytes()));
- else
- resultString = byteArrayToHexString(md.digest(resultString
- .getBytes(charsetname)));
- } catch (Exception exception) {
- }
- return resultString;
- }
-
- private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
- "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
-
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java
deleted file mode 100644
index aac2ac5..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-
-public class ObjectUtil {
-
- public static Boolean isEmpty(Object o){
- if(o == null){
- return true ;
- }
- if(o instanceof List ){
- if(((List) o).size()==0){
- return true ;
- }
- }else if(o instanceof String){
- if(StringUtils.isBlank((String)o)){
- return true ;
- }
- }
- return false ;
- }
-
- public static Boolean isNotEmpty(Object o){
- return !isEmpty(o) ;
- }
-
- public static Boolean isIntegerOverZero(Integer value){
- if(value != null && value >0){
- return true ;
- }else{
- return false ;
- }
- }
-
- /**
- * 把字符串首字母转换为大写
- *
- * @param str
- * @return
- */
- public static String upFirstChar(String str) {
- return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
- }
-
- /**
- * 转化成整数值, 错误时返回-9999
- *
- * @param o
- * @return
- */
- public static Integer parseIntData(Object o) {
- try {
- if (o != null && isNotEmpty(o.toString().trim())) {
- return Integer.parseInt(o.toString().trim());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return -9999;
- }
-
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java
deleted file mode 100644
index 6c012cf..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- *
- */
-public class PropertiesUtil {
- private static Properties p = null;
- public static String defaultFilePath = "config.properties";
-
- /**
- * 获取默认文件的配置值
- *
- * @param property
- * @return
- */
- public static String getProperty(String property) {
- if (p == null) {
- p = getProperties(defaultFilePath);
- }
- return (p.containsKey(property)) ? p.getProperty(property) : "";
- }
-
- /**
- * 获取指定文件的配置值
- *
- * @param property
- * @param path
- * @return
- */
- public static String getProperty(String property, String path) {
- if (p == null) {
- p = getProperties(path);
- }
- return (p.containsKey(property)) ? p.getProperty(property) : "";
- }
-
- /**
- * 读取文件
- *
- * @param filePath
- * @return
- */
- private static Properties getProperties(String filePath) {
- InputStream in = null;
- Properties p = new Properties();
- try {
- in = new BufferedInputStream(new FileInputStream(filePath));
- p.load(in);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return p;
- }
-
-}
diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java
deleted file mode 100644
index 05407a8..0000000
--- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.lpro.iot.utils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 这是一个自定义排序的类,专门针对列表(List)中的数据进行排序;可按指定方法进行。
- * 目前实现对字符串(String)、日期(Date)、整型(Integer)等三种对象进行排序。
- *
- * @author acer
- *
- * @param
- */
-public class SortList {
-
- /**
- * 对列表中的数据按指定字段进行排序。要求类必须有相关的方法返回字符串、整型、日期等值以进行比较。
- *
- * @param list
- * @param field
- * @param reverseFlag
- * 默认正序
- */
- public void sortByField(List list, final String fieldName, final boolean... reverseFlag) {
- Collections.sort(list, new Comparator