예제 #1
0
  @Override
  public Object[] adapt(
      ServletContext sc, HttpServletRequest req, HttpServletResponse resp, String[] pathArgs) {

    // 临时
    if (!Mvcs.getActionContext().getMethod().toGenericString().equals(method.toGenericString())) {
      throw new IllegalArgumentException(
          String.format(
              "Method miss match: expect %s but %s. using Ioc? set singleton=false, pls",
              method, Mvcs.getActionContext().getMethod()));
    }
    return super.adapt(sc, req, resp, pathArgs);
  }
  @At("/browseall/json")
  @Ok("json")
  public List browsealljson(String flowcclass) throws Exception {
    HttpSession session = Mvcs.getHttpSession(true);
    DynamicObject token =
        (DynamicObject)
            session.getAttribute(com.skynet.framework.spec.GlobalConstants.sys_login_token);
    String loginname =
        token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_user);
    String userid = token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_userid);
    flowcclass = "DFGL";

    Map amap = new HashMap();
    // 特殊字段
    amap.put("loginname", loginname);
    amap.put(GlobalConstants.swap_coperatorid, userid);
    amap.put(GlobalConstants.swap_coperatorloginname, loginname);

    amap.put("flowcclass", flowcclass);

    List datas =
        partyduebaseapproveService
            .sdao()
            .queryForList(partyduebaseapproveService.get_browseall_sql(amap));

    return datas; // 后期改为翻页对象
  }
  @At("/startplan")
  @Ok("redirect:locate.action?runactkey=${obj.runactkey}")
  public Map startplan(String planid, String flowdefid) throws Exception {
    Plan plan = planService.get(planid);

    Timestamp nowtime = new Timestamp(System.currentTimeMillis());
    PartyDueBaseApprove baseapprove = new PartyDueBaseApprove();
    baseapprove.setId(UUIDGenerator.getInstance().getNextValue());
    baseapprove.setCname(plan.getCname());
    baseapprove.setCreatetime(nowtime);

    HttpSession session = Mvcs.getHttpSession(true);
    DynamicObject token =
        (DynamicObject)
            session.getAttribute(com.skynet.framework.spec.GlobalConstants.sys_login_token);
    String loginname =
        token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_user);
    String userid = token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_userid);
    String username =
        token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_username);

    DynamicObject swapFlow = new DynamicObject();
    swapFlow.setAttr(GlobalConstants.swap_coperatorid, userid);
    swapFlow.setAttr(GlobalConstants.swap_coperatorloginname, loginname);
    swapFlow.setAttr(GlobalConstants.swap_coperatorcname, username);
    swapFlow.setAttr(GlobalConstants.swap_flowdefid, flowdefid);
    swapFlow.setAttr(GlobalConstants.swap_tableid, tableid);

    String runactkey = partyduebaseapproveService.plancreate(plan, baseapprove, swapFlow);

    ro.put("runactkey", runactkey);
    return ro;
  }
예제 #4
0
파일: Flow.java 프로젝트: happyday517/stuff
 @At
 @Ok("void")
 public void resource(
     @Param("deploymentId") String deploymentId, @Param("resourceName") String resourceName)
     throws IOException {
   Streams.writeAndClose(
       Mvcs.getResp().getOutputStream(), flowService.resource(deploymentId, resourceName));
 }
