| | |
| | | private static final String STATUS_APPLY = "1"; |
| | | private static final String STATUS_APPROVED = "2"; |
| | | private static final String STATUS_REJECTED = "3"; |
| | | |
| | | |
| | | /** |
| | | * 审核状态常量:0-待审核、1-审核通过、2-审核拒绝 |
| | | */ |
| | |
| | | |
| | | @Override |
| | | public IPage<GdSupplyDemandVO> selectGdSupplyDemandPage(IPage<GdSupplyDemandVO> page, GdSupplyDemandPageParam gdSupplyDemand) { |
| | | return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand, buildDeptIdList())); |
| | | return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())))); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (Func.isEmpty(gdSupplyDemand)) { |
| | | throw new ServiceException("需求参数不能为空"); |
| | | } |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, buildDeptIdList()); |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()))); |
| | | if (detail == null) { |
| | | throw new ServiceException("未查询到数据"); |
| | | } |
| | |
| | | if (Func.isEmpty(gdSupplyDemand)) { |
| | | throw new ServiceException("需求参数不能为空"); |
| | | } |
| | | |
| | | |
| | | // 获取前端传入的需求状态 |
| | | String demandStatus = gdSupplyDemand.getDemandStatus(); |
| | | if (StringUtil.isBlank(demandStatus)) { |
| | | throw new ServiceException("需求状态不能为空"); |
| | | } |
| | | |
| | | |
| | | // 校验状态值有效性 |
| | | if (!STATUS_DRAFT.equals(demandStatus) && !STATUS_APPLY.equals(demandStatus)) { |
| | | throw new ServiceException("需求状态值无效,仅支持 0(草稿) 或 1(申请中)"); |
| | | } |
| | | |
| | | |
| | | boolean isInsert = Func.isEmpty(gdSupplyDemand.getId()); |
| | | Long userId = AuthUtil.getUserId(); |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | gdSupplyDemand.setUpdateUser(userId); |
| | | |
| | | |
| | | boolean saved; |
| | | if (isInsert) { |
| | | gdSupplyDemand.setCreateUser(userId); |
| | |
| | | } else { |
| | | saved = baseMapper.updateGdSupplyDemand(gdSupplyDemand) > 0; |
| | | } |
| | | |
| | | |
| | | if (!saved) { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // 仅当状态为"申请中"(1)时才创建审核记录 |
| | | if (STATUS_APPLY.equals(demandStatus)) { |
| | | GdSupplyDemandEntity supplyDemand = loadSupplyDemandForAudit(gdSupplyDemand.getId()); |
| | | GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(supplyDemand, AUDIT_PENDING, null); |
| | | return gdSupplyDemandAuditService.saveSupplyDemandAudit(auditEntity); |
| | | } |
| | | |
| | | |
| | | // 状态为"草稿"(0)时直接返回成功 |
| | | return true; |
| | | } |
| | |
| | | } |
| | | GdSupplyDemandDTO query = new GdSupplyDemandDTO(); |
| | | query.setId(demandId); |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(query, buildDeptIdList()); |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(query, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()))); |
| | | if (detail == null) { |
| | | throw new ServiceException("需求数据不存在"); |
| | | } |
| | | return detail; |
| | | } |
| | | |
| | | private List<Long> buildDeptIdList() { |
| | | if (AuthUtil.isAdministrator()) { |
| | | return null; |
| | | } |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | List<Long> result = new ArrayList<>(); |
| | | if (Func.isNotEmpty(deptIdList)) { |
| | | result.addAll(deptIdList); |
| | | } |
| | | if (!result.contains(deptId)) { |
| | | result.add(deptId); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |