|
|
@@ -19,6 +19,8 @@ import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -40,6 +42,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
private final FeeCenterMapper feeCenterMapper;
|
|
|
private final IDeptUtils deptUtils;
|
|
|
private final ISysClient sysClient;
|
|
|
+ private final IUserClient userClient;
|
|
|
|
|
|
@Override
|
|
|
public R profit(String branchId, String startDate, String endDate) {
|
|
|
@@ -353,7 +356,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
- .in(BCorps::getId, corpIdList));
|
|
|
+ .in(!corpIdList.isEmpty(),BCorps::getId, corpIdList));
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
List<ProfitCustomersSort> customersSortList = new ArrayList<>();
|
|
|
@@ -446,7 +449,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
- .in(BCorps::getId, corpIdList));
|
|
|
+ .in(!corpIdList.isEmpty(),BCorps::getId, corpIdList));
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
List<ProfitCustomersSort> customersSortList = new ArrayList<>();
|
|
|
@@ -480,7 +483,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
@Override
|
|
|
public R customersSortDetailList(String branchId, String type) {
|
|
|
- if ("0".equals(type)){
|
|
|
+ if ("0".equals(type)) {
|
|
|
List<Long> corpIdList = new ArrayList<>();
|
|
|
LambdaQueryWrapper<Bills> lambdaQueryWrapper = new LambdaQueryWrapper<Bills>()
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -538,7 +541,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
- .in(BCorps::getId, corpIdList));
|
|
|
+ .in(!corpIdList.isEmpty(),BCorps::getId, corpIdList));
|
|
|
List<ProfitCustomersSort> customersSortList = new ArrayList<>();
|
|
|
for (BCorps item : corpsList) {
|
|
|
ProfitCustomersSort detail = new ProfitCustomersSort();
|
|
|
@@ -584,7 +587,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
.sorted(Comparator.comparing(ProfitCustomersSort::getAmount).reversed())
|
|
|
.collect(Collectors.toList());
|
|
|
return R.data(sortList);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
List<Long> corpIdList = new ArrayList<>();
|
|
|
LambdaQueryWrapper<Bills> lambdaQueryWrapper = new LambdaQueryWrapper<Bills>()
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -616,7 +619,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<BCorps> corpsList = corpsMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
- .in(BCorps::getId, corpIdList));
|
|
|
+ .in(!corpIdList.isEmpty(),BCorps::getId, corpIdList));
|
|
|
List<ProfitCustomersSort> customersSortList = new ArrayList<>();
|
|
|
for (BCorps item : corpsList) {
|
|
|
ProfitCustomersSort detail = new ProfitCustomersSort();
|
|
|
@@ -639,11 +642,91 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
@Override
|
|
|
public R salesmanTicketNum(String branchId, String startDate, String endDate) {
|
|
|
- return null;
|
|
|
+ LambdaQueryWrapper<Bills> lambdaQueryWrapper = new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getSrcType, "SALES")
|
|
|
+ .eq(ObjectUtils.isNotNull(branchId), Bills::getBranchId, branchId)
|
|
|
+ .ge(ObjectUtils.isNotNull(startDate), Bills::getBillDate, startDate)
|
|
|
+ .le(ObjectUtils.isNotNull(endDate), Bills::getBillDate, endDate);
|
|
|
+ String jurisdiction = sysClient.getParamService("data.jurisdiction");
|
|
|
+ if ("1".equals(jurisdiction)) {
|
|
|
+ if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("老板")
|
|
|
+ && !AuthUtil.getUserRole().contains("副总") && !AuthUtil.getUserRole().contains("财务")
|
|
|
+ && !AuthUtil.getUserRole().contains("经理")) {
|
|
|
+ if (AuthUtil.getUserRole().contains("操作经理")) {
|
|
|
+ lambdaQueryWrapper.like(Bills::getOperatorDept, AuthUtil.getDeptId());
|
|
|
+ } else if (AuthUtil.getUserRole().contains("操作员")) {
|
|
|
+ lambdaQueryWrapper.like(Bills::getOperatorId, AuthUtil.getUserId());
|
|
|
+ } else if (AuthUtil.getUserRole().contains("销售经理")) {
|
|
|
+ lambdaQueryWrapper.like(Bills::getSrcDeptId, AuthUtil.getDeptId());
|
|
|
+ } else if (AuthUtil.getUserRole().contains("业务员")) {
|
|
|
+ lambdaQueryWrapper.like(Bills::getSrcId, AuthUtil.getUserId());
|
|
|
+ } else {
|
|
|
+ lambdaQueryWrapper.eq(Bills::getCreateUser, AuthUtil.getUserId());
|
|
|
+ }
|
|
|
+ lambdaQueryWrapper.eq(Bills::getBranchId, deptUtils.getDeptPid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Bills> billsList = billsMapper.selectList(lambdaQueryWrapper);
|
|
|
+ List<AeaBills> aeaBillsList = aeaBillsMapper.selectList(new LambdaQueryWrapper<AeaBills>()
|
|
|
+ .eq(AeaBills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AeaBills::getIsDeleted, 0)
|
|
|
+ .eq(AeaBills::getSrcType, "SALES")
|
|
|
+ .apply("find_in_set(business_type,'AE,AI')")
|
|
|
+ .eq(ObjectUtils.isNotNull(branchId), AeaBills::getBranchId, branchId)
|
|
|
+ .ge(ObjectUtils.isNotNull(startDate), AeaBills::getBillDate, startDate)
|
|
|
+ .le(ObjectUtils.isNotNull(endDate), AeaBills::getBillDate, endDate));
|
|
|
+ List<ProfitCustomersSort> customersSortList = new ArrayList<>();
|
|
|
+ List<User> userList = userClient.selectListByRole(AuthUtil.getTenantId());
|
|
|
+ for (User item : userList) {
|
|
|
+ ProfitCustomersSort detail = new ProfitCustomersSort();
|
|
|
+ detail.setCorpId(item.getId());
|
|
|
+ detail.setCorpName(item.getRealName());
|
|
|
+ int number = 0;
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ List<Bills> bills = billsList.stream().filter(e -> e.getSrcId().equals(item.getId())).collect(Collectors.toList());
|
|
|
+ if (!bills.isEmpty()) {
|
|
|
+ number = number + bills.size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!aeaBillsList.isEmpty()) {
|
|
|
+ List<AeaBills> bills = aeaBillsList.stream().filter(e -> e.getSrcId().equals(item.getId())).collect(Collectors.toList());
|
|
|
+ if (!bills.isEmpty()) {
|
|
|
+ number = number + bills.size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detail.setNumber(number);
|
|
|
+ customersSortList.add(detail);
|
|
|
+ }
|
|
|
+ //从大到小排序
|
|
|
+ List<ProfitCustomersSort> sortList = customersSortList.stream()
|
|
|
+ .sorted(Comparator.comparing(ProfitCustomersSort::getNumber).reversed())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<String> categories = new ArrayList<>();
|
|
|
+ List<Object> value = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ if (sortList.size() > i) {
|
|
|
+ categories.add(sortList.get(i).getCorpName());
|
|
|
+ value.add(sortList.get(i).getNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("categories", categories);
|
|
|
+ map.put("data", value);
|
|
|
+ return R.data(map);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public R containerVolumeTrend(String branchId, String startDate) {
|
|
|
- return null;
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ List<Map<String, Object>> mapList = billsMapper.trend(AuthUtil.getTenantId(), Long.parseLong(branchId),
|
|
|
+ null, startDate);
|
|
|
+ return R.data(mapList);
|
|
|
+ } else {
|
|
|
+ List<Map<String, Object>> mapList = billsMapper.trend(AuthUtil.getTenantId(), null,
|
|
|
+ null, startDate);
|
|
|
+ return R.data(mapList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|