| 
					
				 | 
			
			
				@@ -3,6 +3,7 @@ package com.ozs.pm.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -13,9 +14,13 @@ import com.ozs.base.domain.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.base.domain.vo.BaseExpertVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.base.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.core.domain.AjaxResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.core.domain.entity.SysDept; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.core.domain.entity.SysRole; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.core.domain.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.enums.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.utils.RandomUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.SecurityUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.common.utils.bean.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.home.domain.vo.HomeToDoQueryResVo; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,6 +36,8 @@ import com.ozs.system.domain.SysFileInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.system.domain.SysFileRef; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.system.domain.vo.SysRegionVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.mapper.SysDeptMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.mapper.SysRoleMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ozs.system.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.swagger.models.auth.In; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,6 +110,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ISysRegionService iSysRegionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysRoleMapper sysRoleMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ISysUserService userService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysDeptMapper deptMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询采购需求 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -352,8 +367,45 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*******************权限代码***********************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Long deptId = sysUser.getDeptId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取登录用户的角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(SecurityUtils.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取属于求单位管理员的列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SysRole> sysRoleList2 = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals(SysRoleKey.DEMAND_UNIT.getCode())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!ObjectUtils.isEmpty(sysRoleList2)) { //属于需求单位管理员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lw.apply("(purchase_dept_id = " + deptId + ")" ) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取属于采购管理部门管理员 或 采购办管理员的列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> (tdto.getRoleKey().equals(SysRoleKey.PURCHASING_MANAGEMENT.getCode()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    || tdto.getRoleKey().equals(SysRoleKey.PROCUREMENT_OFFICE.getCode()))).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!ObjectUtils.isEmpty(sysRoleList)) { //属于采购管理部门管理员 或 采购办管理员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //获取子部门列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<SysDept> sysDeptSubs = deptMapper.selectChildrenDeptById(sysUser.getDeptId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String sysDeptSubStr = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!ObjectUtils.isEmpty(sysDeptSubs)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<String> sysDeptSubIds = sysDeptSubs.stream().map(SysDept::getDeptId).collect(Collectors.toList()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .stream().map(x -> x + "").collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    sysDeptSubStr = String.join(",", sysDeptSubIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String condtionSql= null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(ObjectUtils.isEmpty(sysDeptSubStr)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    condtionSql = "(purchase_dept_id = " + deptId + " AND is_excess = 0) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    condtionSql = "((purchase_dept_id = " + deptId + " AND is_excess = 0) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            " OR (purchase_dept_id IN ("+ sysDeptSubStr +") and AND is excess = 1))"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                lw.apply(condtionSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*******************权限代码end***********************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 |