StringdeleteSql=" delete from equipment_info_duration where depart_id = '"+departId+"' and date_time >= '"+startTime+"' and data_time <='"+endTime+"' ";
commonSqlService.delete(deleteSql);
//2
StringcountTableName=commonSqlService.queryForString("select device_id from sys_factory_device where depart_id = '"+departId+"'");
// 步骤3
Stringmetric_sql="select t.equipment_code as 'info_id', ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t ";
metric_sql+=" left join equipment_info ei on ei.id = t.equipment_code where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 ";
pgSql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql+=" ) aaa group by aaa.time order by aaa.time asc ";
pgSql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql+=" ) aaa group by aaa.time order by aaa.time asc ";
pgSql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm in('"+metricMap.get("yxExpress")+"','"+ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"','"+ConvertUtils.getString(metricMap.get("tzExpress"),"-")+"') and ts <'"+tsEndTime+"' ";
pgSql+=" ) aaa ";
pgSql+=")ccccc on aaaaa.info_id = ccccc.info_id ";
this.getJdbcTemplate().batchUpdate("insert into equipment_info_duration (id,depart_id,info_id,data_time,gz_duration,yz_duration,total_duration,create_time) value(?,?,?,?,?,?,?,?)",batchArgs);
StringdeleteSql=" delete from equipment_info_duration where depart_id = '"+departId+"' and date_time >= '"+startTime+"' and date_time <='"+endTime+"' ";
commonSqlService.delete(deleteSql);
//2
StringcountTableName=commonSqlService.queryForString("select device_id from sys_factory_device where depart_id = '"+departId+"'");
// 步骤3
Stringmetric_sql="select t.equipment_code as 'info_id', ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t ";
metric_sql+=" left join equipment_info ei on ei.id = t.equipment_code where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 ";
pgSql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql+=" ) aaa group by aaa.time order by aaa.time asc ";
pgSql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql+=" ) aaa group by aaa.time order by aaa.time asc ";