| | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DataFormatUtils; |
| | | 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; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.oa.domain.BsSchool; |
| | | import com.ruoyi.oa.domain.DevEquipmentCode; |
| | | import com.ruoyi.oa.mapper.DevEquipmentCodeMapper; |
| | | import com.ruoyi.oa.service.IBsSchoolService; |
| | | import com.ruoyi.oa.service.IDevEquipmentCodeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | |
| | | public class DevEquipmentServiceImpl extends ServicePlusImpl<DevEquipmentMapper, DevEquipment, DevEquipmentVo> implements IDevEquipmentService { |
| | | |
| | | @Autowired |
| | | private DevEquipmentCodeMapper devEquipmentCodeMapper; |
| | | private IDevEquipmentCodeService devEquipmentCodeService; |
| | | |
| | | @Autowired |
| | | private IBsSchoolService iBsSchoolService; |
| | | |
| | | @Override |
| | | public DevEquipmentVo queryById(Long id) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateByBo(DevEquipmentBo bo) { |
| | | List<DevEquipment> list = baseMapper.selectList(new QueryWrapper<DevEquipment>().lambda() |
| | | .eq(DevEquipment::getSequenceCode, bo.getSequenceCode()) |
| | |
| | | // 设备不存在则新建 |
| | | else { |
| | | if(bo.isRegister()) { |
| | | BsSchool bsSchool = iBsSchoolService.getById(5); |
| | | if(bsSchool == null){ |
| | | throw new ServiceException("学校编号不存在,请先到线上维护", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | // 先根据序列码生成序列号 |
| | | List<DevEquipmentCode> devEquipmentCodeList = devEquipmentCodeService.list(); |
| | | DevEquipmentCode c = new DevEquipmentCode(); |
| | | c.setCreateTime(DateUtils.getNowDate()); |
| | | devEquipmentCodeMapper.insert(c); |
| | | if(devEquipmentCodeList != null && devEquipmentCodeList.size() > 0){ |
| | | c = devEquipmentCodeList.get(0); |
| | | }else{ |
| | | c.setCreateTime(DateUtils.getNowDate()); |
| | | c.setCode(Long.parseLong("1")); |
| | | c.setVersion(1); |
| | | devEquipmentCodeService.save(c); |
| | | } |
| | | int i = baseMapper.updateCode(c.getId(), c.getVersion()); |
| | | if(i <= 0){ |
| | | throw new ServiceException("设备编号表被占用,请稍后在校验", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | // 添加设备 |
| | | DevEquipment add = BeanUtil.toBean(bo, DevEquipment.class); |
| | | add.setSerialNumber(c.getId()); |
| | | String schoolCodeHex16 = "0".equals(Integer.toHexString(Integer.parseInt(bsSchool.getCode()))) ? "0000" : Integer.toHexString(Integer.parseInt(bsSchool.getCode()));//DataFormatUtils.strTo16(bsSchool.getCode()); |
| | | String codeHex16 =DataFormatUtils.padLeft(Integer.toHexString(Integer.parseInt(c.getCode().toString())), 4); |
| | | String hostId = (schoolCodeHex16 + codeHex16).toUpperCase(); |
| | | add.setHostId(hostId); |
| | | add.setSerialNumber(c.getCode()); |
| | | add.setUseStatus("1"); |
| | | baseMapper.insert(add); |
| | | return add; |
| | | }else{ |
| | |
| | | if(StringUtils.isNotBlank(bo.getEdition())){ |
| | | po.setEdition(bo.getEdition()); |
| | | } |
| | | if(StringUtils.isNotBlank(bo.getUseStatus())) |
| | | { |
| | | po.setUseStatus(bo.getUseStatus()); |
| | | } |
| | | // 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()); |
| | | // } |
| | | if (null != bo.getBatchId()) { |
| | | po.setBatchId(bo.getBatchId()); |
| | | } |
| | | if (StringUtils.isNotBlank(bo.getRemarks())) { |
| | | po.setRemarks(bo.getRemarks()); |
| | | } |
| | | baseMapper.updateById(po); |
| | | return po; |
| | | } |
| | |
| | | if (StringUtils.isNotBlank(bo.getRemarks())) { |
| | | po.setRemarks(bo.getRemarks()); |
| | | } |
| | | if(StringUtils.isNotBlank(bo.getUseStatus())) |
| | | { |
| | | po.setUseStatus(bo.getUseStatus()); |
| | | } |
| | | baseMapper.updateById(po); |
| | | } |
| | | } |