Example #1
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.");
   }
 }
Example #2
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 + "的任务-完成");
   }
 }
Example #3
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 + "的任务-发送数据到服务器-完成");
   }
 }