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+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_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+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_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 "+countTableName+"_count where nm ='"+ConvertUtils.getString(metricMap.get("tzExpress"),"-")+"' 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+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_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 ";
...
...
@@ -109,7 +117,8 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
@@ -118,7 +127,7 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
}
// this.getJdbcTemplate().batchUpdate();
if(batchArgs!=null&&!batchArgs.isEmpty()){
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);
this.getJdbcTemplate().batchUpdate("insert into equipment_info_duration (id,depart_id,info_id,data_time,yz_duration,gz_duration,zt_duration,total_duration,create_time) value(?,?,?,?,?,?,?,?,?)",batchArgs);
sql+=" select er.depart_id , ei.equipment_name 'name' , '维修费用' as 'cost_type',er.total_cost 'cost',\tDATE_FORMAT( er.repair_date, '%Y-%m-%d' ) 'time' from equipment_repair er , equipment_info ei ";
sql+=" select er.depart_id , ei.equipment_name 'name' , '维修费用' as 'cost_type',er.total_cost 'cost',DATE_FORMAT( er.repair_date, '%Y-%m-%d' ) 'time' from equipment_repair er , equipment_info ei ";
sql+=" where er.info_id = ei.id and er.total_cost > 0 and er.repair_date >= '"+startTime+" 00:00:00' and er.repair_date <='"+endTime+" 23:59:59' and er.depart_id = '"+departId+"' ";
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 ";
sql="select round(ifnull(sum(total_cost),0)/10000,2) 'repair_cost' from equipment_repair where reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59'";
// sql = "select round(ifnull(sum(total_cost),0)/10000,2) 'repair_cost' from equipment_repair where reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59'";
sql="select round(ifnull(sum(maintenance_cost),0)/10000,2) 'repair_cost' from equipment_maintain_task where real_end_time >= '"+startDate+" 00:00:00' and real_end_time <='"+endDate+" 23:59:59'";