Exemplo n.º 1
0
  public String goDelete(String[] sz_idxs, String memId, String route) {
    String responseStr = null;
    Vector<String> sqlBox = new Vector<String>();
    for (int i = 0; i < sz_idxs.length; ++i) {
      sqlBox.addElement(sz_idxs[i]);
    }

    sqlSetUp.backupZoneInfo(sqlBox);

    Vector<Properties> detailInfos = new Vector<Properties>();
    sqlSetUp.getZoneDetailInfo(sqlBox, detailInfos);

    int delCnt = sqlSetUp.deleteZoneInfo(sqlBox);

    if (delCnt > 0) {
      for (int i = 0; i < detailInfos.size(); ++i) {
        Properties detailRec = detailInfos.elementAt(i);
        String useFlagDb = detailRec.getProperty("USEFLAG");

        if (useFlagDb.equals("1")) {
          Vector<String> condVec = new Vector<String>();
          condVec.addElement(detailRec.getProperty("STDT") + detailRec.getProperty("STMM"));
          condVec.addElement(detailRec.getProperty("ENDT") + detailRec.getProperty("ENMM"));
          condVec.addElement("_" + detailRec.getProperty("STMM").substring(1));

          if (sqlSetUp.updateCount(condVec, detailRec.getProperty("WEEKP"), false) == 0) {
            logger.info("[_DEV_] 존 설정 업데이트 건수 : 0건 (확인 요망)");
          }
        }

        NspKTSMS nspKTSMS = new NspKTSMS(memId, route, "order");
        nspKTSMS.smsOrder(
            UTILmgr.getDateTime(), detailRec.getProperty("CCODE"), "DEVICE", "2", CommonDef.DEVICE);
      }
      responseStr = xmlMgr.xmlBasic(1);
      logger.info("[_OPR_] 존 설정 정보 삭제");
    } else {
      responseStr = xmlMgr.xmlBasic(0);
    }
    return responseStr;
  }
