Exemplo n.º 1
0
	@Override
	public void run() {
		try {
			if (KKTool.isStrNullOrBlank(sysParams.getPosBinFileDir())) {
				KKLog.info("Not set pos bin file directory");//本地Pos程序存放目录未设置
				return;
			}
	
			File dir = new File(sysParams.getPosBinFileDir());
			if (!dir.exists()) {
				//logger.info("本地Pos程序存放目录未创建");
				dir.mkdir();
				return;
			}
			
			File[] files = dir.listFiles(new KKFileNameFilter("bin"));
			if (files.length == 0) {
				KKLog.info("No pos bin file");//无Pos升级程序
				posBinFile.clearPosBinData();//没有pos机程序文件
			} else {
				File latestFile = null;
				String fileName = null;
				for (File f: files){//buspos_app_xxxx_xxxxxxxx.bin
					fileName = f.getName();
					if (!fileName.matches("taxipos_app_\\d{4}_\\d{8}.bin"))
						continue;
					try {
						Integer.parseInt(fileName.substring(17, 25));
					} catch (Exception e) {
						KKLog.info("Pos bin file name invalid, can't get bin version, pos bin file name must be like 'buspos_app_xxxx_xxxxxxxx.bin'");//pos程序命名不合法,无法识别版本号,参照格式
						continue;
					}
					if (latestFile == null) {
						latestFile = f;
					} else {
						if (latestFile.getName().substring(17, 25).compareTo(f.getName().substring(17, 25)) < 0)
							latestFile = f;
					}
				}
				if (latestFile == null) {
					KKLog.info("No valid pos bin file");//无Pos升级程序
					posBinFile.clearPosBinData();//没有pos机程序文件
				} else {
					posBinFile.loadNewBinData(latestFile);
					posBinFile.setVersion(latestFile.getName().substring(17, 25));
				}
			}
		} catch (Exception e) {
			KKLog.error("Thread Get Pos Bin File Err:" + KKTool.getExceptionTip(e));
		} finally {
			//加载Pos程序成功,程序大小:        程序版本:
			KKLog.info("Pos bin file size:" + posBinFile.getTotalBytes() + ",file version:" + posBinFile.getVersion());
			KKTool.sleepOneMinute();
			Ics.isLoadingPosBinFile = false;		
		}
	}
Exemplo n.º 2
0
	public ThreadGetPosBinFile(PosBinFile posBinFile) {
		this.posBinFile = posBinFile;
		this.sysParams = SysParams.getInstance();
	}