将List中一列的值取出来 求和后 放到页面显示 用BigDicamal

--------------------------------------------------------------------------java

package gfsoft.his.store.drugStorage.inoutStorageSearch.web;

import gfsoft.his.store.drugStorage.inoutStorageSearch.business.IInStorageSearch;
import gfsoft.his.sys.common.business.ICommon;
import gfsoft.his.util.Convert;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import gfsoft.his.util.GetCookie;

public class OutStorageSearchController extends MultiActionController {
 
 private ICommon commonImpl;
 private IInStorageSearch inStorageSearchImpl;
 
 public ICommon getCommonImpl() {
   return commonImpl;
 }
 public void setCommonImpl(ICommon commonImpl) {
   this.commonImpl = commonImpl;
 }
 public IInStorageSearch getInStorageSearchImpl() {
  return inStorageSearchImpl;
 }
 public void setInStorageSearchImpl(IInStorageSearch inStorageSearchImpl) {
  this.inStorageSearchImpl = inStorageSearchImpl;
 }
 
 
 public ModelAndView index(HttpServletRequest request,HttpServletResponse response)throws Exception{
  ModelAndView modelAndView = new ModelAndView();
  HashMap hashMap = new HashMap();
  Integer forgid = new Integer(GetCookie.getForgId(request));
  String frcode = GetCookie.getFrCode(request);
  Long officeid = new Long(GetCookie.getOfficeId(request));
  Date date = getCommonImpl().getDBDate();
  
  String startDate = request.getParameter("startDate");
  String endDate = request.getParameter("endDate");
  
  Date firstDate = date;
  Date lastDate = date;
  
  String tranid = request.getParameter("tranid");
  String fellowid = request.getParameter("fellowid");
  String supplierName = request.getParameter("supplierName");
  String inoutodd = request.getParameter("inoutodd");
  //&& !"0".equals(tranid)
  if(null != tranid && !"".equals(tranid)){
   hashMap.put("tranid", tranid);
  }else{
   hashMap.put("tranid", 0);
  }
  if(null != fellowid && !"".equals(fellowid)){
   hashMap.put("fellowid", Convert.toLong(fellowid));
  }else{
   hashMap.put("fellowid", 0);
  }
  
  if(null != inoutodd && !"".equals(inoutodd)){
   hashMap.put("inoutodd", inoutodd.trim());
  }else{
   hashMap.put("inoutodd", 0);
  }
   
  
  if(null != startDate ){
   firstDate = Convert.toParseDate(startDate);
  }
  if(null != endDate){
   lastDate = Convert.toParseDate(endDate);
  }
  //查询入库类型
  HashMap trandidMap = new HashMap();
  trandidMap.put("printbs", "1");
  List tranids = this.inStorageSearchImpl.getInStorageTranid(trandidMap);
  
  hashMap.put("forgid", forgid);
  hashMap.put("frcode", frcode);
  hashMap.put("officeid", officeid);
  hashMap.put("startDate", firstDate);
  hashMap.put("endDate", lastDate);
  hashMap.put("ai_crk", 0);
  
  
  List list = this.inStorageSearchImpl.getInStorageSearch(hashMap);
    
     BigDecimal actmon =new BigDecimal("0.00");
     BigDecimal retailmon =new BigDecimal("0.00");
     BigDecimal ce =new BigDecimal("0.00");
  if(null!=list && list.size()>0){
   for(int i=0;i<list.size();i++){
    actmon =actmon.add(Convert.toBigDecimal(((HashMap)list.get(i)).get("actmon").toString()));
    retailmon =retailmon.add(Convert.toBigDecimal(((HashMap)list.get(i)).get("retailmon").toString()));
    ce =ce.add(Convert.toBigDecimal(((HashMap)list.get(i)).get("ce").toString()));

   }
  }
  modelAndView.setViewName("his/drugStorage/outStorageSearch/ShowOutStorageSearch");
  modelAndView.addObject("list",list);
  modelAndView.addObject("startDate",firstDate);
  modelAndView.addObject("endDate",lastDate);
  modelAndView.addObject("tranid",tranid);
  modelAndView.addObject("tranids",tranids);
  modelAndView.addObject("supplierName",supplierName);
  modelAndView.addObject("fellowid",fellowid);
  modelAndView.addObject("inoutodd",inoutodd);
  modelAndView.addObject("actmon",actmon);
  modelAndView.addObject("retailmon",retailmon);
  modelAndView.addObject("ce",ce);
  return modelAndView;
 }
 
 
}

 

 

----------------------------------------------------------------------页面

<table id="inStorageBillTable" style="width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="1" border="0" width="100%">
     <tbody>
      <tr class="TableHeader" >
       <td class="TableHeaderCell" style="width: 25px">

       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        入库方式
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        审核时间
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        单据号
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        审核人
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        供应商
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        进价金额
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        零售金额
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        差额
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        开单时间
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        经手人
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        开单人
       </td>
       <td class="TableHeaderCell" nowrap="nowrap">
        备注
       </td>
      </tr>
      <c:forEach items="${list}" var="result" varStatus="s">
       <tr class="TableRow" oldclass="TableRow"
        οnclick="javascript:RowSelect(this);"
        οnmοuseοver="javascript:if (this.className!='TableRowSelected') this.className='TableRowOver'"
        οnmοuseοut="javascript:if (this.className!='TableRowSelected') this.className='TableRow'" >
        <td class="TableCellIndex" nowrap="nowrap">
         <c:out value="${s.index+1}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.originname}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <fmt:formatDate value="${result.auditdate}"  pattern="yyyy-MM-dd"></fmt:formatDate>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.inoutodd}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.auditor}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell" >
         <c:out value="${result.officename}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell" align="right">
         <c:out value="${result.actmon }"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell" align="right">
         <c:out value="${result.retailmon}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell" align="right">
         <c:out value="${result.ce}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <fmt:formatDate value="${result.happendate}"  pattern="yyyy-MM-dd"></fmt:formatDate>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.hander}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.inputor}"></c:out>
        </td>
        <td nowrap="nowrap" class="TableCell">
         <c:out value="${result.remark}"></c:out>
        </td>
       </tr>
      </c:forEach>
      <tr class="TableRow" >
       <td class="TableCell" style="width: 25px">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap"  align="right">
       <b>合计:</b>
       </td>
       <td nowrap="nowrap" class="TableCell" align="right">
        <b><c:out value="${actmon }"></c:out></b>
       </td>
       <td class="TableCell" nowrap="nowrap" align="right">
        <b><c:out value="${retailmon}"></c:out></b>
       </td>
       <td class="TableCell" nowrap="nowrap" align="right">
        <b><c:out value="${ce}"></c:out></b>
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
       <td class="TableCell" nowrap="nowrap">
       </td>
      </tr>
     </tbody>
    </table>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值