• StringBuffer 可变参数拼接


        @RequestMapping(value="/getFundsCount",method=RequestMethod.POST)
        public Result getFundsCount(HttpServletRequest request,String depcode) {
            //获取用户信息
            String tokenuser = redisTemplate.opsForValue().get(request.getHeader("usertoken"));
            LoginUser user = (LoginUser) JSONUtil.toBean(tokenuser, LoginUser.class);
            String usertype = user.getUsertype();
            Map<String,Object> map = new HashMap<String,Object>();
            //数量默认值是0
            String Notmanagecount = "0";
            String Rejectcount = "0";
            String Projectcount = "0";
            String Fundsidcount = "0";
            
            //count返回值long
            StringBuffer sqlNotmanagecount = new StringBuffer("SELECT count(*) notmanagecount FROM djjf_project_funds where status=");
            StringBuffer sqlRejectcount = new StringBuffer("SELECT count(*) rejectcount FROM djjf_project_funds f LEFT JOIN djjf_review r "
                    +"ON f.fundsid = r.objectid WHERE f.status=05 AND r.status=02 AND r.creusertype=");
            //查询总项目个数
            String sqlProjectcount = "SELECT count(*) projectcount FROM djjf_project";
            String sqlFundsidcount = "SELECT COUNT(*)fundsidcount FROM djjf_project_funds";
            
            if("jdorg.user".equals(usertype)) {
                /*String stq=sqlNotmanagecount.append("'01'").toString();*/
                sqlNotmanagecount.append("'01'");
                sqlRejectcount.append("'jdorg.user'");//可变参数字符串拼接
                if(depcode!=null&&!"".equals(depcode)) {
                    sqlNotmanagecount.append(" and depcode=").append("'"+depcode+"'");
                    sqlRejectcount.append(" and f.depcode=").append("'"+depcode+"'");
                }
                    List<Map<String,Object>> countNotmanagecount = baseServerImpi.findListObjectBySql(sqlNotmanagecount.toString());
                    Notmanagecount = String.valueOf(countNotmanagecount.get(0).get("notmanagecount"));
                    //被驳回
                    List<Map<String,Object>> countRejectcount = baseServerImpi.findListObjectBySql(sqlRejectcount.toString());
                    Rejectcount = String.valueOf(countRejectcount.get(0).get("rejectcount"));
                
            }else if("jdleader.user".equals(usertype)) {
                
                sqlNotmanagecount.append("'02'");
                sqlRejectcount.append("'jdleader.user'");
                if(depcode!=null&&!"".equals(depcode)) {
                    sqlNotmanagecount.append(" and depcode=").append("'"+depcode+"'");
                    sqlRejectcount.append(" and f.depcode=").append("'"+depcode+"'");
                }
                List<Map<String,Object>> countNotmanagecount = baseServerImpi.findListObjectBySql(sqlNotmanagecount.toString());
                Notmanagecount = String.valueOf(countNotmanagecount.get(0).get("notmanagecount"));
                //被驳回
                List<Map<String,Object>> countRejectcount = baseServerImpi.findListObjectBySql(sqlRejectcount.toString());
                Rejectcount = String.valueOf(countRejectcount.get(0).get("rejectcount"));
            }
            //项目总数
            List<Map<String,Object>> countProjectcount = baseServerImpi.findListObjectBySql(sqlProjectcount);
            Projectcount = String.valueOf(countProjectcount.get(0).get("projectcount"));
            //经费总数
            List<Map<String,Object>> countFundsidcount = baseServerImpi.findListObjectBySql(sqlFundsidcount);
            Fundsidcount = String.valueOf(countFundsidcount.get(0).get("fundsidcount"));
            //将数量放入map
            map.put("notmanagecount",Notmanagecount);
            map.put("rejectcount",Rejectcount);
            map.put("projectcount", Projectcount);
            map.put("fundsidcount", Fundsidcount);
            return Result.ok().put("result", map);
        }
  • 相关阅读:
    Arduino-LCD1602液晶显示器
    photoshop--选区变形
    利用github给国外文件下载加速
    开发老人笔记:Git 常用命令清单
    区块链轻节点:“身”轻,责任重
    需求条目化:一个让用户故事有效落地的套路
    十八般武艺玩转GaussDB(DWS)性能调优:Plan hint运用
    跨越全场景统一架构三大挑战,MindSpore亮出“四招”
    看图学NumPy:掌握n维数组基础知识点,看这一篇就够了
    进来抄作业:分布式系统中保证高可用性的常用经验
  • 原文地址:https://www.cnblogs.com/yanchaohui/p/10119421.html
Copyright © 2020-2023  润新知