Commit a7a24f41 authored by tangwei's avatar tangwei

增加activemq ,推送人员数据变化时,发送消息

parent 445774e3
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2023/6/7
*/
@Data
public class MsgBody {
private Map<String, Object> data;
private String method;
private String id;
public MsgBody(Map<String, Object> data, String method, String id) {
this.data = data;
this.method = method;
this.id = id;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2023/6/7
*/
@Data
public class ProduceMsg {
private MsgBody body;
public ProduceMsg(Map<String, Object> data, String method, String id) {
this.body= new MsgBody( data, method, id);
}
}
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.yeejoin.amos.boot.module.jxiop.biz.activemq;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.stereotype.Component;
import javax.jms.Queue;
/**
* @description:
* @author: tw
* @createDate: 2023/6/7
*/
@Component
@EnableJms
public class ConfigBean {
@Value("${myqueue}")
private String myQueue;
//创建一个队列
@Bean
public Queue queue(){
return new ActiveMQQueue(myQueue);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.activemq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;
import javax.jms.Queue;
import java.util.UUID;
/**
* @description:
* @author: tw
* @createDate: 2023/6/7
*/
@Component
public class QuerueProduce {
@Autowired
private JmsMessagingTemplate jmsMessagingTemplate;
@Autowired
private Queue queue;
public void produceMsg(String produceMsg){
jmsMessagingTemplate.convertAndSend(queue,produceMsg);
}
}
...@@ -2,15 +2,18 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; ...@@ -2,15 +2,18 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil; import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.jxiop.api.dto.EXPersonUser; import com.yeejoin.amos.boot.module.jxiop.api.dto.EXPersonUser;
import com.yeejoin.amos.boot.module.jxiop.api.dto.ExStationBasicDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.ExStationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.ProduceMsg;
import com.yeejoin.amos.boot.module.jxiop.api.entity.*; import com.yeejoin.amos.boot.module.jxiop.api.entity.*;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.activemq.QuerueProduce;
import com.yeejoin.amos.boot.module.ugp.api.Util.Constants; import com.yeejoin.amos.boot.module.ugp.api.Util.Constants;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
...@@ -58,6 +61,10 @@ public class ExcelServiceImpl { ...@@ -58,6 +61,10 @@ public class ExcelServiceImpl {
PersonSkillEducationServiceImpl personSkillEducationService; PersonSkillEducationServiceImpl personSkillEducationService;
@Autowired @Autowired
PersonAccountServiceImpl personAccountServiceImpl; PersonAccountServiceImpl personAccountServiceImpl;
@Autowired
QuerueProduce querueProduce;
// 邮箱校验正则 // 邮箱校验正则
static final String EMAIL = "^([a-zA-Z\\d][\\w-]{2,})@(\\w{2,})\\.([a-z]{2,})(\\.[a-z]{2,})?$"; static final String EMAIL = "^([a-zA-Z\\d][\\w-]{2,})@(\\w{2,})\\.([a-z]{2,})(\\.[a-z]{2,})?$";
/** /**
...@@ -65,6 +72,8 @@ public class ExcelServiceImpl { ...@@ -65,6 +72,8 @@ public class ExcelServiceImpl {
*/ */
static final String PHONE = "^1((3|4|5|6|7|8|9){1}\\d{1}|70)\\d{8}$"; static final String PHONE = "^1((3|4|5|6|7|8|9){1}\\d{1}|70)\\d{8}$";
private String EXPORT="EXPORT";
public void templateExport(HttpServletResponse response, ExcelDto excelDto, Map par) throws ClassNotFoundException { public void templateExport(HttpServletResponse response, ExcelDto excelDto, Map par) throws ClassNotFoundException {
String url = excelDto.getClassUrl(); String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url); Class<?> clz = Class.forName(url);
...@@ -286,7 +295,7 @@ public class ExcelServiceImpl { ...@@ -286,7 +295,7 @@ public class ExcelServiceImpl {
@Transactional @Transactional
public void updateEXPersonUserda(List<EXPersonUser> excelDtoList) { public void updateEXPersonUserda(List<EXPersonUser> excelDtoList) {
List<String> listdata = new ArrayList<>();
List<PersonBasic> listPersonBasic = new ArrayList<>(); List<PersonBasic> listPersonBasic = new ArrayList<>();
List<PersonSkillEducation> listPersonSkillEducation = new ArrayList<>(); List<PersonSkillEducation> listPersonSkillEducation = new ArrayList<>();
List<PersonCertificate> listPersonCertificate = new ArrayList<>(); List<PersonCertificate> listPersonCertificate = new ArrayList<>();
...@@ -368,8 +377,10 @@ public class ExcelServiceImpl { ...@@ -368,8 +377,10 @@ public class ExcelServiceImpl {
//根据平台账号获取用户id //根据平台账号获取用户id
wrapper.eq("account_name", exPersonUser.getAccountName()); wrapper.eq("account_name", exPersonUser.getAccountName());
PersonAccount personAccount = personAccountServiceImpl.getOne(wrapper); PersonAccount personAccount = personAccountServiceImpl.getOne(wrapper);
listdata.add(personAccount.getPuserId());
//获取基本信息 //获取基本信息
PersonBasic personBasic = personBasicMapper.selectById(personAccount.getPersonId()); PersonBasic personBasic = personBasicMapper.selectById(personAccount.getPersonId());
BeanUtils.copyProperties(exPersonUser, personBasic); BeanUtils.copyProperties(exPersonUser, personBasic);
listPersonBasic.add(personBasic); listPersonBasic.add(personBasic);
//人员技能 //人员技能
...@@ -388,6 +399,13 @@ public class ExcelServiceImpl { ...@@ -388,6 +399,13 @@ public class ExcelServiceImpl {
personBasicServiceImpl.saveOrUpdateBatch(listPersonBasic); personBasicServiceImpl.saveOrUpdateBatch(listPersonBasic);
personSkillEducationService.saveOrUpdateBatch(listPersonSkillEducation); personSkillEducationService.saveOrUpdateBatch(listPersonSkillEducation);
personCertificateService.saveOrUpdateBatch(listPersonCertificate); personCertificateService.saveOrUpdateBatch(listPersonCertificate);
Map<String, Object> data=new HashMap<>();
data.put("USER_ID",listdata);
ProduceMsg produceMsg= new ProduceMsg(data, EXPORT,null);
querueProduce.produceMsg(JSON.toJSONString(produceMsg));
} }
} }
...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonBasic; ...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonBasic;
import com.yeejoin.amos.boot.module.jxiop.api.entity.*; import com.yeejoin.amos.boot.module.jxiop.api.entity.*;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IPersonBasicService; import com.yeejoin.amos.boot.module.jxiop.api.service.IPersonBasicService;
import com.yeejoin.amos.boot.module.jxiop.biz.activemq.QuerueProduce;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
...@@ -56,6 +57,12 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -56,6 +57,12 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
PersonSkillEducationServiceImpl personSkillEducationService; PersonSkillEducationServiceImpl personSkillEducationService;
@Value("${amos.secret.key}") @Value("${amos.secret.key}")
String secretKey; String secretKey;
@Autowired
QuerueProduce querueProduce;
private String UPDATE="UPDATE";
private String INSERT="INSERT";
/** /**
* 分页查询 * 分页查询
...@@ -162,6 +169,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -162,6 +169,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey)); personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey));
this.personBasicMapper.updateById(personBasic); this.personBasicMapper.updateById(personBasic);
this.personAccountService.updateById(personAccount); this.personAccountService.updateById(personAccount);
Map<String, Object> data=new HashMap<>();
data.put("SEQUENCE_NBR",agencyUserModel.getSequenceNbr());
ProduceMsg produceMsg= new ProduceMsg(data, INSERT,agencyUserModel.getUserId());
querueProduce.produceMsg(JSON.toJSONString(produceMsg));
} }
...@@ -254,6 +268,11 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa ...@@ -254,6 +268,11 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey)); personAccount.setSecondaryPassword(DesUtil.encode(personAccount.getSecondaryPassword(), secretKey));
this.personBasicMapper.updateById(personBasic); this.personBasicMapper.updateById(personBasic);
personAccountService.updateById(personAccount); personAccountService.updateById(personAccount);
Map<String, Object> data=new HashMap<>();
data.put("SEQUENCE_NBR",agencyUserModel.getSequenceNbr());
ProduceMsg produceMsg= new ProduceMsg(data, UPDATE,agencyUserModel.getUserId());
querueProduce.produceMsg(JSON.toJSONString(produceMsg));
return model; return model;
} }
......
...@@ -77,4 +77,11 @@ mybatis-plus.global-config.db-config.update-strategy=ignored ...@@ -77,4 +77,11 @@ mybatis-plus.global-config.db-config.update-strategy=ignored
amos.secret.key=qaz amos.secret.key=qaz
# if your service can't be access ,you can use this setting , you need change ip as your. # if your service can't be access ,you can use this setting , you need change ip as your.
#eureka.instance.prefer-ip-address=true #eureka.instance.prefer-ip-address=true
#eureka.instance.ip-address=172.16.3.122 #eureka.instance.ip-address=172.16.3.122
\ No newline at end of file
spring.activemq.broker-url=tcp://139.9.173.44:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.jms.pub-sub-domain=false
myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment