|
@ -158,23 +158,26 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String updateDeviceAddress(String deviceId, String address){
|
|
|
|
|
|
public String updateDeviceAddress(String deviceIds, String address){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(address)){
|
|
|
|
result.put("msg","deviceId and address is null");
|
|
|
|
|
|
if(StringUtils.isEmpty(deviceIds) && StringUtils.isEmpty(address)){
|
|
|
|
result.put("msg","deviceIds and address is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
|
|
for (String deviceId : deviceIds.split(",")) {
|
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
mediicinedevice.setDeliveryAddress(address);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
}
|
|
}
|
|
}
|
|
mediicinedevice.setDeliveryAddress(address);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("msg",mediicinedevice);
|
|
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
@ -235,41 +238,44 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
/**
|
|
/**
|
|
* 解绑设备
|
|
* 解绑设备
|
|
* @param deviceId
|
|
|
|
|
|
* @param deviceIds
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String unbindDevice(String deviceId){
|
|
|
|
|
|
public String unbindDevice(String deviceIds){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(deviceId)){
|
|
|
|
result.put("msg","deviceId is null");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
|
|
if(StringUtils.isEmpty(deviceIds)){
|
|
|
|
result.put("msg","deviceIds is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
List<Map<String, Object>> list = null;
|
|
|
|
list = hibenateUtils.createSQLQuery("SELECT * FROM t_mediicine_device_user where del = 1 AND device_id = '" + deviceId + "'");
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
if (!StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
|
|
|
|
MediicineDeviceUser mediicineDeviceUser = deviceUserDao.findOne(stringObjectMap.get("id").toString());
|
|
|
|
if (mediicineDeviceUser != null) {
|
|
|
|
mediicineDeviceUser.setDel("0");
|
|
|
|
deviceUserDao.save(mediicineDeviceUser);
|
|
|
|
|
|
for (String deviceId : deviceIds.split(",")) {
|
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> list = null;
|
|
|
|
list = hibenateUtils.createSQLQuery("SELECT * FROM t_mediicine_device_user where del = 1 AND device_id = '" + deviceId + "'");
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
if (!StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
|
|
|
|
MediicineDeviceUser mediicineDeviceUser = deviceUserDao.findOne(stringObjectMap.get("id").toString());
|
|
|
|
if (mediicineDeviceUser != null) {
|
|
|
|
mediicineDeviceUser.setDel("0");
|
|
|
|
deviceUserDao.save(mediicineDeviceUser);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
mediicinedevice.setBelongCommunity(null);
|
|
|
|
mediicinedevice.setCommunity(null);
|
|
|
|
this.save(mediicinedevice);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mediicinedevice.setBelongCommunity(null);
|
|
|
|
mediicinedevice.setCommunity(null);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("msg",mediicinedevice);
|
|
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|