| | |
| | | if(existsByCode(vo.getCode(),null)){ |
| | | throw new ServiceException("机床编码已存在:"+vo.getCode()); |
| | | } |
| | | if(existsByEquipmentCode(vo.getEquipmentCode(),null)){ |
| | | throw new ServiceException("设备编号已存在:"+vo.getEquipmentCode()); |
| | | } |
| | | |
| | | Machine machine = new Machine(); |
| | | BeanUtil.copyProperties(vo, machine); |
| | |
| | | Path dir; |
| | | if(StringUtils.isNotBlank(machine.getProgSendDir())){ |
| | | createDirIsNotExists(machine.getProgSendDir()); |
| | | |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(machine.getProgReceiveDir())){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据 设备编号判断机床是否存在 |
| | | * @param equipmentCode 设备编号 |
| | | * @param excludeId 排除id |
| | | * @return 是否存在 |
| | | */ |
| | | boolean existsByEquipmentCode(String equipmentCode,Long excludeId){ |
| | | return this.lambdaQuery().eq(Machine::getEquipmentCode, equipmentCode).ne(excludeId!=null,Machine::getId, excludeId).count()>0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改机床信息 |
| | | * @param vo |
| | | * @return |
| | |
| | | if(existsByCode(vo.getCode(),vo.getId())){ |
| | | throw new ServiceException("机床编码已存在:"+vo.getCode()); |
| | | } |
| | | |
| | | if(existsByEquipmentCode(vo.getEquipmentCode(),vo.getId())){ |
| | | throw new ServiceException("设备编号已存在:"+vo.getEquipmentCode()); |
| | | } |
| | | Machine machine = this.getById(vo.getId()); |
| | | |
| | | Machine machineBak = new Machine(); |
| | |
| | | |
| | | machine.setMachineSpec(vo.getMachineSpec()); |
| | | machine.setCode(vo.getCode()); |
| | | machine.setEquipmentCode(vo.getEquipmentCode()); |
| | | machine.setName(vo.getName()); |
| | | machine.setMachineGroupCode(vo.getMachineGroupCode()); |
| | | machine.setManufacturer(vo.getManufacturer()); |
| | |
| | | if(StringUtils.isBlank(sendPathLine)){ |
| | | return null; |
| | | } |
| | | //去掉首位括号,排除发那科机床注释 |
| | | String sendPath = escapeSqlWildcard(StringUtils.trim(StringUtils.removeEnd(StringUtils.removeStart(sendPathLine,"("),")"))); |
| | | //去掉末尾括号(发那科) ,末尾路径分隔符 |
| | | String tempPath = StringUtils.removeEnd(StringUtils.removeEnd(StringUtils.removeEnd(sendPathLine,")"),"/"),"\\"); |
| | | //去掉前2位可能的注释(*-)。 |
| | | String sendPath = escapeSqlWildcard(StringUtils.trim(StringUtils.substring(tempPath,2))); |
| | | |
| | | List<Machine> machines = lambdaQuery().eq(Machine::getStatus,Machine.STATUS_ENABLE).likeLeft(Machine::getProgSendDir,sendPath).list(); |
| | | List<Machine> machines = lambdaQuery().eq(Machine::getStatus,Machine.STATUS_ENABLE).like(Machine::getProgSendDir,sendPath).list(); |
| | | if(machines.isEmpty()){ |
| | | return null; |
| | | }else{ |
| | | return machines.get(0); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据设备编号查询机床 |
| | | * @param equipmentCode 设备编号 |
| | | * @return 机床对象 |
| | | */ |
| | | public Machine getByEquipmentCode(String equipmentCode) { |
| | | return this.lambdaQuery().eq(Machine::getEquipmentCode, equipmentCode).one(); |
| | | } |
| | | } |