예제 #5
0
  @At("/forwardselect")
  @Ok("redirect:${obj.url}")
  public Map main(String runactkey, String endactdefid) throws Exception {
    DynamicObject ract = workFlowEngine.getActManager().getRactService().locate(runactkey);

    String actdefid = ract.getFormatAttr("actdefid");
    String dataid = ract.getFormatAttr("dataid");
    String tableid = ract.getFormatAttr("tableid");
    String flowdefid = ract.getFormatAttr("flowdefid");
    String handletype = ract.getFormatAttr("handletype");

    if ("普通".equals(handletype)) {
      String url = "forwardselectsingleframe.action";
      url += "?runactkey=" + StringToolKit.formatText(runactkey);
      ro.put("url", url);
      return ro;
    } else if ("多部门并行".equals(handletype)) {
      // 检查是否是最后的子活动实例转发
      // 如果是最后的自活动实例转发,转向普通的节点间转发界面
      // 否则进入节点内转发界面。
      String suprunactkey =
          workFlowEngine
              .getActManager()
              .getRactService()
              .locate(runactkey)
              .getFormatAttr("suprunactkey");
      int num_nucomplete = workFlowEngine.getActManager().async_uncomplete_num(suprunactkey);
      if (num_nucomplete <= 1) {
        String url = "forwardselectsingleframe.action";
        url += "?runactkey=" + StringToolKit.formatText(runactkey);
        url += "&endactdefid" + StringToolKit.formatText(endactdefid);

        ro.put("url", url);
        return ro;
      } else {
        VForward vo = new VForward();
        vo.runactkey = runactkey;

        HttpSession session = Mvcs.getHttpSession(true);
        DynamicObject token =
            (DynamicObject)
                session.getAttribute(com.skynet.framework.spec.GlobalConstants.sys_login_token);

        vo.userid = token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_userid);
        vo.loginname =
            token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_user);
        vo.username =
            token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_username);
        vo.usertype = DBFieldConstants.PUB_PARTICIPATOR_PERSON;
        List<DynamicObject> acts_forward = workFlowEngine.getActManager().vforward(vo);
        ro.put("acts", acts_forward);
        ro.put("url", "/page/workflow/ui/forwardsuccess.ftl");
        return ro;
      }
    }

    return ro;
  }
예제 #6
0
  public void render(HttpServletRequest req, HttpServletResponse resp, Object obj)
      throws IOException {

    if (resp.getContentType() == null)
      if (jsonp) resp.setContentType(JSONP_CT);
      else resp.setContentType(CT);
    Writer writer = resp.getWriter();
    if (jsonp) writer.write(req.getParameter(jsonpParam == null ? "callback" : jsonpParam) + "(");
    Mvcs.write(resp, writer, null == obj ? data : obj, format.clone());
    if (jsonp) writer.write(");");
  }
