b2c7b5be 张雷

Merge remote-tracking branch 'origin/master' into master

2 个父辈 dadacca0 b80ca998
...@@ -13,11 +13,15 @@ import com.skua.modules.statistics.vo.EquipmentFailurelVO; ...@@ -13,11 +13,15 @@ import com.skua.modules.statistics.vo.EquipmentFailurelVO;
13 import com.skua.modules.statistics.vo.EquipmentOperationRecordVO; 13 import com.skua.modules.statistics.vo.EquipmentOperationRecordVO;
14 import com.skua.modules.statistics.vo.EquipmentRepairMaintainTaskCostDetailVO; 14 import com.skua.modules.statistics.vo.EquipmentRepairMaintainTaskCostDetailVO;
15 import com.skua.modules.statistics.vo.EquipmentRepairMaintainTaskCostVO; 15 import com.skua.modules.statistics.vo.EquipmentRepairMaintainTaskCostVO;
16 import com.skua.tool.util.JSUtils;
17 import lombok.SneakyThrows;
18 import netscape.javascript.JSUtil;
16 import org.apache.commons.lang3.StringUtils; 19 import org.apache.commons.lang3.StringUtils;
17 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.jdbc.core.BeanPropertyRowMapper; 21 import org.springframework.jdbc.core.BeanPropertyRowMapper;
19 import org.springframework.jdbc.core.JdbcTemplate; 22 import org.springframework.jdbc.core.JdbcTemplate;
20 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
24 import org.springframework.transaction.annotation.Transactional;
21 25
22 import javax.annotation.Resource; 26 import javax.annotation.Resource;
23 import java.text.ParseException; 27 import java.text.ParseException;
...@@ -59,6 +63,8 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ ...@@ -59,6 +63,8 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
59 if(StringUtils.isNotEmpty(departIds)){ 63 if(StringUtils.isNotEmpty(departIds)){
60 sql += " and d.id in ("+ departIds +") "; 64 sql += " and d.id in ("+ departIds +") ";
61 } 65 }
66 sql += " order by aaa.repair_cost desc ";
67
62 List<EquipmentRepairMaintainTaskCostVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairMaintainTaskCostVO>(EquipmentRepairMaintainTaskCostVO.class)); 68 List<EquipmentRepairMaintainTaskCostVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairMaintainTaskCostVO>(EquipmentRepairMaintainTaskCostVO.class));
63 return dataList; 69 return dataList;
64 } 70 }
...@@ -72,7 +78,7 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ ...@@ -72,7 +78,7 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
72 */ 78 */
73 public List<EquipmentRepairMaintainTaskCostDetailVO> repairMaintainTaskCostDetailList(String departId, String startTime, String endTime){ 79 public List<EquipmentRepairMaintainTaskCostDetailVO> repairMaintainTaskCostDetailList(String departId, String startTime, String endTime){
74 String sql = "select d.depart_name, aaa.* from ( "; 80 String sql = "select d.depart_name, aaa.* from ( ";
75 sql +=" select er.depart_id , ei.equipment_name 'name' , '维修费用' as 'cost_type',er.total_cost 'cost',er.repair_date 'time' from equipment_repair er , equipment_info ei "; 81 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 ";
76 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+"' "; 82 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+"' ";
77 sql += " UNION " ; 83 sql += " UNION " ;
78 sql += " select emt.depart_id, emt.maintain_plan_name 'name',"; 84 sql += " select emt.depart_id, emt.maintain_plan_name 'name',";
...@@ -80,10 +86,12 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ ...@@ -80,10 +86,12 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
80 sql += " WHEN emp.maintenance_type='sbwh' THEN '维护费用'"; 86 sql += " WHEN emp.maintenance_type='sbwh' THEN '维护费用'";
81 sql += " WHEN emp.maintenance_type='sbby' THEN '保养费用'"; 87 sql += " WHEN emp.maintenance_type='sbby' THEN '保养费用'";
82 sql += " WHEN emp.maintenance_type='jjwx' THEN '基建维修费用'"; 88 sql += " WHEN emp.maintenance_type='jjwx' THEN '基建维修费用'";
83 sql += " ELSE '其他保养' END AS cost_type, emt.maintenance_cost 'cost', DATE_FORMAT(emt.maintain_time,'%Y-%m-%d') 'time', "; 89 sql += " ELSE '其他保养' END AS cost_type, emt.maintenance_cost 'cost', DATE_FORMAT(emt.maintain_time,'%Y-%m-%d') 'time' ";
84 sql += " from equipment_maintain_task emt ,equipment_maintain_plan emp where emt.plan_id = emp.id "; 90 sql += " from equipment_maintain_task emt ,equipment_maintain_plan emp where emt.plan_id = emp.id ";
85 sql += " and emt.depart_id = '"+departId+"' and emt.maintain_time >= '"+startTime+" 00:00:00' and emt.maintain_time <='"+endTime+" 23:59:59' "; 91 sql += " and emt.depart_id = '"+departId+"' and emt.maintain_time >= '"+startTime+" 00:00:00' and emt.maintain_time <='"+endTime+" 23:59:59' ";
86 sql += " ) aaa left join sys_depart d on d.id = aaa.depart_id "; 92 sql += " ) aaa left join sys_depart d on d.id = aaa.depart_id ";
93 sql += " order by aaa.time desc ";
94
87 List<EquipmentRepairMaintainTaskCostDetailVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairMaintainTaskCostDetailVO>(EquipmentRepairMaintainTaskCostDetailVO.class)); 95 List<EquipmentRepairMaintainTaskCostDetailVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<EquipmentRepairMaintainTaskCostDetailVO>(EquipmentRepairMaintainTaskCostDetailVO.class));
88 return dataList; 96 return dataList;
89 } 97 }
...@@ -153,10 +161,6 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ ...@@ -153,10 +161,6 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
153 sql += " ) aaa group by aaa.time order by aaa.time asc"; 161 sql += " ) aaa group by aaa.time order by aaa.time asc";
154 dataList = pgCommonService.queryForList(sql); 162 dataList = pgCommonService.queryForList(sql);
155 } 163 }
156
157
158
159
160 } catch (ParseException e) { 164 } catch (ParseException e) {
161 e.printStackTrace(); 165 e.printStackTrace();
162 } 166 }
...@@ -166,6 +170,68 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ ...@@ -166,6 +170,68 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
166 return dataList; 170 return dataList;
167 } 171 }
168 172
173 /***
174 * 设备运行时长填报数据
175 * @param departId
176 * @param startTime
177 * @param endTime
178 * @return
179 */
180 @Transactional
181 public boolean fillOutEquipmentInfoDuration(String departId,String startTime,String endTime) throws Exception{
182 //清理数据
183 String deleteSql = " delete from equipment_info_duration where depart_id = '"+departId+"' and date_time >= '"+startTime+"' and date_time <='"+endTime+"' ";
184 commonSqlService.delete(deleteSql);
185
186 String metric_sql = "select fd.device_id 'countTableName', ei.id, ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t";
187 metric_sql += " left join equipment_info ei on ei.id = t.equipment_code " +
188 " left join sys_factory_device fd on fd.depart_id = t.depart_id " +
189 "where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 ";
190 List<Map<String, Object>> metricMapList = commonSqlService.queryForList(metric_sql);
191
192
193 if(startTime.length() < 11 ){
194 startTime = startTime +" 00:00:00";
195 }
196 if(endTime.length() < 11 ){
197 endTime = endTime +" 23:59:59";
198 }
199 String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss")) / 1000L);
200 String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss")) / 1000L);
201
202 String metricYXTag = null;
203 List<Map<String, Object>> yx_dataList = null;
204 List<Map<String, Object>> total_dataList = null;
205 if(metricMapList != null && !metricMapList.isEmpty()){
206 for(Map<String, Object> metricMap : metricMapList){ //遍历设备记录以及metric 标签
207
208 metricYXTag = metricMap.get("yxExpress")+","+metricMap.get("gzExpress")+","+metricMap.get("tzExpress");
209
210 metricYXTag = metricYXTag.replaceAll(",,",",");
211 if(metricYXTag.endsWith(",")){
212 metricYXTag = metricYXTag.substring(0, metricYXTag.length() - 1);
213 }
214 //运行时长
215 String yx_sql = " select aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as duration from (";
216 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+"' " ;
217 yx_sql += " ) aaa group by aaa.time order by aaa.time asc";
218 yx_dataList = pgCommonService.queryForList(yx_sql);
219
220
221 String total_sql = " select aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as duration from (";
222 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+"' " ;
223 total_sql += " ) aaa group by aaa.time order by aaa.time asc";
224 total_dataList = pgCommonService.queryForList(total_sql);
225
226
227 //总时间长
228 }
229 }
230
231
232 return false;
233 }
234
169 235
170 236
171 237
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!