Procházet zdrojové kódy

modify:

1. 单位查询修改;
tags/24090101
WendyYang před 2 měsíci
rodič
revize
8fb11f192f
8 změnil soubory, kde provedl 107 přidání a 39 odebrání
  1. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionsCacheHelperImpl.java
  2. +0
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/QxPurchase.java
  3. +8
    -18
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java
  4. +0
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/QxPurchaseRecordReq.java
  5. +0
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/QxPurchaseVO.java
  6. +3
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java
  7. +67
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/user/helper/MhUnitQueryHelper.java
  8. +25
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java

+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionsCacheHelperImpl.java Zobrazit soubor

@@ -2,18 +2,18 @@ package com.hz.pm.api.common.helper.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.StrPool;
import com.hz.pm.api.sys.service.IRegionService;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.CollUtils;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.basic.AbstractRegionCacheHelper;
import com.hz.pm.api.common.model.RegionMapKey;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.sys.convert.RegionConverter;
import com.hz.pm.api.sys.model.dto.RegionDTO;
import com.hz.pm.api.sys.model.dto.RegionTreeDTO;
import com.hz.pm.api.sys.model.vo.RegionTreeVO;
import com.hz.pm.api.sys.service.IRegionService;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.CollUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;


+ 0
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/QxPurchase.java Zobrazit soubor

@@ -34,9 +34,6 @@ public class QxPurchase {
@ApiModelProperty("采购方式")
private String purchaseMethod;

@ApiModelProperty("采购单位ID")
private Long purchaseUnitId;

@ApiModelProperty("采购单位名称")
private String purchaseUnitName;



+ 8
- 18
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java Zobrazit soubor

@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.common.model.constant.MhUnitConst;
import com.hz.pm.api.common.util.BizUtils;
import com.hz.pm.api.projectlib.entity.MhSystemReplaceInfo;
import com.hz.pm.api.projectlib.entity.QxProject;
import com.hz.pm.api.projectlib.entity.QxProjectSystemReplaceInfos;
@@ -24,8 +24,8 @@ import com.hz.pm.api.projectlib.service.IMhSystemReplaceInfoService;
import com.hz.pm.api.projectlib.service.IQxProjectService;
import com.hz.pm.api.projectlib.service.IQxProjectSystemReplaceInfosService;
import com.hz.pm.api.projectlib.service.IQxPurchaseService;
import com.hz.pm.api.user.helper.MhUnitCache;
import com.hz.pm.api.user.security.model.UserInfoDetails;
import com.hz.pm.api.user.helper.MhUnitQueryHelper;
import com.hz.pm.api.user.helper.MhUnitQueryHelper.UnitQueryState;
import com.hz.pm.api.user.util.LoginUserUtil;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;
@@ -51,7 +51,7 @@ import java.util.Map;
@RequiredArgsConstructor
public class QxProjectManage {

private final MhUnitCache mhUnitCache;
private final MhUnitQueryHelper unitQueryHelper;
private final IQxProjectService qxProjectService;
private final IMhSystemReplaceInfoService mhSystemReplaceInfoService;
private final IQxProjectSystemReplaceInfosService qxProjectSystemReplaceInfosService;
@@ -187,21 +187,11 @@ public class QxProjectManage {
"select 1 from qx_project_system_replace_infos " +
"where qx_project_system_replace_infos.project_id = qx_project.id " +
"and replace_type = {0}", req.getReplaceType());
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
if (req.getBuildOrgCode() != null) {
if (!userDetail.hasSuperAdmin()) {
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId());
if (!viewUnitIds.contains(req.getBuildOrgCode())) {
return PageVo.empty();
}
}
query.in(QxProject::getBuildOrgCode, mhUnitCache.getViewChildIdsRecursion(req.getBuildOrgCode()));
} else {
if (!LoginUserUtil.loginUserDetail().hasSuperAdmin()
&& MhUnitConst.ROOT_UNIT_ID != userDetail.getMhUnitId()) {
query.in(QxProject::getBuildOrgCode, mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()));
}
UnitQueryState unitQuery = unitQueryHelper.listCanViewUnitIds(req.getBuildOrgCode());
if (!unitQuery.isState()) {
return PageVo.empty();
}
BizUtils.notEmpty(unitQuery.getUnitIds(), w -> query.in(QxProject::getBuildOrgCode, w));
Page<QxProject> page = qxProjectService.page(req.page(), query);
return PageVo.of(BeanUtil.copyToList(page.getRecords(), QxProjectVO.class), page.getTotal());
}


+ 0
- 4
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/QxPurchaseRecordReq.java Zobrazit soubor

