|
|
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
+import com.sckw.core.model.page.PageHelperUtil;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
@@ -29,6 +31,7 @@ import com.sckw.order.model.vo.res.TransportDemandDetailRes;
|
|
|
import com.sckw.order.model.vo.res.TransportDemandListRes;
|
|
|
import com.sckw.order.model.vo.res.TransportDemandSquaresListRes;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.RemoteUserService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -54,6 +57,9 @@ public class KwoTransportDemandService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteUserService remoteUserService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @desc: 添加草稿
|
|
|
@@ -217,7 +223,28 @@ public class KwoTransportDemandService {
|
|
|
* @return: com.sckw.core.model.page.PageResult
|
|
|
*/
|
|
|
public PageResult select(SelectTransportDemandParam param) {
|
|
|
- LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class));
|
|
|
+
|
|
|
+ //新增客户经理权限过滤
|
|
|
+ List<Long> authEntIdList = new ArrayList<>();
|
|
|
+ if (SystemTypeEnum.MANAGE.getCode() == LoginUserHolder.getSystemType()) {
|
|
|
+
|
|
|
+ authEntIdList = LoginUserHolder.getAuthEntIdList();
|
|
|
+ if (CollectionUtils.isEmpty(authEntIdList)) {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return PageHelperUtil.getPageResult(new PageInfo<>());
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return PageHelperUtil.getPageResult(new PageInfo<>());
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class), authEntIdList);
|
|
|
IPage<KwoTransportDemand> page = new Page<>(param.getPage(), param.getPageSize());
|
|
|
IPage<KwoTransportDemand> demandPage = kwoTransportDemandMapper.selectPage(page, wrapper);
|
|
|
List<KwoTransportDemand> list = demandPage.getRecords();
|
|
|
@@ -271,8 +298,14 @@ public class KwoTransportDemandService {
|
|
|
* @Param param:
|
|
|
* @return: com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.sckw.order.model.KwoTransportDemand>
|
|
|
*/
|
|
|
- private LambdaQueryWrapper<KwoTransportDemand> buildWrapper(ExportTransportDemandParam param) {
|
|
|
+ private LambdaQueryWrapper<KwoTransportDemand> buildWrapper(ExportTransportDemandParam param, List<Long> authEntIdList) {
|
|
|
LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ if (authEntIdList.size() > 0) {
|
|
|
+ authEntIdList = authEntIdList.stream().distinct().collect(Collectors.toList());
|
|
|
+ wrapper.in(KwoTransportDemand::getEntId, authEntIdList);
|
|
|
+ }
|
|
|
+
|
|
|
wrapper.eq(KwoTransportDemand::getDelFlag, Global.NO);
|
|
|
if (!Objects.equals(LoginUserHolder.getSystemType(), SystemTypeEnum.MANAGE.getCode())) {
|
|
|
wrapper.eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId());
|
|
|
@@ -322,7 +355,27 @@ public class KwoTransportDemandService {
|
|
|
*/
|
|
|
public TableStatisticRes statistic(StatisticTransportDemandParam param) {
|
|
|
TableStatisticRes res = new TableStatisticRes();
|
|
|
- LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class));
|
|
|
+
|
|
|
+ //新增客户经理权限过滤
|
|
|
+ List<Long> authEntIdList = new ArrayList<>();
|
|
|
+ if (SystemTypeEnum.MANAGE.getCode() == LoginUserHolder.getSystemType()) {
|
|
|
+ authEntIdList = LoginUserHolder.getAuthEntIdList();
|
|
|
+ if (CollectionUtils.isEmpty(authEntIdList)) {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return getDefaultStatistic(res);
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return getDefaultStatistic(res);
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(BeanUtils.copyProperties(param, ExportTransportDemandParam.class), authEntIdList);
|
|
|
List<KwoTransportDemand> demands = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
Map<Integer, List<KwoTransportDemand>> map = demands.stream().collect(Collectors.groupingBy(KwoTransportDemand::getStatus));
|
|
|
|
|
|
@@ -352,6 +405,25 @@ public class KwoTransportDemandService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ private TableStatisticRes getDefaultStatistic(TableStatisticRes res) {
|
|
|
+ List<TableTop> tableTops = new ArrayList<>();
|
|
|
+ TableTop all = new TableTop();
|
|
|
+ all.setName("全部").setTotal(0);
|
|
|
+ tableTops.add(all);
|
|
|
+ List<TransportDemandStatusEnum> enums = TransportDemandStatusEnum.getSortList();
|
|
|
+ enums.forEach(e -> {
|
|
|
+ Integer value = e.getCode();
|
|
|
+ int total = 0;
|
|
|
+ TableTop tableTop = new TableTop();
|
|
|
+ tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
|
|
|
+ tableTops.add(tableTop);
|
|
|
+ });
|
|
|
+ TableBottom tableBottom = new TableBottom();
|
|
|
+ tableBottom.setTotal(0);
|
|
|
+ res.setTableTops(tableTops).setTableBottom(tableBottom);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @desc: 运需导出
|
|
|
* @author: yzc
|
|
|
@@ -360,7 +432,26 @@ public class KwoTransportDemandService {
|
|
|
* @return: java.util.List<com.sckw.order.model.dto.TransportDemandExport>
|
|
|
*/
|
|
|
public List<TransportDemandExport> export(ExportTransportDemandParam param) {
|
|
|
- LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(param);
|
|
|
+ //新增客户经理权限过滤
|
|
|
+ List<Long> authEntIdList = new ArrayList<>();
|
|
|
+ if (SystemTypeEnum.MANAGE.getCode() == LoginUserHolder.getSystemType()) {
|
|
|
+
|
|
|
+ authEntIdList = LoginUserHolder.getAuthEntIdList();
|
|
|
+ if (CollectionUtils.isEmpty(authEntIdList)) {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Long> ids = remoteUserService.findEnterpriseIdsByUserIdIsMain(LoginUserHolder.getUserId());
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ authEntIdList.addAll(ids);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<KwoTransportDemand> wrapper = buildWrapper(param, authEntIdList);
|
|
|
List<KwoTransportDemand> demands = kwoTransportDemandMapper.selectList(wrapper);
|
|
|
if (CollectionUtils.isEmpty(demands)) {
|
|
|
return Collections.emptyList();
|