|
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -22,12 +23,16 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.finance.feign.IFinanceClient;
|
|
|
+import org.springblade.purchase.sales.entity.Order;
|
|
|
+import org.springblade.purchase.sales.feign.IOrderDescClient;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -59,13 +64,17 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
+ private final IOrderDescClient orderDescClient;
|
|
|
+
|
|
|
+ private final IFinanceClient financeClient;
|
|
|
+
|
|
|
static final int GB_SP_DIFF = 160;
|
|
|
// 存放国标一级汉字不同读音的起始区位码
|
|
|
- static final int[] secPosValueList = { 1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
|
|
|
- 3722, 3730, 3858, 4027, 4086, 4390, 4558, 4684, 4925, 5249, 5600 };
|
|
|
+ static final int[] secPosValueList = {1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
|
|
|
+ 3722, 3730, 3858, 4027, 4086, 4390, 4558, 4684, 4925, 5249, 5600};
|
|
|
// 存放国标一级汉字不同读音的起始区位码对应读音
|
|
|
- static final char[] firstLetter = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
|
|
|
- 'R', 'S', 'T', 'W', 'X', 'Y', 'Z' };
|
|
|
+ static final char[] firstLetter = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
|
|
|
+ 'R', 'S', 'T', 'W', 'X', 'Y', 'Z'};
|
|
|
|
|
|
@Override
|
|
|
public IPage<CorpsDescVO> selectCorpsDescPage(IPage<CorpsDescVO> page, CorpsDescVO corpsDesc) {
|
|
|
@@ -76,15 +85,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
|
|
|
corpsTypeIdList.add(corpsTypeId);
|
|
|
corpsDesc.setTypeList(corpsTypeIdList);
|
|
|
- }else if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())){
|
|
|
+ } else if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())) {
|
|
|
LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getCname,corpsDesc.getCorpsTypeName());
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getCname, corpsDesc.getCorpsTypeName());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
|
|
|
List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsTypeList)) {
|
|
|
List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- corpsTypeList.stream().forEach(item ->{
|
|
|
+ corpsTypeList.stream().forEach(item -> {
|
|
|
corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
|
|
|
corpsTypeIdList.add(item.getId());
|
|
|
});
|
|
|
@@ -96,7 +105,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CorpsDesc> selectShippingCompany(CorpsDesc corpsDesc){
|
|
|
+ public List<CorpsDesc> selectShippingCompany(CorpsDesc corpsDesc) {
|
|
|
return baseMapper.selectShippingCompany(corpsDesc);
|
|
|
}
|
|
|
|
|
|
@@ -105,7 +114,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
public R submit(CorpsDesc corpsDesc) {
|
|
|
Long userId = SecureUtil.getUserId();
|
|
|
Date date = new Date();
|
|
|
- if (null == corpsDesc.getInitials() || "" == corpsDesc.getInitials()){//首字母为空
|
|
|
+ if (null == corpsDesc.getInitials() || "" == corpsDesc.getInitials()) {//首字母为空
|
|
|
//获得名称首字母
|
|
|
String initials = getSpells(corpsDesc.getCname());
|
|
|
corpsDesc.setInitials(initials.substring(0, 1));
|
|
|
@@ -593,7 +602,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
@Override
|
|
|
public CorpsDesc selectCode(String code, String tenantId, String corpType) {
|
|
|
- return baseMapper.getCorpMessage(code,tenantId,corpType);
|
|
|
+ return baseMapper.getCorpMessage(code, tenantId, corpType);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -608,6 +617,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
/**
|
|
|
* 添加客户信息
|
|
|
+ *
|
|
|
* @param corpsDesc
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -623,8 +633,8 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CorpsDesc> selectByCorpIds(String ids){
|
|
|
- if (ids == null || ids.equals("")){
|
|
|
+ public List<CorpsDesc> selectByCorpIds(String ids) {
|
|
|
+ if (ids == null || ids.equals("")) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<Long> collect = Arrays.stream(ids.split(","))
|
|
|
@@ -642,15 +652,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
|
|
|
corpsTypeIdList.add(corpsTypeId);
|
|
|
corpsDescDto.setTypeList(corpsTypeIdList);
|
|
|
- }else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())){
|
|
|
+ } else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())) {
|
|
|
LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getCname,corpsDescDto.getCorpsTypeName());
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getCname, corpsDescDto.getCorpsTypeName());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
|
|
|
List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsTypeList)) {
|
|
|
List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- corpsTypeList.stream().forEach(item ->{
|
|
|
+ corpsTypeList.stream().forEach(item -> {
|
|
|
corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
|
|
|
corpsTypeIdList.add(item.getId());
|
|
|
});
|
|
|
@@ -664,6 +674,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
/**
|
|
|
* 列表统计
|
|
|
+ *
|
|
|
* @param corpsDescDto
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -676,15 +687,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
|
|
|
corpsTypeIdList.add(corpsTypeId);
|
|
|
corpsDescDto.setTypeList(corpsTypeIdList);
|
|
|
- }else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())){
|
|
|
+ } else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())) {
|
|
|
LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getCname,corpsDescDto.getCorpsTypeName());
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getCname, corpsDescDto.getCorpsTypeName());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
|
|
|
List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsTypeList)) {
|
|
|
List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- corpsTypeList.stream().forEach(item ->{
|
|
|
+ corpsTypeList.stream().forEach(item -> {
|
|
|
corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
|
|
|
corpsTypeIdList.add(item.getId());
|
|
|
});
|
|
|
@@ -696,6 +707,61 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
return baseMapper.selectPartsCorpsStatistics(corpsDescDto);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CorpsDescDto getDetailsById(Long id) {
|
|
|
+ CorpsDescDto corpsDescDto = new CorpsDescDto();
|
|
|
+ CorpsDesc corpsDesc = baseMapper.selectById(id);
|
|
|
+ //应收账款
|
|
|
+ BigDecimal debitAmount = new BigDecimal("0.00");
|
|
|
+ //已收账款
|
|
|
+ BigDecimal settlmentAmount = new BigDecimal("0.00");
|
|
|
+ //未收账款
|
|
|
+ BigDecimal balanceAmount = new BigDecimal("0.00");
|
|
|
+ // 预(收)付款
|
|
|
+ BigDecimal advancePayment = new BigDecimal("0.00");
|
|
|
+ if (ObjectUtils.isNotNull(corpsDesc)) {
|
|
|
+ //客户信息
|
|
|
+ corpsDescDto = BeanUtil.copy(corpsDesc, CorpsDescDto.class);
|
|
|
+ //获取订单记录
|
|
|
+ Order order = new Order();
|
|
|
+ order.setCorpId(corpsDesc.getId());
|
|
|
+ order.setBillType("XS");
|
|
|
+ order.setTradeType("JXS");
|
|
|
+ List<Order> orderList = orderDescClient.getByBillNo(order);
|
|
|
+ if (ObjectUtils.isNotNull(orderList)) {
|
|
|
+ //未收账款
|
|
|
+ balanceAmount = balanceAmount.add(orderList.stream().map(Order::getBalanceAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //应收账款
|
|
|
+ debitAmount = debitAmount.add(orderList.stream().map(Order::getDebitAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //已收账款
|
|
|
+ settlmentAmount = settlmentAmount.add(orderList.stream().map(Order::getSettlmentAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //预(收)付款
|
|
|
+ advancePayment = advancePayment.add(orderList.stream().map(Order::getAdvancePayment).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+
|
|
|
+ //未收账款
|
|
|
+ corpsDescDto.setBalanceAmount(balanceAmount);
|
|
|
+ //应收账款
|
|
|
+ corpsDescDto.setDebitAmount(debitAmount);
|
|
|
+ //已收账款
|
|
|
+ corpsDescDto.setSettlmentAmount(settlmentAmount);
|
|
|
+ //预(收)付款
|
|
|
+ corpsDescDto.setAdvancePayment(advancePayment);
|
|
|
+
|
|
|
+ //获取客户文件
|
|
|
+ corpsDescDto.setCorpsFiles(corpsFilesService.list(new QueryWrapper<CorpsFiles>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
|
|
|
+ //获取客户地址
|
|
|
+ corpsDescDto.setCorpsAddrList(corpsAddrService.list(new QueryWrapper<CorpsAddr>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
|
|
|
+
|
|
|
+ //获取客户类别
|
|
|
+ List<String> longs = corpsTypeDescMapper.selectTypeId(corpsDesc.getId());
|
|
|
+ corpsDescDto.setCorpsTypeId(String.join(",", longs));
|
|
|
+
|
|
|
+ }
|
|
|
+ return corpsDescDto;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保护客户联系人信息
|
|
|
*
|
|
|
@@ -874,6 +940,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
/**
|
|
|
* 提取汉字字符串的首字母
|
|
|
+ *
|
|
|
* @param characters 汉字字符串
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -895,6 +962,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
|
|
|
/**
|
|
|
* 获取一个汉字的首字母
|
|
|
+ *
|
|
|
* @param ch 汉字
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -903,7 +971,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
byte[] uniCode = null;
|
|
|
try {
|
|
|
uniCode = String.valueOf(ch).getBytes("GBK");
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
@@ -937,5 +1005,4 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|