Ejemplo n.º 1
0
  @Override
  public String execute(String data) {
    String json = "";
    String txCode = "";
    String status = "";
    SystemRequestVo req = null;
    SystemResponseVo resp = new SystemResponseVo();
    Gson gson = new Gson();
    // logger.debug("execute entry +++++++++++++++++++++");

    try {
      json = data;
      // logger.debug("json:" + json);

      // JSON轉換成物件
      if (!StringTK.isEmpty(json)) {
        req = (SystemRequestVo) gson.fromJson(json, SystemRequestVo.class);
      }

      // 取得交易代碼
      RequestTranslet reqTranslet = getRequestTranslet();

      // 取得交易代碼
      txCode = reqTranslet.getTxcode();
      SystemTranslet sys = new SystemTranslet(this);

      if (StringTK.equals(txCode, ApplicationConstant.TX_CODE_SYSTEM_SYNC)) {
        resp = sys.sync(req);
      } else {
        throw new Exception("交易代碼錯誤");
      }

      setToken(reqTranslet.getToken());

    } catch (Exception e) {
      logger.error("Error:" + e);
      status = e.getMessage();
      if (NullTK.isNull(resp)) {
        resp = new SystemResponseVo();
      }
      resp.setStatus(status);
    } finally {

    }

    // 轉換回傳物件為json
    json = gson.toJson(resp);
    // logger.debug("json:\n" + json);

    return json;
  }
Ejemplo n.º 2
0
  public static PluginServiceInterface buildService(String servicename) {
    PluginServiceInterface instance = null;
    try {
      PluginsDao dao = new PluginsDao(environment);
      PluginsVo vo = dao.find(servicename);
      if (NullTK.isNull(vo)) {
        return null;
      }
      String classname = vo.getClassname();
      instance = (PluginServiceInterface) Class.forName(classname).newInstance();
    } catch (Exception e) {
      logger.error("PluginsManager Error:" + e.getMessage());
    }

    return instance;
  }
