예제 #1
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;
  }
예제 #2
0
  public String goInsert() {
    String responseStr = null;
    String[] paramkeys = {
      "cCode",
      "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"));

            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");
                String sz_idx =
                    makeSZ_IDX(
                        request.getParameter("cCode"), cPhone, request.getParameter("zoneFlag"));
                if (sz_idx == null) {
                  responseStr = xmlMgr.xmlBasic(30);
                  logger.info("[_OPR_] 존아이디 생성중 실패");
                } else {

                  Vector<String> sqlBoxInsert = new Vector<String>();
                  sqlBoxInsert.addElement(sz_idx);
                  sqlBoxInsert.addElement(mcode);
                  sqlBoxInsert.addElement(request.getParameter("cCode"));
                  sqlBoxInsert.addElement(stdt);
                  sqlBoxInsert.addElement(endt);
                  sqlBoxInsert.addElement(stmm);
                  sqlBoxInsert.addElement(enmm);
                  // sqlBoxInsert.addElement(period);
                  sqlBoxInsert.addElement(weekp);
                  sqlBoxInsert.addElement(request.getParameter("useFlag"));
                  sqlBoxInsert.addElement(request.getParameter("radius"));
                  sqlBoxInsert.addElement(request.getParameter("lat"));
                  sqlBoxInsert.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);
                  }

                  sqlBoxInsert.addElement(encZoneAddr);
                  // sqlBoxInsert.addElement(request.getParameter("zoneName"));
                  sqlBoxInsert.addElement(zoneName);
                  sqlBoxInsert.addElement(request.getParameter("zoneFlag"));
                  sqlBoxInsert.addElement(request.getParameter("kind"));
                  java.text.SimpleDateFormat formatter =
                      new java.text.SimpleDateFormat("yyyyMMddHHmmss");
                  String indt = formatter.format(new java.util.Date());
                  sqlBoxInsert.addElement(indt);
                  sqlBoxInsert.addElement(indt);

                  if (sqlSetUp.insertZoneInfo(sqlBoxInsert) == 0) {
                    responseStr = xmlMgr.xmlBasic(1110);
                    logger.info("[_OPR_] 존 설정 인서트 건수 : 0건 (확인 요망)");
                  } else {
                    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건 (확인 요망)");
                    }

                    logger.info("[_OPR_] 존 설정 정보, DB 입력 성공");

                    sqlBox.clear();
                    sqlBox.addElement(request.getParameter("cCode"));
                    resultBox.clear();
                    int ret = sqlSetUp.getMode(sqlBox, resultBox);

                    if (ret == -1) {
                      responseStr = xmlMgr.xmlBasic(1100);
                    } else {
                      if (resultBox.size() > 0) {
                        Properties rec = resultBox.elementAt(0);
                        String mode = rec.getProperty("MODE");

                        if (mode.equals("2")) {
                          logger.info("[_OPR_] 서버모드 진행 [mode:" + mode + "]");
                          Vector<String> sqlBoxPlatForm = new Vector<String>();
                          sqlBoxPlatForm.addElement(sz_idx);
                          sqlBoxPlatForm.addElement(cPhone);
                          sqlBoxPlatForm.addElement(stdt);
                          sqlBoxPlatForm.addElement(stmm);
                          sqlBoxPlatForm.addElement(endt);
                          sqlBoxPlatForm.addElement(enmm);
                          sqlBoxPlatForm.addElement("10"); // 주기 10분
                          sqlBoxPlatForm.addElement(weekp);
                          sqlBoxPlatForm.addElement(request.getParameter("useFlag"));

                          if (sqlSetUp.insertOrder(sqlBoxPlatForm) == 0) {
                            logger.info("[_OPR_] Insert order error on Server Mode");
                            responseStr = xmlMgr.xmlBasic(1110);
                          } else {
                            responseStr = xmlMgr.xmlBasic(1);
                            logger.info("[_OPR_] 서버모드 : ORDER DB 입력 성공");
                          }
                          return responseStr;
                        } else { // if(model_mode.equals("1") || model_mode.equals("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);
                          logger.info(
                              "[_OPR_] Send Device Order : mcode="
                                  + mcode
                                  + ", ccode="
                                  + request.getParameter("cCode")
                                  + ", opt=2");
                        }
                      }
                    }
                    responseStr = xmlMgr.xmlBasic(1);
                  }
                }
              }
            }
          }
        }

      } catch (NumberFormatException e) {
        responseStr = xmlMgr.xmlBasic(930);
        logger.error("[_OPR_] 존 설정 시간이 숫자가 아니여서 실패", e);
      }
    }
    return responseStr;
  }