yangys
2025-09-17 ee6af8dff591418168d5104d281a6f0bf3c961e8
blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/ReceiveFileCheckService.java
@@ -5,6 +5,7 @@
import org.springblade.core.log.exception.ServiceException;
import org.springblade.mdm.basesetting.machine.entity.Machine;
import org.springblade.mdm.basesetting.machine.service.MachineService;
import org.springblade.mdm.commons.contants.RegExpConstants;
import org.springblade.mdm.commons.service.ParamService;
import org.springblade.mdm.gkw.programnode.vo.ProgramNameVO;
import org.springblade.mdm.machinefile.entity.FileSendRecord;
@@ -31,6 +32,7 @@
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
@Slf4j
@Component
@@ -59,10 +61,13 @@
            //非文本
            machineFile.setExceptionType(MachineFile.EXCEPTION_NOT_TEXT);
         }else{
            ProgramNameVO progNameVO =  ProgramFileNameParser.parseProgramName(machineFile.getName());
            if(!progNameVO.isValidFilename()){
            Matcher matcher = RegExpConstants.PROGRAM_FILE_PATTERN.matcher(machineFile.getName());
            boolean filenameValid = matcher.find();
            if(!filenameValid){
               machineFile.setExceptionType(MachineFile.EXCEPTION_BAD_FILENAME);
            }else {
               ProgramNameVO progNameVO =  ProgramFileNameParser.parseProgramName(machineFile.getName());
               String prefix = progNameVO.logicProgramName()+"-";
               long matchCount = allFilesInDir.stream().filter(file -> file.getName().startsWith(prefix)).count();
               if(matchCount != progNameVO.getSegmentCount()){//文件段数缺失