Ejemplo n.º 3
0
  /**
   * 根據id刪除主專案
   *
   * @return boolean 成功或失敗
   */
  public boolean deletePrjInfo(long id) {
    SqlSession session = null;
    boolean status = false;
    int cnt = 0;
    try {
      session = getSession(false);

      Project_subsetVo psVo = new Project_subsetVo();
      ProjectSubsetDao psDao = new ProjectSubsetDao(getDataSourceEnvironment());
      List<Project_subsetVo> psList = null;
      // 根據主專案id先取得所屬子專案資料
      psList = psDao.findByPrjId(id);

      Project_aggregateVo paVo = new Project_aggregateVo();
      ProjectAggregateDao paDao = new ProjectAggregateDao(getDataSourceEnvironment());

      if (!NullTK.isNull(psList)) {
        for (Project_subsetVo d : psList) {
          List<Project_aggregateVo> paList = null;
          View_project_aggregateVo rvo = new View_project_aggregateVo();
          // 根據子專案id取得所屬銷售組合之資料
          paList = paDao.findBySubsetId(d.getId());
          for (Project_aggregateVo dd : paList) {
            // 根據銷售組合資料刪除所屬的費率與佣金資料
            cnt = session.delete("rates.deleteById", dd.getRateid());
            cnt = session.delete("commission.deleteById", dd.getComissionid());
          }
          // 根據子專案id刪除所屬隻銷售組合資料
          cnt = session.delete("projectAggregate.deleteBySubsetId", d.getId());
        }
        cnt = session.delete("projectSubset.deleteByPrjId", id);
      }
      cnt = session.delete("project.deleteById", id);

      session.commit();
      if (cnt > 0) {
        status = true;
      }
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      session.rollback();
    } finally {
      closeCoonnection(session);
    }
    return status;
  }
  public ProjectCommissionResponseVo listBySubPrjId(ProjectCommissionRequestVo vo) {

    ProjectCommissionResponseVo resp = new ProjectCommissionResponseVo();

    String txStatus = "";
    // boolean chk = false;

    try {
      // logger.debug("listBySubPrjId entry=======================");
      //			logger.debug("ProjectCommissionRequestVo vo:" + vo);

      CommissionDao dao = new CommissionDao();
      //			CommissionVo data = CommisssionTK.findCommissionById(vo.getId());
      List<View_project_commissionVo> list = dao.viewListBySubPrjId(vo.getSubsetid());
      //			List<CommissionVo> list = CommisssionTK.findCommissionByRatesId(vo.getRatesid());

      if (NullTK.isNull(list)) {
        logger.debug("Commission of Project is not exist");
        txStatus = "傭金資料不存在";
        logger.warn(txStatus);
        throw new Exception(txStatus);
      } else {
        resp.setTxCode(vo.getTxCode());
        resp.setData(list);
        resp.setTxStatus(ApplicationConstant.TX_SUCCESS); // 設定交易成功狀態
      }

    } catch (Exception e) {
      txStatus = e.getMessage();
      logger.error(e.getMessage());
      resp.setTxStatus(txStatus);
    } finally {

    }

    return resp;
  }
  @Override
  public String execute(String data) {
    String json = "";
    String txCode = "";
    String status = "";
    UserRoleDataRequestVo req = null;
    UserRoleDataResponseVo resp = new UserRoleDataResponseVo();
    Gson gson = new Gson();

    try {
      json = data;
      logger.debug("json:" + json);

      if (StringTK.isEmpty(json)) {
        throw new Exception("ES002:訊息內容異常");
      }

      // JSON轉換成物件
      if (!StringTK.isEmpty(json)) {
        req = (UserRoleDataRequestVo) gson.fromJson(json, UserRoleDataRequestVo.class);
      }

      // 取得交易代碼
      txCode = req.getTxCode();
      UserRoleDataTranslet translet = null;

      logger.debug("getTxCode:" + req.getTxCode());
      logger.debug("getCid:" + req.getCid());

      switch (txCode) {
        case ApplicationConstant.TX_CODE_DATA_USERROLE_LIST:
          // checkSession();
          translet = new UserRoleDataTranslet(this);
          resp = translet.list(req);
          break;
        case ApplicationConstant.TX_CODE_DATA_USERROLE_LIST_ALL:
          // checkSession();
          translet = new UserRoleDataTranslet(this);
          resp = translet.listAll(req);
          break;
        case ApplicationConstant.TX_CODE_DATA_USERROLE_UPDATE:
          checkSession();
          translet = new UserRoleDataTranslet(this);
          resp = translet.update(req);
          break;

        default:
          throw new Exception("EN003:交易代碼錯誤");
      }

    } catch (Exception e) {
      logger.error("Error:" + e);
      status = e.getMessage();
      if (NullTK.isNull(resp)) {
        resp = new UserRoleDataResponseVo();
      }
      resp.setTxStatus(status);
    } finally {

    }

    // 轉換回傳物件為json
    if (!NullTK.isNull(resp)) {
      json = gson.toJson(resp);
    }
    logger.debug("json:\n" + json);
    return json;
  }
