|
|
|
@ -1,13 +1,11 @@
|
|
|
|
|
package cn.iocoder.yudao.module.farm.annotation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskDetailDTO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.dataobject.discuss.DiscussDO; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO; |
|
|
|
@ -25,21 +23,20 @@ import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpMessageService; |
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpService; |
|
|
|
|
import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage; |
|
|
|
|
import me.chanjar.weixin.cp.bean.message.WxCpMessage; |
|
|
|
|
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; |
|
|
|
|
import me.chanjar.weixin.cp.bean.messagebuilder.MiniProgramNoticeMsgBuilder; |
|
|
|
|
import me.chanjar.weixin.cp.tp.message.WxCpTpMessageHandler; |
|
|
|
|
import org.aspectj.lang.ProceedingJoinPoint; |
|
|
|
|
import org.aspectj.lang.annotation.*; |
|
|
|
|
import org.aspectj.lang.annotation.Around; |
|
|
|
|
import org.aspectj.lang.annotation.Aspect; |
|
|
|
|
import org.aspectj.lang.annotation.Pointcut; |
|
|
|
|
import org.aspectj.lang.reflect.MethodSignature; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
@ -79,6 +76,9 @@ public class FarmMsgAspect {
|
|
|
|
|
@Value("${wxma.app_id}") |
|
|
|
|
private String appid; |
|
|
|
|
|
|
|
|
|
@Value("${spring.profiles.active}") |
|
|
|
|
private String active; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 定义切入点 @PointCut |
|
|
|
|
* 使用了@FarmMsg注解的地方切入 |
|
|
|
@ -90,6 +90,7 @@ public class FarmMsgAspect {
|
|
|
|
|
@Around("farmMsgPointCut(farmMsg)") |
|
|
|
|
public Object doAround(ProceedingJoinPoint pjp,FarmMsg farmMsg) throws Throwable { |
|
|
|
|
Object object = pjp.proceed(); |
|
|
|
|
if (active.equalsIgnoreCase("prod")){ |
|
|
|
|
if (object instanceof CommonResult){ |
|
|
|
|
// 只处理接口正常result
|
|
|
|
|
if (farmMsg.type() == FarmMsgTypeEnum.NONE |
|
|
|
@ -117,9 +118,6 @@ public class FarmMsgAspect {
|
|
|
|
|
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); |
|
|
|
|
CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); |
|
|
|
|
|
|
|
|
|
// if (!toUserStr.contains("WeiLaiKeQi")){
|
|
|
|
|
// return object;
|
|
|
|
|
// }
|
|
|
|
|
if (!farmMsgDTO.getNoSendMsg()){ |
|
|
|
|
//企业微信小程序通知消息
|
|
|
|
|
this.sendMiniMsg(user, farmMsgDTO, toUserStr); |
|
|
|
@ -137,6 +135,7 @@ public class FarmMsgAspect {
|
|
|
|
|
logMsgMapper.insert(logMsgDO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return object; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|