Ejemplo n.º 1
0
  public static void main(String args[]) {
    String sql =
        "select a.case_num,a.amount from"
            + " (select case_num,count(case_num) amount from cqmass.work_finance_count_detail "
            + "group by dept_id,case_num ) a where amount >1 ";
    // 同一网点有结算数据相同
    DataStormSession session = null;
    try {
      session = DataStormSession.getInstance();
      List checkList = null, checkList1 = null;
      Map checkMap = null, checkMap1 = null;
      checkList = session.findSql(sql);
      for (int i = 0; i < checkList.size(); i++) {
        checkMap = (Map) checkList.get(i);
        sql =
            "select count_detail_primary_key id from cqmass.work_finance_count_detail where case_num='"
                + checkMap.get("caseNum").toString()
                + "' order by count_money desc";
        checkList1 = session.findSql(sql);
        for (int j = 1; j < checkList1.size(); j++) {
          checkMap1 = (Map) checkList1.get(j);
          sql =
              "delete from cqmass.work_finance_count_detail where count_detail_primary_key='"
                  + checkMap1.get("id").toString()
                  + "'";
          System.out.println(sql);
          session.delete(sql);
        }
      }

      // session.closeSession();
    } catch (CquptException e) {
      e.printStackTrace();
    } finally {
      if (session != null) {
        try {
          session.closeSession();
        } catch (CquptException e) {
          e.printStackTrace();
        }
      }
    }
  }
Ejemplo n.º 2
0
  private String insertStorageInList(
      String storageInList,
      String deptId,
      String deptName,
      String userId,
      String userName,
      String inId) {
    DataStormSession session = null;

    String resultStr = "";
    String sql = "";
    String[] resultArray = null;
    String[] cellArray = null;
    int inCount = 0; // 插入的行数

    String txtBrand = ""; // 品牌
    String txtVersion = ""; // 型号
    String txtColor = ""; // 颜色

    int count = 0; // 商品总数

    List resultListBrand = null;
    List resultList;
    Map resultMap;
    try {
      resultArray = storageInList.split(";");
      inCount = resultArray.length; // 插入的行数

      session = DataStormSession.getInstance();
      String versionId, gadgetsId;
      String resultId = "";
      String fid = "";
      String sid = "";
      List resultListCode = null;
      Map resultMapCode = null;
      List emptyTest = null;
      Map emptyTestCode = null;

      for (int i = 0; i < resultArray.length; i++) {
        System.out.println(resultArray[i]); // 一行的所有数据
        cellArray = resultArray[i].split("@");

        txtBrand = cellArray[0].toUpperCase().trim();
        txtVersion = cellArray[1].toUpperCase().trim();
        txtColor = cellArray[2].toUpperCase().trim();

        resultListCode =
            session.findSql(
                "SELECT brand_id id FROM cqmass.pro_brand where brand_name='" + txtBrand + "'");
        if (resultListCode.size() == 0) {
          // 品牌不存,添加品牌信息
          emptyTest = session.findSql("select count(brand_id) num from cqmass.pro_brand");
          emptyTestCode = (Map) emptyTest.get(0);
          String num = emptyTestCode.get("num").toString();
          if (num.equals("0")) {
            resultId = "001";
          } else {
            resultListCode = session.findSql("select max(brand_id) id from cqmass.pro_brand");
            resultMapCode = (Map) resultListCode.get(0);
            resultId = resultMapCode.get("id").toString();
          }
          int bid = Integer.parseInt(resultId) + 1;

          if (bid < 1000) {
            if (bid < 10) resultId = "00" + bid;
            else if (bid < 100) resultId = "0" + bid;
            else resultId = "" + bid;
          }
          System.out.println("brandId=====" + resultId);

          sql =
              "insert into cqmass.pro_brand (brand_id,brand_name,logo_path,brand_state,in_date,oper_user_name) "
                  + " values ('"
                  + resultId
                  + "','"
                  + txtBrand
                  + "','','可用',sysdate(),'"
                  + userName
                  + "')";
          logger.info("插入pro_brand:" + sql);
          session.add(sql);

          fid = resultId;
        } else {
          // 品牌存在,得到相应品牌ID
          resultMapCode = (Map) resultListCode.get(0);
          fid = resultMapCode.get("id").toString();
          System.out.println("fid =" + fid);
        }
        resultListCode =
            session.findSql(
                "SELECT count(brand_id) id FROM cqmass.pro_version where brand_name='"
                    + txtBrand
                    + "'");
        resultMapCode = (Map) resultListCode.get(0);
        String mark = resultMapCode.get("id").toString();
        System.out.println("mark=" + mark);
        if (mark.equals("0")) {
          resultId = fid + "001"; // 型号初始ID
        } else {

          resultListCode =
              session.findSql(
                  "SELECT max(version_id) id FROM cqmass.pro_version where brand_name='"
                      + txtBrand
                      + "'"); // 找相应品牌下的最大型号ID
          System.out.println(
              "SELECT max(version_id) id FROM cqmass.pro_version where brand_name='"
                  + txtBrand
                  + "'");
          resultMapCode = (Map) resultListCode.get(0);
          resultId = resultMapCode.get("id").toString();
          System.out.println("resultId =" + resultId);
          sid = resultId.substring(3); // 在相应供应商内的id
          System.out.println("sid =" + sid);
          int bid = Integer.parseInt(sid) + 1;
          if (bid < 1000) {
            if (bid < 10) resultId = fid + "00" + bid;
            else if (bid < 100) resultId = fid + "0" + bid;
            else resultId = fid + bid;
          }
        }

        System.out.println("versionId=====" + resultId);
        sql =
            "select version_id from cqmass.pro_version where brand_name='"
                + txtBrand
                + "'and version_name = '"
                + txtVersion
                + "'";
        List resultList1 = session.findSql(sql);
        if (resultList1.size() == 0) {
          // 型号不存在时才插入
          sql =
              "insert into cqmass.pro_version (version_id,brand_id,brand_name,version_name,color,version_state,in_date,oper_user_name)"
                  + " values ('"
                  + resultId
                  + "','"
                  + fid
                  + "','"
                  + txtBrand
                  + "','"
                  + txtVersion
                  + "','"
                  + txtColor
                  + "','可用',sysdate(),'"
                  + userName
                  + "')";
          System.out.println(sql);
          session.add(sql);
          resultStr = "success@@";
        }
      } // for循环结束
      String[] result = resultStr.split("@");
      if (result[0].equals("success")) {
        resultStr = "success@" + inId + "@" + inCount;
      }
      session.closeSession();

    } catch (Exception e) {
      resultStr = "系统异常,请重试或者联系系统管理员@@";
      try {
        session.exceptionCloseSession();
      } catch (Exception e1) {
        e1.printStackTrace();
      }
      e.printStackTrace();
    }
    System.out.println(resultStr);
    return resultStr;
  }