?? sumxqqkaction.java
字號:
/*
* Created on 2006-8-1
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.ug.sztz.webview.structs.actions.oa;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ug.sztz.domain.assistant.DateProcessor;
import org.ug.sztz.domain.oa.StudentBaseInfo;
import org.ug.sztz.domain.oa.TongJi_XuQiu;
import org.ug.sztz.domain.oa.XQInfo;
/**
* @author Skywalker
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class SumXqqkAction extends BaseAction {
/*
* (non-Javadoc)
*
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
String work = request.getParameter("worktype");
if (work == null) {
List list = this.tjxqDao.getTJXQList();
if(list.size()!=0){
try {
request.setAttribute("xqqklist", list);
request.setAttribute("time",((TongJi_XuQiu)list.get(0)).getDatetime());
return mapping.findForward("success");
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("reason", "數據庫操作失敗!");
return mapping.findForward("failure");
}
}
}
try {
Vector yjList = this.getXqList("研究生");
Vector bkList = this.getXqList("本科生");
Vector list = new Vector();
if (bkList != null)
for (int i = 0; i < bkList.size(); i++)
list.add(bkList.get(i));
if (yjList != null)
for (int i = 0; i < yjList.size(); i++)
list.add(yjList.get(i));
request.setAttribute("xqqklist", list);
for (int i = 0; i < list.size(); i++) {
HashMap map = new HashMap();
map.put("zy", ((TongJi_XuQiu) list.get(i)).getZy());
map.put("xl", ((TongJi_XuQiu) list.get(i)).getXl());
if (this.tjxqDao.getTJXQByMap(map) != null) {
this.tjxqDao.updateTJXQ((TongJi_XuQiu) list.get(i));
} else {
this.tjxqDao.insertTJXQ((TongJi_XuQiu) list.get(i));
}
}
request.setAttribute("time",DateProcessor.getStringDate2());
return mapping.findForward("success");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute("reason", "數據庫操作失敗!");
return mapping.findForward("failure");
}
}
private Vector getXqList(String xl) throws Exception {
Vector all = new Vector();
String allsql = "select * from bysbase where xsstatus='1' and xl='"
+ xl + "' order by zy";
HashMap map = new HashMap();
map = new HashMap();
map.put("sql", allsql);
List allList = this.stuBaseDao.getSQLBaseInfoList(map);
if (allList.size() == 0) {
return null;
}
Vector zyList = new Vector();
String temp = "";
for (int i = 0; i < allList.size(); i++) {
String zy = ((StudentBaseInfo) allList.get(i)).getZy();
if (!zy.equals(temp)) {
temp = zy;
zyList.add(zy.trim());
}
}
TongJi_XuQiu main = new TongJi_XuQiu();
main.setGxb(0);
main.setSum(allList.size());
main.setXl(xl);
main.setZy("總計");
main.setXq(0);
main.setDatetime(DateProcessor.getStringDate2());
all.add(main);
int sumxq = 0;
List xqxxList = this.xqxxDao.getXQInfoList();
for (int i = 0; i < zyList.size(); i++) {
TongJi_XuQiu tj = new TongJi_XuQiu();
tj.setZy((String) zyList.get(i));
String sql = "select * from bysbase where xsstatus='1' and zy='"
+ zyList.get(i) + "' and xl='" + xl + "'";
map.put("sql", sql);
List sList = this.stuBaseDao.getSQLBaseInfoList(map);//取得該專業的學生列表
tj.setSum(sList.size());
int zyxq = 0;//該專業的需求量
for (int j = 0; j < xqxxList.size(); j++) {
XQInfo info = (XQInfo) xqxxList.get(j);
String zyyq = info.getXqzyyq().trim();
String[] detail = zyyq.split(";");//用“;”拆分字符串,結果為一個字符數組,每一元素為一條具體需求信息
for (int k = 0; k < detail.length; k++) {
String[] item = detail[k].split("-");//用“-”拆分字符串,結果為一個字符數組,第一項為學生類型,第二項為需求專業,第三項為需求數,第四項為相關要求
if (item[0].equals(xl)
&& item[1].equals((String) zyList.get(i))) {
zyxq = zyxq + Integer.parseInt(item[2]);
}
}
}
sumxq = sumxq + zyxq;
tj.setXq(zyxq);
tj.setXl(xl);
tj.setGxb((float) zyxq / sList.size());
tj.setDatetime(DateProcessor.getStringDate2());
all.add(tj);
}
main.setXq(sumxq);
main.setGxb((float)sumxq / allList.size());
all.set(0, main);
return all;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -