内部线程

//保存学校信息
		@RequestMapping("/saveSchoolInfo")
		@ResponseBody
		public String saveSchoolInfo(School school,HttpSession session,HttpServletRequest request){
			
			HashMap<String, Object> result = schoolService.saveSchoolInfo(school);
			String data = null;
			if ((Boolean) result.get("success")) {
				data="0";
				session.setAttribute("schoolInfo", school);
				
				
				Date currentTime = new Date();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
				String format = sdf.format(currentTime);
				String filepath=PathRoot+"/" + format + "学校信息导出.xls";
				
				 zjzpsrc=request.getServletContext().getRealPath(school.getZjzp());
				 frsfzzmzpsrc=request.getServletContext().getRealPath(school.getFrsfzzmzp());
				 frsfzfmzpsrc=request.getServletContext().getRealPath(school.getFrsfzfmzp());
				 sydwfrzssrc=request.getServletContext().getRealPath(school.getSydwfrzs());
				 excelpath=request.getServletContext().getRealPath(filepath);
				 list=new ArrayList<School>(Arrays.asList(school));
				try {
					log.info("===========进入邮箱发送===============");
					// 启动线程
					log.info("启动线程---------");
					MyThreadPoolManager.getInstance().execute(new Runnable() {
						
						@Override
						public void run() {
							try {	
								List<File> fList  = new Vector<File>();
								fList.add(new File(zjzpsrc));
						        fList.add(new File(frsfzzmzpsrc));
						        fList.add(new File(frsfzfmzpsrc));
						        fList.add(new File(sydwfrzssrc));
						        schoolService.schoolToExcel(excelpath,list);
						        
						        fList.add(new File(excelpath));
								
								EmailSenderUtil.sendEmail("学校信息", "详情见附件",fList);
							} catch (Exception e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
					});
					
					
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}else{
				data="1";
			}
			return data;
		}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值