zoukankan      html  css  js  c++  java
  • 员工培训课时达成率导出

    /**
    	 * 员工培训课时达成率导出
    	 * @param response
    	 * @param startDate
    	 * @param endDate
    	 */
    	@Override
    	public void exportTrainingRecord(HttpServletResponse response, String startDate, String endDate) {
    		startDate+="-01";
    		endDate+="-31";
    		//获取工号,部门名称,入职时间,员工姓名,员工基本信息表左联用户表,查找在结束日期之前入职的人员
    		List<AllEmployeeBasicInformation> employeeList=employeeTrainingRecordMapper.getEmployeeMsg(AuthUtil.getTenantId(),"");
    		log.info("获取工号,部门名称,入职时间,员工姓名,employeeList======"+employeeList);
    		//要导出的list
    		List<ExcelTrainingRecord> excelList=new ArrayList<>();
    		if(Func.isNotEmpty(employeeList)){
    			for(AllEmployeeBasicInformation basicInfo:employeeList){
    				ExcelTrainingRecord excelTrainingRecord=new ExcelTrainingRecord();
    				//获取员工培训记录时长,根据开始和结束时间区间
    				double sum=employeeTrainingRecordMapper.getEmployeeTrainingHours(AuthUtil.getTenantId(),startDate,endDate,basicInfo.getAccount());
    				//员工是否在开始时间年之后年份入职
    				String[]dates=startDate.split("-");
    				String entryDate=basicInfo.getEntryDate();
    				String[]entryDates=entryDate.split("-");
    				String[]endTimes=endDate.split("-");
    				//开始日期月份
    				int startMoth=Integer.parseInt(dates[1]);
    				//结束日期月份
    				int endMoth=Integer.parseInt(endTimes[1]);
    				double hours=0;
    				if(dates[0].equals(entryDates[0])){
    					//员工是在开始时间年份入职
    					//获取月份
    					int entryMoth= Integer.parseInt(entryDates[1]);
    					//如果入职月份大于等于开始月份
    					if(entryMoth>=startMoth){
    						//计算入职月份应参加课时数
    						int dat=Integer.parseInt(entryDates[2]);
    						if(dat==30){
    							hours=(6.7/30)*1;
    						}else if(dat==31){
    							hours=(6.7/30)*2;
    						}else {
    							hours=(6.7/30)*(30-dat);
    						}
    						//计算其他月份的培训课时
    						if((endMoth-entryMoth)>=1){
    							hours+=6.7*(endMoth-entryMoth);
    						}
    					}else{
    						//如果入职年份小于开始年份
    						hours=(endMoth-startMoth+1)*6.7;
    					}
    				}else{
    					//在开始日期之前入职的
    					hours=(endMoth-startMoth+1)*6.7;
    
    				}
    				//判断是否达标
    				if((sum/hours)>=1){
    					excelTrainingRecord.setIsAccomplish("是");
    				}else {
    					excelTrainingRecord.setIsAccomplish("否");
    				}
    				//保留两位小数
    				DecimalFormat df= new DecimalFormat("######0.00");
    				double msg=0;
    				if(hours!=0){
    					msg=(sum/hours)*100;
    				}
    				String achievingRate=String.valueOf(df.format(msg))+"%";
    				excelTrainingRecord.setAchievingRate(achievingRate);
    				//应参加课时数
    				excelTrainingRecord.setTakePartInHours(String.valueOf(df.format(hours)));
    				//实际参加课时数
    				excelTrainingRecord.setPracticalTakePartInHours(String.valueOf(sum));
    				//入职日期
    				excelTrainingRecord.setEntryDate(basicInfo.getEntryDate());
    				//姓名
    				excelTrainingRecord.setRealName(basicInfo.getRealName());
    				//部门名称
    				excelTrainingRecord.setDepartment(basicInfo.getDepartment());
    				excelList.add(excelTrainingRecord);
    			}
    		}
    		log.info("员工培训课时达成率导出excelList========"+excelList);
    		ExcelUtil.export(response, "员工"+startDate+"——"+endDate+"培训课时达成率"+ DateUtil.time(), "员工培训课时达成率导出", excelList, ExcelTrainingRecord.class);
    	}
    

      

  • 相关阅读:
    死磕itchat源码--core.py
    死磕itchat源码--config.py
    死磕itchat源码--content.py
    死磕itchat源码--__init__.py
    SyntaxError Non-ASCII character 'xe5' in file
    死磕itchat源码--目录结构
    pip是用代理
    `itchat`配置代理
    搭建`wenblogic`执行`install`脚本失败
    sublimeText3的安装及插件的配置使用
  • 原文地址:https://www.cnblogs.com/xianz666/p/14144146.html
Copyright © 2011-2022 走看看