|
@@ -9,6 +9,7 @@ import com.fire.admin.service.DistributeGroupService;
|
|
|
import com.fire.admin.util.SecurityUtil;
|
|
|
import com.fire.common.exception.BaseException;
|
|
|
import com.fire.dto.DistributeGroup;
|
|
|
+import com.fire.dto.DistributeGroupChannel;
|
|
|
import com.fire.dto.enums.Status;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
@@ -60,16 +61,16 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveDistributeGroups(List<DistributeGroup> distributeGroups) {
|
|
|
+ public void saveOrUpdateDistributeGroups(List<DistributeGroup> distributeGroups) {
|
|
|
if (ObjectUtil.isNotEmpty(distributeGroups)) {
|
|
|
for (DistributeGroup distributeGroup : distributeGroups) {
|
|
|
+ if (distributeGroup.getChannelGroupId() == null) {
|
|
|
+ distributeGroup.setChannelGroupId(1L);
|
|
|
+ }
|
|
|
if (distributeGroup.getDistributeGroupId() == null) {
|
|
|
distributeGroup.setDistributeGroupId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
distributeGroup.setCreator(SecurityUtil.getUser().getUsername());
|
|
|
distributeGroup.setCreateTime(new Date());
|
|
|
- if (distributeGroup.getChannelGroupId() == null) {
|
|
|
- distributeGroup.setChannelId(1L);
|
|
|
- }
|
|
|
log.info("添加的分发组是:", distributeGroups);
|
|
|
} else {
|
|
|
distributeGroup.setUpdator(SecurityUtil.getUser().getUsername());
|
|
@@ -78,6 +79,14 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
}
|
|
|
}
|
|
|
boolean result = this.saveOrUpdateBatch(distributeGroups);
|
|
|
+
|
|
|
+ for (DistributeGroup distributeGroup : distributeGroups) {
|
|
|
+ Long distributeGroupId = distributeGroup.getDistributeGroupId();
|
|
|
+ for (DistributeGroupChannel channel : distributeGroup.getChannels()) {
|
|
|
+ channel.setDistributeGroupId(distributeGroupId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (result) {
|
|
|
rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
log.info("分发组是:【{}】", distributeGroups);
|
|
@@ -107,7 +116,7 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
if (distGroupId != null) {
|
|
|
int distResult = baseMapper.deleteById(distGroupId);
|
|
|
int channelResult = distGroupChannelService.removeChannelByDistGroupId(distGroupId);
|
|
|
- if (distResult > 0 && channelResult > 0) {
|
|
|
+ if (distResult > 0 || channelResult > 0) {
|
|
|
rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
log.info("编号为【{}】的分发组删除成功!", distGroupId);
|
|
|
log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
|