| New file |
| | |
| | | package cn.gistack.sm.sg.service.impl; |
| | | |
| | | import cn.gistack.sm.sg.DO.SgDeviceDO; |
| | | import cn.gistack.sm.sg.DO.SgGxStepDO; |
| | | import cn.gistack.sm.sg.DO.SgProgressReportDO; |
| | | import cn.gistack.sm.sg.DTO.SgDeviceSearchDTO; |
| | | import cn.gistack.sm.sg.mapper.SgDeviceMapper; |
| | | import cn.gistack.sm.sg.mapper.SgGxStepMapper; |
| | | import cn.gistack.sm.sg.mapper.SgProgressReportMapper; |
| | | import cn.gistack.sm.sg.service.SgDeviceService; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 施工项目子设备 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author shenyijian |
| | | * @since 2024-06-13 11:51:20 |
| | | */ |
| | | @Service |
| | | public class SgDeviceServiceImpl extends ServiceImpl<SgDeviceMapper, SgDeviceDO> implements SgDeviceService { |
| | | @Autowired |
| | | private SgGxStepMapper sgGxStepMapper; |
| | | |
| | | @Autowired |
| | | private SgProgressReportMapper sgProgressReportMapper; |
| | | |
| | | |
| | | @Override |
| | | public IPage<SgDeviceDO> queryPageList(IPage<SgDeviceDO> page, SgDeviceSearchDTO searchDTO) { |
| | | List<SgDeviceDO> sgDeviceDOS = baseMapper.queryPageList(page,searchDTO); |
| | | return page.setRecords(sgDeviceDOS); |
| | | } |
| | | |
| | | /** |
| | | * 根据项目id查询下下面的设备list |
| | | * |
| | | * @param programId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SgDeviceDO> getDeviceList(String programId) { |
| | | List<SgDeviceDO> list = new ArrayList<>(); |
| | | QueryWrapper<SgDeviceDO> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("program_id", programId); |
| | | SgDeviceDO sg1 = new SgDeviceDO(); |
| | | sg1.setId((long) 999); |
| | | sg1.setDeviceName("施工准备"); |
| | | sg1.setDeviceType("sgzb"); |
| | | sg1.setStatus(0); |
| | | list.add(sg1); |
| | | |
| | | List<SgDeviceDO> sgDeviceDOS = baseMapper.selectList(queryWrapper); |
| | | if (CollectionUtils.isNotEmpty(sgDeviceDOS)) { |
| | | list.addAll(sgDeviceDOS); |
| | | } |
| | | |
| | | SgDeviceDO sg2 = new SgDeviceDO(); |
| | | sg2.setId((long) 998); |
| | | sg2.setDeviceName("施工验收"); |
| | | sg2.setDeviceType("sgys"); |
| | | sg2.setStatus(0); |
| | | list.add(sg2); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public SgDeviceDO getSgDeviceById(String id) { |
| | | return baseMapper.getSgDeviceById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<SgGxStepDO> queryStepList(String deviceId) { |
| | | if(deviceId.equals("998")){ |
| | | return sgGxStepMapper.queryStepLists("sgys"); |
| | | }else if (deviceId.equals("999")){ |
| | | return sgGxStepMapper.queryStepLists("sgzb"); |
| | | } |
| | | List<SgGxStepDO> sgGxStepDOS = sgGxStepMapper.queryStepList(deviceId); |
| | | return sgGxStepDOS; |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveById(SgDeviceDO sgDeviceDO) { |
| | | QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>(); |
| | | SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper.eq("profram_id", sgDeviceDO.getProgramId()).eq("gx_step_id",26)); |
| | | if (sgProgressReportDO != null) { |
| | | if(sgProgressReportDO.getStatus().equals(2)){ |
| | | throw new ServiceException("施工验收完成不能增加设备"); |
| | | } |
| | | } |
| | | |
| | | return save(sgDeviceDO); |
| | | } |
| | | } |