Exemplo n.º 2
0
  public String goUpdate() {
    String responseStr = null;
    String[] paramkeys = {
      "cCode",
      "sz_idx",
      "zoneFlag",
      "stdt",
      "endt",
      "weekp",
      "useFlag",
      "radius",
      "lat",
      "lon",
      "zoneAddr",
      "zoneName",
      "kind",
      "stmm",
      "enmm"
    };
    if (!ISParameter.isParameterOK(request, paramkeys)) {
      responseStr = xmlMgr.xmlBasic(2);
      logger.info("[_OPR_] 존 설정 업데이트 중 파라메타 에러");

    } else {
      try {
        String stdt = request.getParameter("stdt");
        String endt = request.getParameter("endt");
        String stmm = request.getParameter("stmm");
        String enmm = request.getParameter("enmm");

        int stdtNum = Integer.parseInt(stdt);
        int endtNum = Integer.parseInt(endt);
        int stmmNum = Integer.parseInt(stmm);
        int enmmNum = Integer.parseInt(enmm);

        String weekp = request.getParameter("weekp");
        String zoneName = request.getParameter("zoneName");
        String zoneAddr = request.getParameter("zoneAddr");
        try {
          zoneName = new String(zoneName.getBytes("ISO-8859-1"), "EUC-KR");
          zoneName = java.net.URLDecoder.decode(zoneName, "UTF-8");
          zoneAddr = new String(zoneAddr.getBytes("ISO-8859-1"), "EUC-KR");
          zoneAddr = java.net.URLDecoder.decode(zoneAddr, "UTF-8");
        } catch (Exception e) {
          logger.error("[EXCEPTION]", e);
        }

        if ((stdt.equals(endt) && stmm.equals(enmm))
            || stdtNum > 23
            || endtNum > 23
            || stdtNum > endtNum
            || (stdt.equals(endt) && (stmmNum > enmmNum))
            || stmmNum > 59
            || enmmNum > 59) {
          responseStr = xmlMgr.xmlBasic(930);
          logger.info("[_OPR_] 존 설정 시간이 규칙에 위반하여 실패");

        } else if (weekp.length() != 7 || weekp.equals("0000000")) {
          responseStr = xmlMgr.xmlBasic(930);
          logger.info("[_OPR_] 존 설정 요일이 규칙에 위반하여 실패");

        } else {

          String stdt2 = null;
          if (stdtNum < 10) stdt2 = "0" + stdtNum;
          else stdt2 = "" + stdtNum;

          String endt2 = null;
          if (endtNum < 10) endt2 = "0" + endtNum;
          else endt2 = "" + endtNum;

          Vector<Properties> timeOfFull = new Vector<Properties>();
          Properties prop = adjustSettingTime(stdt2, stmmNum, endt2, enmmNum, weekp, timeOfFull);
          if (prop == null) {
            Properties timeOfFullProp = timeOfFull.lastElement();
            String fullWeek = timeOfFullProp.getProperty("WEEK");
            String fullHour = timeOfFullProp.getProperty("HOURCODE");
            String fullMinute = timeOfFullProp.getProperty("MINUTECODE");
            String msg =
                "죄송합니다. 설정하신 시간 중에 ("
                    + fullWeek
                    + ")["
                    + fullHour
                    + ":"
                    + fullMinute.substring(0, 1)
                    + "0]시간대가 이용량이 많아  설정할 수 없습니다. 해당 시간을 피해서 설정해주세요.";
            responseStr = xmlMgr.xmlBasic(1040, msg);

            logger.info("[_OPR_] 설정 시간대에 이용량이 많아 설정 실패");

          } else {
            stmm = prop.getProperty("STMM");
            enmm = prop.getProperty("ENMM");

            Vector<String> sqlBox = new Vector<String>();
            sqlBox.addElement(request.getParameter("cCode"));
            sqlBox.addElement(request.getParameter("sz_idx"));

            Vector<Properties> resultBox = new Vector<Properties>();
            sqlSetUp.getZoneTimeInfoByCCODE(sqlBox, resultBox);

            if (isOverDayLimit(stdt, stmm, endt, enmm, weekp, resultBox)) {
              responseStr = xmlMgr.xmlBasic(940);
              logger.info("[_OPR_] 하루 최대 측위 건수 초과하여 설정됨으로 실패");
            } else {
              resultBox.clear();

              sqlBox.clear();
              sqlBox.addElement(mcode);
              sqlBox.addElement(request.getParameter("cCode"));
              sqlSetUp.getCPhoneByCCODE(sqlBox, resultBox);
              if (resultBox.size() == 0) {
                responseStr = xmlMgr.xmlBasic(-2);
                logger.info("[_OPR_] 입력된 코드에 해당하는 단말 번호 정보가 없음. 실패");
              } else {
                String cPhone = resultBox.elementAt(0).getProperty("CPHONE");

                sqlBox.clear();
                sqlBox.addElement(request.getParameter("sz_idx"));
                Vector<Properties> detailInfo = new Vector<Properties>();
                sqlSetUp.getZoneDetailInfo(sqlBox, detailInfo);

                if (detailInfo.size() == 0) {
                  responseStr = xmlMgr.xmlBasic(-2);
                  logger.info("[_OPR_] 입력된 코드(sz_idx)에 해당하는 정보가 없음. 실패");
                } else {
                  String zoneFlagDb = detailInfo.elementAt(0).getProperty("ZONEFLAG");

                  String sz_idx_forUpdate = null;

                  if (request.getParameter("zoneFlag").equals(zoneFlagDb)) {
                    sz_idx_forUpdate = request.getParameter("sz_idx");
                  } else {
                    sz_idx_forUpdate =
                        makeSZ_IDX(
                            request.getParameter("cCode"),
                            cPhone,
                            request.getParameter("zoneFlag"));
                  }

                  if (sz_idx_forUpdate == null) {
                    responseStr = xmlMgr.xmlBasic(30);
                    logger.info("[_OPR_] 존아이디 생성중 실패");

                  } else {
                    sqlBox.clear();
                    sqlBox.addElement(request.getParameter("sz_idx"));
                    sqlSetUp.backupZoneInfo(sqlBox);

                    Vector<String> sqlBoxUpdate = new Vector<String>();
                    sqlBoxUpdate.addElement(sz_idx_forUpdate);
                    sqlBoxUpdate.addElement(request.getParameter("cCode"));
                    sqlBoxUpdate.addElement(stdt);
                    sqlBoxUpdate.addElement(endt);
                    sqlBoxUpdate.addElement(stmm);
                    sqlBoxUpdate.addElement(enmm);
                    sqlBoxUpdate.addElement(weekp);
                    sqlBoxUpdate.addElement(request.getParameter("useFlag"));
                    sqlBoxUpdate.addElement(request.getParameter("radius"));
                    sqlBoxUpdate.addElement(request.getParameter("lat"));
                    sqlBoxUpdate.addElement(request.getParameter("lon"));
                    String encZoneAddr = null;
                    try {
                      StringEncrypter stEncrypt = new StringEncrypter();
                      // encZoneAddr = stEncrypt.encrypt(request.getParameter("zoneAddr"));
                      encZoneAddr = stEncrypt.encrypt(zoneAddr);
                    } catch (Exception e) {
                      encZoneAddr = "";
                      logger.error("[EXCEPTION]", e);
                    }
                    sqlBoxUpdate.addElement(encZoneAddr);
                    // sqlBoxUpdate.addElement(request.getParameter("zoneName"));
                    sqlBoxUpdate.addElement(zoneName);
                    sqlBoxUpdate.addElement(request.getParameter("zoneFlag"));
                    sqlBoxUpdate.addElement(request.getParameter("kind"));
                    sqlBoxUpdate.addElement(request.getParameter("sz_idx"));

                    if (sqlSetUp.updateZoneInfo(sqlBoxUpdate) == 0) {
                      responseStr = xmlMgr.xmlBasic(1110);
                    } else {
                      logger.info("[_OPR_] 존 설정 정보, DB 업데이트 성공");

                      Properties detailRec = detailInfo.elementAt(0);
                      String useFlagDb = detailRec.getProperty("USEFLAG");
                      if (useFlagDb.equals("1")) {
                        Vector<String> condVec = new Vector<String>();
                        condVec.addElement(
                            detailRec.getProperty("STDT") + detailRec.getProperty("STMM"));
                        condVec.addElement(
                            detailRec.getProperty("ENDT") + detailRec.getProperty("ENMM"));
                        condVec.addElement("_" + detailRec.getProperty("STMM").substring(1));

                        if (sqlSetUp.updateCount(condVec, detailRec.getProperty("WEEKP"), false)
                            == 0) {
                          logger.info("[_OPR_] 존 설정 업데이트 건수 : 0건 (확인 요망)");
                        }
                      }

                      if (request.getParameter("useFlag").equals("1")) {
                        Vector<String> condVec = new Vector<String>();
                        condVec.addElement(stdt + stmm);
                        condVec.addElement(endt + enmm);
                        condVec.addElement("_" + stmm.substring(1));

                        if (sqlSetUp.updateCount(condVec, weekp, true) == 0) {
                          logger.info("[_OPR_] 존 설정 업데이트 건수 : 0건 (확인 요망)");
                        }
                      }

                      String route = request.getParameter("route");
                      NspKTSMS nspKTSMS = new NspKTSMS(mcode, route, "order");
                      responseStr =
                          nspKTSMS.smsOrder(
                              UTILmgr.getDateTime(),
                              request.getParameter("cCode"),
                              "DEVICE",
                              "2",
                              CommonDef.DEVICE);
                    }
                  }
                }
              }
            }
          }
        }
      } catch (NumberFormatException e) {
        responseStr = xmlMgr.xmlBasic(930);
        logger.error("[_OPR_] 존 설정 시간이 숫자가 아니여서 실패", e);
      }
    }
    return responseStr;
  }