예제 #7
0
 public NutMap upload(TempFile tmp, int userId) throws IOException {
   NutMap re = new NutMap();
   if (userId < 1) return re.setv("msg", "请先登陆!");
   if (tmp == null || tmp.getSize() == 0) {
     return re.setv("msg", "空文件");
   }
   if (tmp.getSize() > 10 * 1024 * 1024) {
     tmp.delete();
     return re.setv("msg", "文件太大了");
   }
   String id = R.UU32();
   String path = "/" + id.substring(0, 2) + "/" + id.substring(2);
   File f = new File(imageDir + path);
   Files.createNewFile(f);
   Files.write(f, tmp.getInputStream());
   tmp.delete();
   re.put("url", Mvcs.getServletContext().getContextPath() + "/yvr/upload" + path);
   re.setv("success", true);
   return re;
 }
 public void process(ActionContext ac) throws Throwable {
   try {
     if (pool == null) pool = Mvcs.getIoc().get(JedisPool.class);
     int uid = Toolkit.uid();
     if (uid > 0) {
       try (Jedis jedis = pool.getResource()) {
         Pipeline pipe = jedis.pipelined();
         pipe.setbit(RKEY_ONLINE_DAY + Toolkit.today_yyyyMMdd(), uid, true);
         pipe.setbit(RKEY_ONLINE_HOUR + Toolkit.today_yyyyMMddHH(), uid, true);
         pipe.sync();
       }
     }
   } catch (Exception e) {
     if (e instanceof JedisConnectionException) {
       log.debug("jedis is down? ignore error");
     } else {
       log.debug("something wrong? ignore error", e);
     }
   }
   doNext(ac);
 }
  public void loc(String runactkey) throws Exception {
    HttpSession session = Mvcs.getHttpSession(true);
    DynamicObject token =
        (DynamicObject)
            session.getAttribute(com.skynet.framework.spec.GlobalConstants.sys_login_token);
    String deptid = token.getFormatAttr(com.skynet.framework.spec.GlobalConstants.sys_login_dept);

    DynamicObject ract =
        partyduebaseapproveService
            .getWorkFlowEngine()
            .getActManager()
            .getRactService()
            .locate(runactkey);
    String id = ract.getFormatAttr("dataid");
    String tableid = ract.getFormatAttr("tableid");
    DynamicObject baseapprove = partyduebaseapproveService.locate(id);
    DynamicObject baseapprovedetail =
        partyduebaseapprovedetailService.locateBy(
            Cnd.where("suggestid", "=", id).and("deptid", "=", deptid));
    List<DynamicObject> baseapprovedetails =
        partyduebaseapprovedetailService.findByCond(Cnd.where("suggestid", "=", id)); // 汇总意见
    // 权限设置
    set_author();

    // 查询可选路由
    String actdefid = ract.getFormatAttr("actdefid");
    List<DynamicObject> routes =
        partyduebaseapproveService
            .getWorkFlowEngine()
            .getFlowManager()
            .getBrouteService()
            .getRoutes(actdefid);

    ro.put("tableid", tableid);
    ro.put("runactkey", runactkey);
    ro.put("baseapprove", baseapprove);
    ro.put("baseapprovedetail", baseapprovedetail);
    ro.put("baseapprovedetails", baseapprovedetails);
    ro.put("routes", routes);
  }
 public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue)
     throws Exception {
   HttpServletRequest req = (HttpServletRequest) request;
   HttpServletResponse resp = (HttpServletResponse) response;
   if ("GET".equals(req.getMethod()) && !Strings.isBlank(req.getParameter("token"))) {
     String token = req.getParameter("token");
     try {
       token = Toolkit._3DES_decode(CrossScreen.csKEY, Toolkit.hexstr2bytearray(token));
       NutMap map = Json.fromJson(NutMap.class, token);
       Long t = map.getLong("t", -1);
       if (System.currentTimeMillis() - t > timeout * 1000) {
         resp.sendError(403); // TODO 提示token已经过期
         return false;
       }
       Integer uid = (Integer) map.get("uid");
       if (uid != null) {
         // 有登陆用户
         Toolkit.doLogin(new CrossScreenUserToken(uid), uid);
         if (sysLogService == null) {
           try {
             sysLogService = Mvcs.ctx().getDefaultIoc().get(SysLogService.class);
           } catch (Throwable e) {
           }
         }
         sysLogService.async(SysLog.c("method", "用户登陆", null, uid, "用户通过跨屏二维码登陆"));
       }
       resp.sendRedirect(map.getString("url"));
       return false;
     } catch (Exception e) {
       log.debug("bad token?", e);
       resp.sendError(502);
       return false;
     }
   } else {
     resp.sendError(403);
     return false;
   }
 }
  public DynamicObject get_author_common() throws Exception {
    // 获取各类权限
    // 流程信息
    DynamicObject swapFlow = ActionHelper.prepared_author_base();

    String runactkey = Mvcs.getReq().getParameter("runactkey");
    DynamicObject ract =
        partyduebaseapproveService
            .getWorkFlowEngine()
            .getActManager()
            .getRactService()
            .locate(runactkey);
    String runflowkey = ract.getFormatAttr("runflowkey");
    String dataid = ract.getFormatAttr("dataid");

    swapFlow.setAttr(GlobalConstants.swap_dataid, dataid);
    swapFlow.setAttr(GlobalConstants.swap_runactkey, runactkey);
    swapFlow.setAttr(GlobalConstants.swap_runflowkey, runflowkey);

    swapFlow.setAttr(GlobalConstants.swap_tableid, "PartyDue");

    return swapFlow;
  }
