| | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | |
| | | DevEquipment po = baseMapper.selectOne(new QueryWrapper<DevEquipment>().lambda() |
| | | .eq(DevEquipment::getSequenceCode, bo.getSequenceCode())); |
| | | // 设备存在,直接返回设备信息 |
| | | if (StringUtils.isEmpty(po)) { |
| | | if (StringUtils.isNotEmpty(po)) { |
| | | return po; |
| | | } |
| | | // 设备不存在则新建 |
| | | else { |
| | | // 先根据序列码生成序列号 |
| | | DevEquipmentCode c = new DevEquipmentCode(); |
| | | c.setSequenceCode(bo.getSequenceCode()); |
| | | devEquipmentCodeMapper.insert(c); |
| | | // 添加设备 |
| | | DevEquipment add = BeanUtil.toBean(bo, DevEquipment.class); |
| | | add.setSerialNumber(c.getId()); |
| | | baseMapper.insert(add); |
| | | return add; |
| | | if(bo.isRegister()) { |
| | | // 先根据序列码生成序列号 |
| | | DevEquipmentCode c = new DevEquipmentCode(); |
| | | c.setCreateTime(DateUtils.getNowDate()); |
| | | devEquipmentCodeMapper.insert(c); |
| | | // 添加设备 |
| | | DevEquipment add = BeanUtil.toBean(bo, DevEquipment.class); |
| | | add.setSerialNumber(c.getId()); |
| | | baseMapper.insert(add); |
| | | return add; |
| | | }else{ |
| | | return po; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public DevEquipment equipmentEdit(DevEquipmentBo bo) { |
| | | DevEquipment po = baseMapper.selectById(bo.getId()); |
| | | if (po == null) { |
| | | throw new ServiceException("没有设备信息", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | if (null != bo.getSchoolId()) { |
| | | po.setSchoolId(bo.getSchoolId()); |
| | | } |
| | | if (StringUtils.isEmpty(bo.getHostId())) { |
| | | if (StringUtils.isNotBlank(bo.getHostId())) { |
| | | po.setHostId(bo.getHostId()); |
| | | } |
| | | if (StringUtils.isEmpty(bo.getNetworkId())) { |
| | | po.setNetworkId(bo.getNetworkId()); |
| | | if(StringUtils.isNotBlank(bo.getEdition())){ |
| | | po.setEdition(bo.getEdition()); |
| | | } |
| | | if (StringUtils.isEmpty(bo.getFrequencyBand())) { |
| | | po.setFrequencyBand(bo.getFrequencyBand()); |
| | | // if (StringUtils.isEmpty(bo.getNetworkId())) { |
| | | // po.setNetworkId(bo.getNetworkId()); |
| | | // } |
| | | // if (StringUtils.isEmpty(bo.getFrequencyBand())) { |
| | | // po.setFrequencyBand(bo.getFrequencyBand()); |
| | | // } |
| | | // if (null != bo.getBatchId()) { |
| | | // po.setBatchId(bo.getBatchId()); |
| | | // } |
| | | // if (StringUtils.isEmpty(bo.getRemarks())) { |
| | | // po.setRemarks(bo.getRemarks()); |
| | | // } |
| | | baseMapper.updateById(po); |
| | | return po; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void submitComment(DevEquipmentBo bo) { |
| | | DevEquipment po = baseMapper.selectById(bo.getId()); |
| | | if (po == null) { |
| | | throw new ServiceException("没有设备信息", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | if (null != bo.getBatchId()) { |
| | | po.setBatchId(bo.getBatchId()); |
| | | } |
| | | if (StringUtils.isEmpty(bo.getRemarks())) { |
| | | if (StringUtils.isNotBlank(bo.getRemarks())) { |
| | | po.setRemarks(bo.getRemarks()); |
| | | } |
| | | baseMapper.updateById(po); |
| | | return po; |
| | | } |
| | | } |