hexiao 2 years ago
parent
commit
5d8d254f46

+ 88 - 0
purchase-admin/src/main/java/com/ozs/web/controller/base/BaseNoticeController.java

@@ -10,10 +10,15 @@ import com.ozs.base.service.BaseNoticeTypeService;
 import com.ozs.base.vo.BaseNoticePageReqVo;
 import com.ozs.base.vo.BaseNoticeVo;
 import com.ozs.common.annotation.Log;
+import com.ozs.common.constant.Constants;
 import com.ozs.common.constant.ModularConstans;
 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.common.core.domain.entity.SysRole;
 import com.ozs.common.enums.BusinessType;
+import com.ozs.plan.doman.MonthlyReconciliation;
+import com.ozs.system.service.ISysDeptService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -39,6 +44,9 @@ public class BaseNoticeController extends BaseController {
     @Autowired
     private BaseNoticeTypeService baseNoticeTypeService;
 
+    @Autowired
+    private ISysDeptService iSysDeptService;
+
     @ApiOperation(value = "分页查询公告信息")
     @PostMapping("/page")
     @PreAuthorize("@ss.hasPermi('base:notice:list')")
@@ -130,4 +138,84 @@ public class BaseNoticeController extends BaseController {
         return success(baseNoticeVo);
     }
 
+
+
+    @ApiOperation(value = "分页查询公告信息")
+    @PostMapping("/homePage")
+    @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
+    public AjaxResult homePage(@NotEmpty(message = "数据为空")
+                           @RequestBody BaseNoticePageReqVo vo) {
+        LambdaQueryWrapper<BaseNotice> lw = new LambdaQueryWrapper<>();
+        if(!StringUtils.isBlank(vo.getTitle())){
+            lw.like(BaseNotice::getTitle,vo.getTitle());
+        }
+        if(!ObjectUtils.isEmpty(vo.getStartTime())){
+            lw.ge(BaseNotice::getReleaseTime,vo.getStartTime());
+        }
+        if(!ObjectUtils.isEmpty(vo.getStartTime())){
+            lw.le(BaseNotice::getReleaseTime,vo.getEntTime());
+        }
+
+        // 添加数据权限
+        List<String> roleKeys = getLoginUser().getUser().getRoles().stream().map(SysRole::getRoleKey).collect(Collectors.toList());
+        if (roleKeys.contains(Constants.DEMAND_UNIT)) {
+            // 需求单位
+            /*(purchase_dept_id = 当前用户deptID) */
+            lw.eq(BaseNotice::getDeptId, getDeptId());
+        } else if (roleKeys.contains(Constants.PURCHASING_MANAGEMENT)
+                || roleKeys.contains(Constants.PURCHASE_SERVICES)) {
+            // 采购管理部门  或  采购办
+            SysDept sysDept = new SysDept();
+            sysDept.setParentId(getDeptId());
+            sysDept.setStatus("0");
+            List<Long> childDeptIds = iSysDeptService.selectDeptList(sysDept)
+                    .stream()
+                    .map(SysDept::getDeptId)
+                    .collect(Collectors.toList());
+            if(ObjectUtils.isEmpty(childDeptIds)){
+                lw.and((wrapper) -> {
+                    wrapper.eq(BaseNotice::getIsExcess, 0);
+                    wrapper.eq(BaseNotice::getDeptId, getDeptId());
+                });
+            }else {
+                lw.and((wrapper) -> {
+                    wrapper.eq(BaseNotice::getIsExcess, 0);
+                    wrapper.eq(BaseNotice::getDeptId, getDeptId());
+                })
+                        .or((wrapper) -> {
+                            wrapper.eq(BaseNotice::getIsExcess, 1);
+                            wrapper.in(BaseNotice::getDeptId, childDeptIds);
+                        });
+            }
+        }
+
+
+        IPage<BaseNotice> page = baseNoticeService.page(new Page<>(vo.getPageNum(), vo.getPageSize()), lw);
+        IPage<BaseNoticeVo> pagev = new Page<>();
+        pagev.setTotal(page.getTotal());
+        pagev.setCurrent(page.getCurrent());
+        pagev.setPages(page.getPages());
+
+        if(!ObjectUtils.isEmpty(page) && page.getRecords().size()>0){
+            List<BaseNoticeType> list = baseNoticeTypeService.list();
+            List<Long> ids = list.stream().map(BaseNoticeType::getId).collect(Collectors.toList());
+            List<BaseNoticeVo> collect = page.getRecords().stream().map(o -> {
+                BaseNoticeVo baseNoticeVo = new BaseNoticeVo();
+                BeanUtils.copyProperties(o, baseNoticeVo);
+                if (ids.contains(o.getType())) {
+                    List<BaseNoticeType> collect1 = list.stream().filter(tdto -> tdto.getId().equals(o.getType())).collect(Collectors.toList());
+                    if(!ObjectUtils.isEmpty(collect1)){
+                        baseNoticeVo.setTypeName(collect1.get(0).getName());
+                    }
+
+                }
+                return baseNoticeVo;
+            }).collect(Collectors.toList());
+            pagev.setRecords(collect);
+        }else {
+            pagev.setRecords(null);
+        }
+        return success(pagev);
+
+    }
 }

+ 15 - 0
purchase-system/src/main/java/com/ozs/base/domain/BaseNotice.java

@@ -35,6 +35,21 @@ public class BaseNotice extends BaseDto {
     @TableId(type = IdType.AUTO)
     private Long id;
 
+    /** 主键id */
+    @ApiModelProperty("项目ID")
+    @NotBlank(message = "项目ID")
+    private Long demandId;
+
+    /** 单位ID */
+    @ApiModelProperty("单位ID")
+    @NotBlank(message = "单位ID")
+    private Long deptId;
+
+    /** 超限额 */
+    @ApiModelProperty("超限额")
+    @NotBlank(message = "超限额")
+    private Integer isExcess;
+
     /** 项目名称 */
     @Excel(name = "项目名称")
     @ApiModelProperty("项目名称")