|
@ -3,6 +3,7 @@ package com.yihu.iot.service.monitorPlatform;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.iot.dao.dict.IotSystemDictDao;
|
|
|
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
|
|
|
import com.yihu.iot.service.common.MyJdbcTemplate;
|
|
|
import com.yihu.iot.service.device.IotPatientDeviceService;
|
|
@ -57,6 +58,8 @@ public class MonitorPlatformService {
|
|
|
private IotEquipmentDetailDao iotEquipmentDetailDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private IotSystemDictDao iotSystemDictDao;
|
|
|
|
|
|
/**
|
|
|
* 获取位置信息
|
|
@ -142,34 +145,41 @@ public class MonitorPlatformService {
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String anotherResult = sendGet(url,params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(anotherResult);
|
|
|
if("200".equals(jsonObject.get("status").toString())){
|
|
|
JSONArray dataresult= jsonObject.getJSONArray("data");
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
String sqlAre = "select count(1) AS \"total\",t.belong_are AS \"belong_are\",t.belong_are_code AS \"belong_are_code\" from iot_equipmet_detail t group by t.belong_are_code order by \"total\" desc ";
|
|
|
List<Map<String, Object>> iotEquip = hibenateUtils.createSQLQuery(sqlAre);
|
|
|
if (dataresult.size()>0){
|
|
|
for(int i=0;i<dataresult.size();i++){
|
|
|
JSONObject item= JSONObject.parseObject(dataresult.get(i).toString());
|
|
|
if(null!=item.get("num")){
|
|
|
Integer itemCount = Integer.parseInt(item.get("num").toString());
|
|
|
for(Map<String, Object> map:iotEquip){
|
|
|
if (item.get("code").toString().equals(map.get("belong_are_code"))){
|
|
|
itemCount = Integer.parseInt(map.get("total").toString())+itemCount;
|
|
|
item.put("num",itemCount);
|
|
|
String sqlAre = "select count(1) AS \"total\",t.belong_are AS \"belong_are\",t.belong_are_code AS \"belong_are_code\" from iot_equipmet_detail t group by t.belong_are_code order by \"total\" desc ";
|
|
|
List<Map<String, Object>> iotEquip = hibenateUtils.createSQLQuery(sqlAre);
|
|
|
if("8"==deviceType){
|
|
|
return iotEquip.toString();
|
|
|
}else {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(anotherResult);
|
|
|
if("200".equals(jsonObject.get("status").toString())){
|
|
|
JSONArray dataresult= jsonObject.getJSONArray("data");
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
if (dataresult.size()>0){
|
|
|
for(int i=0;i<dataresult.size();i++){
|
|
|
JSONObject item= JSONObject.parseObject(dataresult.get(i).toString());
|
|
|
if(null!=item.get("num")){
|
|
|
Integer itemCount = Integer.parseInt(item.get("num").toString());
|
|
|
for(Map<String, Object> map:iotEquip){
|
|
|
if (item.get("code").toString().equals(map.get("belong_are_code"))){
|
|
|
itemCount = Integer.parseInt(map.get("total").toString())+itemCount;
|
|
|
item.put("num",itemCount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
resultArray.add(item);
|
|
|
}
|
|
|
resultArray.add(item);
|
|
|
}
|
|
|
jsonObject.replace("data",resultArray);
|
|
|
System.out.println(jsonObject.toString());
|
|
|
|
|
|
}
|
|
|
jsonObject.replace("data",resultArray);
|
|
|
System.out.println(jsonObject.toString());
|
|
|
return jsonObject.toString();
|
|
|
}
|
|
|
|
|
|
return jsonObject.toString();
|
|
|
}
|
|
|
|
|
|
/*private String dealSql(Map<String, Object> params){
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
sql.append()
|
|
|
}*/
|
|
|
|
|
|
/**
|
|
|
* 慢病患者情况-统计
|