学生成绩总表(选课前)

 

;
(function() {
    'use strict';
    var REPORT3001 = {
        offOn: true,
        init: function() {
            this.renderTable();
            this.onClickStar();
            this.downTemplate();
        },
        renderTable: function() {
            DREPORT.getNewSelectBefore(function(res){
                document.getElementById('report3001').innerHTML = template('report3001Temp', res);
                var order = [[0, 'asc']], noSort = [{ targets: [], "orderable": false }]
                TOOL.dataTable('report3001', order, noSort, true, 'search');
                // 判断变化上升还是下降
                TOOL.fallOrUpChange('report3001');
            });
        },
        downTemplate: function() {
            $('#download').click(function() {
                window.open('url.xlsx', '_blank');
            })
        },
        // 关注
        onClickStar: function() {
            let self = this;
            $('#togglerStar').on('click', function() {
                if (self.offOn) {
                    $(this).find('.iconfont').removeClass('icon-heart-o').addClass('icon-heart');
                    console.log('已关注')
                    self.offOn = false;
                } else {
                    $(this).find('.iconfont').removeClass('icon-heart').addClass('icon-heart-o');
                    console.log('未关注')
                    self.offOn = true;
                }
            });
        }
    }
    REPORT3001.init();
})()
	// 学生成绩总表 选课前
	getNewSelectBefore: function(callback){
		var json = JSON.parse($.cookie('user'))
		var schCode = json.schCode;
		var yearIn = json.yearIn;
		let url = "../../../report/xscjzb1/list/2001544525215806/"+schCode+"/"+yearIn;
		Tomd.wait();
		$.get(url).done(function (response) {
			Tomd.waitok();
         	if (0 != response.code)
         		return;
         	callback(response.data);
		});
	},
package com.moofen.school.report.controller;

import javax.annotation.Resource;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.moofen.school.BaseController;
import com.moofen.school.report.service.Report_3001_Service;

@Controller
@RequestMapping("/report/xscjzb1")
public class report_3001_controller extends BaseController {
	
	@Resource(name = "report_3001_service")
	private Report_3001_Service service;
	
	/**
	 * 学生成绩总表(选课前)
	 */
	@ResponseBody
	@GetMapping("/list/{examCode}/{schCode}/{yearIn}")
	public JSONObject xscjzb1(@NonNull @PathVariable Long examCode,
			@NonNull @PathVariable Long schCode,
			@NonNull @PathVariable Integer yearIn) {
		JSONObject result = service.findXscjzb1(examCode, schCode, yearIn, INCLUDE_ABSENT, INCLUDE_TRANSIENT, EXAM_CATEGORY);
		return result;
	}
}
package com.moofen.school.report.service.impl;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.moofen.core.constant.AnalyzeConstant;
import com.moofen.school.basic.service.ContextService;
import com.moofen.school.report.service.Report_3001_Service;
import com.moofen.school.util.StringUtil;
import com.moofen.school.xqfx.multi.qkfx.service.impl.MultiServiceImpl;

@Service("report_3001_service")
public class Report_3001_ServiceImpl extends MultiServiceImpl implements Report_3001_Service {

	
	@Resource(name = "contextService")
	private ContextService contextService;
	
	@Override
	public JSONObject findXscjzb1(Long examCode, Long schCode, Integer yearIn, Integer includeAbsent,
			Integer includeTransient, Integer examCategory) {
		JSONObject allJson = findMulTotalScores(AnalyzeConstant.SUMM_ALL, examCode, schCode, yearIn, null, null, null, includeAbsent, includeTransient, examCategory, null);
		JSONObject majorJson = findMulTotalScores(AnalyzeConstant.SUMM_MAJOR, examCode, schCode, yearIn, null, null, null, includeAbsent, includeTransient, examCategory, null);
		Map<String, JSONObject> majorMap = groupByStudent(majorJson.getJSONArray("data"));
		List<String> titleList = new ArrayList<String>();
		
		JSONArray array = new JSONArray();
		for (int i = 0; i < allJson.getJSONArray("data").size(); i++) {
			JSONObject stuJson = allJson.getJSONArray("data").getJSONObject(i);
			JSONObject json = new JSONObject();
			json.put("className", stuJson.getJSONObject("clazz").getString("clzAlias"));
			String stuCode = stuJson.getJSONObject("student").getString("schStuCode");
			json.put("stuCode", stuCode);
			json.put("stuName", stuJson.getJSONObject("student").getString("stuAlias"));
			json.put("gender", "无");
			json.put("selection", "无");
			json.put("courseScore", StringUtil.formatNumber(majorMap.get(stuCode).getDouble("score") / 100));
			json.put("courseClsRank", majorMap.get(stuCode).getInteger("clzRankPosition"));
			json.put("courseGrdRank", majorMap.get(stuCode).getInteger("grdRankPosition"));
			json.put("score", StringUtil.formatNumber(stuJson.getDouble("score") / 100));
			json.put("clsRank", stuJson.getInteger("clzRankPosition"));
			json.put("grdRank", stuJson.getInteger("grdRankPosition"));
			List<Object> items = new ArrayList<Object>();
			sortItems(stuJson.getJSONArray("items"));
			for (int j = 0; j < stuJson.getJSONArray("items").size(); j++) {
				String subCode = stuJson.getJSONArray("items").getJSONObject(j).getString("subCode");
				String section = stuJson.getJSONArray("items").getJSONObject(j).getString("section");
				if (0 == i) {
					if (AnalyzeConstant.ALL.equals(section)) {
						titleList.add(contextService.getSubjectBy(subCode).getName());
					} else {
						titleList.add(contextService.getSubjectBy(subCode).getName() + section);
					}
				}
				items.add(StringUtil.formatNumber(stuJson.getJSONArray("items").getJSONObject(j).getDouble("score") / 100));
			}
			json.put("data", items);
			array.add(json);
		}

		JSONObject json = new JSONObject();
		json.put("title", titleList);
		json.put("datas", array);
		allJson.put("data", json);
		return allJson;
	}
	
	
	private Map<String, JSONObject> groupByStudent(JSONArray array){
		Map<String, JSONObject> result = new HashMap<String, JSONObject>();
		for(int i = 0; i < array.size(); i++){
			String stuCode = array.getJSONObject(i).getJSONObject("student").getString("schStuCode");
			result.put(stuCode, array.getJSONObject(i));
		}
		return result;
	}
	
	

	private void sortItems(JSONArray array) {
		array.sort(new Comparator<Object>() {

			@Override
			public int compare(Object o1, Object o2) {
				JSONObject json1 = (JSONObject) o1;
				JSONObject json2 = (JSONObject) o2;
				int result = json1.getString("subCode").compareTo(json2.getString("subCode"));
				if (0 != result)
					return result;
				if (AnalyzeConstant.ALL.equals(json1.getString("section"))) {
					if (AnalyzeConstant.ALL.equals(json2.getString("section"))) {
						return 0;
					} else {
						return -1;
					}
				} else {
					if (AnalyzeConstant.ALL.equals(json2.getString("section"))) {
						return 1;
					} else {
						return json1.getString("section").compareTo(json2.getString("section"));
					}
				}
			}

		});
	}
	

}

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值