添加推送功能

This commit is contained in:
yangjun 2025-12-24 10:43:51 +08:00
parent 56d58c415c
commit db2eba863d
5 changed files with 239 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nu.dto.SuppliersInfoMQDto;
import com.nu.entity.EmployeesAdvisoryInfoEntity; import com.nu.entity.EmployeesAdvisoryInfoEntity;
import com.nu.entity.SuppliersApplyEntity; import com.nu.entity.SuppliersApplyEntity;
import com.nu.entity.SuppliersOrgAllEntity; import com.nu.entity.SuppliersOrgAllEntity;
@ -17,6 +18,7 @@ import com.nu.modules.bizSuppliers.service.INuBizSuppliersApplyService;
import com.nu.modules.orgapplyinfo.entity.OrgAllInfo; import com.nu.modules.orgapplyinfo.entity.OrgAllInfo;
import com.nu.modules.orgapplyinfo.entity.OrgAllInfoApiEntity; import com.nu.modules.orgapplyinfo.entity.OrgAllInfoApiEntity;
import com.nu.modules.suppliers.ISuppliersApi; import com.nu.modules.suppliers.ISuppliersApi;
import com.nu.utils.RabbitMQUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,6 +42,9 @@ public class NuBizSuppliersApplyServiceImpl extends ServiceImpl<NuBizSuppliersAp
@Autowired @Autowired
private IEmployessAdvisioryInfoApi employessAdvisioryInfoApi; private IEmployessAdvisioryInfoApi employessAdvisioryInfoApi;
@Autowired
private RabbitMQUtil rabbitMQUtil;
@Override @Override
public SuppliersApplyEntity addSuppliers(SuppliersApplyEntity suppliersApplyEntity) { public SuppliersApplyEntity addSuppliers(SuppliersApplyEntity suppliersApplyEntity) {
QueryWrapper<NuBizSuppliersApply> queryWrapper = new QueryWrapper<>(); QueryWrapper<NuBizSuppliersApply> queryWrapper = new QueryWrapper<>();
@ -108,6 +113,22 @@ public class NuBizSuppliersApplyServiceImpl extends ServiceImpl<NuBizSuppliersAp
nuBizSuppliersOrgMapper.insert(nuBizSuppliersOrg); nuBizSuppliersOrgMapper.insert(nuBizSuppliersOrg);
//todo 向对应业务机构添加供应商审核数据 //todo 向对应业务机构添加供应商审核数据
NuBizSuppliersApply nuBizSuppliersApply = list.get(0);
SuppliersInfoMQDto suppliersInfoMQDto = new SuppliersInfoMQDto();
suppliersInfoMQDto.setSuppliersName(nuBizSuppliersApply.getSuppliersName());
suppliersInfoMQDto.setSuppliersNature(nuBizSuppliersApply.getSuppliersNature());
suppliersInfoMQDto.setSuppliersAddress(nuBizSuppliersApply.getSuppliersAddress());
suppliersInfoMQDto.setPersonInCharge(nuBizSuppliersApply.getPersonInCharge());
suppliersInfoMQDto.setContactNumber(nuBizSuppliersApply.getContactNumber());
suppliersInfoMQDto.setSupplyState(nuBizSuppliersApply.getSupplyState());
suppliersInfoMQDto.setOpeningBank(nuBizSuppliersApply.getOpeningBank());
suppliersInfoMQDto.setOpeningBankNo(nuBizSuppliersApply.getOpeningBankNo());
suppliersInfoMQDto.setImgPath(nuBizSuppliersApply.getImgPath());
suppliersInfoMQDto.setApplyStatus("1");
suppliersInfoMQDto.setSysOrgCode(nuBizSuppliersOrg.getOrgCode());
suppliersInfoMQDto.setApplyId(nuBizSuppliersOrg.getId());
suppliersInfoMQDto.setSuppliersId(nuBizSuppliersApply.getId());
rabbitMQUtil.sendToExchange("nu.suppliers.applyStatus", nuBizSuppliersOrg.getOrgCode() + ".suppliers.applyStatus", suppliersInfoMQDto);
BeanUtils.copyProperties(nuBizSuppliersOrg, suppliersOrgEntity); BeanUtils.copyProperties(nuBizSuppliersOrg, suppliersOrgEntity);
return suppliersOrgEntity; return suppliersOrgEntity;
@ -126,7 +147,31 @@ public class NuBizSuppliersApplyServiceImpl extends ServiceImpl<NuBizSuppliersAp
BeanUtils.copyProperties(suppliersApplyEntity, nuBizSuppliersApply); BeanUtils.copyProperties(suppliersApplyEntity, nuBizSuppliersApply);
baseMapper.updateById(nuBizSuppliersApply); baseMapper.updateById(nuBizSuppliersApply);
QueryWrapper<NuBizSuppliersOrg> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status", "2");
queryWrapper.eq("iz_history", "N");
List<NuBizSuppliersOrg> list = nuBizSuppliersOrgMapper.selectList(queryWrapper);
for(NuBizSuppliersOrg nuBizSuppliersOrg:list){
//todo 修改对应机构的供应商数据 //todo 修改对应机构的供应商数据
SuppliersInfoMQDto suppliersInfoMQDto = new SuppliersInfoMQDto();
suppliersInfoMQDto.setSuppliersName(nuBizSuppliersApply.getSuppliersName());
suppliersInfoMQDto.setSuppliersNature(nuBizSuppliersApply.getSuppliersNature());
suppliersInfoMQDto.setSuppliersAddress(nuBizSuppliersApply.getSuppliersAddress());
suppliersInfoMQDto.setPersonInCharge(nuBizSuppliersApply.getPersonInCharge());
suppliersInfoMQDto.setContactNumber(nuBizSuppliersApply.getContactNumber());
suppliersInfoMQDto.setSupplyState(nuBizSuppliersApply.getSupplyState());
suppliersInfoMQDto.setOpeningBank(nuBizSuppliersApply.getOpeningBank());
suppliersInfoMQDto.setOpeningBankNo(nuBizSuppliersApply.getOpeningBankNo());
suppliersInfoMQDto.setImgPath(nuBizSuppliersApply.getImgPath());
// suppliersInfoMQDto.setApplyStatus("1");
suppliersInfoMQDto.setSysOrgCode(nuBizSuppliersOrg.getOrgCode());
suppliersInfoMQDto.setSuppliersId(nuBizSuppliersApply.getId());
rabbitMQUtil.sendToExchange("nu.suppliers.editSuppliersApply", nuBizSuppliersOrg.getOrgCode() + ".suppliers.editSuppliersApply", suppliersInfoMQDto);
}
BeanUtils.copyProperties(nuBizSuppliersApply, suppliersApplyEntity); BeanUtils.copyProperties(nuBizSuppliersApply, suppliersApplyEntity);
return suppliersApplyEntity; return suppliersApplyEntity;

View File

@ -0,0 +1,20 @@
package com.nu.mq.suppliers.exceptionhandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler;
import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
import org.springframework.stereotype.Component;
@Slf4j
@Component("suppliersMQExceptionHandler")
public class SuppliersMQExceptionHandler implements RabbitListenerErrorHandler {
@Override
public Object handleError(Message message, org.springframework.messaging.Message<?> message1, ListenerExecutionFailedException e) {
log.error("MQ消息处理失败 | 消息体: {} | 异常原因: {}", new String(message.getBody()), e.getCause().getMessage());
throw new AmqpRejectAndDontRequeueException("消息处理失败且禁止重试", e);
}
}

View File

@ -0,0 +1,99 @@
package com.nu.mq.suppliers.listener;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import com.nu.dto.SuppliersInfoMQDto;
import com.nu.dto.WorkOrderMQDto;
import com.nu.entity.NuWxNoticeEntity;
import com.nu.entity.WxNoticeEntity;
import com.nu.enums.WxClientType;
import com.nu.modules.bizSuppliers.entity.NuBizSuppliersOrg;
import com.nu.modules.bizSuppliers.service.INuBizSuppliersOrgService;
import com.nu.modules.wxnotice.IWxNoticeApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
@Slf4j
@Component
public class SuppliersMQListener {
@Autowired
private INuBizSuppliersOrgService nuBizSuppliersOrgService;
@Autowired
private IWxNoticeApi wxNoticeApi;
/**
* 工单回执
*/
@AutoLog(value = "供应商-供应商审核回执")
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "nu.suppliers.suppliersApplyStatus"),
exchange = @Exchange(name = "nu.suppliers.suppliersApplyStatus", type = ExchangeTypes.DIRECT),
key = "nu.suppliers.suppliersApplyStatus"
),
errorHandler = "suppliersMQExceptionHandler"
)
public void suppliersApplyStatus(SuppliersInfoMQDto suppliersInfoMQDto) {
log.info("供应商审核回执");
log.info("供应商审核回执: {}", suppliersInfoMQDto);
log.info("业务处理");
NuBizSuppliersOrg nuBizSuppliersOrg = new NuBizSuppliersOrg();
nuBizSuppliersOrg.setId(suppliersInfoMQDto.getApplyId());
nuBizSuppliersOrg.setStatus(suppliersInfoMQDto.getApplyStatus());
nuBizSuppliersOrg.setAuditContent(suppliersInfoMQDto.getApplyContent());
nuBizSuppliersOrgService.updateById(nuBizSuppliersOrg);
nuBizSuppliersOrg = nuBizSuppliersOrgService.getById(nuBizSuppliersOrg.getId());
String content1 = "";
String content2 = "";
// QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("org_code", nuBizSuppliersOrg.getOrgCode());
// SysDepart dto = sysDepartService.getOne(queryWrapper);
//审核通过
if(StringUtils.equals("2",nuBizSuppliersOrg.getStatus())){
content1 = "您好,您提交的入驻信息已通过";
content2 = "审核通过";
}else if(StringUtils.equals("3",nuBizSuppliersOrg.getStatus())){
content1 = "您好,您提交的入驻信息已驳回";
content2 = "审核驳回";
}
NuWxNoticeEntity nuWxNotice = new NuWxNoticeEntity();
nuWxNotice.setOpenId(nuBizSuppliersOrg.getOpenId());
nuWxNotice.setIzRead("N");
nuWxNotice.setOrgCode(nuBizSuppliersOrg.getOrgCode());
nuWxNotice.setTitle("入驻机构审批");
nuWxNotice.setContent(content1);
nuWxNotice.setType("suppliers_status");
Map<String, Object> extend = Maps.newHashMap();
extend.put("orgCode", nuBizSuppliersOrg.getOrgCode());
extend.put("dataId", nuBizSuppliersOrg.getSuppliersId());
nuWxNotice.setExtend(JSONObject.toJSONString(extend));
nuWxNotice.setClientType(WxClientType.ELDER.getCode());
wxNoticeApi.addNotice(nuWxNotice);
WxNoticeEntity wxNotice = new WxNoticeEntity();
wxNotice.setPageRoute("pages/supplierindex/index");
wxNotice.setThing1("供应商入驻审核");
wxNotice.setThing4(content2);
wxNotice.setLogMainInfo("供应商入驻审核");
wxNoticeApi.sendWechartMessage_SHENHE(wxNotice, nuWxNotice);
}
}

View File

@ -0,0 +1,73 @@
package com.nu.dto;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: nu_config_suppliers_apply
* @Author: jeecg-boot
* @Date: 2025-12-23
* @Version: V1.0
*/
@Data
public class SuppliersInfoMQDto implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@ApiModelProperty(value = "id")
private String id;
/**供应商名称*/
private String suppliersName;
/**供应商性质 1代理商 2批发商 3制造商*/
private String suppliersNature;
/**供应商地址*/
private String suppliersAddress;
/**负责人*/
private String personInCharge;
/**联系电话*/
private String contactNumber;
/**供应状态 1正常供应 2暂停供应*/
private String supplyState;
/**开户行*/
private String openingBank;
/**开户行账号*/
private String openingBankNo;
/**微信账号*/
private String wechartId;
/**资质照片*/
private String imgPath;
/**创建人*/
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**所属部门*/
private String sysOrgCode;
/**审核状态*/
@Excel(name = "审核状态", width = 15)
private String applyStatus;
/**审核备注*/
private String applyContent;
/**申请id*/
private String applyId;
/**供应商id*/
private String suppliersId;
}