| | |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 供需需求信息表 服务实现类 |
| | |
| | | |
| | | @Override |
| | | public IPage<GdSupplyDemandVO> selectGdSupplyDemandPage(IPage<GdSupplyDemandVO> page, GdSupplyDemandPageParam gdSupplyDemand) { |
| | | return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())))); |
| | | List<Long> deptList = new ArrayList<>(); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | } |
| | | gdSupplyDemand.setDeptList(deptList); |
| | | return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (Func.isEmpty(gdSupplyDemand)) { |
| | | throw new ServiceException("需求参数不能为空"); |
| | | } |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()))); |
| | | List<Long> deptList = new ArrayList<>(); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | } |
| | | GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, deptList); |
| | | if (detail == null) { |
| | | throw new ServiceException("未查询到数据"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submitSupplyDemand(GdSupplyDemandEntity gdSupplyDemand) { |
| | | public boolean submitSupplyDemand(GdSupplyDemandDTO gdSupplyDemand) { |
| | | if (Func.isEmpty(gdSupplyDemand)) { |
| | | throw new ServiceException("需求参数不能为空"); |
| | | } |
| | | GdSupplyDemandEntity supplyDemand = Objects.requireNonNull(BeanUtil.copy(gdSupplyDemand, GdSupplyDemandEntity.class)); |
| | | |
| | | // 获取前端传入的需求状态 |
| | | String demandStatus = gdSupplyDemand.getDemandStatus(); |
| | | String demandStatus = supplyDemand.getDemandStatus(); |
| | | if (StringUtil.isBlank(demandStatus)) { |
| | | throw new ServiceException("需求状态不能为空"); |
| | | } |
| | |
| | | throw new ServiceException("需求状态值无效,仅支持 0(草稿) 或 1(申请中)"); |
| | | } |
| | | |
| | | boolean isInsert = Func.isEmpty(gdSupplyDemand.getId()); |
| | | boolean isInsert = Func.isEmpty(supplyDemand.getId()); |
| | | Long userId = AuthUtil.getUserId(); |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | gdSupplyDemand.setUpdateUser(userId); |
| | | supplyDemand.setUpdateUser(userId); |
| | | |
| | | boolean saved; |
| | | if (isInsert) { |
| | | gdSupplyDemand.setCreateUser(userId); |
| | | gdSupplyDemand.setCreateDept(deptId); |
| | | saved = baseMapper.insertGdSupplyDemand(gdSupplyDemand) > 0; |
| | | supplyDemand.setCreateUser(userId); |
| | | supplyDemand.setCreateDept(deptId); |
| | | saved = baseMapper.insertGdSupplyDemand(supplyDemand) > 0; |
| | | } else { |
| | | saved = baseMapper.updateGdSupplyDemand(gdSupplyDemand) > 0; |
| | | saved = baseMapper.updateGdSupplyDemand(supplyDemand) > 0; |
| | | } |
| | | |
| | | if (!saved) { |
| | |
| | | |
| | | // 仅当状态为"申请中"(1)时才创建审核记录 |
| | | if (STATUS_APPLY.equals(demandStatus)) { |
| | | GdSupplyDemandEntity supplyDemand = loadSupplyDemandForAudit(gdSupplyDemand.getId()); |
| | | GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(supplyDemand, AUDIT_PENDING, null); |
| | | GdSupplyDemandEntity auditDemand = loadSupplyDemandForAudit(supplyDemand.getId()); |
| | | GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(auditDemand, AUDIT_PENDING, null); |
| | | return gdSupplyDemandAuditService.saveSupplyDemandAudit(auditEntity); |
| | | } |
| | | |