hexiao 2 anni fa
parent
commit
c0c08c834c

+ 47 - 0
purchase-admin/src/main/java/com/ozs/web/controller/pm/PmAuditDeptRefController.java

@@ -0,0 +1,47 @@
+package com.ozs.web.controller.pm;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ozs.common.core.controller.BaseController;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.entity.SysDept;
+import com.ozs.pm.doman.PmAuditDeptRef;
+import com.ozs.pm.service.PmAuditDeptRefService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Api(tags = "审核关联")
+@RestController
+@RequestMapping("/pm/audit")
+public class PmAuditDeptRefController extends BaseController {
+
+    @Autowired
+    private PmAuditDeptRefService pmAuditDeptRefService;
+    @Autowired
+    private com.ozs.system.service.ISysDeptService deptService;
+
+    @PostMapping("/list")
+    public AjaxResult list(@RequestBody PmAuditDeptRef vo) {
+        LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
+        lw.eq(PmAuditDeptRef::getRefId, vo.getRefId());
+        lw.eq(PmAuditDeptRef::getRefType, vo.getRefType());
+        List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
+        if (!ObjectUtils.isEmpty(list)) {
+            for (PmAuditDeptRef pmAuditDeptRef : list) {
+                com.ozs.common.core.domain.entity.SysDept d = deptService.selectById(pmAuditDeptRef.getDeptId());
+                if (!ObjectUtils.isEmpty(d)) {
+                    pmAuditDeptRef.setDeptName(d.getDeptName());
+                }
+                pmAuditDeptRef.setStatusStr(pmAuditDeptRef.getStatus().equals(Integer.parseInt("0")) ? "待审核" : "已审核");
+            }
+        }
+        return success(list);
+    }
+}

+ 5 - 0
purchase-system/src/main/java/com/ozs/pm/doman/PmAuditDeptRef.java

