问题遇到的现象和发生背景
代码链接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);