|
@ -2,9 +2,10 @@ package com.yihu.jw.base.service.a3service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
|
|
|
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -26,6 +27,9 @@ public class MedicineServive {
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private MediicinedrugsDao mediicinedrugsDao;
|
|
|
@Autowired
|
|
|
private MediicineDeviceDao deviceDao;
|
|
|
|
|
|
@Value("${medicine.socketUrl}")
|
|
|
private String socketUrl;
|
|
|
|
|
@ -101,20 +105,22 @@ public class MedicineServive {
|
|
|
, Boolean humidityControl, Boolean heat) throws Exception {
|
|
|
JSONObject object = new JSONObject();
|
|
|
String param = "";
|
|
|
|
|
|
if (StringUtils.isNoneBlank(devId)) {
|
|
|
param = "?devId=" + devId;
|
|
|
param += "?devId=" + devId;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(temperature)) {
|
|
|
param += "?temperature=" + temperature;
|
|
|
object.put("temperature",temperature);
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(humidity)) {
|
|
|
param += "?humidity=" + humidity;
|
|
|
object.put("humidity",humidity);
|
|
|
}
|
|
|
param += "?temperatureControl=" + temperatureControl;
|
|
|
param += "?humidityControl=" + humidityControl;
|
|
|
param += "?heat=" + heat;
|
|
|
object.put("temperatureControl",temperatureControl);
|
|
|
object.put("humidityControl",humidityControl);
|
|
|
object.put("heat",heat);
|
|
|
param+="&type=SetTemperatureAndHumidity&mess="+object.toJSONString()+"";
|
|
|
String res = httpClientUtil.get(socketUrl+param,"utf-8");
|
|
|
System.out.println(res);
|
|
|
System.out.println(res);
|
|
|
/* if (StringUtils.isNoneBlank(res)){
|
|
|
object =JSONObject.parseObject(res);
|
|
|
}else{
|
|
@ -123,27 +129,47 @@ public class MedicineServive {
|
|
|
}
|
|
|
|
|
|
|
|
|
/*public void sendSocketMessage(String devId, String type,String message) throws Exception {
|
|
|
/**
|
|
|
* socket发送事件
|
|
|
* @param devId
|
|
|
* @param type
|
|
|
* @param message
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String sendSocketMessage(String devId, String type,String message) throws Exception {
|
|
|
JSONObject object = new JSONObject();
|
|
|
String param = "";
|
|
|
if (StringUtils.isNoneBlank(devId)) {
|
|
|
param = "?devId=" + devId;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(temperature)) {
|
|
|
param += "?temperature=" + temperature;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(humidity)) {
|
|
|
param += "?humidity=" + humidity;
|
|
|
}
|
|
|
param += "?temperatureControl=" + temperatureControl;
|
|
|
param += "?humidityControl=" + humidityControl;
|
|
|
param += "?heat=" + heat;
|
|
|
param +="&type="+type+"&mess="+message+"";
|
|
|
String res = httpClientUtil.get(socketUrl+param,"utf-8");
|
|
|
System.out.println(res);
|
|
|
*//* if (StringUtils.isNoneBlank(res)){
|
|
|
object =JSONObject.parseObject(res);
|
|
|
}else{
|
|
|
throw new Exception("调用设备通信接口设置温湿度失败!");
|
|
|
}*//*
|
|
|
}*/
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* socket发送事件
|
|
|
* @param equNum
|
|
|
* @param type
|
|
|
* @param message
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String systemUpdate(String equNum, String type,String message) throws Exception {
|
|
|
int i=0;
|
|
|
if (StringUtils.isNoneBlank(equNum)){
|
|
|
String res = sendSocketMessage(equNum+"_T",type,message);
|
|
|
logger.info("更新设备"+res);
|
|
|
i++;
|
|
|
}else {
|
|
|
List<Mediicinedevice> mediicinedeviceList =deviceDao.selectByBelongComminity();
|
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
|
String res = sendSocketMessage(mediicinedevice.getEquNum()+"_T",type,message);
|
|
|
logger.info("更新设备"+res);
|
|
|
i++;
|
|
|
}
|
|
|
logger.info("更新"+i+"台设备");
|
|
|
}
|
|
|
return "更新"+i+"台设备";
|
|
|
}
|
|
|
}
|