Ejemplo n.º 6
0
  /**
   * @param csv 匯入核心
   * @throws Exception
   */
  public void doImport(List<String[]> csv) throws Exception {
    try {

      initResource();

      String eorderno = "";
      String strProject = "";
      String imei = "";
      String itemno = "";
      String bcode = "";
      String cost = "";
      // String strStatus = "";
      // String issuestatus = "";
      int status = 0; // 0-未啟用 1-已啟用 2-作業處理中
      // FetOrderImeiCollection orderList = null;
      FetorderVo order = null;
      FetorderitemVo item = null;
      int imeiCount = 0;
      boolean isProject = false;
      List<FetimeiVo> imeiList = new ArrayList<FetimeiVo>();
      FetimeiVo fetimei = null;
      FetimeiitemVo fetimeiitem = null;
      int errOrderNotExistCount = 0;
      // int itemnoChangeCnt = 0;
      // FetimeihistoryVo imeiHistVo = null;

      // 產生IMEI 清單與匯入 IMEI進貨明細表
      List<FetorderimeiVo> imeilist = buildImeiCollection(csv);
      String key = "";
      String msg = "";
      // String oldItemno = "";
      // String newItemno = "";
      // 轉檔IMEI主檔 產生訂單彙總
      for (FetorderimeiVo imeivo : imeilist) {
        isProject = false;
        eorderno = imeivo.getEorderno();
        logger.info("EOrder No: " + eorderno);
        order = isOrderExist(eorderno);

        // 對應訂單是否存在
        if (NullTK.isNull(order)) {
          msg = "/查無訂單主檔 電子訂單編號:" + imeivo.getEorderno() + "/料號:" + imeivo.getItemno();
          logger.warn(msg);
          importmemo.append(msg + "\n");
          errOrderNotExistCount++;
          continue;
          // throw new Exception(msg);
        }

        // 查詢ITEM項目是否為專案機,以 電子訂單編號與料號抓取。
        key = imeivo.getEorderno() + imeivo.getItemno();
        item = isOrderItemExist(key);
        if (NullTK.isNull(order)) {
          msg = "/查無訂單明細主檔 電子訂單編號:" + imeivo.getEorderno() + "/料號:" + imeivo.getItemno();
          logger.warn(msg);
          importmemo.append(msg + "\n");
          errOrderNotExistCount++;
          // throw new Exception(msg);
          continue;
        }

        strProject = item.getSp();
        isProject = StringTK.equals("專", strProject) ? true : false;
        bcode = imeivo.getBcode();
        imei = imeivo.getImei();
        itemno = imeivo.getItemno();
        cost = Integer.toString(item.getPrice());
        status = imeivo.getStatus();

        // 回寫 訂單明細 店碼
        if (StringTK.isEmpty(order.getBcode())) {
          order.setBcode(bcode);
          orderDao.updateBCode(order);
          orderCache.put(eorderno, order);
        }

        // 專案機拋到 IMEI 主檔清單
        if (isProject) {
          fetimei = new FetimeiVo();
          fetimei.setImei(imei);
          fetimei.setItemno(itemno);
          fetimei.setEorderno(eorderno);
          fetimei.setBcode(bcode);
          fetimei.setCost(Integer.parseInt(cost));
          fetimei.setStatus(status);
          imeiList.add(fetimei);
        }
      }

      // IMEI主檔拋轉匯入
      logger.info("Import IMEI  ");
      for (FetimeiVo iv : imeiList) {
        // 檢查是否存在
        imei = iv.getImei();
        fetimei = fetimeiCache.get(imei);
        if (NullTK.isNull(fetimei)) {
          fetimei = iv;
          logger.info(">>>fetimei null");
          fetimeiDao.insert(fetimei);
          fetimeiCache.put(imei, fetimei);
        } else {
          fetimei.setCost(iv.getCost());
          if (fetimei.getStatus() != 1) { // 已啟用保留狀態
            fetimei.setStatus(status);
          }

          // 促代異動變更 料號紀錄
          /*oldItemno = fetimei.getItemno();
          newItemno = iv.getItemno();
          if(!StringTK.equals(oldItemno, newItemno)) {
          	logger.info(">>>IMEI拋轉促代異動 " + oldItemno + " => " + newItemno);
          	importmemo.append(">>>IMEI拋轉促代異動 " + oldItemno + " => " + newItemno);
          	imeiHistVo = new FetimeihistoryVo();
          	imeiHistVo.setImei(imei);
          	imeiHistVo.setItemno(oldItemno);
          	imeiHistDao.insert(imeiHistVo);

          	fetimei.setItemno(newItemno);
          	fetimeiDao.update(fetimei);
          	fetimeiCache.put(imei, fetimei);
          	itemnoChangeCnt++;
          }*/
        }

        // IMEI細項主檔匯入
        logger.debug("IMEI細項主檔匯入");
        fetimeiitem = fetimeiItemCache.get(imei);
        if (NullTK.isNull(fetimeiitem)) {
          fetimeiitem = new FetimeiitemVo();
          fetimeiitem.setImei(imei);
          fetimeiitem.setItemno(fetimei.getItemno());
          fetimeiItemDao.insert(fetimeiitem);
          fetimeiItemCache.put(imei, fetimeiitem);
        }

        imeiCount++;
      }

      logger.info("IMEI主檔拋轉共 " + imeiCount + " 筆");
      // logger.info("IMEI主檔拋轉促代異動共 " + itemnoChangeCnt + " 筆");
      importmemo.append("IMEI主檔拋轉共 " + imeiCount + " 筆\n");
      // importmemo.append("IMEI主檔拋轉促代異動共 " + itemnoChangeCnt + " 筆\n");

    } catch (Exception e) {
      logger.error("FetImeiImporter: doImport err:" + e);
      throw e;
    }
  }
