| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.service.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.mapper.NcNodeMapper; |
| | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 程序节点 |
| | |
| | | * @param processNo 工序版次 |
| | | * @return 程序包名/程序名称 |
| | | */ |
| | | public static String genProgramName(String drawingNo,String processNo){ |
| | | return drawingNo+"-"+processNo; |
| | | public static String genProgramName(String drawingNo,String processNo,String processEdition){ |
| | | return drawingNo+"-"+processNo+"-"+processEdition; |
| | | } |
| | | |
| | | /** |
| | |
| | | .likeRight(NcNode::getParentIds,"0,2,").eq(NcNode::getIsCured,1) |
| | | .in(!machineCodesInGroup.isEmpty(),NcNode::getMachineCode,machineCodesInGroup) |
| | | .eq(NcNode::getIsLastEdition,1).list(); |
| | | |
| | | if(nodes.isEmpty()){ |
| | | return null; |
| | | }else { |
| | | return nodes.get(0); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取最新的固化程序,不用工序版次匹配 |
| | | * @param programPkgName |
| | | * @param machineCode |
| | | * @return |
| | | */ |
| | | public NcNode getLastCuredProgramPackageWithoutProcessEdition(String programPkgName,String machineCode) { |
| | | Machine machine = machineService.getByCode(machineCode); |
| | | List<Machine> sameGroupMachines = machineService.lambdaQuery().eq(Machine::getMachineGroupCode,machine.getMachineGroupCode()).list(); |
| | | List<String> machineCodesInGroup = sameGroupMachines.stream().map(Machine::getCode).toList(); |
| | | List<NcNode> nodes = lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE) |
| | | .eq(NcNode::getName, programPkgName) |
| | | .likeRight(NcNode::getParentIds,"0,2,").eq(NcNode::getIsCured,1) |
| | | .in(!machineCodesInGroup.isEmpty(),NcNode::getMachineCode,machineCodesInGroup) |
| | | .eq(NcNode::getIsLastEdition,1).orderByDesc(NcNode::getCreateTime).list(); |
| | | |
| | | if(nodes.isEmpty()){ |
| | | return null; |
| | |
| | | return this.lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_FILE) |
| | | .eq(NcNode::getParentId,packageNodeId).eq(NcNode::getIsLastEdition,1).list(); |
| | | } |
| | | |
| | | /** |
| | | * 升级版本号(+1) |
| | | * @param nodeId 节点id |
| | |
| | | this.updateById(node); |
| | | } |
| | | @Transactional |
| | | public void lock(Long id,String remark) { |
| | | NcNode node = this.getById(id); |
| | | node.lock(remark); |
| | | this.updateById(node); |
| | | } |
| | | @Transactional |
| | | public void unlock(Long id) { |
| | | NcNode node = this.getById(id); |
| | | node.unlock(); |
| | | this.updateById(node); |
| | | } |
| | | |
| | | /** |
| | | * 查询偏离单的序号 |
| | | * @param programPkgNode 偏离单的程序包名节点 |
| | | * @return 序号 |
| | | */ |
| | | public long getDeviationSerialForNode(NcNode programPkgNode) { |
| | | return lambdaQuery().eq(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE) |
| | | .eq(NcNode::getName,programPkgNode.getName()) |
| | | |
| | | .eq(NcNode::getDrawingNo,programPkgNode.getDrawingNo()) |
| | | .eq(NcNode::getProcessNo,programPkgNode.getProcessNo()) |
| | | .eq(NcNode::getProcessEdition,programPkgNode.getProcessEdition()) |
| | | |
| | | .isNotNull(NcNode::getDeviation) |
| | | .le(NcNode::getCreateTime,programPkgNode.getCreateTime()) //时间小于等于当前节点 |
| | | .count(); |
| | | } |
| | | |
| | | /** |
| | | * 根据上级节点id,移动下面的加工机床节点 |
| | | * @param parentId 上级节点id |
| | | */ |
| | | public void deleteMachineNodeByParentId(Long parentId) { |
| | | baseMapper.deleteMachineNodeByParentId(parentId); |
| | | } |
| | | } |