| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 流程程序处理,包括上传,查询展示 |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 验证程序文件的完整性,仅在编制节点使用 |
| | | * @param processInstanceId 流程实例id |
| | | */ |
| | | public void checkProgramFiles(String processInstanceId,boolean isPass) { |
| | | List<FlowProgramFile> flowPrograms = this.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, processInstanceId).orderByAsc(FlowProgramFile::getCreateTime).list(); |
| | | if(isPass && flowPrograms.isEmpty()){ |
| | | throw new ServiceException("请上传程序文件"); |
| | | } |
| | | int totalSeg = 0; |
| | | if(!flowPrograms.isEmpty()){ |
| | | FlowProgramFile progFile = flowPrograms.get(0); |
| | | totalSeg = getProgramSegCount(progFile.getName()); |
| | | } |
| | | |
| | | if(totalSeg != flowPrograms.size()){ |
| | | throw new ServiceException("应上传"+totalSeg+"段程序,实际上传"+flowPrograms.size()+"段"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据文件名获取程序总段树 |
| | | * @param filename 文件名 |
| | | * @return |
| | | */ |
| | | int getProgramSegCount(String filename){ |
| | | int idx = filename.lastIndexOf("."); |
| | | String tempstr = filename.substring(0,idx);//去掉扩展名 |
| | | //System.out.println(tempstr); |
| | | idx = tempstr.lastIndexOf("-"); |
| | | tempstr = tempstr.substring(0,idx); |
| | | //System.out.println(tempstr); |
| | | idx = tempstr.lastIndexOf("-"); |
| | | tempstr = tempstr.substring(idx+1); |
| | | //System.out.println(tempstr); |
| | | return Func.toInt(tempstr); |
| | | } |
| | | } |