Package org.luke.ct.model

Examples of org.luke.ct.model.CarReg


    // 設定5/100的機率下,會去清除過期的資料
    Random random = new Random(System.currentTimeMillis());
    if (random.nextDouble() < 1)
      CleanOutOfDate();

    CarReg cr = cr_service.getDataByID(carID);
    // 該carID已註冊
    if (null != cr) {
      log.info("該carID已註冊");
      String filter = String.format("carID=='%s'", carID);
      List<CarPhoneRandomNumber> list = cprn_service.getPaginationData(filter, "deadTime desc").getResultList();
View Full Code Here


      throw new Error("提供的訊息內容中,carID, title 或 message 字串錯誤 !");
    log.info("get carID = " + carID);
    System.out.println("get carID = " + carID);

    // 檢查carID是否合法
    CarReg cr = cr_service.getDataByID(carID);
    if (null == cr)
      throw new Error("該carID尚未註冊");

    // 找出和該carID連結的phoneID list
    String filter = String.format("carID=='%s'", carID);
View Full Code Here

    // 產生carRegIDList
    List<String> devices = new ArrayList<String>();
    for (PhoneCarPushNotification o : pcpn_list) {
      // 判斷是否傳送過
      if (!o.getIsSend()) {
        CarReg cr = cr_service.getDataByID(o.getCarID());
        devices.add(cr.getRegisterID());
        o.setIsSend(true);
        o.setSendTime(CTCommon.getNowTime());
        pcpn_service.modify(o);
      }
    }
View Full Code Here

  @ApiMethod(name = "cppn.send", httpMethod = HttpMethod.POST)
  public JSONObject postCPPushNotificationSend(@Named("carID") String carID, @Named("messageID") String messageID) {
    JSONObject retJson = null;
    // 檢查carID是否合法
    CarReg cr = cr_service.getDataByID(carID);
    if (null == cr)
      throw new Error("該carID尚未註冊");

    // 找出和該carID連結的message
    String filter = String.format("carID=='%s' && messageID=='%s'", carID, messageID);
View Full Code Here

    PhoneReg pr = pr_service.getDataByID(phoneID);
    if (null == pr)
      throw new Error("該phoneID尚未註冊");

    // 檢查carID是否合法
    CarReg cr = cr_service.getDataByID(carID);
    if (null == cr)
      throw new Error("該carID尚未註冊");

    // 找出和該phoneID連結的carID list
    String filter = String.format("phoneID=='%s' && carID=='%s'", phoneID, carID);
View Full Code Here

    int i = 0;
    log.info("count=" + list.size());
    for (CarReg o : list) {
      log.info("index:" + (++i) + ", CarReg=" + JSON.toJSONString(o));
    }
    CarReg reg = cr_service.getDataByID(id);
    return reg;
  }
View Full Code Here

    return cr_service.getPaginationData().getResultList();
  }

  @ApiMethod(name = "creg.merge", httpMethod = HttpMethod.POST)
  public CarReg postCarRegisterMerge(CarReg cr, HttpServletRequest req) {   
    CarReg retCR = null;
    // check deviceID, appVersion
    if (StringUtils.isNotBlank(cr.getDeviceID()) && StringUtils.isNotBlank(cr.getAppVersion())) {
      String dateStr = CTCommon.getNowTime();
      String filter = String.format("deviceID=='%s' && appVersion=='%s'", cr.getDeviceID(), cr.getAppVersion());
      QueryResult<CarReg> qr = cr_service.getPaginationData(filter);
      // 第一次註冊,新增資料
      if (qr.getTotalRecord() == 0) {
        retCR = new CarReg();
        retCR.setAddTime(dateStr);
        retCR.setAppVersion(cr.getAppVersion());
        retCR.setDeviceID(cr.getDeviceID());
        retCR.setDeviceIP(req.getRemoteAddr());
        retCR.setModTime(dateStr);
        retCR.setRegisterID(cr.getRegisterID());
        retCR.setSenderID(cr.getSenderID());
        cr_service.add(retCR);
        log.info("新增一筆設備註冊記錄:" + JSON.toJSONString(retCR));
      } else if (qr.getTotalRecord() == 1) {
        retCR = qr.getResultList().get(0);
        retCR.setAppVersion(cr.getAppVersion());
        retCR.setDeviceID(cr.getDeviceID());
        retCR.setDeviceIP(req.getRemoteAddr());
        retCR.setModTime(dateStr);
        retCR.setRegisterID(cr.getRegisterID());
        retCR.setSenderID(cr.getSenderID());
        cr_service.modify(retCR);
        log.info("修改一筆設備註冊記錄:" + JSON.toJSONString(retCR));
      } else {
        log.severe("設備記錄數目異常,不處理");
      }
View Full Code Here

  @ApiMethod(name = "image_upload_url", httpMethod = HttpMethod.POST)
  public JSONObject postCTUploadURL(@Named("devID") String devID) {
    JSONObject retJson = null;
    // 檢查是否為合法的carID
    CarReg cr = cr_service.getDataByID(devID);
    if (null == cr) {
      // 檢查是否為合法的phoneID
      PhoneReg pr = pr_service.getDataByID(devID);
      if (null == pr)
        throw new Error("提供的ID尚未註冊, devID = " + devID);
View Full Code Here

      sendError(res, "mySerial必須是數字");
      return;
    }

    // 檢查是否為合法的carID
    CarReg cr = null;
    PhoneReg pr = null;
    cr = cr_service.getDataByID(devID);
    if (null == cr) {
      // 檢查是否為合法的phoneID
      pr = pr_service.getDataByID(devID);
      if (null == pr) {
        sendError(res, "提供的ID尚未註冊, devID = " + devID);
        return;
      }
    }

    List<BlobKey> blobs = blobstoreService.getUploads(req).get("myFile");
    BlobKey blobKey = blobs.get(0);
    if (null == blobKey) {
      sendError(res, "無法正常儲存上傳的檔案");
      return;
    }

    ImagesService imagesService = ImagesServiceFactory.getImagesService();
    ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);

    String servingUrl = imagesService.getServingUrl(servingOptions);

    res.setStatus(HttpServletResponse.SC_OK);
    res.setContentType("application/json");

    // 二種方式都能存取上傳的圖檔
    JSONObject json = new JSONObject();
    // json.put("serving_url", servingUrl);
    // json.put("blob_key", blobKey.getKeyString());
    // json.put("direct_url", "/serve?blob_key=" + blobKey.getKeyString());

    // 儲存在db的動作
    DeviceUpload du = new DeviceUpload();
    du.setDevID(devID);
    du.setMySerial(mySerial);
    du.setServing_url(servingUrl);
    du.setBlob_key(blobKey.getKeyString());
    du.setAddTime(CTCommon.getNowTime());
    du_service.add(du);
    log.info("新增一筆設備上傳記錄:" + JSON.toJSONString(du));

    // 直接新增message info到db
    // 並直接把message content發給相關的devices
    JSONObject retJson = new JSONObject();
    CarTracePushNotificationAPI ctpn_api = new CarTracePushNotificationAPI();
    if (null != cr) {
      String carID = cr.getEncodedKey();
      String title = "設備上傳記錄";
      String message = String.format("設備於%s上傳圖片", du.getAddTime());
      JSONObject rowdata = new JSONObject();
      rowdata.put("carID", carID);
      rowdata.put("addTime", du.getAddTime());
View Full Code Here

TOP

Related Classes of org.luke.ct.model.CarReg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.