| | |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.api.IResultCode; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.commons.contants.RegExpConstants; |
| | | import org.springblade.mdm.flow.service.FlowProgramProperties; |
| | | import org.springblade.mdm.gkw.programnode.vo.ProgramNameVO; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | |
| | | import java.util.regex.Matcher; |
| | | |
| | | public class ProgramFileNameParser { |
| | | /** |
| | |
| | | */ |
| | | public static ProgramNameVO parseProgramName(String filename){ |
| | | ProgramNameVO pname = new ProgramNameVO(); |
| | | int idx = filename.lastIndexOf("."); |
| | | String tempstr = filename.substring(0,idx);//去掉扩展名 |
| | | |
| | | idx = tempstr.lastIndexOf("-"); |
| | | Matcher matcher = RegExpConstants.PROGRAM_FILE_PATTERN.matcher(filename); |
| | | if(matcher.find()){ |
| | | pname.setDrawingNo(matcher.group(1)); |
| | | pname.setProcessNo(matcher.group(2)); |
| | | |
| | | if(idx != -1){ |
| | | |
| | | String segNo = tempstr.substring(idx+1); |
| | | int idx2 = StringUtils.indexOfIgnoreCase(segNo,"P"); |
| | | if(idx2!= -1){ |
| | | //带P,是偏离单号 |
| | | pname.setPldPart(segNo.substring(idx+1)); |
| | | |
| | | tempstr = segNo.substring(0, idx2);//去掉偏离单部分 |
| | | } |
| | | idx = tempstr.lastIndexOf("-"); |
| | | if(idx != -1) { |
| | | idx = tempstr.lastIndexOf("-"); |
| | | pname.setSegmentNo(Func.toInt(segNo)); |
| | | |
| | | tempstr = tempstr.substring(0,idx); |
| | | } |
| | | |
| | | |
| | | } |
| | | idx = tempstr.lastIndexOf("-"); |
| | | if(idx != -1){ |
| | | String seg = tempstr.substring(idx+1); |
| | | pname.setSegmentCount(Func.toInt(seg)); |
| | | tempstr = tempstr.substring(0,idx); |
| | | pname.setProcessEdition(matcher.group(3)); |
| | | pname.setSegmentCount(Func.toInt(matcher.group(4))); |
| | | pname.setSegmentNo(Func.toInt(matcher.group(5))); |
| | | pname.setLgPart(matcher.group(6)); |
| | | } |
| | | |
| | | //解析工序版次 |
| | | idx = tempstr.lastIndexOf("-"); |
| | | if(idx != -1){ |
| | | String processEdition = tempstr.substring(idx+1); |
| | | pname.setProcessEdition(processEdition); |
| | | tempstr = tempstr.substring(0,idx); |
| | | } |
| | | |
| | | //解析工序号 |
| | | String processNo = ""; |
| | | idx = tempstr.lastIndexOf("-"); |
| | | if(idx != -1){ |
| | | processNo = tempstr.substring(idx+1); |
| | | tempstr = tempstr.substring(0,idx); |
| | | } |
| | | pname.setProcessNo(processNo); |
| | | pname.setDrawingNo(tempstr); |
| | | return pname; |
| | | } |
| | | |