|
...
|
...
|
@@ -12,6 +12,7 @@ import com.zhonglai.luhui.dao.service.PublicService; |
|
|
|
import com.zhonglai.luhui.device.domain.IotAlert;
|
|
|
|
import com.zhonglai.luhui.device.domain.IotAlertNoticeChannel;
|
|
|
|
import com.zhonglai.luhui.device.domain.IotAlertUserNotice;
|
|
|
|
import com.zhonglai.luhui.device.dto.UserAlertPhone;
|
|
|
|
import com.zhonglai.luhui.device.dto.WeiXinGongZhongHaoNoticeDto;
|
|
|
|
import com.zhonglai.luhui.device.dto.WeiXinXiaoChengXuNoticeDto;
|
|
|
|
import com.zhonglai.luhui.security.utils.SecurityUtils;
|
|
...
|
...
|
@@ -120,7 +121,7 @@ public class UserInfoAlarmController extends BaseController { |
|
|
|
{
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert` where product_id="+product_id));
|
|
|
|
}else {
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert` where product_id="+product_id+"alert_id in("+map.get("alert_ids")+")"));
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert` where product_id="+product_id+" and alert_id in("+map.get("alert_ids")+")"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
...
|
...
|
@@ -128,7 +129,7 @@ public class UserInfoAlarmController extends BaseController { |
|
|
|
{
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert_user` where product_id="+product_id));
|
|
|
|
}else {
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert_user` where product_id="+product_id+"alert_id in("+map.get("alert_ids")+")"));
|
|
|
|
map.put("iotAlertList",publicService.getObjectListBySQL("select * from `iot_alert_user` where product_id="+product_id+" and alert_id in("+map.get("alert_ids")+")"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
...
|
...
|
@@ -209,16 +210,11 @@ public class UserInfoAlarmController extends BaseController { |
|
|
|
uPiotAlertUserNotice.setAlert_ids(alert_ids);
|
|
|
|
}else {
|
|
|
|
List<Map<String,Object>> aidsList = publicService.getObjectListBySQL("SELECT GROUP_CONCAT(alert_id) aids FROM `iot_alert` WHERE product_id<>"+product_id+" AND alert_id IN("+iotAlertUserNotice.getAlert_ids()+")");
|
|
|
|
if(null != aidsList && aidsList.size() != 0)
|
|
|
|
if(null != aidsList && aidsList.size() != 0 && null != aidsList.get(0) && null != aidsList.get(0).get("aids"))
|
|
|
|
{
|
|
|
|
Object aids = aidsList.get(0).get("aids");
|
|
|
|
if(null != aids && !aids.equals(""))
|
|
|
|
{
|
|
|
|
uPiotAlertUserNotice.setAlert_ids(aids+","+alert_ids);
|
|
|
|
}else {
|
|
|
|
uPiotAlertUserNotice.setAlert_ids(alert_ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
uPiotAlertUserNotice.setAlert_ids(aidsList.get(0).get("aids")+","+alert_ids);
|
|
|
|
}else {
|
|
|
|
uPiotAlertUserNotice.setAlert_ids(alert_ids);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -231,6 +227,66 @@ public class UserInfoAlarmController extends BaseController { |
|
|
|
return AjaxResult.success(upi);
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("获取告警通知的手机号")
|
|
|
|
@GetMapping(value = "getUserAlertPhoneList")
|
|
|
|
public AjaxResult getUserAlertPhoneList()
|
|
|
|
{
|
|
|
|
Integer user_id = SecurityUtils.getUserId().intValue();
|
|
|
|
List<Map<String,Object>> list = publicService.getObjectListBySQL("select * from user_alert_phone where user_id="+user_id);
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("删除告警通知的手机号")
|
|
|
|
@ApiImplicitParam(value = "被删除的手机号",name = "phone")
|
|
|
|
@PostMapping(value = "delUserAlertPhone")
|
|
|
|
public AjaxResult delUserAlertPhone(String phone)
|
|
|
|
{
|
|
|
|
Integer user_id = SecurityUtils.getUserId().intValue();
|
|
|
|
return AjaxResult.success(publicService.updateBySql("DELETE FROM `user_alert_phone` WHERE phone='"+phone+"' AND user_id="+user_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("添加告警通知手机号")
|
|
|
|
@ApiImplicitParam(value = "手机号",name = "phone")
|
|
|
|
@PostMapping(value = "addUserAlertPhone")
|
|
|
|
public AjaxResult addUserAlertPhone(String phone)
|
|
|
|
{
|
|
|
|
|
|
|
|
Integer user_id = SecurityUtils.getUserId().intValue();
|
|
|
|
UserAlertPhone userAlertPhone = new UserAlertPhone();
|
|
|
|
userAlertPhone.setPhone(phone);
|
|
|
|
userAlertPhone.setUser_id(user_id);
|
|
|
|
Long lg = publicService.getObjectListTotle(userAlertPhone,null);
|
|
|
|
if (lg>0)
|
|
|
|
{
|
|
|
|
return AjaxResult.error("该手机号已经添加过了");
|
|
|
|
}
|
|
|
|
return AjaxResult.success( publicService.insert(userAlertPhone));
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("开通指定通知服务")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(value = "渠道id(管理员提供)",name = "channel_id"),
|
|
|
|
@ApiImplicitParam(value = "告警类型(1系统告警,2用户告警)",name = "type"),
|
|
|
|
})
|
|
|
|
@Log(title = "开通指定通知服务", businessType = BusinessType.INSERT)
|
|
|
|
@Transactional
|
|
|
|
@PostMapping(value = "openNoticeService/{channel_id}/{type}")
|
|
|
|
public AjaxResult openNoticeService(@PathVariable Integer channel_id,@PathVariable Integer type)
|
|
|
|
{
|
|
|
|
//检查渠道是否存在
|
|
|
|
IotAlertNoticeChannel iotAlertNoticeChannel = publicService.getObject(IotAlertNoticeChannel.class,"id",channel_id+"");
|
|
|
|
if(null == iotAlertNoticeChannel)
|
|
|
|
{
|
|
|
|
return AjaxResult.error("通知渠道不存在");
|
|
|
|
}
|
|
|
|
if(iotAlertNoticeChannel.getType()!=1)
|
|
|
|
{
|
|
|
|
return AjaxResult.error("该渠道不是公众号通知渠道");
|
|
|
|
}
|
|
|
|
Integer user_id = SecurityUtils.getUserId().intValue();
|
|
|
|
return upIotAlertUserNotice(user_id,channel_id,type);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void upOpenid(Integer user_id,String openid,Integer xcxConfigid)
|
|
|
|
{
|
|
|
|
//更新用户openid表
|
...
|
...
|
|