sgj
10 小时以前 4b2b0ec05306c285cff9f95064cf70b5e6e37516
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/SnapReplyService.java
@@ -8,6 +8,7 @@
import com.fzzy.igds.domain.SnapReply;
import com.fzzy.igds.mapper.SnapReplyMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.WxUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -22,6 +23,8 @@
    @Resource
    private SnapReplyMapper snapReplyMapper;
    @Resource
    private WxUtil weChatUtil;
    /**
@@ -53,7 +56,7 @@
    }
    public void listPageByListDept(Page<SnapReply> page, IgdsBaseParam param, List<String> listDept) {
        if( listDept == null || listDept.isEmpty()){
        if (listDept == null || listDept.isEmpty()) {
            return;
        }
@@ -166,4 +169,55 @@
        return snapReplyMapper.deleteById(snapReply) > 0 ? BaseResp.success() : BaseResp.error("删除失败");
    }
    /**
     * 发送警告到微信
     * @param deptId
     */
    public BaseResp sendNotice(String deptId){
        //todo 未完成
        if(StringUtils.isEmpty(deptId)){
            return BaseResp.error("请选择库区");
        }
//        //需要推送的用户
//        List<SysUser> users= new ArrayList<>();
//        String res = "";
//        //遍历用户,发送微信消息
//        for (SysUser user : users) {
//            if(StringUtils.isNotEmpty(user.getOpenId())){
//                boolean b = weChatUtil.sendMessage(
//                        user.getOpenId(),
//                        snapReply.getId(),
//                        snapReply.getCompanyId(),
//                        "库区告警批复测试推送",
//                        snapReply.getDeptId(),
//                        snapReply.getContent(),
//                        DateFormatUtils.format(snapReply.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),
//                        "",
//                        "",
//                        user.getUserName());
//                if(!b){
//                    res += user.getUserName() + "用户微信推送失败,";
//                    return BaseResp.error(res);
//
//                }
//            }else{
//                log.debug("------用户openid不存在,不进行推送------");
//                res += user.getUserName() + "用户未绑定,";
//                return BaseResp.error(res);
//
//            }
//        }
//        if(StringUtils.isEmpty(res)){
//            return BaseResp.success("微信:推送成功;");
//        }else{
//            return BaseResp.error("微信:"+res+";");
//        }
        return BaseResp.success("微信:推送成功;");
    }
}