@ -104,16 +104,16 @@ public interface DataProcessMapper {
@Select ( "select * from ${tableName} where grade = 0 order by cur_time desc" )
List < DeviceReport > queryUntreatedData ( String tableName ) ;
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and EXTRACT(YEAR FROM AGE(cur_time, #{curTime})) = 0 ;" )
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and EXTRACT(YEAR FROM cur_time) = EXTRACT(YEAR FROM #{curTime}::timestamp) ;" )
Integer selectDataByYY ( @Param ( "tableName" ) String tableName , @Param ( "curTime" ) Date curTime , @Param ( "deviceNum" ) String deviceNum ) ;
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and EXTRACT(MONTH FROM AGE(cur_time, #{curTime})) = 0 ;" )
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and DATE_TRUNC('month', cur_time) = DATE_TRUNC('month', #{curTime}::timestamp) ;" )
Integer selectDataByMM ( @Param ( "tableName" ) String tableName , @Param ( "curTime" ) Date curTime , @Param ( "deviceNum" ) String deviceNum ) ;
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and EXTRACT(DAY FROM AGE(cur_time, #{curTime})) = 0; " )
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and DATE(cur_time) = DATE(#{curTime}::timestamp) " )
Integer selectDataByDD ( @Param ( "tableName" ) String tableName , @Param ( "curTime" ) Date curTime , @Param ( "deviceNum" ) String deviceNum ) ;
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and EXTRACT(HOUR FROM AGE(cur_time, #{curTime})) = 0 ; " )
@Select ( "select count(1) from ${tableName} where device_num = #{deviceNum} and DATE_TRUNC('hour', cur_time) = DATE_TRUNC('hour', #{curTime}::timestamp) ; " )
Integer selectDataByHH ( @Param ( "tableName" ) String tableName , @Param ( "curTime" ) Date curTime , @Param ( "deviceNum" ) String deviceNum ) ;
@Insert ( "insert into ${tableName}(device_num, device_code, device_type, last_value, last_time, cur_value,cur_time,calc_value,used_value,ratio,grade) " +
@ -132,19 +132,19 @@ public interface DataProcessMapper {
void insertTable ( @Param ( "data" ) DeviceReport data , @Param ( "tableName" ) String tableName ) ;
@Update ( "update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue}::numeric,calc_value = (#{data.curValue}::numeric - last_value)*ratio,used_value = #{data.curValue}::numeric - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(MONTH FROM AGE(cur_time, #{data.curTime})) = 0 " )
"where device_num = #{data.deviceNum} and DATE_TRUNC('month', cur_time) = DATE_TRUNC('month', #{data.curTime}::timestamp); " )
void updateTableMM ( @Param ( "data" ) DeviceReport data , @Param ( "tableName" ) String tableName ) ;
@Update ( "update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue}::numeric,calc_value = (#{data.curValue}::numeric - last_value)*ratio,used_value = #{data.curValue}::numeric - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(YEAR FROM AGE(cur_time, #{data.curTime})) = 0 " )
"where device_num = #{data.deviceNum} and EXTRACT(YEAR FROM cur_time) = EXTRACT(YEAR FROM #{data.curTime}::timestamp); " )
void updateTableYY ( @Param ( "data" ) DeviceReport data , @Param ( "tableName" ) String tableName ) ;
@Update ( "update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue}::numeric,calc_value = (#{data.curValue}::numeric - last_value)*ratio,used_value = #{data.curValue}::numeric - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(DAY FROM AGE(cur_time, #{data.curTime})) = 0 " )
"where device_num = #{data.deviceNum} and DATE(cur_time) = DATE(#{data.curTime}::timestamp) " )
void updateTableDD ( @Param ( "data" ) DeviceReport data , @Param ( "tableName" ) String tableName ) ;
@Update ( "update ${tableName} set cur_time = #{data.curTime},cur_value = #{data.curValue}::numeric,calc_value = (#{data.curValue}::numeric - last_value)*ratio,used_value = #{data.curValue}::numeric - last_value " +
"where device_num = #{data.deviceNum} and EXTRACT(HOUR FROM AGE(cur_time, #{data.curTime})) = 0 " )
"where device_num = #{data.deviceNum} and DATE_TRUNC('hour', cur_time) = DATE_TRUNC('hour', #{data.curTime}::timestamp); " )
void updateTableHH ( @Param ( "data" ) DeviceReport data , @Param ( "tableName" ) String tableName ) ;
/ * *
@ -155,7 +155,7 @@ public interface DataProcessMapper {
* @param grade
* /
@Update ( "<script>" +
"update ${tableName} set grade = #{grade} where I d in(" +
"update ${tableName} set grade = #{grade} where i d in(" +
"<foreach collection ='ids' item='id' index = 'index' separator=','>" +
"#{id}" +
"</foreach>" +