|
|
package com.platform.controller;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.base.BaseController;
|
|
|
import com.platform.entities.oracleForm;
|
|
|
import com.platform.service.ILogRead;
|
|
|
import com.platform.service.IOracleExtractService;
|
|
|
import com.platform.service.thread.ThreadExtractOracle;
|
|
|
import com.platform.service.thread.ThreadGainOracleConnect;
|
|
|
import com.platform.utils.Configs;
|
|
|
|
|
|
/** oracle相关业务
|
|
|
* @author chen
|
|
|
*
|
|
|
*/
|
|
|
@Controller
|
|
|
public class OracleController extends BaseController {
|
|
|
|
|
|
@Resource(name = "OracleExtract")
|
|
|
private IOracleExtractService OracleExtract;
|
|
|
|
|
|
@Resource(name = "logReadService")
|
|
|
private ILogRead logReadService;
|
|
|
|
|
|
@RequestMapping(value = "/oracle/{name}/StandardExtract", method = RequestMethod.POST)
|
|
|
public void oracleStandardExtract(HttpServletRequest res, HttpServletResponse req,
|
|
|
@RequestBody oracleForm form) throws Exception {
|
|
|
Configs.CONSOLE_LOGGER.error("/oracle/{name}/StandardExtract");
|
|
|
// res.setCharacterEncoding("UTF-8");
|
|
|
boolean isConnect = false;
|
|
|
//5秒内是否能获得oracle连接,否则认为超时。
|
|
|
if (null != form.getTarget()) {
|
|
|
ThreadGainOracleConnect thOrcl = new ThreadGainOracleConnect(form, OracleExtract);
|
|
|
thOrcl.start();
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
Thread.sleep(400);
|
|
|
isConnect = thOrcl.isConnect();
|
|
|
if (isConnect) {
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
if (thOrcl.isExcept()) {
|
|
|
break;
|
|
|
}
|
|
|
Thread.sleep(100);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (isConnect)
|
|
|
req.setStatus(200);
|
|
|
else
|
|
|
req.setStatus(500);
|
|
|
// 开始抽取数据到汇总库
|
|
|
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
|
|
|
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
|
|
|
thExtra.start();
|
|
|
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
|
|
|
// form.getTarget());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** 读取抽取的日志,包括sqlserver,oracle
|
|
|
* @param name
|
|
|
* @param res
|
|
|
* @param req
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@RequestMapping(value = "/StandardExtract/log", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public Object getStandardExtractLog(@RequestParam("rcName") String name,
|
|
|
HttpServletRequest res, HttpServletResponse req) throws Exception {
|
|
|
Configs.CONSOLE_LOGGER.info("/oracle/StandardExtract/log");
|
|
|
String result = logReadService.readStandardLog(name);
|
|
|
// StringBuilder sb = new StringBuilder();
|
|
|
// sb.append("查看相应日志").append("\n").append("看到了");
|
|
|
Map<String, String> log = new HashMap<>();
|
|
|
log.put(name, result);
|
|
|
return log;
|
|
|
}
|
|
|
}
|