| | |
| | | package com.fzzy.appwx.manager; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fzzy.appwx.param.WeChatBaseParam; |
| | | import com.fzzy.appwx.util.WeChatUtil; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.constant.RespCodeEnum; |
| | | import com.fzzy.igds.data.IgdsBaseParam; |
| | | import com.fzzy.igds.data.PageResponse; |
| | | import com.fzzy.igds.domain.SnapReply; |
| | | import com.fzzy.igds.service.SnapReplyService; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | @Component |
| | | public class WeChatManager { |
| | |
| | | private WeChatUtil weChatUtil; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Resource |
| | | private SnapReplyService snapReplyService; |
| | | |
| | | |
| | | public String getOpenid(String code) { |
| | |
| | | deptId = Long.valueOf(user.getCompanyId()); |
| | | user.setDeptId(deptId); |
| | | } |
| | | return new PageResponse(RespCodeEnum.CODE_0000.getCode(), "查询成功",user); |
| | | return new PageResponse(RespCodeEnum.CODE_0000.getCode(), "查询成功", user); |
| | | } |
| | | |
| | | //绑定openId |
| | | public PageResponse<String> bandOpenId(WeChatBaseParam param) { |
| | | public PageResponse<String> bandOpenId(WeChatBaseParam param) { |
| | | |
| | | //判断参数 |
| | | if (null == param || StringUtils.isEmpty(param.getOpenid())) { |
| | |
| | | |
| | | //根据手机号查看用户是否是系统用户 |
| | | SysUser user = sysUserService.selectUserByPhoneNumber(param.getMobile()); |
| | | if(user == null || StringUtils.isEmpty(user.getPhonenumber())){ |
| | | if (user == null || StringUtils.isEmpty(user.getPhonenumber())) { |
| | | return new PageResponse<String>(RespCodeEnum.CODE_1006.getCode(), "手机号不在系统内,请联系管理员!"); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | //解绑openId |
| | | public PageResponse<String> unBandOpenId(WeChatBaseParam param) { |
| | | public PageResponse<String> unBandOpenId(WeChatBaseParam param) { |
| | | |
| | | //判断参数 |
| | | if (null == param || StringUtils.isEmpty(param.getOpenid())) { |
| | |
| | | |
| | | //根据手机号查询用户是否已经绑定 |
| | | SysUser user = sysUserService.selectUserByPhoneNumber(param.getMobile()); |
| | | if(user == null || StringUtils.isEmpty(user.getPhonenumber())){ |
| | | if (user == null || StringUtils.isEmpty(user.getPhonenumber())) { |
| | | return new PageResponse<String>(RespCodeEnum.CODE_1006.getCode(), "手机号不在系统内,请联系管理员!"); |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | public PageResponse<Page<SnapReply>> getSnapReplyPage(WeChatBaseParam param) { |
| | | |
| | | if (null == param) { |
| | | return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_1007.getCode(), "参数不完整,请核查"); |
| | | } |
| | | |
| | | SysUser user; |
| | | |
| | | //微信公众号 |
| | | if (StringUtils.isEmpty(param.getOpenid())) { |
| | | return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_1007.getCode(), "参数不完整,请核查"); |
| | | |
| | | } |
| | | //根据openid查询用户是否已经绑定 |
| | | user = sysUserService.selectUserByOpenId(param.getOpenid()); |
| | | if (user == null) { |
| | | return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_1006.getCode(), "尚未绑定服务,请先绑定!"); |
| | | |
| | | } |
| | | //分页拼接 |
| | | Page<SnapReply> page = new Page<>(param.getPageNo(), param.getPageSize()); |
| | | //查询参数组装 |
| | | IgdsBaseParam queryParam = new IgdsBaseParam(); |
| | | queryParam.setDeptId(String.valueOf(user.getDeptId())); |
| | | queryParam.setCompanyId(user.getCompanyId()); |
| | | queryParam.setKey(Constant.YN_N); |
| | | snapReplyService.listPage(page, queryParam); |
| | | return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_0000.getCode(), "请求成功", page); |
| | | } |
| | | |
| | | public PageResponse<SnapReply> getSnapReplyInfoById(WeChatBaseParam param) { |
| | | |
| | | //判断参数 |
| | | if (null == param || StringUtils.isEmpty(param.getId())) { |
| | | return new PageResponse<SnapReply>(RespCodeEnum.CODE_1007.getCode(), "参数不完整,请核查"); |
| | | |
| | | } |
| | | |
| | | SnapReply warn = snapReplyService.getById(param.getId()); |
| | | if (warn == null) { |
| | | return new PageResponse<SnapReply>(RespCodeEnum.CODE_1007.getCode(), "未获取到该警告信息!"); |
| | | |
| | | } |
| | | |
| | | return new PageResponse<SnapReply>(RespCodeEnum.CODE_0000.getCode(), "请求成功", warn); |
| | | |
| | | } |
| | | |
| | | public PageResponse<String> handleSnapReply(WeChatBaseParam param) { |
| | | |
| | | //判断参数 |
| | | if (null == param || StringUtils.isEmpty(param.getId())) { |
| | | return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "参数不完整,请核查"); |
| | | |
| | | } |
| | | |
| | | //处理时间 |
| | | Date date = new Date(); |
| | | |
| | | // if(StringUtils.isEmpty(companyId)){ |
| | | // companyId = ShiroUtils.getLoginUserCompanyId(); |
| | | // } |
| | | String info = (String) param.getRemark(); |
| | | String id = param.getId(); |
| | | String userName = param.getUserName(); |
| | | |
| | | //告警处理 |
| | | SnapReply warn = snapReplyService.getById(id); |
| | | if(Constant.YN_N.equals(warn.getIsHandle())){ |
| | | return new PageResponse<String>(RespCodeEnum.CODE_1008.getCode(), "改告警已处理,无需重复批复!"); |
| | | } |
| | | warn.setId(id); |
| | | warn.setUpdateBy(userName); |
| | | warn.setUpdateTime(date); |
| | | warn.setIsHandle(Constant.YN_Y); |
| | | warn.setReplyText(info); |
| | | warn.setDays(param.getDays()); |
| | | snapReplyService.updateData(warn); |
| | | |
| | | return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "请求成功"); |
| | | |
| | | } |
| | | |
| | | } |