示例#1
0
  public int update(int oid, String quantity, String memo) { // 更新揀貨單的揀貨數量
    logger.debug(
        "OrderPlaceDDAO.update: "
            + "pickId: "
            + oid
            + ", quantity: "
            + quantity
            + ", memo: "
            + memo);

    EntityManager em = XPersistence.getManager();
    OrderPlaceD bean = em.find(OrderPlaceD.class, oid);
    logger.debug("OrderPlaceD.update: orderPlaceD: " + bean);
    if (bean != null) {
      //			bean.setQuantity(quantity);
      bean.setRemark(memo);
      try {
        em.merge(bean);
        XPersistence.commit();
      } catch (Exception e) {
        logger.error("OrderPlaceD.update: " + e);
      }
      return 1; // 1:成功
    }
    return 0; // 0:失敗
  }
示例#2
0
  public Long getCatchSize(Long channelId, String startDate, String endDate) {
    Long size = 0L;

    Connection conn = null;
    PreparedStatement pst = null;
    ResultSet rs = null;

    try {
      conn = OracleUtil.getConnection();
      pst =
          conn.prepareStatement(
              "select nvl(sum(a.log_catch_count),0) from twap_app_log_webcrawler a where exists(select 1 from twap_public_channel b where a.log_channel_id = b.channel_id start with b.channel_id=? connect by prior b.channel_id=b.channel_pid) and (to_char(a.create_time,'yyyy-mm-dd')<=? and to_char(a.create_time,'yyyy-mm-dd')>=?)");
      pst.setLong(1, channelId);
      pst.setString(3, startDate);
      pst.setString(2, endDate);
      rs = pst.executeQuery();
      if (rs.next()) size = rs.getLong(1);
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e);
    } finally {
      close(conn, pst, rs);
    }

    return size;
  }
示例#3
0
  public Map<String, String> getCatchSizeList(Long channelId) {
    Map<String, String> map = null;
    Connection conn = null;
    PreparedStatement pst = null;
    ResultSet rs = null;

    try {
      List<Channel> list = new ChannelDao().getChannels(channelId);
      if (list != null && !list.isEmpty()) {
        conn = OracleUtil.getConnection();
        map = new HashMap<String, String>();
        String sql =
            "select nvl(sum(a.log_catch_count),0) from twap_app_log_webcrawler a where exists(select 1 from twap_public_channel b where a.log_channel_id = b.channel_id start with b.channel_id=? connect by prior b.channel_id=b.channel_pid) and (to_char(a.create_time,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd') )";
        for (Channel channel : list) {
          pst = conn.prepareStatement(sql);
          pst.setLong(1, channel.getChannelId());
          log.debug(sql.replaceAll("\\?", channel.getChannelId().toString()));
          rs = pst.executeQuery();
          if (rs.next()) {
            map.put(channel.getChannelName(), String.valueOf(rs.getLong(1)));
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e);
    } finally {
      close(conn, pst, rs);
    }

    return map;
  }
示例#4
0
 // TODO this requires redesign for writables
 public static boolean perform(WebHandle handle, WebDriver driver) {
   WebElement we = handle.findElement(driver);
   if (we == null) {
     // TODO this place strongly interferes with driver's implicitly wait. So, I think, personal
     // fails counter per handle needed.
     log.error(
         handle.url.graphUrl()
             + " | "
             + handle.xpath
             + "\n"
             + "Unable to .perform(WebDriver), cause search of element by stored selector is failed.");
     return false;
   }
   if (!we.isDisplayed() || !we.isEnabled()) {
     log.error(
         handle.url.graphUrl()
             + " | "
             + handle.xpath
             + "\n"
             + "Failed to .perform(WebDriver), cause element not displayed or not enabled.");
     return false;
   }
   switch (handle.eltype) {
     case clickable:
       we.click();
       break;
       //            case writable: we.sendKeys(context); break;
     case terminal:
       if (handle.isRoot()) return true;
       assert false : "terminal elements was touched";
       break;
     default:
       assert false : "this shouldn't have happened???";
       break;
   }
   return true;
 }
示例#5
0
  public List<AppLog> getAppLogList(Long channelId, String startDate, String endDate) {
    List<AppLog> list = null;

    Connection conn = null;
    PreparedStatement pst = null;
    ResultSet rs = null;

    try {
      conn = OracleUtil.getConnection();
      pst =
          conn.prepareStatement(
              "select rownum row_num,a.log_message,(select channel_name from twap_public_channel t where t.channel_id = a.log_channel_id) channel_name,a.log_channel_id,a.log_url,a.log_catch_count,to_char(a.create_time,'yy/mm/dd hh24:mi:ss') create_time  from twap_app_log_webcrawler a where exists(select 1 from twap_public_channel b where a.log_channel_id = b.channel_id start with b.channel_id=? connect by prior b.channel_id=b.channel_pid) and (to_char(a.create_time,'yyyy-mm-dd')<=? and to_char(a.create_time,'yyyy-mm-dd')>=?) order by a.create_time desc");
      pst.setLong(1, channelId);
      pst.setString(3, startDate);
      pst.setString(2, endDate);
      rs = pst.executeQuery();
      list = new ArrayList<AppLog>();
      while (rs.next()) {
        AppLog appLog =
            new AppLog(
                rs.getString("log_message"),
                rs.getLong("log_channel_id"),
                rs.getString("log_url"),
                rs.getLong("log_catch_count"));
        appLog.setChannelName(rs.getString("channel_name"));
        appLog.setCreateTime(rs.getString("create_time"));
        appLog.setLogId(rs.getLong("row_num"));
        list.add(appLog);
      }
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e);
      rollback(conn);
    } finally {
      close(conn, pst, rs);
    }

    return list;
  }