提交 d8142607 作者: 典文龙

增加成功次数和失败信息

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