提交 d8142607 作者: 典文龙

增加成功次数和失败信息

上级 0d88aedd
......@@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.*;
/**
* @Author: Dwl
......@@ -46,42 +44,76 @@ public class AccountDistributeRecord implements Serializable {
*/
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;
/**
* 成功次数
*/
private Integer successCount;
/**
* 失败的原因
*/
private String reason;
private static final long serialVersionUID = 1L;
public void saveDistribute(Long authId, Long targetId, List<String> functionName, Long createUser) {
public void saveDistribute(Long authId, Long targetId, List<String> functionName, Long createUser, Integer count, Map<String, String> reasonMap) {
this.authId = authId;
this.targetAuthId = targetId;
this.functionName = groupName(functionName);
this.createUser = createUser;
this.successCount = count;
this.reason = getReasonMapInfo(functionName, reasonMap);
this.gmtCreate = new Date();
this.gmtModified = new Date();
}
public String typeNameMap(String type) {
Map<String, String> nameMap = new HashMap<>();
nameMap.put("1", "关回");
nameMap.put("2", "关键词");
nameMap.put("3", "延时客服");
nameMap.put("4", "菜单管理");
return nameMap.get(type);
}
private String getReasonMapInfo(List<String> functionName, Map<String, String> reasonMap) {
String name;
List<String> nameList = new ArrayList<>(reasonMap.size());
for (String type : functionName) {
name = typeNameMap(type) + reasonMap.get(type);
nameList.add(name);
}
if (nameList.isEmpty()) {
return "";
}
return nameList.toString();
}
private String groupName(List<String> functionName) {
String name = "";
for (String s : functionName) {
switch (s) {
StringBuilder name = new StringBuilder();
for (String type : functionName) {
switch (type) {
case "1":
name += "关回, ";
name.append("关回, ");
break;
case "2":
name += "关键词, ";
name.append("关键词, ");
break;
case "3":
name += "延时客服, ";
name.append("延时客服, ");
break;
case "4":
name += "菜单管理, ";
name.append("菜单管理, ");
break;
default:
break;
}
}
if (!name.isEmpty()) {
name = name.substring(0, name.length() - 2);
if (name.length() > 0) {
name = new StringBuilder(name.substring(0, name.length() - 2));
}
return name;
return name.toString();
}
}
package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.dto.DistributeDTO;
import com.yaoyaozw.customer.dto.MenuMainCopyDTO;
import com.yaoyaozw.customer.dto.follow.FollowReplyCopyDTO;
......@@ -15,7 +16,9 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -53,7 +56,8 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
List<String> targetApp = targetAuthList.stream().map(AuthInfoVO::getAppId).collect(Collectors.toList());
List<Long> idList = targetAuthList.stream().map(AuthInfoVO::getId).collect(Collectors.toList());
List<String> typeList = distributeDTO.getTypeList();
Map<String, String> reasonMap = new HashMap<>();
Integer count = 0;
try {
for (String type : typeList) {
switch (type) {
......@@ -62,7 +66,8 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
try {
log.info("开始关回复用");
FollowReplyCopyDTO followReplyCopyDTO = new FollowReplyCopyDTO(sourceAuth, targetAuthList);
followReplyService.copy(followReplyCopyDTO);
BaseResult result = followReplyService.copy(followReplyCopyDTO);
count = statusLog(result, count, type, reasonMap);
log.info("关回复用结束");
} catch (Exception e) {
log.error("Off reply failed: {}", e.getMessage(), e);
......@@ -75,7 +80,8 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
log.info("开始关键词复用");
CustomerKeywordCopyDTO customerKeywordCopyDTO = new CustomerKeywordCopyDTO();
customerKeywordCopyDTO.replace(sourceAuth, targetAuthList, targetAppList);
keywordService.copy(customerKeywordCopyDTO);
BaseResult result = keywordService.copy(customerKeywordCopyDTO);
count = statusLog(result, count, type, reasonMap);
log.info("关键词复用结束");
} catch (Exception e) {
log.error("Keyword reuse failure: {}", e.getMessage(), e);
......@@ -86,7 +92,8 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
try {
log.info("开始延时客服复用");
removeBatch(distributeDTO.appIds(), type, new ArrayList<>());
customerGraphicsDelayService.copy(sourceAuth.getAppId(), "", "", null, targetApp);
BaseResult result = customerGraphicsDelayService.copy(sourceAuth.getAppId(), "", "", null, targetApp);
count = statusLog(result, count, type, reasonMap);
log.info("延时客服复用结束");
} catch (Exception e) {
log.error("Delayed customer service reuse failure: {}", e.getMessage(), e);
......@@ -99,7 +106,8 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
removeBatch(distributeDTO.appIds(), type, distributeDTO.getAuthIds());
MenuMainCopyDTO menuMainCopyDTO = new MenuMainCopyDTO();
menuMainCopyDTO.addList(sourceAuth.getId(), idList);
menuFeignClient.copy(menuMainCopyDTO);
BaseResult result = menuFeignClient.copy(menuMainCopyDTO);
count = statusLog(result, count, type, reasonMap);
log.info("菜单管理复用结束");
} catch (Exception e) {
log.error("Menu management reuse failure: {}", e.getMessage(), e);
......@@ -113,15 +121,26 @@ public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeServ
log.error("Distribution reuse exception:{}", e.getMessage(), e);
}
Integer finalCount = count;
idList.forEach(c -> {
AccountDistributeRecord distributeLog = new AccountDistributeRecord();
distributeLog.saveDistribute(sourceAuth.getId(), c, typeList, userId);
distributeLog.saveDistribute(sourceAuth.getId(), c, typeList, userId, finalCount, reasonMap);
distributeLogList.add(distributeLog);
});
distributeService.saveBatch(distributeLogList);
}
private Integer statusLog(BaseResult result, Integer count, String type, Map<String, String> reasonMap) {
Boolean success = result.getSuccess();
if (success) {
count++;
} else {
reasonMap.put(type, "失败的信息_" + result.getMessage());
}
return count;
}
private void removeBatch(List<String> appIds, String type, List<Long> authIds) {
if ("3".equals(type)) {
try {
......
......@@ -19,4 +19,6 @@ public class AccountDistributeLogVO {
private Date gmtCreate;
private Date gmtModified;
private String userName;
private Integer successCount;
private String reason;
}
......@@ -8,7 +8,9 @@
adr.function_name AS functionName,
adr.gmt_create AS gmtCreate,
adr.gmt_modified AS gmtModified,
au.nick_name AS userName
au.nick_name AS userName,
adr.success_count AS successCount,
adr.reason AS reason
FROM account_distribute_record adr
LEFT JOIN authorizer_info ai ON ai.id = adr.target_auth_id
LEFT JOIN authorizer_info a ON a.id = adr.auth_id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论