@@ -51,6 +51,9 @@ public class PmAuditDeptRef implements Serializable {
     @TableField("DEPT_ID")
     private Long deptId;
 
+    @TableField(exist = false)
+    private String deptName;
+
 
     @ApiModelProperty("单位级别(A:最低级,B:中间,C:最高级)")
     @TableField("DEPT_LEVEL")
@@ -61,6 +64,8 @@ public class PmAuditDeptRef implements Serializable {
     @TableField("STATUS")
     private Integer status;
 
+    @TableField(exist = false)
+    private String statusStr;
 
     @ApiModelProperty("创建者")
     @TableField("CREATED")

+ 3 - 2
purchase-system/src/main/java/com/ozs/system/service/ISysDeptService.java

@@ -12,8 +12,7 @@ import com.ozs.common.core.domain.entity.SysDept;
  *
  * @author ruoyi
  */
-public interface ISysDeptService
-{
+public interface ISysDeptService {
     /**
      * 查询部门管理数据
      *
@@ -126,4 +125,6 @@ public interface ISysDeptService
     public int deleteDeptById(Long deptId);
 
     public String isExcessOrNo(String projectType, BigDecimal evaluation, Long deptId);
+
+    public SysDept selectById(Long deptId);
 }

+ 46 - 75
purchase-system/src/main/java/com/ozs/system/service/impl/SysDeptServiceImpl.java

@@ -42,8 +42,7 @@ import javax.annotation.Resource;
  * @author ruoyi
  */
 @Service
-public class SysDeptServiceImpl implements ISysDeptService
-{
+public class SysDeptServiceImpl implements ISysDeptService {
     @Autowired
     private SysDeptMapper deptMapper;
 
@@ -60,8 +59,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      */
     @Override
     @DataScope(deptAlias = "d")
-    public List<SysDept> selectDeptList(SysDept dept)
-    {
+    public List<SysDept> selectDeptList(SysDept dept) {
         return deptMapper.selectDeptList(dept);
     }
 
@@ -72,8 +70,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 部门树信息集合
      */
     @Override
-    public List<TreeSelect> selectDeptTreeList(SysDept dept)
-    {
+    public List<TreeSelect> selectDeptTreeList(SysDept dept) {
         List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
         return buildDeptTreeSelect(depts);
     }
@@ -85,21 +82,17 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 树结构列表
      */
     @Override
-    public List<SysDept> buildDeptTree(List<SysDept> depts)
-    {
+    public List<SysDept> buildDeptTree(List<SysDept> depts) {
         List<SysDept> returnList = new ArrayList<SysDept>();
         List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
-        for (SysDept dept : depts)
-        {
+        for (SysDept dept : depts) {
             // 如果是顶级节点, 遍历该父节点的所有子节点
-            if (!tempList.contains(dept.getParentId()))
-            {
+            if (!tempList.contains(dept.getParentId())) {
                 recursionFn(depts, dept);
                 returnList.add(dept);
             }
         }
-        if (returnList.isEmpty())
-        {
+        if (returnList.isEmpty()) {
             returnList = depts;
         }
         return returnList;
@@ -112,8 +105,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 下拉树结构列表
      */
     @Override
-    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
-    {
+    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
         List<SysDept> deptTrees = buildDeptTree(depts);
         return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
     }
@@ -125,8 +117,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 选中部门列表
      */
     @Override
-    public List<Long> selectDeptListByRoleId(Long roleId)
-    {
+    public List<Long> selectDeptListByRoleId(Long roleId) {
         SysRole role = roleMapper.selectRoleById(roleId);
         return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
     }
@@ -138,22 +129,21 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 部门信息
      */
     @Override
-    public Map<String, Object> selectDeptById(Long deptId)
-    {
+    public Map<String, Object> selectDeptById(Long deptId) {
         Map<String, Object> returnMap = new HashMap<>();
         SysDept sysDept = deptMapper.selectDeptById(deptId);
         SysDeptResponseVo sysDeptResponseVo = new SysDeptResponseVo();
-        if(ObjectUtils.isEmpty(sysDept)){
-            throw new BaseException("deptId为"+deptId+"的单位不存在");
+        if (ObjectUtils.isEmpty(sysDept)) {
+            throw new BaseException("deptId为" + deptId + "的单位不存在");
         }
         BeanUtils.copyProperties(sysDept, sysDeptResponseVo);
         QueryWrapper<SysProcurementStandard> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("dept_id",deptId);
+        queryWrapper.eq("dept_id", deptId);
         List<SysProcurementStandard> sysProcurementStandardsList = sysProcurementStandardMapper.selectList(queryWrapper);
 
-        returnMap.put("sysDept",sysDeptResponseVo);
-        returnMap.put("sysProcurementStandardsList",sysProcurementStandardsList);
-        returnMap.put("dto",sysDept);
+        returnMap.put("sysDept", sysDeptResponseVo);
+        returnMap.put("sysProcurementStandardsList", sysProcurementStandardsList);
+        returnMap.put("dto", sysDept);
         return returnMap;
     }
 
@@ -164,8 +154,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 子部门数
      */
     @Override
-    public int selectNormalChildrenDeptById(Long deptId)
-    {
+    public int selectNormalChildrenDeptById(Long deptId) {
         return deptMapper.selectNormalChildrenDeptById(deptId);
     }
 
@@ -176,8 +165,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果
      */
     @Override
-    public boolean hasChildByDeptId(Long deptId)
-    {
+    public boolean hasChildByDeptId(Long deptId) {
         int result = deptMapper.hasChildByDeptId(deptId);
         return result > 0;
     }
@@ -189,8 +177,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果 true 存在 false 不存在
      */
     @Override
-    public boolean checkDeptExistUser(Long deptId)
-    {
+    public boolean checkDeptExistUser(Long deptId) {
         int result = deptMapper.checkDeptExistUser(deptId);
         return result > 0;
     }
@@ -202,12 +189,10 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果
      */
     @Override
-    public String checkDeptNameUnique(SysDept dept)
-    {
+    public String checkDeptNameUnique(SysDept dept) {
         Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
         SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
-        if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
-        {
+        if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -219,15 +204,12 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @param deptId 部门id
      */
     @Override
-    public void checkDeptDataScope(Long deptId)
-    {
-        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
-        {
+    public void checkDeptDataScope(Long deptId) {
+        if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
             SysDept dept = new SysDept();
             dept.setDeptId(deptId);
             List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
-            if (StringUtils.isEmpty(depts))
-            {
+            if (StringUtils.isEmpty(depts)) {
                 throw new ServiceException("没有权限访问部门数据!");
             }
         }
@@ -240,12 +222,10 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果
      */
     @Override
-    public int insertDept(SysDept dept)
-    {
+    public int insertDept(SysDept dept) {
         SysDept info = deptMapper.selectDeptById(dept.getParentId());
         // 如果父节点不为正常状态,则不允许新增子节点
-        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
-        {
+        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
             throw new ServiceException("部门停用,不允许新增");
         }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
@@ -259,12 +239,10 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果
      */
     @Override
-    public int updateDept(SysDept dept)
-    {
+    public int updateDept(SysDept dept) {
         SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
         SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
-        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
-        {
+        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
             String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
             String oldAncestors = oldDept.getAncestors();
             dept.setAncestors(newAncestors);
@@ -272,8 +250,7 @@ public class SysDeptServiceImpl implements ISysDeptService
         }
         int result = deptMapper.updateDept(dept);
         if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
-                && !StringUtils.equals("0", dept.getAncestors()))
-        {
+                && !StringUtils.equals("0", dept.getAncestors())) {
             // 如果该部门是启用状态,则启用该部门的所有上级部门
             updateParentDeptStatusNormal(dept);
         }
@@ -285,8 +262,7 @@ public class SysDeptServiceImpl implements ISysDeptService
      *
      * @param dept 当前部门
      */
-    private void updateParentDeptStatusNormal(SysDept dept)
-    {
+    private void updateParentDeptStatusNormal(SysDept dept) {
         String ancestors = dept.getAncestors();
         Long[] deptIds = Convert.toLongArray(ancestors);
         deptMapper.updateDeptStatusNormal(deptIds);
@@ -295,19 +271,16 @@ public class SysDeptServiceImpl implements ISysDeptService
     /**
      * 修改子元素关系
      *
-     * @param deptId 被修改的部门ID
+     * @param deptId       被修改的部门ID
      * @param newAncestors 新的父ID集合
      * @param oldAncestors 旧的父ID集合
      */
-    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
-    {
+    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
         List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
-        for (SysDept child : children)
-        {
+        for (SysDept child : children) {
             child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
         }
-        if (children.size() > 0)
-        {
+        if (children.size() > 0) {
             deptMapper.updateDeptChildren(children);
         }
     }
@@ -319,23 +292,19 @@ public class SysDeptServiceImpl implements ISysDeptService
      * @return 结果
      */
     @Override
-    public int deleteDeptById(Long deptId)
-    {
+    public int deleteDeptById(Long deptId) {
         return deptMapper.deleteDeptById(deptId);
     }
 
     /**
      * 递归列表
      */
-    private void recursionFn(List<SysDept> list, SysDept t)
-    {
+    private void recursionFn(List<SysDept> list, SysDept t) {
         // 得到子节点列表
         List<SysDept> childList = getChildList(list, t);
         t.setChildren(childList);
-        for (SysDept tChild : childList)
-        {
-            if (hasChild(list, tChild))
-            {
+        for (SysDept tChild : childList) {
+            if (hasChild(list, tChild)) {
                 recursionFn(list, tChild);
             }
         }
@@ -344,15 +313,12 @@ public class SysDeptServiceImpl implements ISysDeptService
     /**
      * 得到子节点列表
      */
-    private List<SysDept> getChildList(List<SysDept> list, SysDept t)
-    {
+    private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
         List<SysDept> tlist = new ArrayList<SysDept>();
         Iterator<SysDept> it = list.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             SysDept n = (SysDept) it.next();
-            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
-            {
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
                 tlist.add(n);
             }
         }
@@ -391,4 +357,9 @@ public class SysDeptServiceImpl implements ISysDeptService
         return result;
 
     }
+
+    @Override
+    public SysDept selectById(Long deptId) {
+        return deptMapper.selectDeptById(deptId);
+    }
 }