Commit 21ab75ef authored by wujipeng's avatar wujipeng
Browse files

人与人关系弹框分页-优化

parent fe9324cc
......@@ -12,18 +12,12 @@ import com.platform.exception.BusinessException;
import com.platform.mapper.UserMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.UserDTO;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.entity.UserAccountEntity;
import com.platform.model.entity.UserEntity;
import com.platform.model.entity.UserRelationEntity;
import com.platform.model.entity.*;
import com.platform.model.vo.AssociationVO;
import com.platform.model.vo.EveryoneVO;
import com.platform.model.vo.ExcelDataVO;
import com.platform.model.vo.UserVO;
import com.platform.service.ExcelDataService;
import com.platform.service.UserAccountService;
import com.platform.service.UserRelationService;
import com.platform.service.UserService;
import com.platform.service.*;
import com.platform.utils.DozerUtils;
import com.platform.utils.IdCardUtils;
import org.jetbrains.annotations.NotNull;
......@@ -33,6 +27,8 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
......@@ -43,6 +39,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
private UserRelationService userRelationService;
@Resource
private ExcelDataService excelDataService;
@Resource
private CaseRuleConfigService caseRuleConfigService;
@Override
public UserVO getDetail(UserDTO userDTO) {
......@@ -218,12 +216,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
return save(userDTO);
} catch (Exception e) {
throw new BusinessException("用户" + userDTO.getUserName() + "已经存在");
// 匹配开头的一个或多个中文字符
Pattern pattern = Pattern.compile("^[\\u4E00-\\u9FA5]+");
Matcher matcher = pattern.matcher(userDTO.getUserName());
if (matcher.find()) {
String chinesePart = matcher.group();
throw new BusinessException("用户" + chinesePart + "已经存在");
} else {
throw new BusinessException("用户" + userDTO.getUserName() + "已经存在");
}
}
}
@Override
public List<ExcelDataEntity> cashFlow(UserDTO userDTO) {
CaseRuleConfigEntity byCaseId = caseRuleConfigService.getByCaseId(userDTO.getCaseId());
userDTO.setMinAmount(byCaseId.getMinAmount());
userDTO.setMaxAmount(byCaseId.getMaxAmount());
userDTO.setMinTransaction(byCaseId.getMinTransaction());
userDTO.setMaxTransaction(byCaseId.getMaxTransaction());
userDTO.setStartTime(byCaseId.getStartTime());
userDTO.setEndTime(byCaseId.getEndTime());
List<ExcelDataEntity> excelDataList = excelDataService.cashFlow(userDTO);
for (ExcelDataEntity excelDataEntity : excelDataList) {
if ("出账".equals(excelDataEntity.getDirection())) {
......@@ -239,6 +252,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
@Override
public EveryoneVO relationPage(UserDTO userDTO) {
CaseRuleConfigEntity byCaseId = caseRuleConfigService.getByCaseId(userDTO.getCaseId());
userDTO.setMinAmount(byCaseId.getMinAmount());
userDTO.setMaxAmount(byCaseId.getMaxAmount());
userDTO.setMinTransaction(byCaseId.getMinTransaction());
userDTO.setMaxTransaction(byCaseId.getMaxTransaction());
userDTO.setStartTime(byCaseId.getStartTime());
userDTO.setEndTime(byCaseId.getEndTime());
EveryoneVO everyoneVO = new EveryoneVO();
//标题
everyoneVO.setTitle(userDTO.getUserName() + "," + userDTO.getOtherName());
......@@ -248,21 +268,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
if (!ObjectUtils.isEmpty(userRelation)) {
everyoneVO.setRelation(userRelation);
}
//查询账户
List<String> oneselfAccountList = userAccountService.queryUserAccountList(userDTO.getUserName());
List<ExcelDataVO> ExcelDataList = excelDataService.queryOtherAccountList(userDTO.getOtherName(), userDTO.getCaseId());
Set<String> otherAccountSet = new HashSet<>();
for (ExcelDataVO excelDataVO : ExcelDataList) {
otherAccountSet.add(excelDataVO.getPayAccount());
otherAccountSet.add(excelDataVO.getPaymentAccount());
}
List<String> otherAccountList = Lists.newArrayList(otherAccountSet);
List<ExcelDataEntity> details = Lists.newArrayList();
if (!ObjectUtils.isEmpty(oneselfAccountList) && !ObjectUtils.isEmpty(otherAccountList)) {
details = excelDataService.relationPage(oneselfAccountList, otherAccountList, userDTO);
everyoneVO.setDetails(details);
userDTO.setOtherUserName(userDTO.getOtherName());
List<ExcelDataEntity> excelDataList = excelDataService.cashFlow(userDTO);
for (ExcelDataEntity excelDataEntity : excelDataList) {
if ("出账".equals(excelDataEntity.getDirection())) {
excelDataEntity.setSelfAccount(excelDataEntity.getPayAccount());
excelDataEntity.setAssociationAccount(excelDataEntity.getPayeeAccount());
} else if ("入账".equals(excelDataEntity.getDirection())) {
excelDataEntity.setSelfAccount(excelDataEntity.getPayeeAccount());
excelDataEntity.setAssociationAccount(excelDataEntity.getPayAccount());
}
}
everyoneVO.setDetails(excelDataList);
//汇总文字
List<String> totalDescription = Lists.newArrayList();
//入账次数
......@@ -273,8 +290,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
int outCount = 0;
//出账合计
double outTotal = 0;
if (!details.isEmpty()) {
for (ExcelDataEntity detail : details) {
if (!excelDataList.isEmpty()) {
for (ExcelDataEntity detail : excelDataList) {
if ("入账".equals(detail.getDirection())) {
inCount++;
inTotal += detail.getAmount();
......
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