Ejemplo n.º 7
0
  /**
   * @param csv
   * @return List<FetorderimeiVo>
   * @throws Exception
   */
  private List<FetorderimeiVo> buildImeiCollection(List<String[]> csv) throws Exception {
    List<FetorderimeiVo> list = new ArrayList<FetorderimeiVo>();
    FetorderimeiVo imeivo = null;
    int imeiCount = 0;

    try {
      String area = "";
      String bcode = "";
      String storename = "";
      String orderdate = "";
      String eorderno = "";
      String itemno = "";
      String itemname = "";
      String imei = "";
      String sender = "";
      String strStatus = "";
      int status = 1;

      FieldObject fo = null;
      FetOrderImeiFormat orderFields = new FetOrderImeiFormat();

      // 以訂單編號查詢存在訂單檔案
      for (String[] ss : csv) {
        fo = orderFields.getField(FetOrderImeiFormat.Fields.AREA.getName());
        area = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.STORE_CODE.getName());
        bcode = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.STORE_NAME.getName());
        storename = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.ORDER_DATE.getName());
        orderdate = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.ORDER_E_NO.getName());
        eorderno = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.ITEM_NO.getName());
        itemno = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.ITEM_NAME.getName());
        itemname = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.IMEI.getName());
        imei = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.STATUS.getName());
        strStatus = ss[fo.getItemno() - 1];
        fo = orderFields.getField(FetOrderImeiFormat.Fields.SENDER.getName());
        sender = ss[fo.getItemno() - 1];

        Date d =
            new Date(
                DateConverter.parseDateTime(orderdate, DateConverter.FORMAT_WEST_DATE).getTime());

        switch (strStatus) {
          case "作業處理中":
            status = 2;
            break;
          case "未啟用":
            status = 0;
            break;
          case "已啟用":
            status = 1;
            break;
          default:
            status = 0;
            break;
        }

        imeivo = new FetorderimeiVo();
        imeivo.setArea(area);
        imeivo.setBcode(bcode);
        imeivo.setStorename(storename);
        imeivo.setOrderdate(d);
        imeivo.setEorderno(eorderno);
        imeivo.setItemno(itemno);
        imeivo.setItemname(itemname);
        imeivo.setImei(imei);
        imeivo.setStatus(status);
        imeivo.setSender(sender);
        list.add(imeivo);
      }

      // 匯入 IMEI進貨明細表
      for (FetorderimeiVo v : list) {
        imei = v.getImei();
        imeivo = isImeiExist(imei);
        if (NullTK.isNull(imeivo)) {
          orderimeiDao.insert(v);
        } else {
          orderimeiDao.update(v);
        }
        imeiCache.put(imei, v);
        imeiCount++;
      }

      logger.info("匯入IMEI筆數:" + imeiCount);
      importmemo.append("/匯入IMEI筆數:" + imeiCount + "\n");
    } catch (Exception e) {
      logger.error(e);
      throw new Exception("FetImeiImporter:匯入 IMEI進貨明細表 異常:" + e.getMessage());
    }
    return list;
  }