예제 #1
0
 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;
   }
 }
예제 #2
0
 public void triggers(TaskDTO taskDto) {
   this.taskDto = taskDto;
   this.eventNumber = taskDto.getEventType();
   if (null != this.eventNumber && !this.eventNumber.isEmpty()) {
     try {
       this.taskId = taskDto.getId().toString();
       this.input = Utils.parasToMap(taskDto.getInputParas());
       this.client.sendTaskStartLog(
           this.taskId, "ID:" + this.taskId + "的任务-开始执行" + this.input.toString());
       destinationName = this.input.get("SAP_SYSTEM") + "_" + this.taskDto.getUserId();
       ThreadLocalUtil.setTaskDTO(
           this.eventNumber,
           String.valueOf(taskDto.getUserId()),
           taskDto.getInputParas(),
           String.valueOf(taskDto.getId()),
           String.valueOf(taskDto.getRunId()));
       if ("A0001".equals(this.eventNumber)) {
         this.switchConnJCo();
       } else if ("E0000".equals(this.eventNumber)) {
         if (this.switchUsi()) {
           this.switchEvent();
         }
       } else if ("E0015".equals(this.eventNumber)) {
         if (this.switchUsi()) {
           this.switchTable();
         }
       } else {
         if (this.switchUsi()) {
           this.switchOther();
         }
       }
     } catch (JCoException
         | NotFoundException
         | InstantiationException
         | IllegalAccessException
         | ClassNotFoundException
         | IOException
         | DocumentException
         | SAXException ex) {
       Logger.getLogger(EventMdl.class.getName()).log(Level.SEVERE, null, ex);
       String errorMessage = ex.getMessage();
       this.client.sendTaskErrorLog(
           this.taskId,
           "ID:"
               + this.taskId
               + ","
               + (errorMessage.length() > 200 ? errorMessage.substring(0, 200) : errorMessage));
     }
   } else {
     this.client.sendTaskErrorLog(this.taskId, "Event Number is null.");
   }
 }
예제 #3
0
 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 + "的任务-完成");
   }
 }
예제 #4
0
 @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 + "的任务-发送数据到服务器-完成");
   }
 }