• 公司培训课时汇总


    /**
    	 * 公司培训课时汇总
    	 * @return
    	 */
    	@Override
    	public List<CompanyTrainingClassGather> getCompanyTrainingClassGather() {
    		List<CompanyTrainingClassGather> list=new ArrayList<>();
    		//查询部门表获取所有部门名称和部门id
    		List<Dept>deptList=deptUserEmployeeUtil.getDeptList(AuthUtil.getTenantId());
    		if(Func.isNotEmpty(deptList)){
    			String nowStartDate=getFirstDayOfMonth();//当月开始第一天
    			String nowEndDate=getLastDayOfMonth();//当月最后一天
    				for(Dept dept:deptList){
    					double twelveMonthTotal=0;//该部门12月培训总时长
    					CompanyTrainingClassGather trainingClassGather= new CompanyTrainingClassGather();
    					for(int i=1;i<=12;i++){
    						double sum=0;//每个部门该月培训总时长
    						trainingClassGather.setDeptName(dept.getDeptName());
    						String startDate=getFirstDayOfMonth(i);
    						String endDate=getLastDayOfMonth(i);
    						String deptId=String.valueOf(dept.getId());
    						//查询每个部门该月的培训时长
    						sum=employeeTrainingRecordMapper.getTrainingRecordTotalByDeptId(deptId,startDate,endDate,AuthUtil.getTenantId());
    						twelveMonthTotal+=sum;
    						//将每个部门的12月的培训时长放入对应的月份
    						switch (i) {
    							case 1:
    								//将一月份人员培训时长放入实体类类
    								trainingClassGather.setJanuary(String.valueOf(sum));
    								break;
    							case 2:
    								trainingClassGather.setFebruary(String.valueOf(sum));
    								break;
    							case 3:
    								trainingClassGather.setMarch(String.valueOf(sum));
    								break;
    							case 4:
    								trainingClassGather.setApril(String.valueOf(sum));
    								break;
    							case 5:
    								trainingClassGather.setMay(String.valueOf(sum));
    								break;
    							case 6:
    								trainingClassGather.setJune(String.valueOf(sum));
    								break;
    							case 7:
    								trainingClassGather.setJuly(String.valueOf(sum));
    								break;
    							case 8:
    								trainingClassGather.setAugust(String.valueOf(sum));
    								break;
    							case 9:
    								trainingClassGather.setSeptember(String.valueOf(sum));
    								break;
    							case 10:
    								trainingClassGather.setOctober(String.valueOf(sum));
    								break;
    							case 11:
    								trainingClassGather.setNovember(String.valueOf(sum));
    								break;
    							case 12:
    								trainingClassGather.setDecember(String.valueOf(sum));
    								break;
    						}
    					}
    					//根据部门id查询当前部门在职人数
    					List<AllEmployeeBasicInformation> deptUserSum= employeeTrainingRecordMapper.getDeptUserByDeptId(String.valueOf(dept.getId()),nowStartDate,nowEndDate,AuthUtil.getTenantId());
    					//计算部门员工培训时长平均值
    					if(Func.isNotEmpty(deptUserSum)){
    						double averageValue= twelveMonthTotal/deptUserSum.size();
    						//保留两位小数
    						DecimalFormat df= new DecimalFormat("######0.00");
    						trainingClassGather.setAverageValue(String.valueOf(df.format(averageValue)));
    					}
    					//将每个部门12个月培训总时长放入实体类
    					trainingClassGather.setTotals(String.valueOf(twelveMonthTotal));
    					list.add(trainingClassGather);
    				}
    
    		}
    		return list;
    	}
    
    	/**
    	 * 人均培训时长
    	 * @return
    	 */
    	@Override
    	public Map<String,List> getAverageTrainingClass() {
    		//查询部门表获取所有部门名称和部门id
    		List<Dept>deptList=deptUserEmployeeUtil.getDeptList(AuthUtil.getTenantId());
    		Map<String,List>returnMap=new HashMap<>();
    		//部门名称列表
    		List<String>deptNameList=new ArrayList<>();
    		//人均课时列表
    		List<String>averageValueList=new ArrayList<>();
    		returnMap.put("deptNameList",deptNameList);
    		returnMap.put("averageValueList",averageValueList);
    		if(Func.isNotEmpty(deptList)){
    			String nowStartDate=getFirstDayOfMonth();//当月开始第一天
    			String nowEndDate=getLastDayOfMonth();//当月最后一天
    			for(Dept dept:deptList){
    				//查询每个部门该月的培训时长
    				String deptId=String.valueOf(dept.getId());
    				double sum=employeeTrainingRecordMapper.getTrainingRecordTotalByDeptId(deptId,"","",AuthUtil.getTenantId());
    				//根据部门id查询当前部门在职人数
    				List<AllEmployeeBasicInformation> deptUserSum= employeeTrainingRecordMapper.getDeptUserByDeptId(deptId,nowStartDate,nowEndDate,AuthUtil.getTenantId());
    				//计算部门员工培训时长平均值
    				double averageValue=0;
    				if(Func.isNotEmpty(deptUserSum)){
    					averageValue= sum/deptUserSum.size();
    				}
    				returnMap.get("deptNameList").add(dept.getDeptName());
    				//保留两位小数
    				DecimalFormat df= new DecimalFormat("######0.00");
    				returnMap.get("averageValueList").add(df.format(averageValue));
    			}
    
    		}
    		return returnMap;
    	}
    
    	/**
    	 * 某个月份各个部门培训课时数
    	 * @param moth 年月日格式
    	 * @return
    	 */
    	@Transactional(rollbackFor = Exception.class)
    	@Override
    	public Map<String, List> getEachDeptTrainingClass(String moth) {
    		//查询部门表获取所有部门名称和部门id
    		List<Dept>deptList=deptUserEmployeeUtil.getDeptList(AuthUtil.getTenantId());
    		Map<String,List>returnMap=new HashMap<>();
    		//部门名称列表
    		List<String>deptNameList=new ArrayList<>();
    		//某个月份部门培训课时列表
    		List<String>totalTrainingList=new ArrayList<>();
    		returnMap.put("deptNameList",deptNameList);
    		returnMap.put("totalTrainingList",totalTrainingList);
    		if(Func.isNotEmpty(deptList)){
    			String startDate="";
    			String endDate="";
    			if(Func.isNotEmpty(moth)){
    				//日期转化格式
    				log.info("某个月份各个部门培训课时数moth======="+moth);
    				String findMoth=moth.replace("/","-");
    				String[]times=findMoth.split("-");
    				//获取指定日期年份
    				int year=Integer.valueOf(times[0]);
    				//获取指定日期月份
    				int mothOne=Integer.valueOf(times[1]);
    				//获取某年某月的第一天
    				startDate=getFisrtDayOfMonth(year,mothOne);
    				//获取某月的最后一天
    				endDate=getLastDayOfMonth(year,mothOne);
    			}else {
    				//moth为空获取当前月的第一天
    				startDate=getFirstDayOfMonth();
    				//获取当前月的最后一天
    				endDate=getLastDayOfMonth();
    			}
    			for(Dept dept:deptList){
    				//查询每个部门该月的培训时长
    				String deptId=String.valueOf(dept.getId());
    				double sum=employeeTrainingRecordMapper.getTrainingRecordTotalByDeptId(deptId,startDate,endDate,AuthUtil.getTenantId());
    				returnMap.get("deptNameList").add(dept.getDeptName());
    				//保留两位小数
    				DecimalFormat df= new DecimalFormat("######0.00");
    				returnMap.get("totalTrainingList").add(String.valueOf(df.format(sum)));
    			}
    		}
    		return returnMap;
    	}
    
    	/**
    	 * 培训课时趋势图
    	 * @return
    	 */
    	@Override
    	public Map<String, List> getTrainingClassTendencyPicture() {
    		Map<String,List>returnMap=new HashMap<>();
    		//月份列表
    		List<String>mothList=new ArrayList<>();
    		//每个月课时汇总list
    		List<String>eachMothTotalList=new ArrayList<>();
    		//每个月人均课时列表
    		List<String>mothAverageList=new ArrayList<>();
    		returnMap.put("mothList",mothList);
    		returnMap.put("mothAverageList",mothAverageList);
    		returnMap.put("eachMothTotalList",eachMothTotalList);
    		for(int i=1;i<=12;i++){
    			//获取该月第一天
    			String startDate=getFirstDayOfMonth(i);
    			//获取该月最后一天
    			String endDate=getLastDayOfMonth(i);
    			//获取公司该月培训总时长
    			double sum=employeeTrainingRecordMapper.getTrainingRecordTotalByDeptId("",startDate,endDate,AuthUtil.getTenantId());
    			//查询公司当前在职人数
    			int persons=employeeTrainingRecordMapper.getOnJobPerson(AuthUtil.getTenantId());
    			//计算公司该月平均培训课时
    			double averageValue=0;
    			if(Func.isNotEmpty(persons)){
    				averageValue=sum/persons;
    			}
    			//保留两位小数
    			DecimalFormat df= new DecimalFormat("######0.00");
    			returnMap.get("eachMothTotalList").add(String.valueOf(df.format(sum)));
    
    			returnMap.get("mothAverageList").add(String.valueOf(df.format(averageValue)));
    			switch (i) {
    				case 1:
    					returnMap.get("mothList").add("1月份");
    					break;
    				case 2:
    					returnMap.get("mothList").add("2月份");
    					break;
    				case 3:
    					returnMap.get("mothList").add("3月份");
    					break;
    				case 4:
    					returnMap.get("mothList").add("4月份");
    					break;
    				case 5:
    					returnMap.get("mothList").add("5月份");
    					break;
    				case 6:
    					returnMap.get("mothList").add("6月份");
    					break;
    				case 7:
    					returnMap.get("mothList").add("7月份");
    					break;
    				case 8:
    					returnMap.get("mothList").add("8月份");
    					break;
    				case 9:
    					returnMap.get("mothList").add("9月份");
    					break;
    				case 10:
    					returnMap.get("mothList").add("10月份");
    					break;
    				case 11:
    					returnMap.get("mothList").add("11月份");
    					break;
    				case 12:
    					returnMap.get("mothList").add("12月份");
    					break;
    			}
    
    		}
    		return returnMap;
    	}
    
    	/**
    	 * 从1月份到现在
    	 * 各个部门总培训课时数
    	 * @return
    	 */
    	@Override
    	public Map<String, List> getEveryDeptClassTotal() {
    		//查询部门表获取所有部门名称和部门id
    		List<Dept>deptList=deptUserEmployeeUtil.getDeptList(AuthUtil.getTenantId());
    		Map<String,List>returnMap=new HashMap<>();
    		//部门名称列表
    		List<String>deptNameList=new ArrayList<>();
    		//部门培训课时汇总
    		List<String>totalValueList=new ArrayList<>();
    		returnMap.put("deptNameList",deptNameList);
    		returnMap.put("totalValueList",totalValueList);
    		if(Func.isNotEmpty(deptList)){
    			for(Dept dept:deptList){
    				//每个部门从1月份到现在培训课时总数
    				String deptId=String.valueOf(dept.getId());
    				//获取当前月份最后一天
    				String endDate=getLastDayOfMonth();
    				//获取部门从1月份到现在培训总课时
    				double sum=employeeTrainingRecordMapper.getTrainingRecordTotalByDeptId(deptId,"",endDate,AuthUtil.getTenantId());
    				returnMap.get("deptNameList").add(dept.getDeptName());
    				returnMap.get("totalValueList").add(String.valueOf(sum));
    			}
    
    		}
    		return returnMap;
    	}
    
    	/**
    	 * double类型相加
    	 * @param v1
    	 * @param v2
    	 * @return
    	 */
    	public double add(double v1, double v2) {
    		BigDecimal b1 = new BigDecimal(Double.toString(v1));
    		BigDecimal b2 = new BigDecimal(Double.toString(v2));
    		return b1.add(b2).doubleValue();
    	}
    
    	/**
    	 * 获取某年某月的第一天
    	 * @Title:getFisrtDayOfMonth
    	 * @Description:
    	 * @param:@param year
    	 * @param:@param month
    	 * @param:@return
    	 * @return:String
    	 * @throws
    	 */
    	public String getFisrtDayOfMonth(int year,int month){
    		Calendar cal = Calendar.getInstance();
    		//设置年份
    		cal.set(Calendar.YEAR,year);
    		//设置月份
    		cal.set(Calendar.MONTH, month-1);
    		//获取某月最小天数
    		int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
    		//设置日历中月份的最小天数
    		cal.set(Calendar.DAY_OF_MONTH, firstDay);
    		//格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String firstDayOfMonth = sdf.format(cal.getTime());
    		return firstDayOfMonth;
    	}
    	/**
    	 * 获取某月的最后一天
    	 * @Title:getLastDayOfMonth
    	 * @Description:
    	 * @param:@param year
    	 * @param:@param month
    	 * @param:@return
    	 * @return:String
    	 * @throws
    	 */
    	public String getLastDayOfMonth(int year,int month){
    		Calendar cal = Calendar.getInstance();
    		//设置年份
    		cal.set(Calendar.YEAR,year);
    		//设置月份
    		cal.set(Calendar.MONTH, month-1);
    		//获取某月最大天数
    		int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    		//设置日历中月份的最大天数
    		cal.set(Calendar.DAY_OF_MONTH, lastDay);
    		//格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String lastDayOfMonth = sdf.format(cal.getTime());
    		return lastDayOfMonth;
    	}
    
    	/**
    	 * 获得该月第一天
    	 * @param month
    	 * @return
    	 */
    	public String getFirstDayOfMonth(int month) {
    		Calendar cal = Calendar.getInstance();
    		// 设置月份
    		cal.set(Calendar.MONTH, month - 1);
    		// 获取某月最小天数
    		int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
    		// 设置日历中月份的最小天数
    		cal.set(Calendar.DAY_OF_MONTH, firstDay);
    		// 格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String firstDayOfMonth = sdf.format(cal.getTime());
    		return firstDayOfMonth;
    	}
    	/**
    	 * 获得该月最后一天
    	 *
    	 * @param month
    	 * @param month
    	 * @return
    	 */
    	public String getLastDayOfMonth(int month) {
    		Calendar cal = Calendar.getInstance();
    		// 设置月份
    		cal.set(Calendar.MONTH, month - 1);
    		// 获取某月最大天数
    		int lastDay=0;
    		//2月的平年瑞年天数
    		if(month==2) {
    			lastDay = cal.getLeastMaximum(Calendar.DAY_OF_MONTH);
    		}else {
    			lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    		}
    		// 设置日历中月份的最大天数
    		cal.set(Calendar.DAY_OF_MONTH, lastDay);
    		// 格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String lastDayOfMonth = sdf.format(cal.getTime());
    		return lastDayOfMonth;
    	}
    
    	/**
    	 * 获得现在月第一天
    	 * @param
    	 * @return
    	 */
    	public String getFirstDayOfMonth() {
    		Calendar cal = Calendar.getInstance();
    		int month = cal.get(Calendar.MONTH) + 1;
    		// 设置月份
    		cal.set(Calendar.MONTH, month - 1);
    		// 获取某月最小天数
    		int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
    		// 设置日历中月份的最小天数
    		cal.set(Calendar.DAY_OF_MONTH, firstDay);
    		// 格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String firstDayOfMonth = sdf.format(cal.getTime());
    		return firstDayOfMonth;
    	}
    	/**
    	 * 获得现在月最后一天
    	 *
    	 * @param
    	 * @return
    	 */
    	public String getLastDayOfMonth() {
    		Calendar cal = Calendar.getInstance();
    		// 设置月份
    		int month = cal.get(Calendar.MONTH) + 1;
    		cal.set(Calendar.MONTH, month - 1);
    		// 获取某月最大天数
    		int lastDay=0;
    		//2月的平年瑞年天数
    		if(month==2) {
    			lastDay = cal.getLeastMaximum(Calendar.DAY_OF_MONTH);
    		}else {
    			lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    		}
    		// 设置日历中月份的最大天数
    		cal.set(Calendar.DAY_OF_MONTH, lastDay);
    		// 格式化日期
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    		String lastDayOfMonth = sdf.format(cal.getTime());
    		return lastDayOfMonth;
    	}
    

      

  • 相关阅读:
    《人月神话》读后感
    软件工程心得体会(十一)
    Arch + Win10 EFI 引导重装记录
    BurpSuite 的使用
    Wireshark 的使用
    Android 中的反调试技术
    IDA 对 so 的动态调试
    Smail 中的一些点
    IDA 对 SO 的逆向
    动态调试smali代码
  • 原文地址:https://www.cnblogs.com/xianz666/p/14134073.html
Copyright © 2020-2023  润新知