You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhky/src/main/java/com/zky/zhyw/smpx/TrainManageServlet.java

681 lines
29 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zky.zhyw.smpx;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.org.bjca.exceptions.CommonClientException;
import cn.org.bjca.utils.Base64;
import com.zky.bjca.SM4;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import com.zky.manager.Login;
import com.zky.manager.Operate;
import com.zky.manager.StudentPullulate;
import com.zky.pojo.Employee;
import com.zky.pojo.Train;
import com.zky.pub.Common;
import com.zky.pub.DbConn;
import com.zky.pub.DispatchServlet;
import com.zky.pub.HashFmlBuf;
import com.zky.util.PageQuery;
import com.zky.util.jdbc.HashFmlBufResultSetHandler;
import com.zky.util.jdbc.JDBCUtils;
/**
* @author cxz
*
* 培训管理
*/
public class TrainManageServlet extends DispatchServlet {
private static final Logger log = Logger.getLogger(TrainManageServlet.class);
/**
* 登记培训记录
* @param request
* @param response
* @throws IOException
*/
Connection conn = null;
private StudentPullulate p=new StudentPullulate();
public void addTrain(HttpServletRequest request, HttpServletResponse response) throws IOException, CommonClientException {
Login login = (Login) request.getSession().getAttribute("login");
//培训记录信息
String trainTime=request.getParameter("trainTime");//获得天数
String trainType=request.getParameter("trainType");
String trainName=request.getParameter("trainName");
String trainSubject=request.getParameter("trainSubject");
String trainAddress=request.getParameter("trainAddress");
//将数据库中加密的培训地址信息取出解密,显示解密内容到前端页面
//String trainAddress=SM4.SM4Decrypt(Base64.decode(request.getParameter("trainAddress")));
String trainNum=request.getParameter("trainNum");
String trainMark=request.getParameter("trainMark");
String sj=request.getParameter("sj");
String qj=request.getParameter("qj");
String departId=request.getParameter("school");
String part=request.getParameter("pary");
String trainTimeend=request.getParameter("trainTimeend");//获得天数
String sql =
"insert into td_train(train_time,train_type," +
"train_name,train_subject,train_address,areaId,frameworkId,train_state,depart_id,train_timeend,part) values(to_date(?,'%Y-%m-%d'),?,?,?,?,?,?,1,?,to_date(?,'%Y-%m-%d'),?)";
Connection conn = null;
PreparedStatement prep = null;
try {
conn = DbConn.getConn();
prep = conn.prepareStatement(sql);
prep.setString(1,trainTime);
prep.setString(2,trainType);
prep.setString(3,trainName);
prep.setString(4,trainSubject);
prep.setString(5,Base64.toBase64String(SM4.SM4Encrypt(trainAddress)));
// prep.setString(5,trainAddress);
prep.setString(6,qj);
prep.setString(7,sj);
prep.setString(8, departId);
prep.setString(9, trainTimeend);
prep.setString(10, part);
prep.execute();
conn.commit();
StringBuffer sql1 =
new StringBuffer("select date_format( a.train_timeend,'%Y-%m-%d') as train_timeend,a.train_Id,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_type " +
",a.train_subject,a.train_num,a.empid,a.TRAIN_ADDRESS,a.train_name,a.train_state,b.radioresult,b.empname from td_train a left join tab_employee b on a.empid=b.empname where 1=1");
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql1.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(1000);
request.setAttribute("train_info",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainManage.jsp").forward(request,response);
} catch (SQLException e) {
String errorinfo = "";
if (e.getMessage().startsWith("ORA-00001")) {
errorinfo = "培训登记失败!";
} else {
errorinfo = "培训登记失败!" + e.toString();
}
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode(errorinfo,"utf-8")));
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("培训登记失败!","utf-8") + e.toString()));
} finally {
try {
if (prep!= null) {
prep.close();
}
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 培训编辑
* @param request
* @param response
* @throws IOException
*/
public void modifyTrain(HttpServletRequest request, HttpServletResponse response) throws IOException {
Login login = (Login) request.getSession().getAttribute("login");
String trainId=request.getParameter("trainId");
String trainTime=request.getParameter("empidenddate");
String trainType=request.getParameter("trainType");
String trainSubject=request.getParameter("trainSubject");
String trainAddress=request.getParameter("trainAddress");
String trainName=request.getParameter("trainName");
String updateStaffid=request.getParameter("update_staffid");
String updateDepartid=request.getParameter(" update_departid");
String updateDate=request.getParameter("update_date");
String part=request.getParameter("pary");
System.out.println(part);
String sql =
"update td_train a set a.train_time=?, a.train_type=?,a.train_subject=?,a.train_address=?," +
"a.update_staffid=?,a.update_departid=?,a.update_date=now(),a.train_name=?,a.part=? where a.train_id=?";
Connection conn = null;
PreparedStatement prep = null;
try {
conn = DbConn.getConn();
prep = conn.prepareStatement(sql);
prep.setString(1,trainTime );
prep.setString(2,trainType );
prep.setString(3,trainSubject);
//编辑修改培训地址时,将修改后的字段加密存到数据库里面
prep.setString(4,Base64.toBase64String(SM4.SM4Encrypt(trainAddress)));
prep.setString(5,login.getEmpid());
prep.setString(6,login.getDepartid());
prep.setString(7,trainName);
prep.setString(8,part);
prep.setString(9,trainId);
prep.execute();
//oracle数据库手动提交mysql中 自动提交autoCommit();
conn.commit();
StringBuffer sql1 =
new StringBuffer("select date_format( a.train_timeend,'%Y-%m-%d') as train_timeend,a.train_Id,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_type " +
",a.train_subject,a.train_num,a.empid,a.TRAIN_ADDRESS,a.train_name,a.train_state,b.radioresult,b.empname from td_train a left join tab_employee b on a.empid=b.empname where 1=1");
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql1.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(1000);
request.setAttribute("train_info",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainManage.jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("培训记录修改失败!","utf-8") + e.toString()));
} finally {
try {
if (prep!= null) {
prep.close();
}
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 培训编辑
* @param request
* @param response
* @throws IOException
*/
@SuppressWarnings({ "null", "null" })
public void modifyTrainState(HttpServletRequest request, HttpServletResponse response) throws IOException {
Login login = (Login) request.getSession().getAttribute("login");
String trainId=request.getParameter("trainId");
String trainName=request.getParameter("trainName");
String trainState=request.getParameter("trainState");
String tainerInfo=request.getParameter("tainerInfo");
String sql =
"update td_train a set a.train_state=?,a.empid=?,a.tainerInfo=?,a.TRAIN_DATE=now() where a.train_id=?";
Connection conn = null;
PreparedStatement prep = null;
PreparedStatement pstmt;
try {
conn = DbConn.getConn();
prep = conn.prepareStatement(sql);
prep.setString(1,trainState);
prep.setString(2,login.getEmpname());
prep.setString(3,tainerInfo);
prep.setString(4,trainId);
prep.execute();
String sql1="update tab_employee set submitbtn='0' where empname=?";
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1,trainName);
pstmt.execute();
//oracle数据库手动提交mysql中 自动提交autoCommit();
conn.commit();
StringBuffer sql2 =
new StringBuffer("select date_format( a.train_timeend,'%Y-%m-%d') as train_timeend,a.train_Id,a.empid,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_type " +
",a.train_subject,a.train_num,a.TRAIN_ADDRESS,a.train_name,a.train_state,b.radioresult,b.empname from td_train a left join tab_employee b on a.empid=b.empname where 1=1");
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql2.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(1000);
request.setAttribute("train_info",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainManage.jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("培训记录修改失败!","utf-8") + e.toString()));
} finally {
try {
if (prep!= null) {
prep.close();
}
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 培训记录注销
* @param request
* @param response
* @throws IOException
*/
public void cancelTrain(HttpServletRequest request, HttpServletResponse response) throws IOException {
log.debug("# cancel tain!");
Login login = (Login) request.getSession().getAttribute("login");
String[] trainId = request.getParameterValues("train_id");
String sql =
"update td_train a set a.train_state=0,a.update_staffid=?,a.update_departid=?,a.update_date=now() where a.train_id=?";
Connection conn = null;
PreparedStatement prep = null;
try {
conn = DbConn.getConn();
conn.setAutoCommit(false);
prep = conn.prepareStatement(sql);
for (int i=0; i<trainId.length; i++) {
prep.setString(1,login.getEmpid());
prep.setString(2,login.getDepartid());
prep.setString(3,trainId[i]);
prep.addBatch();
}
prep.executeBatch();
//oracle数据库手动提交mysql中 自动提交autoCommit();
conn.commit();
Common.updateParaTab("td_train");
queryTrain(request,response);
response.sendRedirect(Common.GbConvertIso("/success.jsp?message=培训记录注销成功!"));
} catch (Exception e) {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("培训记录注销失败!","utf-8") + e.toString()));
} finally {
try {
if (prep!= null) {
prep.close();
}
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 删除人员培训详细信息
* @param request
* @param response
* @throws IOException
*/
public void queryTrainBydelete(HttpServletRequest request, HttpServletResponse response) throws IOException {
String trainId = request.getParameter("trainId");
String sql = "delete from td_train where train_id=? ";
Connection conn = null;
PreparedStatement prep = null;
try {
conn = DbConn.getConn();
prep = conn.prepareStatement(sql);
prep.setString(1,trainId);
prep.execute();
conn.commit();
StringBuffer sql1 =
new StringBuffer("select date_format( a.train_timeend,'%Y-%m-%d') as train_timeend,a.train_Id,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_type " +
",a.train_subject,a.train_num,a.empid,a.TRAIN_ADDRESS,a.train_name,a.train_state,b.radioresult,b.empname from td_train a left join tab_employee b on a.empid=b.empname where 1=1");
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql1.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(1000);
request.setAttribute("train_info",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainManage.jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("删除失败!","utf-8") + e.toString()));
} finally {
try {
if (prep!= null) {
prep.close();
}
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public InputStream getTrainData(List<Train> trainData) throws ParseException
{
HSSFWorkbook workBook=new HSSFWorkbook();
String[] title={"培训编号","人员姓名","培训次数"};
int i=0;
int k=1;
HSSFSheet tableSheet=workBook.createSheet("培训清单");
HSSFRow row=tableSheet.createRow((short)0);
//创建标题栏单元格字体
HSSFFont titleFont=workBook.createFont();
//创建标题栏样式
HSSFCellStyle titleStyle=workBook.createCellStyle();
//设置标题栏字体颜色
titleFont.setColor(HSSFColor.BLUE.index);
//设置标题栏字体样式
titleStyle.setFont(titleFont);
//创建状态异常的数据行字体
HSSFFont contentFont=workBook.createFont();
//创建状态异常的数据行样式
HSSFCellStyle contentStyle=workBook.createCellStyle();
//设置状态异常的数据行字体颜色
contentFont.setColor(HSSFColor.RED.index);
//为状态异常的数据行样式设置字体
contentStyle.setFont(contentFont);
//迭代标题数组,根据数组长度创建单元格,并设置标题栏单元格字体颜色
for(String s:title)
{
HSSFCell cell=row.createCell(i);
cell.setCellValue(s);
cell.setCellStyle(titleStyle);
i++;
}
//迭代数据信息,填入数据行
for(Iterator iterator=trainData.iterator();iterator.hasNext();)
{
Train Info=(Train)iterator.next();
HSSFRow hssfRow=tableSheet.createRow((short)k);
hssfRow.createCell(0).setCellValue(Info.getTrianId());
hssfRow.createCell(1).setCellValue(Info.getTrainName());
hssfRow.createCell(2).setCellValue(Info.getTrianNum());
k++;
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
workBook.write(os);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] content = os.toByteArray();
InputStream is = new ByteArrayInputStream(content);
return is;
}
@Override
public void defaultMethod(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
}
/***
* 导出信息
* @param request
* @param response
* @throws Exception
*/
public void exportExcelNum(HttpServletRequest request,HttpServletResponse response) throws Exception
{
// String empid = request.getParameter("empid");
StringBuffer sql =
new StringBuffer("select a.train_Id,a.train_time,a.train_type " +
",a.train_subject,a.train_mark,a.train_num,a.train_name,a.train_state from td_train a ");
Connection conn = null;
List<Train> trains = new ArrayList<Train>();;
try {
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(20);
Train train=null;
if(buf!=null)
{
for(int i=0;i<buf.getRowCount();i++)
{
train=new Train();
train.setTrianId(buf.fget("train_Id", i));
train.setTrainName(buf.fget("train_name", i));
train.setTrianNum(buf.fget("train_num", i));
trains.add(train);
}
response.reset();
response.setContentType("application/x-download;charset=gbk");
response.setHeader("Content-Disposition" ,"attachment;filename="+new String("培训统计查询.xls".getBytes("GB2312"),"iso-8859-1"));
ServletOutputStream outputStream=response.getOutputStream();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(this.getTrainData(trains));
bos = new BufferedOutputStream(outputStream);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while (-1 != (bytesRead = bis.read(buff,0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (final IOException e) {
System.out.println("IOException.");
throw e;
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(NullPointerException e)
{
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("报表导出失败!","utf-8") + e.toString()));
}
finally
{
if(conn!=null)
{
conn.close();
}
}
}
/**
* 编辑培训根据Id查询到相应的记录行
* @param request
* @param response
* @throws IOException
*/
public void queryTrainById(HttpServletRequest request, HttpServletResponse response) throws IOException {
String trainId = request.getParameter("trainId");
StringBuffer sql=new StringBuffer("select ta.train_id,ta.train_name,tf.FRAMEWORKNAME,td.AREADEF,t.DEPARTNAME,ta.train_type,ta.train_num,ta.part,ta.tainerInfo,date_format(ta.train_time,'%Y-%m-%d') as train_time,ta.train_subject,ta.train_address" +
" from td_train ta left join tab_framework tf on ta.FRAMEWORKID=tf.FRAMEWORKID " +
" left join tab_area td on ta.AREAID=td.AREAID left join tab_department t on ta.DEPART_ID=t.DEPARTID where ta.train_id =?");
Connection conn = null;
try {
conn = DbConn.getConn();
HashFmlBuf buf = (HashFmlBuf)JDBCUtils.query(conn,sql.toString(),new Object[]{trainId},new HashFmlBufResultSetHandler());
request.setAttribute("by_trainId",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainUpdate.jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("根据编号查询培训记录失败!","utf-8") + e.toString()));
} finally {
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 根据Id查询到相应的记录行进行审核
* @param request
* @param response
* @throws IOException
*/
public void queryTrainStId(HttpServletRequest request, HttpServletResponse response) throws IOException {
String trainId = request.getParameter("trainId");
StringBuffer sql=new StringBuffer("select a.empid,a.train_id,te.departname,a.train_name,a.train_type,a.train_num,a.train_time,a.train_subject,a.train_address,ta.areadef,tf.FRAMEWORKNAME from td_train a " +
"left join tab_area ta on a.AREAID=ta.AREAID " +
"left join tab_framework tf on a.FRAMEWORKID=tf.FRAMEWORKID " +
"left join tab_department te on a.DEPART_ID=te.DEPARTID where train_id =?");
Connection conn = null;
try {
conn = DbConn.getConn();
HashFmlBuf buf = (HashFmlBuf)JDBCUtils.query(conn,sql.toString(),new Object[]{trainId}, new HashFmlBufResultSetHandler());
request.setAttribute("by_trainId",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainState.jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("根据编号查询培训记录失败!","utf-8") + e.toString()));
} finally {
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 查询所有的培训记录
* @param request
* @param response
* @throws IOException
*/
public void queryTrain(HttpServletRequest request, HttpServletResponse response) throws IOException {
String trainId = request.getParameter("train_id");
String trainState = request.getParameter("trainState");
String trainType = request.getParameter("trainType");
String trainSubject = request.getParameter("trainSubject");
String sj = request.getParameter("sj");
String qj = request.getParameter("qj");
String pcs = request.getParameter("pcs");
StringBuffer sql =
new StringBuffer("select date_format( a.train_timeend,'%Y-%m-%d') as train_timeend,a.train_Id,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_type ,a.train_subject,a.TRAIN_ADDRESS,a.train_num,a.empid,a.train_name,a.train_state,b.radioresult,b.empname from td_train a left join tab_employee b on a.empid=b.empname where 1=1");
if (!Common.isNull(trainId)) {
sql.append(" and a.trainId='").append( trainId).append("'");
}
if (!Common.isNull(sj)) {
sql.append(" and a.frameworkid='").append(sj).append("'");
}
if (!Common.isNull(qj)) {
sql.append(" and a.areaid='").append(qj).append("'");
}
if (!Common.isNull(pcs)) {
sql.append(" and a.depart_id='").append(pcs).append("'");
}
if (!Common.isNull(trainType)) {
sql.append(" and a.train_type ='").append( trainType).append("'");
}
if (!Common.isNull(trainState)) {
sql.append(" and a.train_state ='").append( trainState).append("'");
}
if (!Common.isNull(trainSubject)) {
sql.append(" and a.train_subject ='").append( trainSubject).append("'");
}
Connection conn = null;
try {
conn = DbConn.getConn();
PageQuery pageQuery = new PageQuery(conn,sql.toString(),new HashFmlBufResultSetHandler(),request);
HashFmlBuf buf=(HashFmlBuf)pageQuery.query(20);
request.setAttribute("train_info",buf);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainManage.jsp").forward(request,response);
//操作日志
Operate oper=new Operate();
oper.operatesmrypxcxLog(request);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo="+URLEncoder.encode("培训信息查询失败!","utf-8") + e.toString()));
} finally {
try {
if (conn!= null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 根据Id查询到相应的记录行
* @param request
* @param response
* @throws IOException
*/
public void queryTrainShowById(HttpServletRequest request, HttpServletResponse response) throws IOException {
String trainId = request.getParameter("trainId");
StringBuffer sql = new StringBuffer("select a.empid ,a.part,a.tainerInfo,a.train_id,date_format(a.TRAIN_TIMEEND,'%Y-%m-%d') as TRAIN_TIMEEND,td.DEPARTNAME,a.depart_id,a.train_name,a.train_type,a.train_num,date_format(a.train_time,'%Y-%m-%d') as train_time,a.train_subject," +
"a.train_address,a.areaid,a.frameworkid,a.train_state,b.radioresult,b.radioresult1,b.tklxtype,date_format(b.RADIODATE,'%Y-%m-%d HH24:MI') as RADIODATE , a.train_num,date_format(a.TRAIN_DATE,'%Y-%m-%d') as TRAIN_DATE,ta.AREADEF,tf.FRAMEWORKNAME from td_train a " +
"left join tab_employee b ON a.train_name=b.empname left join tab_area ta on " +
"a.AREAID=ta.AREAID left join tab_framework tf on a.FRAMEWORKID=tf.FRAMEWORKID " +
"left join tab_department td on a.DEPART_ID=td.DEPARTID where a.train_id =?");
// StringBuffer sql2 = new StringBuffer("select a.train_address from td_train a where a.train_id =?");
Connection conn = null;
try {
conn = DbConn.getConn();
HashFmlBuf buf = (HashFmlBuf) JDBCUtils.query(conn, sql.toString(), new Object[]{trainId},
new HashFmlBufResultSetHandler());
request.setAttribute("by_trainId", buf);
// request.setAttribute("by_trainId", buf1);
request.getRequestDispatcher("/zhyw/smry/rypx/TrainShowInfo.jsp?operate=modifyEmp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(Common.GbConvertIso("/error.jsp?errorinfo=" + URLEncoder.encode("根据编号查询培训记录失败!", "utf-8") + e.toString()));
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}