private boolean switchUsi() throws NotFoundException, FileNotFoundException, ClassNotFoundException, IOException, DocumentException, SAXException { this.funcName = this.eventDao.selectFuncName(this.eventNumber); if (null != this.funcName && !this.funcName.isEmpty()) { System.out.println("Func Name:" + this.funcName); String classpath = ConstructorUtil.class.getResource("/").getPath() + PropertyUtil.getHbPjResource(); this.client.sendTaskStartLog(this.taskId, "classpath:" + classpath); boolean loadClassFlag = this.loadClass(this.eventNumber, this.funcName, this.input); if (loadClassFlag) { this.export.put("FUNC_NAME", this.funcName); this.export.put("EVENT_NUMBER", this.eventNumber); this.export.put("USER_ID", this.taskId); this.export.put("FIRST_LOAD", this.input.get("FIRST_LOAD")); this.export.put(FbConstants.FB_PUSH_KEY, this.input.get(FbConstants.FB_PUSH_KEY)); this.export.put(FbConstants.FB_LIMIT, this.input.get(FbConstants.FB_LIMIT)); this.export.put(FbConstants.FB_PATH, this.input.get(FbConstants.FB_PATH)); taskDto.setCompanyId(PropertyUtil.getCompanyId()); dto.setTaskDTO(taskDto); return true; } else { this.client.sendTaskErrorLog(this.taskId, "Class and Table load fail."); return false; } } else { this.client.sendTaskErrorLog( this.taskId, "FUNC_NAME not found. Event Number (" + this.eventNumber + ")"); return false; } }
private void switchOther() throws JCoException, NotFoundException { client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-开始"); JCoUtil ju = new JCoUtil(funcName, destinationName); Map<String, Object> jcoExport = ju.getExport(input); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-完成"); RayCompare rc = new RayCompare(eventNumber, jcoExport); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-Table数据比较-开始"); Map<String, Object> compareExport = rc.compare(String.valueOf(taskDto.getUserId()), taskId, client); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-Table数据比较-完成"); if (rc.isUpdateData()) { export.putAll(compareExport); dto.setData(export); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始"); System.out.println("Sending data...."); client.postData(dto); System.out.println("Send data finish."); client.sendTaskEndLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成"); } else { client.sendTaskLog(taskId, "ID:" + taskId + "的任务-SAP数据没有更新"); client.sendTaskEndLog(taskId, "ID:" + taskId + "的任务-完成"); } }
private void switchTable() throws JCoException, NotFoundException { int size; int loopCount; int count = 0; int rowSkips = 0; int rowCount = input.get("ROWCOUNT") != null ? getInt(input.get("ROWCOUNT").trim()) : defaultMaxCount; int rowMax = input.get("ROWMAX") != null ? getInt(input.get("ROWMAX").trim()) : defaultMaxCount; String[] options = input.get("OPTIONS") != null ? input.get("OPTIONS").split(querySlash + queryDelimiter) : null; JCoRdTB jr = new JCoRdTB(funcName, destinationName); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-开始"); if (rowMax % rowCount > 0) { loopCount = rowMax / rowCount + 1; } else { loopCount = rowMax / rowCount; } String queryTable = input.get("QUERY_TABLE"); List<?> list = jr.getTable(queryTable, rowSkips, rowCount, options); size = list.size(); StructureDao dud = new StructureDao(eventNumber + "_" + queryTable); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-开始Loop(1/" + loopCount + ")"); dud.saveEntityToList(list); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-完成Loop(1/" + loopCount + ")" + size); export.put(queryTable, list); dto.setData(export); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始Loop(1/" + loopCount + ")"); client.postData(dto); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成Loop(1/" + loopCount + ")"); count += size; for (int i = 2; size == rowCount && count < rowMax; i++) { export.remove("FIRST_LOAD"); rowSkips = rowCount * (i - 1); JCoRdTB jr2 = new JCoRdTB(funcName, destinationName); List<?> list2 = jr2.getTable(queryTable, rowSkips, rowCount, options); size = list2.size(); count += size; if (count > rowMax) { List<Object> list3 = new ArrayList<Object>(); for (int j = 0; j < (list2.size() - (count - rowMax)); j++) { list3.add(list2.get(j)); } client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-开始Loop(" + i + "/" + loopCount + ")"); dud.saveEntityToList(list3); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-完成Loop(" + i + "/" + loopCount + ")" + size); export.put(queryTable, list3); dto.setData(export); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始Loop(" + i + "/" + loopCount + ")"); client.postData(dto); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成Loop(" + i + "/" + loopCount + ")"); } else { client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-开始Loop(" + i + "/" + loopCount + ")"); dud.saveEntityToList(list2); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-完成Loop(" + i + "/" + loopCount + ")" + size); export.put(queryTable, list2); dto.setData(export); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始Loop(" + i + "/" + loopCount + ")"); client.postData(dto); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成Loop(" + i + "/" + loopCount + ")"); } } client.sendTaskEndLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成"); }
@SuppressWarnings("unchecked") private void switchEvent() throws JCoException, NotFoundException, UnsupportedEncodingException, InstantiationException, IllegalAccessException { if (input.get("FUNC_NAME") != null) { String eventNumberFlag = eventDao.selectEventNumber(input.get("FUNC_NAME")); if (null == eventNumberFlag) { EventPojo createEvent = eventDao.buildEvent(String.valueOf(taskDto.getUserId()), input.get("FUNC_NAME")); if (null != createEvent && null != createEvent.getEVENT_NUMBER()) { eventNumberFlag = createEvent.getEVENT_NUMBER(); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-创建一个新的Event Number(" + eventNumberFlag + ")"); List<EventPojo> createEvents = new ArrayList<EventPojo>(); createEvents.add(createEvent); export.put("A0001", createEvents); } else { client.sendTaskLog(taskId, "ID:" + taskId + "的任务-创建一个Event Number失败."); } } else { client.sendTaskLog( taskId, "ID:" + taskId + "的任务-Bapi[" + input.get("FUNC_NAME") + "] 对应的Event Number(" + eventNumberFlag + ")已经存在"); } client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-开始"); JCoFuDD job = new JCoFuDD(funcName, destinationName); List<?> list = job.getFUPARAREF(input.get("FUNC_NAME")); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-(FUPARAREF:" + list.size() + ")"); List<?> list2 = job.getDD03L(list); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-(DD03L:" + list2.size() + ")"); List<?> list3 = job.getDD04T(list2); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-(DD04T:" + list3.size() + ")"); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-完成"); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-开始"); new BapiFUPARAREFDao().save((List<BapiFUPARAREFPojo>) list); new BapiDD03LDao().save((List<BapiDD03LPojo>) list2); new BapiDD04TDao().save((List<BapiDD04TPojo>) list3); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-完成,FUPARAREF.size(" + list.size() + "),DD03L.size(" + list2.size() + "),DD04T.size(" + list3.size() + ")"); export.put("FUPARAREF", list); export.put("DD03L", list2); export.put("DD04T", list3); export.put("FUNC_NAME", funcName); export.put("EVENT_NUMBER", eventNumber); dto.setData(export); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始"); client.postData(dto); client.sendTaskEndLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成"); } else if (input.get("TABNAME") != null) { String[] tabNames = input.get("TABNAME").split(querySlash + queryDelimiter); List<Object> list = new ArrayList<Object>(); for (String tabName : tabNames) { BapiFUPARAREFPojo pojo = new BapiFUPARAREFPojo(); pojo.setSTRUCTURE(tabName); list.add(pojo); } client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-开始"); JCoFuDD job = new JCoFuDD(funcName, destinationName); List<?> list2 = job.getDD03L(list); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-(DD03L:" + list2.size() + ")"); List<?> list3 = job.getDD04T(list2); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-(DD04T:" + list3.size() + ")"); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-抽取数据-完成"); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-开始"); new BapiDD03LDao().save((List<BapiDD03LPojo>) list2); new BapiDD04TDao().save((List<BapiDD04TPojo>) list3); client.sendTaskLog( taskId, "ID:" + taskId + "的任务-保存数据到Agent DB-完成,FUPARAREF.size(" + list.size() + "),DD03L.size(" + list2.size() + "),DD04T.size(" + list3.size() + ")"); export.put("DD03L", list2); export.put("DD04T", list3); export.put("FUNC_NAME", funcName); export.put("EVENT_NUMBER", eventNumber); dto.setData(export); client.sendTaskLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-开始"); client.postData(dto); client.sendTaskEndLog(taskId, "ID:" + taskId + "的任务-发送数据到服务器-完成"); } }