|
@ -16,14 +16,12 @@ import com.epmet.dto.region.LogOperationResultDTO; |
|
|
import com.epmet.entity.LogOperationEntity; |
|
|
import com.epmet.entity.LogOperationEntity; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.service.LogOperationService; |
|
|
import com.epmet.service.LogOperationService; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
@ -54,29 +52,35 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR |
|
|
@Override |
|
|
@Override |
|
|
public List<LogOperationResultDTO> listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) { |
|
|
public List<LogOperationResultDTO> listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) { |
|
|
// 1.条件查询
|
|
|
// 1.条件查询
|
|
|
List<LogOperationResultDTO> logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize); |
|
|
//List<LogOperationResultDTO> logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize);
|
|
|
if (CollectionUtils.isEmpty(logDtos)) { |
|
|
//if (CollectionUtils.isEmpty(logDtos)) {
|
|
|
logDtos = listByOperatorName(condition, pageNo, pageSize); |
|
|
// logDtos = listByOperatorName(condition, pageNo, pageSize);
|
|
|
} |
|
|
//}
|
|
|
|
|
|
//
|
|
|
if (CollectionUtils.isEmpty(logDtos)) { |
|
|
//if (CollectionUtils.isEmpty(logDtos)) {
|
|
|
return new ArrayList<>(); |
|
|
// return new ArrayList<>();
|
|
|
} |
|
|
//}
|
|
|
|
|
|
|
|
|
// 2.直接分页查询
|
|
|
// 2.直接分页查询
|
|
|
// 条件查询,排序
|
|
|
// 条件查询,排序
|
|
|
LambdaQueryWrapper<LogOperationEntity> w = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<LogOperationEntity> w = new LambdaQueryWrapper<>(); |
|
|
|
|
|
if (StringUtils.isNotBlank(condition)) { |
|
|
|
|
|
w.like(LogOperationEntity::getOperatorName, condition) |
|
|
|
|
|
.or() |
|
|
|
|
|
.like(LogOperationEntity::getOperatorMobile, condition); |
|
|
|
|
|
} |
|
|
|
|
|
w.eq(LogOperationEntity::getCustomerId, customerId); |
|
|
w.orderByDesc(LogOperationEntity::getOperatingTime); |
|
|
w.orderByDesc(LogOperationEntity::getOperatingTime); |
|
|
IPage<LogOperationEntity> iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); |
|
|
IPage<LogOperationEntity> iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); |
|
|
List<LogOperationEntity> logEntities = iPage.getRecords(); |
|
|
List<LogOperationEntity> logEntities = iPage.getRecords(); |
|
|
List<String> userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); |
|
|
Set<String> userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds)); |
|
|
return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Map<String, CustomerStaffDTO> getStaffMapByUserIds(List<String> userIds) { |
|
|
private Map<String, CustomerStaffDTO> getStaffMapByUserIds(Set<String> userIds) { |
|
|
CustomerStaffFormDTO form = new CustomerStaffFormDTO(); |
|
|
CustomerStaffFormDTO form = new CustomerStaffFormDTO(); |
|
|
form.setUserIds(userIds); |
|
|
form.setUserIds(new ArrayList<>(userIds)); |
|
|
Result<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form); |
|
|
Result<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form); |
|
|
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); |
|
|
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); |
|
|
|
|
|
|
|
@ -168,6 +172,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR |
|
|
ldto.setTargetId(l.getTargetId()); |
|
|
ldto.setTargetId(l.getTargetId()); |
|
|
ldto.setType(l.getType()); |
|
|
ldto.setType(l.getType()); |
|
|
ldto.setTypeDisplay(l.getTypeDisplay()); |
|
|
ldto.setTypeDisplay(l.getTypeDisplay()); |
|
|
|
|
|
ldto.setCustomerId(l.getCustomerId()); |
|
|
ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); |
|
|
ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); |
|
|
ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); |
|
|
ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); |
|
|
return ldto; |
|
|
return ldto; |
|
|