多条件过滤

 

 

 

	getExamList:function(semester, timeStart, timeEnd, examType, subCode, callback){
		var json = JSON.parse($.cookie('user'))
		if (subCode === undefined) {
			subCode = '0';
		}
		if (timeStart === null || timeStart === undefined || timeStart === '') {
			timeStart = 0;
			timeEnd = 0;
		}
		var url = "../xqfx/multi/dkfx/kslb/list/" + json.schCode+ "/"+ json.yearIn + "/"+json.clzCode + "/"+subCode + "/"+semester + "/"+timeStart + "/"+timeEnd + "/"+examType;
		Tomd.wait();
		$.get(url, function(response){
         	if (0 != response.code)
         		return;
			Tomd.waitok();
         	callback(response.data);
		});
	},
	/**
	 * 考试(试卷列表)
	 */
	@ResponseBody
	@GetMapping("/list/{schCode}/{yearIn}/{clzCode}/{subCode}/{semester}/{timeStart}/{timeEnd}/{examType}")
	public JSONObject findPapers(@NonNull @PathVariable Long schCode,
			@NonNull @PathVariable Integer yearIn,
			@NonNull @PathVariable Long clzCode,
			@NonNull @PathVariable String subCode,
			@NonNull @PathVariable Integer semester,
			@PathVariable Long timeStart,
			@PathVariable Long timeEnd,
			@NonNull @PathVariable Integer examType) {
		JSONObject result = service.findPapers(subCode, schCode, yearIn, clzCode, semester, timeStart, timeEnd, examType);
		return result;
	}
@Override
	public JSONObject findPapers(String subCode, Long schCode, Integer yearIn, Long clzCode, Integer semester, Long timeStart, Long timeEnd, Integer examType) {
		JSONObject result = findClzPapers(schCode, yearIn, clzCode, subCode);
		JSONArray array = new JSONArray();
		for (int i=0;i<result.getJSONArray("data").size();i++){
			JSONObject json = new JSONObject();
			long examDate = result.getJSONArray("data").getJSONObject(i).getJSONObject("examination").getLongValue("examDate");
			Integer examTypeCode = result.getJSONArray("data").getJSONObject(i).getJSONObject("examination").getJSONObject("examType").getInteger("code");
			String examTypeName = result.getJSONArray("data").getJSONObject(i).getJSONObject("examination").getJSONObject("examType").getString("name");
			long examCode = result.getJSONArray("data").getJSONObject(i).getJSONObject("examination").getLong("examCode");
			String examName = result.getJSONArray("data").getJSONObject(i).getJSONObject("examination").getString("examName");
			long paperCode = result.getJSONArray("data").getJSONObject(i).getJSONObject("paper").getLong("paperCode");
			String subject = result.getJSONArray("data").getJSONObject(i).getJSONObject("paper").getJSONObject("subject").getString("code");

			if(semester == 0){
				if(examType == 0){
				 	json.put("examType", examTypeName);
					json.put("examCode", examCode);
					json.put("examName", examName);
					json.put("paperCode", paperCode);
					json.put("subCode", subject);
					array.add(json);
				}else if(examTypeCode == examType){
				 	json.put("examType", examTypeName);
					json.put("examCode", examCode);
					json.put("examName", examName);
					json.put("paperCode", paperCode);
					json.put("subCode", subject);
					array.add(json);
				}
				
			}else if(semester == -1){
				if(examType == 0 && examDate >= timeStart && examDate <= timeEnd){
				 	json.put("examType", examTypeName);
					json.put("examCode", examCode);
					json.put("examName", examName);
					json.put("paperCode", paperCode);
					json.put("subCode", subject);
					array.add(json);
				}else if(examTypeCode == examType && examDate >= timeStart && examDate <= timeEnd){
				 	json.put("examType", examTypeName);
					json.put("examCode", examCode);
					json.put("examName", examName);
					json.put("paperCode", paperCode);
					json.put("subCode", subject);
					array.add(json);
				}
			}else if(semester != 0 && semester != -1){
				 long recent = getRecent(semester); 
				 if(examType == 0 && examDate > recent){
					 json.put("examType", examTypeName);
						json.put("examCode", examCode);
						json.put("examName", examName);
						json.put("paperCode", paperCode);
						json.put("subCode", subject);
						array.add(json);
				 }else if(examTypeCode == examType && examDate > recent){
					 	json.put("examType", examTypeName);
						json.put("examCode", examCode);
						json.put("examName", examName);
						json.put("paperCode", paperCode);
						json.put("subCode", subject);
						array.add(json);
				 }
				 
			}	
		}
		result.put("data", array);
		return result;
	}
	
	@Override
	public JSONObject getPaper(Long paperCode, Long schCode, Integer yearIn, Integer includeAbsent, Integer includeTransient, Integer examCategory) {
		JSONObject result = getSglSchRis(paperCode, schCode, yearIn, 0L, AnalyzeConstant.ALL, includeAbsent, includeTransient, examCategory);
		return result;
	}
	
	//获取最近日期
	public long getRecent(Integer semester){
		long recent = 0;
		 Calendar c = Calendar.getInstance();
	        //过去七天
	        c.setTime(new Date());
	        c.add(Calendar.DATE, - 7);
	        long week = c.getTimeInMillis();
	        
	        //过去一月
	        c.setTime(new Date());
	        c.add(Calendar.MONTH, -1);
	        long mon = c.getTimeInMillis();
	         
	        //过去六个月
	        c.setTime(new Date());
	        c.add(Calendar.MONTH, -6);
	        long mon6 = c.getTimeInMillis();
	         
	        //过去一年
	        c.setTime(new Date());
	        c.add(Calendar.YEAR, -1);
	        long year = c.getTimeInMillis();
		
	        if(semester == 1){
	        	recent = year;
	        }else if(semester == 2){
	        	recent = mon6;
	        }else if(semester == 3){
	        	recent = mon;
	        }else if(semester == 4){
	        	recent = week;
	        }
		
		return recent;
		
	}

 

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c = Calendar.getInstance();
         
        //过去七天
        c.setTime(new Date());
        c.add(Calendar.DATE, - 7);
        Date d = c.getTime();
        String day = format.format(d);
        System.out.println("过去七天:"+day);
         
        //过去一月
        c.setTime(new Date());
        c.add(Calendar.MONTH, -1);
        Date m = c.getTime();
        String mon = format.format(m);
        System.out.println("过去一个月:"+mon);
         
        //过去三个月
        c.setTime(new Date());
        c.add(Calendar.MONTH, -3);
        Date m3 = c.getTime();
        String mon3 = format.format(m3);
        System.out.println("过去三个月:"+mon3);
         
        //过去一年
        c.setTime(new Date());
        c.add(Calendar.YEAR, -1);
        Date y = c.getTime();
        String year = format.format(y);
        System.out.println("过去一年:"+year);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值