📄 checkpollstep1action.java
字号:
package tarena.action;import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.Set;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import tarena.pojo.Poll;import tarena.pojo.PollLine;import tarena.util.ContextUtil;public class CheckPollStep1Action extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { Poll poll = (Poll) request.getSession().getAttribute(ContextUtil.POLL); Set pollLineSet = poll.getPollLineSet(); String[] index = request.getParameterValues("index"); Map map = new HashMap(); if (index != null) { // 得到无效调查明细列表ID for (int i = 0; i < index.length; i++) { map.put(Integer.valueOf(index[i]), ""); } } // 更新PollLine属性值 double totalScore = 0.0d; for (Iterator it = pollLineSet.iterator(); it.hasNext();) { PollLine pollLine = (PollLine) it.next(); if (map.get(pollLine.getId())!=null) pollLine.setIsValid("n"); else { totalScore += pollLine.getC1().doubleValue() + pollLine.getC2().doubleValue() + pollLine.getC3().doubleValue() + pollLine.getC4().doubleValue() + pollLine.getC5().doubleValue() + pollLine.getC6().doubleValue() + pollLine.getC7().doubleValue(); pollLine.setIsValid("y"); } } // 更新Poll属性值 if (index != null) { poll .setAvailableNum(new Integer(pollLineSet.size() - index.length)); } else { poll.setAvailableNum(new Integer(pollLineSet.size())); } poll.setTotalscore(new Integer((int) totalScore)); poll.setAvgScore(new Double(Math.round(totalScore / poll.getAvailableNum().intValue() / 7 * 100) / 100.00)); return mapping.findForward("return"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -