@@ -179,11 +179,13 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
//清理数据
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 ";
yx_sql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+metricMap.get("countTableName")+"_count where nm = '"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
yx_sql+=" ) aaa group by aaa.time order by aaa.time asc";
total_sql+=" select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+metricMap.get("countTableName")+"_count where nm in ("+JSUtils.quoteEach(metricYXTag,",")+") ' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
total_sql+=" ) aaa group by aaa.time order by aaa.time asc";
sql+=" left join ( select ei.depart_id ,count( eee.equip_info_id) 'total_count' ,ifnull( SUM( CASE WHEN fff.equip_info_id > '0' THEN 1 ELSE 0 END ),0) as 'yj_count',ifnull( SUM( CASE WHEN ggg.equip_info_id > '0' THEN 1 ELSE 0 END ),0) as 'yc_count'";
sql+=" from ( "+getInspectionEquipIdsSql(departIds,startDate,endDate)+") eee ";
sql+=" left join ( "+getCheckedInspectionEquipIds(departIds,startDate,endDate,null)+" ) fff on fff.equip_info_id = eee.equip_info_id";
sql+=" left join ( "+getCheckedInspectionEquipIds(departIds,startDate,endDate,"0")+" ) ggg on ggg.equip_info_id = eee.equip_info_id ";
sql+=" left join equipment_info ei on eee.equip_info_id = ei.id ";
sql+=" group by ei.depart_id ";
sql+=" ) kkk on d.id = kkk.depart_id ";
sql+=" where d.depart_type = 1 ";
if(StringUtils.isNotEmpty(departIds)){
sql+=" and d.id in ("+JSUtils.quoteEach(departIds,",")+") ";
@@ -1032,6 +1054,7 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService
sql+=" and depart_id in ("+JSUtils.quoteEach(departIds,",")+")";
}
sql+=" ) AND equip_info_id IS NOT NULL AND equip_info_id <> '' ";
sql+=" GROUP BY equip_info_id,inspection_point_fill_group_id,inspection_fill_group_id,inspection_task_id ";
returnsql;
}
//获取已检设备的id集合
...
...
@@ -1048,7 +1071,7 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService
sql+=")aaa on isfc.inspection_task_id = aaa.inspection_task_id and isfc.inspection_point_fill_group_id = aaa.inspection_point_fill_group_id and isfc.inspection_fill_group_id = aaa.inspection_fill_group_id ";
sql+=" where isfc.fill_content IS NOT NULL AND isfc.fill_content <> '' AND aaa.equip_info_id IS NOT NULL AND aaa.equip_info_id <> '' ";