예제 #12
0
  /**
   * 为当前的 HTTP 请求对象设置一些必要的属性。包括:
   *
   * <ul>
   *   <li>本地化子字符串 => ${msg}
   *   <li>应用的路径名 => ${base}
   * </ul>
   *
   * @param req HTTP 请求对象
   */
  public static void updateRequestAttributes(HttpServletRequest req) {
    // 初始化本次请求的多国语言字符串
    Map<String, Map<String, Object>> msgss = getMessageSet();
    if (msgss == null && !ctx.localizations.isEmpty())
      msgss = ctx.localizations.values().iterator().next();
    if (null != msgss) {
      Map<String, Object> msgs = null;

      String lKey = Strings.sBlank(Mvcs.getLocalizationKey(), getDefaultLocalizationKey());

      if (!Strings.isBlank(lKey)) msgs = msgss.get(lKey);

      // 没有设定特殊的 Local 名字,随便取一个
      if (null == msgs) {
        if (msgss.size() > 0) msgs = msgss.values().iterator().next();
      }
      // 记录到请求中
      req.setAttribute(MSG, msgs);
    }

    // 记录一些数据到请求对象中
    req.setAttribute("base", req.getContextPath());
    req.setAttribute("$request", req);
  }
  public void init() {
    try {
      super.init();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    // 添加全局变量
    Map<String, Object> share = groupTemplate.getSharedVars();
    if (share == null) {
      share = new NutMap();
      groupTemplate.setSharedVars(share);
    }
    Ioc ioc = Mvcs.getIoc();
    share.put("ioc", ioc);
    PropertiesProxy conf = ioc.get(PropertiesProxy.class, "conf");
    share.put("conf", conf.toMap());

    if (!conf.getBoolean("cdn.enable", false) || Strings.isBlank(conf.get("cdn.urlbase"))) {
      share.put("cdnbase", "");
    } else {
      share.put("cdnbase", conf.get("cdn.urlbase"));
      MarkdownFunction.cdnbase = conf.get("cdn.urlbase");
    }
  }
예제 #14
0
파일: ParameterMod.java 프로젝트: naily/iph
  @POST
  @At("/ht/savepamdata")
  @Ok("json")
  public JSONObject saveParameterDataFromAccess(
      String mdbPath,
      String stationId,
      String mdbTableName,
      String dateField,
      ServletContext context) {
    JSONObject json = new JSONObject();
    json.put(Constant.SUCCESS, false);
    // log.info("tableName:"+ mdbTableName + " timefield:" + dateField + " station:" +stationId) ;

    try {
      long start = System.currentTimeMillis();
      AccessUtil au = new AccessUtil(this.getAppRealPath(context) + mdbPath);
      Ioc ioc = Mvcs.getIoc();
      if (null != ioc) {
        PropertiesProxy prop = ioc.get(PropertiesProxy.class, "config");
        if (StringUtil.checkNotNull(prop.get("accessdriver"))) {
          au.setDburl(prop.get("accessdriver"));
        }
      }
      log.info(au.getDburl());
      Connection con = au.getConnection();

      Statement stat = con.createStatement();
      total = au.getTotalRowNumber(stat, mdbTableName);

      long pageTotal = au.getTotalPageNumber(total);

      long insertdb = 0;
      String tmpl =
          "select top PAGESPEED * from TABLENAME where ID >(select top 1 max(ID) from (select top BEFOREROW ID from TABLENAME order by ID asc)) order by ID asc ";
      tmpl =
          tmpl.replaceAll("ID", dateField)
              .replaceAll("PAGESPEED", String.valueOf(au.pageSpeed))
              .replaceAll("TABLENAME", mdbTableName);
      for (int i = 1; i <= pageTotal; i++) {
        int ii = (i - 1) * au.pageSpeed;
        String sql = tmpl.replaceAll("BEFOREROW", String.valueOf(ii));

        if (i == 1) {
          sql = sql.substring(0, sql.indexOf("where"));
          sql += "order by ID asc".replace("ID", dateField);
        }
        ResultSet rset = au.execSQL(stat, sql);
        if (null != rset) {
          // 把当前结果集中存在的fieldsName找出来
          List<String> available = new ArrayList<String>();
          List<String> list = au.getAllColumnName(rset.getMetaData());
          for (String str : au.fieldsName) {
            if (au.isExistString(list, str)) {
              available.add(str);
            }
          }

          List<Parameter> data = new ArrayList();
          while (rset.next()) {
            Parameter p = new Parameter();
            String time = rset.getString(dateField);

            p.setSrcTimestr(time);
            p.setCreateDate(DateUtil.convertStringToDate(time, DateUtil.pattern5));
            p.setStationID(stationId);
            // StringBuilder ss = new StringBuilder(rset.getString("mytime")).append("\t");
            // 遍历全部字段并存到java object 中
            for (String fn : available) {
              // ss.append(rset.getString(fn)).append("\t") ;
              BeanUtils.setProperty(p, fn, String.valueOf(rset.getString(fn)));
            }

            data.add(p);
            dls.insertNDY(tableName, p.getStationID(), null, p.getCreateDate());
          }
          // log.info("得到: " + data.size()) ;
          if (null != data && data.size() > 0) {
            // 把已经存在的对象删除掉
            batchDeleteParameter(stationId, data);
            insertdb += data.size();
            for (Parameter pa : data) {
              baseService.dao.insert(stationId, cov(pa, true));
            }
            // baseService.dao.insert(data) ;
            dls.insert("01", tableName, getHTLoginUserName());
            courr = insertdb;
          }
        }
      }
      // log.info("共得到: " + insertdb) ;
      long end = System.currentTimeMillis();

      json.put(Constant.SUCCESS, true);
      json.put("usetime", (end - start) / 1000 + " 秒");
      json.put("insertRow", insertdb + " 条");
      // log.debug(json.get("usetime")) ;
    } catch (Exception e) {
      // e.printStackTrace();
      json.put(Constant.INFO, e.getLocalizedMessage());
    } finally {
      return json;
    }
  }
예제 #15
0
파일: NutzUtil.java 프로젝트: Geolem/Jcoder
 public static void init(Class<?> c) {
   IocBy ib = c.getAnnotation(IocBy.class);
   Ioc ioc = Mirror.me(ib.type()).born().create(null, ib.args());
   Mvcs.setIoc(ioc);
 }
예제 #16
0
 public void render(HttpServletRequest req, HttpServletResponse resp, Object obj)
     throws IOException {
   Mvcs.write(resp, null == obj ? data : obj, format);
 }
예제 #17
0
파일: WechatModule.java 프로젝트: howe/gs
  @At("/wechat/gaoseng")
  @POST
  @Ok("raw")
  public void responseMsg() throws IOException, DocumentException {

    SAXReader reader = new SAXReader();
    InputStream in = Mvcs.getReq().getInputStream();
    Document doc = reader.read(in);
    Element root = doc.getRootElement();

    String toUserName = root.elementText("ToUserName"); // 开发者微信号
    String fromUserName = root.elementText("FromUserName"); // 发送方帐号(一个OpenID)
    String createTime = root.elementText("CreateTime"); // 消息创建时间 (整型)
    String msgType = root.elementText("MsgType"); // 消息类型
    String content = root.elementText("Content"); // 文本消息内容
    String msgId = root.elementText("MsgId"); // 消息id,64位整型

    //		System.out.println("fromUserName: "******"toUserName: "******"qq") || content.equals("求签")) {

      Date date = new Date();
      DateFormat format = new SimpleDateFormat("yyyy-MM-dd");

      Sql sql1 =
          Sqls.create(
              "SELECT t.* FROM gs_qiuqian_result t WHERE t.OPENID = @OPENID AND t.CREATETIME = @CREATETIME");
      sql1.params().set("CREATETIME", format.format(date).substring(0, 10));
      sql1.params().set("OPENID", fromUserName);
      sql1.setCallback(
          new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql1) throws SQLException {
              Map<String, String> map = new HashMap<String, String>();
              while (rs.next()) map.put("qwid", rs.getString("qwid"));
              return map;
            }
          });
      dao.execute(sql1);
      Map<String, String> map = sql1.getObject(HashMap.class);
      if (map.size() == 0) {
        String qwId = cn.gaoseng.tool.Lottery.getLottery("1");
        Sql sql2 = Sqls.create("SELECT t.* FROM gs_qiuqian_qianwen t WHERE t.ID=@ID");
        sql2.params().set("ID", qwId);

        Sql sql3 =
            Sqls.create(
                "INSERT INTO gs_qiuqian_result(OPENID,CREATETIME,QWID) VALUES(@OPENID,@CREATETIME,@QWID)");
        sql3.params().set("QWID", qwId);
        sql3.params().set("OPENID", fromUserName);
        sql3.params().set("CREATETIME", format.format(date).substring(0, 10));
        sql2.setCallback(
            new SqlCallback() {
              public Object invoke(Connection conn, ResultSet rs, Sql sql2) throws SQLException {
                Map<String, String> map1 = new HashMap<String, String>();
                while (rs.next()) {
                  map1.put("id", rs.getString("id"));
                  map1.put("title", rs.getString("title"));
                  map1.put("url", rs.getString("url"));
                  map1.put("jieqian", rs.getString("jieqian"));
                  map1.put("picurl", rs.getString("picurl"));
                  map1.put("typeid", rs.getString("typeid"));
                }
                return map1;
              }
            });
        dao.execute(sql2, sql3);
        Map<String, String> map1 = sql2.getObject(HashMap.class);
        if (map1.size() == 0) {
          out.printf(
              RESPONSE_TXT,
              fromUserName,
              toUserName,
              System.currentTimeMillis(),
              "text",
              "欢迎您访问高僧网[呲牙]   在线求签 请输入 qq或者求签");
        } else {

          out.printf(
              RESPONSE_IMAGE_TXT,
              fromUserName,
              toUserName,
              System.currentTimeMillis(),
              map1.get("title"),
              map1.get("jieqian"),
              map1.get("picurl"),
              map1.get("url"));
        }
      } else {
        Sql sql4 = Sqls.create("SELECT t.* FROM gs_qiuqian_qianwen t WHERE t.ID=@ID");
        sql4.params().set("ID", map.get("qwid"));
        sql4.setCallback(
            new SqlCallback() {
              public Object invoke(Connection conn, ResultSet rs, Sql sql4) throws SQLException {
                Map<String, String> map2 = new HashMap<String, String>();
                while (rs.next()) {
                  map2.put("id", rs.getString("id"));
                  map2.put("title", rs.getString("title"));
                  map2.put("url", rs.getString("url"));
                  map2.put("jieqian", rs.getString("jieqian"));
                  map2.put("picurl", rs.getString("picurl"));
                  map2.put("typeid", rs.getString("typeid"));
                }
                return map2;
              }
            });
        dao.execute(sql4);
        Map<String, String> map2 = sql4.getObject(HashMap.class);
        if (map2.size() == 0) {
          out.printf(
              RESPONSE_TXT,
              fromUserName,
              toUserName,
              System.currentTimeMillis(),
              "text",
              "欢迎您访问高僧网[呲牙]   在线求签 请输入 qq或者求签");
        } else {

          out.printf(
              RESPONSE_IMAGE_TXT,
              fromUserName,
              toUserName,
              System.currentTimeMillis(),
              map2.get("title"),
              map2.get("jieqian"),
              map2.get("picurl"),
              map2.get("url"));
        }
      }

    } else {

      out.printf(
          RESPONSE_TXT,
          fromUserName,
          toUserName,
          System.currentTimeMillis(),
          "text",
          "欢迎您访问高僧网[呲牙]   在线求签 请输入 qq或者求签");
    }
    /** The Dead Code end */
    in.close();
    in = null;
    out.close();
    out = null;
  }
예제 #18
0
 private static final String webinfPath(String str) {
   return Mvcs.getServletContext().getRealPath("/WEB-INF") + str;
 }
예제 #19
0
파일: NutzUtil.java 프로젝트: Geolem/Jcoder
 public static void close() {
   Mvcs.close();
 }