GoogleDocs 2022-07-27 16:01 采纳率: 0%
浏览 214
已结题

mongodb liunx 服务 报错Document does not contain key counts

问题遇到的现象和发生背景

代码链接mongodb 线下的服务 正常运行 没有错误
改为liunx 部署的mongodb接口就会报错异常

问题相关代码,请勿粘贴截图
List<Object> countData = new ArrayList<>();


        long startTime = 0; //开始时间(秒)

        long endTime = 0; //结束时间(秒),默认为当前时间

        /**
         * 如时间单位为月和天,默认开始时间为当前时间的一年前 ; 时间单位为小时,默认开始时间为当前时间的一个月前;
         * 时间单位为分钟,则默认开始时间为当前这一天的0点
         */
        long defStartTime = timeUnit == 4 ? DateUtil.getTodayMorning().getTime() / 1000
                : timeUnit == 3 ? DateUtil.getLastMonth().getTime() / 1000 : DateUtil.getLastYear().getTime() / 1000;

        startTime = StringUtil.isEmpty(startDate) ? defStartTime : DateUtil.toDate(startDate).getTime() / 1000;
        endTime = StringUtil.isEmpty(endDate) ? DateUtil.currentTimeSeconds() : DateUtil.toDate(endDate).getTime() / 1000;

        BasicDBObject queryTime = new BasicDBObject("$ne", null);

        if (startTime != 0 && endTime != 0) {
            queryTime.append("$gt", startTime);
            queryTime.append("$lt", endTime);
        }

        BasicDBObject query = new BasicDBObject("createTime", queryTime);

        //获得用户集合对象
        DBCollection collection = SKBeanUtils.getDatastore().getCollection(getEntityClass());

        String mapStr = "function Map() { "
                + "var date = new Date(this.createTime*1000);"
                + "var year = date.getFullYear();"
                + "var month = (\"0\" + (date.getMonth()+1)).slice(-2);"  //month 从0开始,此处要加1
                + "var day = (\"0\" + date.getDate()).slice(-2);"
                + "var hour = (\"0\" + date.getHours()).slice(-2);"
                + "var minute = (\"0\" + date.getMinutes()).slice(-2);"
                + "var dateStr = date.getFullYear()" + "+'-'+" + "(parseInt(date.getMonth())+1)" + "+'-'+" + "date.getDate();";

        if (timeUnit == 1) { // counType=1: 每个月的数据
            mapStr += "var key= year + '-'+ month;";
        } else if (timeUnit == 2) { // counType=2:每天的数据
            mapStr += "var key= year + '-'+ month + '-' + day;";
        } else if (timeUnit == 3) { //counType=3 :每小时数据
            mapStr += "var key= year + '-'+ month + '-' + day + '  ' + hour +' : 00';";
        } else if (timeUnit == 4) { //counType=4 :每分钟的数据
            mapStr += "var key= year + '-'+ month + '-' + day + '  ' + hour + ':'+ minute;";
        }

        mapStr += "emit(key,1);}";

        String reduce = "function Reduce(key, values) {" +
                "return Array.sum(values);" +
                "}";
        MapReduceCommand.OutputType type = MapReduceCommand.OutputType.INLINE;//
        MapReduceCommand command = new MapReduceCommand(collection, mapStr, reduce, null, type, query);


        MapReduceOutput mapReduceOutput = collection.mapReduce(command);

运行结果及报错内容

img

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月4日
    • 创建了问题 7月27日

    悬赏问题

    • ¥30 为什么会失败呢,该如何调整
    • ¥50 如何在不能联网影子模式下的电脑解决usb锁
    • ¥20 服务器redhat5.8网络问题
    • ¥15 如何利用c++ MFC绘制复杂网络多层图
    • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
    • ¥15 python螺旋图像
    • ¥15 算能的sail库的运用
    • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
    • ¥15 找代写python里的jango设计在线书店
    • ¥15 请教如何关于Msg文件解析