| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | private SgGxMapper sgGxMapper; |
| | | @Override |
| | | public IPage<SgGxVO> queryPageList(IPage<SgGxVO> page, ProjectSearchDTO searchDTO) { |
| | | List<SgGxVO> list = sgGxMapper.queryPageList(searchDTO); |
| | | List<SgGxVO> list = sgGxMapper.queryPageList(page,searchDTO); |
| | | if (CollectionUtils.isNotEmpty(list)){ |
| | | List<Long> ids = list.stream().map(SgGxDO::getId).collect(Collectors.toList()); |
| | | List<SgGxStepDO> stepDOS = sgGxMapper.queryStepByIds(ids); |
| | | if (CollectionUtils.isNotEmpty(stepDOS)){ |
| | | Map<Long, List<SgGxStepDO>> map = stepDOS.stream().collect(Collectors.groupingBy(SgGxStepDO::getGxInfoId)); |
| | | for (SgGxVO sgGxDO : list) { |
| | | sgGxDO.setStepDOList(map.get(sgGxDO.getId())); |
| | | List<SgGxStepDO> sgGxStepDOS = map.get(sgGxDO.getId()); |
| | | if (CollectionUtils.isNotEmpty(sgGxStepDOS)){ |
| | | sgGxDO.setStepDOList(sgGxStepDOS); |
| | | sgGxDO.setGxStepCount(sgGxStepDOS.size()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void add(SgGxDO sgGxDO) { |
| | | sgGxDO.setCreateUpdateTime(); |
| | | if (sgGxMapper.selectByGxType(sgGxDO.getGxType())!= null){ |
| | | throw new RuntimeException("工序类型已存在"); |
| | | throw new ServiceException("工序类型已存在"); |
| | | } |
| | | this.save(sgGxDO); |
| | | } |
| | | |
| | | @Override |
| | | public void update(SgGxDO sgGxDO) { |
| | | if (sgGxMapper.selectByGxType(sgGxDO.getGxType())!= null){ |
| | | throw new RuntimeException("工序类型已存在"); |
| | | sgGxDO.setCreateUpdateTime(); |
| | | SgGxDO one = sgGxMapper.selectByGxType(sgGxDO.getGxType()); |
| | | if (one != null && one.getId()!= sgGxDO.getId() ){ |
| | | throw new ServiceException("工序类型已存在"); |
| | | } |
| | | this.updateById(sgGxDO); |
| | | } |
| | | |
| | | @Override |
| | | public SgGxVO detail(Long id) { |
| | | SgGxVO byId = (SgGxVO) this.getById(id); |
| | | byId.setStepDOList(sgGxMapper.queryStepByIds(List.of(id))); |
| | | SgGxVO byId = sgGxMapper.getById(id); |
| | | List<SgGxStepDO> stepDOS = sgGxMapper.queryStepByIds(List.of(id)); |
| | | byId.setStepDOList(stepDOS); |
| | | return byId; |
| | | } |
| | | } |