Exemplo n.º 1
0
  /**
   * 天健发送短信函数 其实只记录到数据库表,不发送 要立即发送,请调用 sendRealSm
   *
   * @param recvNum //测试接收号码,号码间用逗号隔开
   * @param content //测试内容
   * @return
   */
  public static synchronized String sendSm(
      String recvNum, String content, String unkey, Connection conn, String sendtime) {
    // recvNum="13632254864";
    String clientNo = "057188216999"; // "057187719000,057188216999";
    String remark = MessageFormat.format("平台{2}发短信{0}:{1}", recvNum, content, clientNo);
    //// System.out.println(remark);

    DbUtil dbUtil = null;
    String re = "";
    int eff = 0;
    SmsConfigVO smsConfigVO = null;
    try {
      dbUtil = new DbUtil(conn);
      smsConfigVO = dbUtil.load(SmsConfigVO.class, "sys");
      SmsVO smsVO = new SmsVO();
      smsVO.setClient_num(smsConfigVO.getClient_no());
      smsVO.setContext(content);
      smsVO.setCreate_time(StringUtil.getCurDateTime());
      smsVO.setSend_date(StringUtil.getCurDate());
      // System.out.println("=====================sendtime="+sendtime);
      smsVO.setSend_time(sendtime);
      smsVO.setRemark(remark);
      smsVO.setUn_key(unkey);
      smsVO.setUuid(UUID.randomUUID().toString());
      smsVO.setState("r"); //
      smsVO.setMobile(recvNum);

      eff += dbUtil.insert(smsVO);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return re;
  }
  /**
   * 删除客户潜在项目
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView removeLatencyCustomer(
      HttpServletRequest request, HttpServletResponse response) throws Exception {

    Connection conn = null;

    String customerId = request.getParameter("customerid");
    try {
      conn = new DBConnect().getConnect("");
      // 要删除的客户潜在项目的autoid
      String autoid = request.getParameter("autoid");

      LatencyCustomerService latencyCustomerService = new LatencyCustomerService(conn);
      // 删除客户潜在项目
      latencyCustomerService.removeLatencyCustomer(autoid);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbUtil.close(conn);
    }

    if ("".equals(customerId) || customerId == null) {
      response.sendRedirect("latencyCustomer.do");
    } else {
      response.sendRedirect("latencyCustomer.do?customerid=" + customerId);
    }

    return null;
  }
  /**
   * 编辑客户潜在项目
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView exitLatencyCustomer(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    ModelAndView modelAndView = new ModelAndView(_latencyCustomerEdit);

    LatencyCustomer latencyCustomer = new LatencyCustomer();

    // 要修改的客户潜在项目的autoid
    String autoid = request.getParameter("autoid");

    Connection conn = null;
    try {
      conn = new DBConnect().getConnect("");

      LatencyCustomerService latencyCustomerService = new LatencyCustomerService(conn);
      // 根据customerId获得客户潜在项目
      latencyCustomer = latencyCustomerService.getLatencyCustomer(autoid);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbUtil.close(conn);
    }

    modelAndView.addObject("autoid", autoid);
    modelAndView.addObject("LatencyCustomer", latencyCustomer);

    return modelAndView;
  }
  /**
   * 根据indexid 得到所有图片
   *
   * @param indexId
   * @return
   */
  public List<Attach> getImages(String indexId) {

    PreparedStatement ps = null;
    ResultSet rs = null;

    String sql =
        " select "
            + " 	ATTACHID, ATTACHNAME, ATTACHFILE, ATTACHFILEPATH, ATTACHTYPE, "
            + " 	UPDATEUSER, UPDATETIME, INDEXTABLE, INDEXMETADATA, INDEXID, "
            + " 	PROPERTY,FILESIZE  FROM `MT_COM_ATTACH` where  indexid=? ";
    List<Attach> listImage = new ArrayList<Attach>();

    try {

      ps = conn.prepareStatement(sql);

      ps.setString(1, indexId);

      rs = ps.executeQuery();
      while (rs.next()) {
        Attach attach = new Attach();

        attach.setAttachId(rs.getString(1));
        attach.setAttachName(rs.getString(2));
        attach.setAttachFile(rs.getString(3));
        attach.setAttachFilePath(rs.getString(4));
        attach.setAttachType(rs.getString(5));

        attach.setUpdateUser(rs.getString(6));
        attach.setUpdateTime(rs.getString(7));
        attach.setIndexTable(rs.getString(8));
        attach.setIndexMetadata(rs.getString(9));
        attach.setIndexId(rs.getString(10));

        attach.setProperty(rs.getString(11));
        attach.setFileSize(rs.getLong(12));
        listImage.add(attach);
      }

    } catch (SQLException e) {
      System.out.println("得到附件信息错误:" + e.getMessage());
    } finally {
      DbUtil.close(rs);
      DbUtil.close(ps);
    }
    return listImage;
  }
  /**
   * 构造方法
   *
   * @param conn 连接
   * @param projectId 项目编号
   * @throws Exception
   */
  public TaskTreeService(Connection conn, String projectId) throws Exception {
    DbUtil.checkConn(conn);
    this.conn = conn;

    if ("".equals(projectId) || projectId == null) {
      // throw new Exception("项目Id不能为空!");
      this.projectId = "0";
    } else {
      this.projectId = projectId;
    }
  }
 public static void main(String[] args) throws Exception {
   Connection conn = null;
   try {
     conn = new DBConnect().getConnect("");
     String ss = new TaskTreeService(conn, "2007631623").getSubTree("0");
     System.out.println(ss);
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     DbUtil.close(conn);
   }
 }
Exemplo n.º 7
0
  /**
   * 得到部门的树
   *
   * @param parentid 部门的autoid,机构ID为555555
   * @return
   * @throws Exception
   */
  public String getATreeTable(String parentid) throws MatechException {
    ResultSet rs = null;
    StringBuffer sb = new StringBuffer("");
    try {
      String sql = "select * from k_department where parentid='" + parentid + "' order by property";

      ps = conn.prepareStatement(sql);
      rs = ps.executeQuery();
      sb.append("<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" >");
      while (rs.next()) {
        sb.append("<tr height=\"20\" style=\"cursor: hand;\">");
        sb.append(
            "<td width=\"20\" align=\"center\"  nowrap onclick=\"getSubTree("
                + rs.getString("autoid")
                + ");\">");
        sb.append(
            "<img id=\"ActImg"
                + rs.getString("autoid")
                + "\" src=\"images/nofollow.jpg\" width=\"11\" height=\"11\" />");
        sb.append("</td>");
        sb.append("<td align=left valign=\"bottom\"  nowrap>");
        sb.append(
            "<input type=\"checkbox\" name=\"departname\" value=\""
                + rs.getString("autoid")
                + "\" onclick=\"getBUser();\" >"
                + "<span onclick=\"getSubTree("
                + rs.getString("autoid")
                + ");\"><font size=2>"
                + rs.getString("departname")
                + "</font></span>");
        sb.append("</td></tr>");

        sb.append(
            "<tr><td id='subImg"
                + rs.getString("autoid")
                + "' style='display:block'></td><td align=\"left\" valign=\"bottom\" style='display:block' id='subTree"
                + rs.getString("autoid")
                + "'>");
        sb.append(getATreeTable(rs.getString("autoid")));
        sb.append("</td></tr>");
      }
      sb.append("</table>");

      return sb.toString();
    } catch (Exception e) {
      Debug.print(Debug.iError, "访问失败", e);
      throw new MatechException("访问失败:" + e.getMessage(), e);
    } finally {
      DbUtil.close(rs);
    }
  }
Exemplo n.º 8
0
  /**
   * 短信号码,多个用,分割 内容:短信内容 unkey,唯一主键(确保不重复发送)
   *
   * @param recvNum
   * @param content
   * @param unkey
   * @return
   */
  public static synchronized String sendSm(
      String recvNum, String content, String unkey, String sendtime) {
    Connection conn = null;
    try {
      conn = new DBConnect().getConnect();

      return sendSm(recvNum, content, unkey, conn, sendtime);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return "-1";
    } finally {
      DbUtil.close(conn);
    }
  }
  /**
   * 输出脚本
   *
   * @param taskid
   * @return
   * @throws Exception
   */
  public String getScript(String taskid) throws Exception {

    PreparedStatement ps = null;
    ResultSet rs = null;
    String level = "";
    String result = "";

    try {
      new DBConnect().changeDataBaseByProjectid(conn, this.projectId);

      ps =
          conn.prepareStatement(
              "select parenttaskid,level0 from jbpm_z_task where projectid=? and taskid=?");
      ps.setString(1, this.projectId);

      while (!level.equals("0")) {
        ps.setString(2, taskid);
        rs = ps.executeQuery();
        if (rs.next()) {
          result = "getSubTree('" + taskid + "');" + result;
          level = rs.getString("level0");
          taskid = rs.getString("parenttaskid");
        } else {
          break;
        }
      }
    } catch (Exception e) {
      Debug.print(Debug.iError, "输出脚本出错", e);
      throw e;
    } finally {
      DbUtil.close(rs);
      DbUtil.close(ps);
    }

    return result;
  }
Exemplo n.º 10
0
 /**
  * 得到角色的所有权限
  *
  * @param loginid
  * @param conn
  * @return
  * @throws MatechException
  */
 public String getRolePpm(String loginid) throws MatechException {
   String ppm = "";
   ResultSet rs = null;
   try {
     ps = conn.prepareStatement("select popedom from  k_role b where id='" + loginid + "'");
     rs = ps.executeQuery();
     while (rs.next()) {
       ppm += rs.getString(1);
     }
     return ppm;
   } catch (Exception e) {
     Debug.print(Debug.iError, "访问失败", e);
     throw new MatechException("访问失败:" + e.getMessage(), e);
   } finally {
     DbUtil.close(rs);
   }
 }
Exemplo n.º 11
0
  /**
   * 得到项目权限
   *
   * @param userid 用户登录名
   * @return
   */
  public String getProjectPopedomById(String id) throws MatechException {
    String ppm = "";
    ResultSet rs = null;
    try {
      ps = conn.prepareStatement("select Popedom from k_user where id ='" + id + "'");
      rs = ps.executeQuery();
      if (rs.next()) {
        ppm = rs.getString(1) + "";
      }
      rs.close();
      ps.close();

    } catch (Exception e) {
      Debug.print(Debug.iError, "访问失败", e);
      throw new MatechException("访问失败:" + e.getMessage(), e);
    } finally {
      DbUtil.close(rs);
    }
    return ppm;
  }
  /**
   * 增加客户潜在项目
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView addLatencyCustomer(
      HttpServletRequest request, HttpServletResponse response, LatencyCustomer latencyCustomer)
      throws Exception {

    Connection conn = null;

    // 客户编号
    String customerId = "";
    boolean flag = false;

    String CustomerID = request.getParameter("CustomerID");

    if ("".equals(CustomerID) || CustomerID == null) {
      customerId = request.getParameter("customerid");
    } else {
      customerId = CustomerID;
      flag = true;
    }

    try {
      conn = new DBConnect().getConnect("");

      LatencyCustomerService latencyCustomerService = new LatencyCustomerService(conn);
      // 增加客户潜在项目
      latencyCustomerService.addLatencyCustomer(latencyCustomer, customerId);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbUtil.close(conn);
    }

    if (flag) {
      response.sendRedirect("latencyCustomer.do");
    } else {
      response.sendRedirect("latencyCustomer.do?customerid=" + customerId);
    }

    return null;
  }
Exemplo n.º 13
0
 /**
  * 得到用户的所有权限
  *
  * @param loginid
  * @return
  * @throws MatechException
  */
 public String getUserPpmAll(String loginid) throws MatechException {
   String ppm = "";
   ResultSet rs = null;
   try {
     String sql =
         "select popedom from k_user where loginid ='"
             + loginid
             + "' union select b.popedom from k_userrole a, k_role b,k_user c where c.loginid='"
             + loginid
             + "' and a.rid = b.id and a.userid=c.id and c.state=0";
     ps = conn.prepareStatement(sql);
     rs = ps.executeQuery();
     while (rs.next()) {
       ppm += rs.getString(1);
     }
     return ppm;
   } catch (Exception e) {
     Debug.print(Debug.iError, "访问失败", e);
     throw new MatechException("访问失败:" + e.getMessage(), e);
   } finally {
     DbUtil.close(rs);
   }
 }
Exemplo n.º 14
0
  /**
   * 通过系统权限得到系统所有菜单
   *
   * @param pid
   * @param ppm
   * @param onlyPpm
   * @param conn
   * @return
   * @throws MatechException
   */
  public String getSubTree(String pid, String ppm, String onlyPpm) throws MatechException {
    ResultSet rs = null;
    try {
      String sql = "select * from s_config where sname = '启用的中心' ";
      ps = conn.prepareStatement(sql);
      rs = ps.executeQuery();
      boolean bool = false;
      if (rs.next()) {
        String svalue = rs.getString("svalue");
        if (!"".equals(svalue)) {
          bool = true;
        }
      }
      StringBuffer sb = new StringBuffer("");
      if (bool) {
        sql =
            "select DISTINCT menuversion,c.Autoid 	"
                + "	from k_menuversion a ,s_config b,k_dic c  	"
                + "	where b.sname = '启用的中心' 	"
                + "	AND c.ctype = 'dogversion' "
                + "	AND a.menuversion = c.Name "
                + "	and concat(',',b.svalue,',') like concat('%,',a.menuversion,',%') "
                + "	ORDER BY c.Autoid	";
        ps = conn.prepareStatement(sql);
        rs = ps.executeQuery();

        String menuversion = "";
        String menuverid = "";
        int opt = 0;
        while (rs.next()) {
          menuversion = rs.getString("menuversion");
          menuverid = rs.getString("Autoid");

          sb.append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
          sb.append("<tr style=\"cursor: hand;\">");
          sb.append("<td width=\"20\" height=\"18\" align=\"right\" >");
          sb.append("");
          sb.append("</td>");
          sb.append(
              "<td align=left valign=\"bottom\" nowrap>&nbsp;<font size=2>"
                  + menuversion
                  + "</font></td>");
          sb.append("</tr>");
          sb.append("<tr>");
          sb.append("<td id='subImg' ></td>");
          sb.append(
              "<td id='subTree' >"
                  + getSubTree1(pid, ppm, onlyPpm, menuversion, menuverid)
                  + "</td>");
          sb.append("</tr>");
          sb.append("</table>");

          opt++;
        }
      } else {
        sb.append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
        sb.append("<tr style=\"cursor: hand;\">");
        sb.append("<td width=\"20\" height=\"18\" align=\"right\" >");
        sb.append("");
        sb.append("</td>");
        sb.append("<td align=left valign=\"bottom\" nowrap>&nbsp;<font size=2>审计作业中心</font></td>");
        sb.append("</tr>");
        sb.append("<tr>");
        sb.append("<td id='subImg' ></td>");
        sb.append("<td id='subTree' >" + getSubTree1(pid, ppm, onlyPpm) + "</td>");
        sb.append("</tr>");
        sb.append("</table>");

        //				sb.append(getSubTree1(pid, ppm, onlyPpm));
      }
      return sb.toString();
    } catch (Exception e) {
      Debug.print(Debug.iError, "访问失败", e);
      throw new MatechException("访问失败:" + e.getMessage(), e);
    } finally {
      DbUtil.close(rs);
    }
  }
Exemplo n.º 15
0
  public String getSubTree1(String pid, String ppm, String onlyPpm) throws MatechException {
    ResultSet rs = null;
    try {

      DbUtil db = new DbUtil(conn);

      String strSql = "";
      if ("role".equals(this.property)) {
        strSql =
            "	and (a.property = '' or  a.property is null or a.property <= '"
                + this.userRoleOptimization
                + "') ";
      }

      String sql =
          "select depth,menu_id,name,ctype,parentid,id from s_sysmenu a where parentid = '"
              + pid
              + "' and id in ("
              + SysPpm
              + ") and parentid <> '000'and ctype<>'000' "
              + strSql
              + "order by seq_no,menu_id";
      //			System.out.println(sql);
      ps = conn.prepareStatement(sql);
      rs = ps.executeQuery();
      int i = 0;
      StringBuffer sb = new StringBuffer("");
      int depth = 0;
      String menu_id = "";
      String name = "";
      String type = "&nbsp;<font size=2 color=blue>[菜单项]</font>";
      String state = "";
      String parentid = "";
      String powerid = "";
      String ctype = "";
      String only = "";

      // conn.close();
      while (rs.next()) {
        depth = rs.getInt("depth");
        menu_id = rs.getString("menu_id");
        name = rs.getString("NAME");
        ctype = rs.getString("ctype");
        parentid = rs.getString("parentid");
        powerid = rs.getString("id");
        state = "";
        only = "";
        if (ppm.indexOf("." + powerid + ".") >= 0) {
          state = "checked";
        }
        if ("02".equals(rs.getString(4))) {
          type = "&nbsp;<font size=2 color=red>[按钮]</font>";
        } else {
          type = "&nbsp;<font size=2 color=blue>[菜单项]</font>";
        }

        if (this.userPopedom) {
          if (depth != 1 && !"02".equals(ctype)) {
            // 人员与部门权限:判断是否已授权 1为已授权
            // 1、property 2、loginid roleid
            ASFuntion CHF = new ASFuntion();
            String userpopedom = "";
            if ("role".equals(this.property)) {
              // 角色的部门授权
              sql =
                  "select 1 from k_userpopedom a where a.userid = ? and a.menuid =? and a.property =? ";
              userpopedom =
                  CHF.showNull(
                      db.queryForString(sql, new String[] {this.roleid, powerid, this.property}));
            } else {
              // 用户的部门授权
              sql =
                  "select 1 from k_userpopedom a,k_user b where a.userid = b.id and b.loginid = ? and a.menuid =? and a.property =? ";
              userpopedom =
                  CHF.showNull(
                      db.queryForString(sql, new String[] {this.loginid, powerid, this.property}));
            }
            if ("1".equals(userpopedom)) {
              type +=
                  "&nbsp;<input type='hidden' id='departmentid"
                      + powerid
                      + "' name='departmentid' value='' >"
                      + "<input type='hidden' id='menuid"
                      + powerid
                      + "' name='menuid' value='"
                      + powerid
                      + "' >"
                      + "<a href=\"javascript:void(0);\" onclick=\"getUserPopedom('"
                      + powerid
                      + "');\");\">[部门授权]<font color=red>(已授权)</font></a>";
            } else {
              type +=
                  "&nbsp;<input type='hidden' id='departmentid"
                      + powerid
                      + "' name='departmentid' value='' >"
                      + "<input type='hidden' id='menuid"
                      + powerid
                      + "' name='menuid' value='"
                      + powerid
                      + "' >"
                      + "<a href=\"javascript:void(0);\" onclick=\"getUserPopedom('"
                      + powerid
                      + "');\");\">[部门授权]</a>";
            }

            if ("role".equals(this.property)) {
              // 只有角色才有
              // 通过SQL得到哪些菜单要字段权限
              strSql = "select 1 from k_Field where menuid = '" + powerid + "' limit 1";
              String ifTrue = CHF.showNull(db.queryForString(strSql));
              if ("1".equals(ifTrue)) {
                type +=
                    "&nbsp;"
                        + "<input type='hidden' id='omenuid"
                        + powerid
                        + "' name='omenuid' value='"
                        + powerid
                        + "' >"
                        + "<input type='hidden' id='reading"
                        + powerid
                        + "' name='reading' value='' >"
                        + "<input type='hidden' id='editing"
                        + powerid
                        + "' name='editing' value='' >"
                        + "<a href=\"javascript:void(0);\" onclick=\"getFieldPopedom('"
                        + powerid
                        + "');\");\">[字段权限]</a>";
              }
            }
          }
        }

        if (onlyPpm.indexOf("." + powerid + ".") >= 0) {
          only = " disabled ";
        }

        i++;
        sb.append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
        if (depth > 0) {
          sb.append("<tr style=\"cursor: hand;\">");
          sb.append(
              "<td width=\"20\" height=\"18\" align=\"right\" onclick=\"getSubTree("
                  + menu_id
                  + ");\">");
          sb.append(
              "<img id=\"ActImg"
                  + menu_id
                  + "\" src=\"images/plus.jpg\" width=\"11\" height=\"11\" />");
          sb.append("</td>");
          sb.append(
              "<td align=left valign=\"bottom\" nowrap>&nbsp;<input type='checkbox' menuName='"
                  + name
                  + "' id='"
                  + parentid
                  + "'  name='MenuID' Menu='"
                  + menu_id
                  + "' value='"
                  + powerid
                  + "' MyID='"
                  + menu_id
                  + "' ParentID='"
                  + parentid
                  + "' onclick='setCountEnable(); setEnableTree(this);' "
                  + state
                  + only
                  + "><span onclick=\"getSubTree("
                  + menu_id
                  + ");\"><font size=2>"
                  + name
                  + "</font></span>"
                  + type
                  + "</td>");
          sb.append("</tr>");
          sb.append("<tr>");
          sb.append("<td id='subImg" + menu_id + "' style='display:none'></td>");
          sb.append(
              "<td id='subTree"
                  + menu_id
                  + "' style='display:none'>"
                  + getSubTree1(menu_id, ppm, onlyPpm)
                  + "</td>");
          sb.append("</tr>");
          sb.append("</table>");
        } else {
          sb.append("<tr style=\"cursor: hand;\">");
          sb.append("<td width=\"20\" height=\"18\" align=\"right\">");
          sb.append(
              "<img id=\"ActImg"
                  + menu_id
                  + "\" src=\"images/sjx1.gif\" width=\"11\" height=\"11\" />");
          sb.append("</td>");
          sb.append(
              "<td align=left valign=\"bottom\" nowrap>&nbsp;<input type='checkbox' menuName='"
                  + name
                  + "' id='"
                  + parentid
                  + "' name='MenuID' Menu='"
                  + menu_id
                  + "' value='"
                  + powerid
                  + "' depth=0 MyID='"
                  + menu_id
                  + "' ParentID='"
                  + parentid
                  + "' onclick='setCountEnable();setEnableTree(this);' "
                  + state
                  + only
                  + "><font size=2>"
                  + name
                  + "</font>&nbsp;"
                  + type
                  + "</td>");
          sb.append("</tr>");
          sb.append("<tr>");
          sb.append("<td id='subImg" + menu_id + "' style='display:none'></td>");
          sb.append("<td id='subTree" + menu_id + "' style='display:none'></td>");
          sb.append("</tr>");
          sb.append("</table>");
        }
      }
      rs.close();
      ps.close();
      return sb.toString();
    } catch (Exception e) {
      Debug.print(Debug.iError, "访问失败", e);
      throw new MatechException("访问失败:" + e.getMessage(), e);
    } finally {
      DbUtil.close(rs);
    }
  }
  /**
   * 根据indexId 得到图片信息
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView getImage(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    Connection conn = null;
    ModelAndView modelAndView = new ModelAndView(VIEW);

    try {
      ASFuntion asf = new ASFuntion();
      String indexId = asf.showNull(request.getParameter("indexId"));
      UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
      String defaultImageId = asf.showNull(request.getParameter("defaultImageId"));

      conn = new DBConnect().getConnect();

      ImagesBrowserService browserService = new ImagesBrowserService(conn);
      AttachService attachService = new AttachService(conn);
      // indexId = "c17946f8-ad51-4381-b1cf-11d0eec72126";  测试数据
      List<Attach> listImages = null;

      if (!"".equals(indexId)) {

        listImages = browserService.getImages(indexId);

        // 得到图片的长宽
        for (int i = 0; i < listImages.size(); i++) {
          try {
            Attach images = listImages.get(i);

            String attachFilePath = AttachService.ATTACH_FILE_PATH;

            if (attachFilePath.lastIndexOf("/") != attachFilePath.length()) {
              attachFilePath += "/";
            }
            // 如果不指定模块,则放到
            if (!"".equals(images.getIndexTable())) {
              attachFilePath += images.getIndexTable() + "/";
            } else {
              attachFilePath += AttachService.ATTACH_FILE_DEFAULT_FOLDER;
            }

            File _file = new File(attachFilePath + images.getAttachId()); // 读入文件
            Image src = javax.imageio.ImageIO.read(_file); // 构造Image对象
            int width = src.getWidth(null); // 得到源图宽
            int height = src.getHeight(null); // 得到源图长

            if (width != 0 && height != 0) {
              images.setWidth(width + "");
              images.setHeight(height + "");
            }

            //					      AttachLog attachLog = new AttachLog();
            //					      attachLog.setIndexId(indexId);
            //					      attachLog.setFileId(images.getId());
            //					      attachLog.setFileName(images.getFileName());
            //					      attachLog.setFilePath(images.getFilePath());
            //					      attachLog.setLookDate(asf.getCurrentDate()+"" + asf.getCurrentTime());
            //					      attachLog.setUserName(userSession.getUserName());
            //					      attachLog.setUserIp(userSession.getUserIp());
            //					      attachLog.setProperty("企业资质");
            //
            //					      attachService.saveLog(attachLog); //企业资质
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }

      modelAndView.addObject("listImages", listImages);
      modelAndView.addObject("defaultImageId", defaultImageId);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbUtil.close(conn);
    }
    return modelAndView;
  }
Exemplo n.º 17
0
  /**
   * 获得子树
   *
   * @param parentTaskId
   * @return
   * @throws Exception
   */
  public String getSubTree(String parentTaskId) throws Exception {
    ASFuntion asf = new ASFuntion();
    PreparedStatement ps = null;
    ResultSet rs = null;

    if (parentTaskId == null) {
      return "";
    }

    try {

      String sql =
          "select distinct IsLeaf,TaskID,TaskName,ManuID,b.name,taskcode,user1,user2,user3,User4,user5,a.property,ismust "
              + " from jbpm_z_Task a left join k_user b on  a.user0=b.id  "
              + " where ParentTaskID = ? "
              + " and ProjectID = ? "
              + " and (property not like 'A%' or property is null) ";

      // 不显示叶子节点,也就是底稿
      if (!isleaf) {
        sql += " and isleaf=0 ";
      }

      sql += " order by orderid,taskcode";

      ps = conn.prepareStatement(sql);
      ps.setString(1, parentTaskId);
      ps.setString(2, this.projectId);

      rs = ps.executeQuery();

      int i = 0;
      StringBuffer sb = new StringBuffer("");

      while (rs.next()) {
        i++;
        String taskusr = rs.getString(5);

        if (taskusr != null && !"".equals(taskusr)) {
          taskusr = "******" + taskusr + ")";
        } else {
          taskusr = "";
        }

        String property = rs.getString(12);

        // coalition.gif

        String taskId = rs.getString(2);
        String tcode = rs.getString(6);
        String taskName = rs.getString(3);
        String manuId = rs.getString(4);
        String url = "";

        if ("22".equals(property)) {
          tcode = "<img src=\"../images/coalition.gif\" width=\"18\" height=\"16\">&nbsp;" + tcode;
        }

        sb.append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");

        if (rs.getInt(1) == 0) {
          sb.append("<tr style=\"cursor: hand;\">");
          sb.append(
              "<td onclick=\"getSubTree('"
                  + taskId
                  + "');\" width=\"11\" height=\"11\" align=\"right\">");
          sb.append(
              "<img id=\"ActImg"
                  + taskId
                  + "\" src=\"../images/plus.jpg\" width=\"11\" height=\"11\" />");
          sb.append("</td>");
          sb.append(
              "<td onclick=\"showObj('" + taskId + "');\" align=left valign=\"bottom\" nowrap>");

          if (isleaf) {
            // 显示底稿列表
            url = "/AuditSystem/oa/task.do?method=list&parentTaskId=" + taskId;
          } else {
            // 不显示底稿列表,只显示程序和目标
            url =
                "/AuditSystem/oa/task.do?method=tarAndPro&parentTaskId="
                    + taskId
                    + "&projectId="
                    + this.projectId
                    + "&isLeaf="
                    + isleaf;
          }

          sb.append(
              "<a id=\"a"
                  + taskId
                  + "\" href=\""
                  + url
                  + "\" target='TaskMainFrame' onclick='doIt(this);'> ");
          sb.append("<font size=2>&nbsp;" + tcode + " " + taskName);
          sb.append("</a></td></tr>");
        } else {
          String user1 = asf.showNull(rs.getString(7));
          String user2 = asf.showNull(rs.getString(8));
          String user3 = asf.showNull(rs.getString(9));
          String user4 = asf.showNull(rs.getString(10));
          String user5 = asf.showNull(rs.getString(11));
          // String ismust = asf.showNull(rs.getString(13));
          String stateHTML = ""; // getTaskStateHTML(ismust);

          String picName = "";

          if (!"".equals(user1)) {
            picName = "1";
          }

          if (!"".equals(user5)) {
            picName = "5";
          }

          if (!"".equals(user2)) {
            picName = "2";
          }

          if (!"".equals(user3)) {
            picName = "3";
          }

          if (!"".equals(user4)) {
            picName = "4";
          }

          sb.append("<tr style=\"cursor: hand;\">");
          sb.append("<td width=\"27\" height=\"16\" nowrap align=\"right\">");
          String extendName = taskName;

          if (extendName.lastIndexOf(".") <= -1) {
            continue;
          }

          extendName = extendName.substring(extendName.lastIndexOf("."));

          if (".doc".equalsIgnoreCase(extendName)) {
            picName = "word" + picName + ".gif";
          } else if (".xls".equalsIgnoreCase(extendName)) {
            picName = "excel" + picName + ".gif";
          }

          sb.append("<img id=\"ActImg\" src=\"../images/office/" + picName + "\" />");
          sb.append("</td>");

          String goUrl = "'" + manuId + "','" + taskId + "'";

          String style = "style=\"cursor:hand;\"";
          String title = "";
          String isuntread = "no";
          if (!"".equals(user4)) {
            style = " style=\" cursor:hand;font-weight:bold; color:red; \" ";
            title = " title=\"被退回的底稿\" ";
            isuntread = "yes";
          }

          sb.append("<td align=left valign=\"bottom\" nowrap>");
          sb.append(
              "<a isuntread='"
                  + isuntread
                  + "'"
                  + title
                  + " id='a"
                  + taskId
                  + "' "
                  + style
                  + " onclick=\"doIt(this);");
          sb.append(" goUrl(" + goUrl + ");\" >&nbsp;");
          sb.append(tcode + " " + taskName + " " + taskusr + " " + stateHTML);
          sb.append("</a>");
          sb.append("</td></tr>");
        }

        sb.append("<tr>");
        sb.append("<td id='subImg" + taskId + "' style='display:none'></td>");
        sb.append("<td id='subTree" + taskId + "' style='display:none'></td>");
        sb.append("</tr>");
        sb.append("</table>");
      }
      return sb.toString();
    } catch (Exception e) {
      Debug.print(Debug.iError, "获得子树失败", e);
      throw e;
    } finally {
      DbUtil.close(rs);
      DbUtil.close(ps);
    }
  }