|
...
|
...
|
@@ -2,12 +2,12 @@ package com.zhonglai.luhui.mqtt.comm.dao; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.ruoyi.common.annotation.PublicSQLConfig;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.util.StringUtils;
|
|
|
|
import org.apache.commons.dbutils.*;
|
|
|
|
import org.apache.commons.dbutils.handlers.BeanHandler;
|
|
|
|
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
|
|
|
import org.apache.commons.dbutils.handlers.MapListHandler;
|
|
|
|
import org.apache.commons.dbutils.handlers.ScalarHandler;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
...
|
...
|
@@ -56,7 +56,7 @@ public class BaseDao { |
|
|
|
}
|
|
|
|
Method method;
|
|
|
|
try {
|
|
|
|
method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
if(null != value)
|
|
...
|
...
|
@@ -66,7 +66,7 @@ public class BaseDao { |
|
|
|
sql += ",";
|
|
|
|
values += ",";
|
|
|
|
}
|
|
|
|
sql += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
sql += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
values += "?";
|
|
|
|
valueList.add(value);
|
|
|
|
}
|
|
...
|
...
|
@@ -126,7 +126,7 @@ public class BaseDao { |
|
|
|
String sql = "insert into ";
|
|
|
|
if(StringUtils.isBlank(tableName))
|
|
|
|
{
|
|
|
|
tableName = com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(object.getClass().getSimpleName());
|
|
|
|
tableName = StringUtils.toUnderScoreCase(object.getClass().getSimpleName());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Object> valueList = new ArrayList<Object>();
|
|
...
|
...
|
@@ -155,7 +155,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
attributeStr += ",";
|
|
|
|
}
|
|
|
|
attributeStr += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
attributeStr += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
}
|
|
|
|
attributeStr += ")";
|
|
|
|
return attributeStr;
|
|
...
|
...
|
@@ -177,7 +177,7 @@ public class BaseDao { |
|
|
|
}
|
|
|
|
Method method;
|
|
|
|
try {
|
|
|
|
method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
if(!"(".equals(values) )
|
|
|
|
{
|
|
...
|
...
|
@@ -253,7 +253,7 @@ public class BaseDao { |
|
|
|
}
|
|
|
|
Method method = null;
|
|
|
|
try {
|
|
|
|
method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
continue;
|
|
|
|
}
|
|
...
|
...
|
@@ -264,7 +264,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
sql += ",";
|
|
|
|
}
|
|
|
|
sql += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=?";
|
|
|
|
sql += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`"+"=?";
|
|
|
|
j++;
|
|
|
|
valueList.add(value);
|
|
|
|
}
|
|
...
|
...
|
@@ -293,10 +293,10 @@ public class BaseDao { |
|
|
|
for(int i =0;i<wheres.length;i++)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Method method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(wheres[i]));
|
|
|
|
Method method = object.getClass().getMethod("get"+ StringUtils.getName(wheres[i]));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
sql += " and ";
|
|
|
|
sql += com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(wheres[i]) + "=?";
|
|
|
|
sql += StringUtils.toUnderScoreCase(wheres[i]) + "=?";
|
|
|
|
valueList.add(value);
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
...
|
...
|
@@ -334,7 +334,7 @@ public class BaseDao { |
|
|
|
idName = field.getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
method = object.getClass().getMethod("get"+ com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(idName));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(idName));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
sql += " and ";
|
|
|
|
|
|
...
|
...
|
@@ -369,7 +369,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
QueryRunner runner = new QueryRunner(dBFactory.getDataSource());
|
|
|
|
|
|
|
|
String tableName = com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
String tableName = StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
|
|
|
|
String sql = "select * from "+tableName+" where 1=1 ";
|
|
|
|
try {
|
|
...
|
...
|
@@ -415,7 +415,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
QueryRunner runner = new QueryRunner(dBFactory.getDataSource());
|
|
|
|
|
|
|
|
String tableName = com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
String tableName = StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
|
|
|
|
String sql = "select * from "+tableName+" where 1=1 ";
|
|
|
|
String idName = "id";
|
|
...
|
...
|
@@ -454,7 +454,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
QueryRunner runner = new QueryRunner(dBFactory.getDataSource());
|
|
|
|
|
|
|
|
String tableName = com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
String tableName = StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
String sql = "DELETE FROM "+tableName+" WHERE 1=1 ";
|
|
|
|
try {
|
|
|
|
List<Object> valueList = new ArrayList<Object>();
|
|
...
|
...
|
@@ -487,7 +487,7 @@ public class BaseDao { |
|
|
|
|
|
|
|
if(StringUtils.isBlank(tableName))
|
|
|
|
{
|
|
|
|
tableName = com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
tableName = StringUtils.toUnderScoreCase(clas.getSimpleName());
|
|
|
|
}
|
|
|
|
String sql = "DELETE FROM "+tableName+" WHERE 1=1 ";
|
|
|
|
try {
|
|
...
|
...
|
@@ -745,7 +745,7 @@ public class BaseDao { |
|
|
|
}
|
|
|
|
try {
|
|
|
|
Method method;
|
|
|
|
method = object.getClass().getMethod("get"+ com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
if(!(null == value))
|
|
|
|
{
|
|
...
|
...
|
@@ -757,17 +757,17 @@ public class BaseDao { |
|
|
|
if("like".equals(s))
|
|
|
|
{
|
|
|
|
value = "%"+value+"%";
|
|
|
|
like += " or " + "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+s+" ?"+orther ;
|
|
|
|
like += " or " + "`"+ StringUtils.toUnderScoreCase(field.getName())+"`"+s+" ?"+orther ;
|
|
|
|
valueList.add(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if("time".equals(s))
|
|
|
|
{
|
|
|
|
s = ">";
|
|
|
|
orther = " and `"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`< '"+whereMap.get("end_"+field.getName())+"'";
|
|
|
|
orther = " and `"+ StringUtils.toUnderScoreCase(field.getName())+"`< '"+whereMap.get("end_"+field.getName())+"'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
where += " and `"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+s+" ?"+orther;
|
|
|
|
where += " and `"+ StringUtils.toUnderScoreCase(field.getName())+"`"+s+" ?"+orther;
|
|
|
|
valueList.add(value);
|
|
|
|
}
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
...
|
...
|
@@ -819,7 +819,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
if(null != value)
|
|
|
|
{
|
|
...
|
...
|
@@ -829,9 +829,9 @@ public class BaseDao { |
|
|
|
values += ",";
|
|
|
|
update += ",";
|
|
|
|
}
|
|
|
|
sql += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
sql += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`";
|
|
|
|
values += "'"+ value+"'";
|
|
|
|
update += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`)";
|
|
|
|
update += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+ StringUtils.toUnderScoreCase(field.getName())+"`)";
|
|
|
|
}
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
} catch (SecurityException e) {
|
|
...
|
...
|
@@ -891,8 +891,8 @@ public class BaseDao { |
|
|
|
sb.append(",");
|
|
|
|
update += ",";
|
|
|
|
}
|
|
|
|
sb.append("`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`");
|
|
|
|
update += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`)";
|
|
|
|
sb.append("`"+ StringUtils.toUnderScoreCase(field.getName())+"`");
|
|
|
|
update += "`"+ StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+ StringUtils.toUnderScoreCase(field.getName())+"`)";
|
|
|
|
}
|
|
|
|
sb.append(")");
|
|
|
|
sb.append("VALUES ");
|
|
...
|
...
|
@@ -904,7 +904,7 @@ public class BaseDao { |
|
|
|
Field field = fields[j];
|
|
|
|
Method method;
|
|
|
|
try {
|
|
|
|
method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName()));
|
|
|
|
method = object.getClass().getMethod("get"+ StringUtils.getName(field.getName()));
|
|
|
|
Object value = method.invoke(object);
|
|
|
|
if(null == value)
|
|
|
|
{
|
|
...
|
...
|
@@ -963,7 +963,7 @@ public class BaseDao { |
|
|
|
{
|
|
|
|
Object value = mapwhere.get(key);
|
|
|
|
where += " and ";
|
|
|
|
where += com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(key) + "=?";
|
|
|
|
where += StringUtils.toUnderScoreCase(key) + "=?";
|
|
|
|
valueList.add(value);
|
|
|
|
}
|
|
|
|
return where;
|
|
...
|
...
|
@@ -1007,6 +1007,6 @@ public class BaseDao { |
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
return com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(tableNmae);
|
|
|
|
return StringUtils.toUnderScoreCase(tableNmae);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|