解决SIDE输出的SAS output时间不对的BUG

可劲儿折腾SIDE,让它不停的跑SAS代码...突然发现每次SAS output中显示的时间都一样,好像都是SAS Server Manager的启动时间。直接在SAS系统上运行可不是这个效果(其实这不是个BUG,SAS系统里面的Output中的时间就是SAS Session启动的时间,而不是执行SAS代码的时间,是我看错了 ...如果想让它显示每次SAS代码的执行时间,可以把它替换掉)

 

我把下列代码改了改:

 

package com.grs.app.side.service;

import com.grs.app.side.domain.SasResultWrapper;
import com.grs.app.slink.facade.ICommandFacade;
import com.grs.app.slink.result.ICommandResult;
import com.grs.app.slink.server.ServerManager;

public class SasService {
	public SasResultWrapper run(String code) throws Exception {
		ServerManager manager = ServerManager.getInstance();
		ICommandFacade facade = manager.getCommandFacade();
		ICommandResult result = facade.doExecBaseCode(code);

		String log = result.getLog();
		
		SasResultWrapper sasResult = new SasResultWrapper();
		sasResult.setRetCode(result.getRetCode());
		sasResult.setRetMsg(result.getRetMsg());
		sasResult.setLog(result.getLog());
		sasResult.setData(result.getData());

		String output = result.getOutput();
		sasResult.setOutput(output);

		return sasResult;
	}
}

 

更新后的代码如下:

package com.grs.app.side.service;

import com.grs.app.side.domain.SasResultWrapper;
import com.grs.app.slink.facade.ICommandFacade;
import com.grs.app.slink.result.ICommandResult;
import com.grs.app.slink.server.ServerManager;

public class SasService {
	public SasResultWrapper run(String code) throws Exception {
		ServerManager manager = ServerManager.getInstance();
		ICommandFacade facade = manager.getCommandFacade();
		ICommandResult result = facade.doExecBaseCode(code);

		String log = result.getLog();
		
		SasResultWrapper sasResult = new SasResultWrapper();
		sasResult.setRetCode(result.getRetCode());
		sasResult.setRetMsg(result.getRetMsg());
		sasResult.setLog(result.getLog());
		sasResult.setData(result.getData());

		String output = result.getOutput();

		// Bug fixed: the date is always when the backend started. Replace it with the current date ==>
//		sasResult.setOutput(output);
		int indexOfNewLine = output.indexOf("\r\n\r\n");
		if (-1 != indexOfNewLine) {
			String part1 = output.substring(0, indexOfNewLine);
			String part2 = output.substring(indexOfNewLine);
			
			part1 = part1.replaceAll("\\d{1,2}:\\d{1,2}\\s\\w+,\\s\\w+\\s\\d+,\\s\\d{4}", new java.text.SimpleDateFormat("HH:mm EEEE, MMMM d, yyyy").format(new java.util.Date()));
			sasResult.setOutput(part1 + part2);
		}
		// Bug fixed: the date is always when the backend started. Replace it with the current date <==
		
		return sasResult;
	}
}

 关键点在于正则表达式

\d{1,2}:\d{1,2}\s\w+,\s\w+\s\d+,\s\d{4}

和时间格式

HH:mm EEEE, MMMM d, yyyy

的使用。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值