@@ -33,10 +33,6 @@ public class QxPurchaseRecordReq {
@NotBlank(message = "采购方式不能为空")
private String purchaseMethod;

@ApiModelProperty("采购单位ID")
@NotNull(message = "采购单位ID不能为空")
private Long purchaseUnitId;

@ApiModelProperty("采购单位名称")
@NotBlank(message = "采购单位名称不能为空")
private String purchaseUnitName;


+ 0
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/QxPurchaseVO.java Zobrazit soubor

@@ -30,9 +30,6 @@ public class QxPurchaseVO {
@ApiModelProperty("采购方式")
private String purchaseMethod;

@ApiModelProperty("采购单位ID")
private Long purchaseUnitId;

@ApiModelProperty("采购单位名称")
private String purchaseUnitName;



+ 3
- 2
hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java Zobrazit soubor

@@ -35,8 +35,9 @@ public class MhUnitController {

@GetMapping("/tree")
@ApiOperation("单位树")
public List<MhUnitTreeDTO> getMhUnitTree(@RequestParam(required = false) String name) {
return mhUnitManage.getMhUnitTree(name);
public List<MhUnitTreeDTO> getMhUnitTree(@RequestParam(required = false) String name,
@RequestParam(required = false) Long unitId) {
return mhUnitManage.getMhUnitTree(name, unitId);
}

@GetMapping("/wflowModelConfig/tree")


+ 67
- 0
hz-pm-api/src/main/java/com/hz/pm/api/user/helper/MhUnitQueryHelper.java Zobrazit soubor

@@ -0,0 +1,67 @@
package com.hz.pm.api.user.helper;

import com.hz.pm.api.common.model.constant.MhUnitConst;
import com.hz.pm.api.user.security.model.UserInfoDetails;
import com.hz.pm.api.user.util.LoginUserUtil;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* <p>
* MhUnitQueryHelper
* </p>
*
* @author WendyYang
* @since 16:31 2024/8/31
*/
@Component
@RequiredArgsConstructor
public class MhUnitQueryHelper {

private final MhUnitCache unitCache;

@Data
public static class UnitQueryState {

private boolean state = true;

private List<Long> unitIds;

}

/**
* 获取可查看的子部门ID列表
*
* @param unitId 当前单位
* @param user 用户信息
* @return 可查看的子部门ID列表
*/
public UnitQueryState listCanViewUnitIds(Long unitId, UserInfoDetails user) {
UnitQueryState state = new UnitQueryState();
if (unitId == null) {
if (!user.hasSuperAdmin() && MhUnitConst.ROOT_UNIT_ID != user.getMhUnitId()) {
state.setUnitIds(unitCache.getViewChildIdsRecursion(user.getMhUnitId()));
}
} else {
if (!user.hasSuperAdmin() && !unitId.equals(user.getMhUnitId())) {
List<Long> unitIdPaths = unitCache.getUnitIdPaths(unitId);
if (!unitIdPaths.contains(user.getMhUnitId())) {
state.setState(false);
return state;
}
}
if (!unitId.equals(MhUnitConst.ROOT_UNIT_ID)) {
state.setUnitIds(unitCache.getViewChildIdsRecursion(unitId));
}
}
return state;
}

public UnitQueryState listCanViewUnitIds(Long unitId) {
return listCanViewUnitIds(unitId, LoginUserUtil.loginUserDetail());
}

}

+ 25
- 5
hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java Zobrazit soubor

@@ -2,7 +2,9 @@ package com.hz.pm.api.user.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -55,13 +57,25 @@ public class MhUnitManage {
private final MhUnitCache mhUnitCache;
private final IUserInfoService userInfoService;

public List<MhUnitTreeDTO> getMhUnitTree(String name) {
public List<MhUnitTreeDTO> getMhUnitTree(String name, Long unitId) {
List<UnitDTO> retUnits;
List<UnitDTO> allUnits = mhUnitCache.all();
if (StrUtils.isNotBlank(name)) {
allUnits.removeIf(w -> !w.getName().contains(name));
if (StrUtil.isNotBlank(name) || unitId != null) {
if (StrUtil.isNotBlank(name)) {
allUnits.removeIf(w -> !w.getName().contains(name));
}
retUnits = allUnits.stream()
.map(w -> mhUnitCache.getUnitIdPaths(w.getId()))
.map(w -> {
List<Long> unitIdPaths = mhUnitCache.getUnitIdPaths(w.getId());
if (unitId != null) {
if (!unitIdPaths.contains(unitId)) {
return null;
}
return unitIdPaths.subList(unitIdPaths.indexOf(unitId), unitIdPaths.size());
}
return unitIdPaths;
})
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.distinct()
.map(mhUnitCache::getById)
@@ -78,7 +92,13 @@ public class MhUnitManage {
node.setStrip(node.getType().getStrip());
return node;
}).collect(Collectors.toList());
return TreeUtil.convertToTree(nodes, unitRootParentId);
Long tmpRootParentId;
if (unitId != null) {
tmpRootParentId = mhUnitCache.getById(unitId).getParentId();
} else {
tmpRootParentId = unitRootParentId;
}
return TreeUtil.convertToTree(nodes, tmpRootParentId);
}

public List<MhUnitTreeDTO> getMhUnitStripTree() {


Načítá se…
Zrušit
Uložit