123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <%@ page language="java" contentType="text/html; charset=gbk"%>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
- <%@ page import="com.kpt.common.Util" %>
- <%@page import="java.util.List"%>
- <%@page import="java.util.Map"%>
- <%@page import="java.util.Date"%>
- <%@page import="java.util.ArrayList"%>
- <%@page import="java.math.BigDecimal"%>
- <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
- <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
- <%
- String str = Util.getHeaderType(request,"价格分析");
- response.setContentType("application/vnd.ms-excel;charset=gbk");response.setHeader("Content-disposition",str);
- %>
- <head>
- <style>
- .STYLE1 {color: #FFFFFF}
- </style>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>readers</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml><![endif]-->
- </head>
- <body style="margin:0";>
- <div class="content">
- <table cellspacing="1" cellpadding="0" border="0" style="width:1400px;" class="tabsty">
- <tbody>
- <tr align="center" style="height: 25px;">
- <th>饲料名称</th>
- <c:if test="${tjTarget == 0}">
- <c:forEach var="feed" items="${feedlist}">
- <th colspan="2"><c:out value="${feed.FNAME}" /></th>
- </c:forEach>
- <th colspan="2">合计</th>
- </c:if>
- <c:if test="${tjTarget != 0}">
- <c:forEach var="feed" items="${feedlist}">
- <th><c:out value="${feed.FNAME}" /></th>
- </c:forEach>
- <th>合计</th>
- </c:if>
- </tr>
- <tr align="center" style="height: 25px;">
- <c:if test="${tjType == 0}">
- <th>舍栏类别</th>
- </c:if>
- <c:if test="${tjType == 1}">
- <th>舍栏</th>
- </c:if>
- <c:if test="${tjType == 2}">
- <th>日期</th>
- </c:if>
- <c:if test="${tjType == 3}">
- <th>TM</th>
- </c:if>
- <c:if test="${tjType == 4}">
- <th>班次</th>
- </c:if>
- <c:if test="${tjTarget == 0}">
- <c:forEach var="feed" items="${feedlist}">
- <th>理论</th>
- <th>实际</th>
- </c:forEach>
- <th>理论</th>
- <th>实际</th>
- </c:if>
- <c:if test="${tjTarget == 1}">
- <c:forEach var="feed" items="${feedlist}">
- <th>理论</th>
- </c:forEach>
- <th>理论</th>
- </c:if>
- <c:if test="${tjTarget == 2}">
- <c:forEach var="feed" items="${feedlist}">
- <th>实际</th>
- </c:forEach>
- <th>实际</th>
- </c:if>
- </tr>
- <%
- List list = (List) request.getAttribute("list");
- List feedlist = (List) request.getAttribute("feedlist");
- String tjType = (String) request.getAttribute("tjType");
- String tjTarget = (String) request.getAttribute("tjTarget");
-
- String strname = "";
- if(list.size() == 1){
- Map strnameMap = (Map)list.get(0);
- strname = (String)strnameMap.get("1");
- }
-
- if(list.size() > 0 && !"1".equals(strname)){
- //动态列头数组
- int fsize = feedlist.size();
- if("0".equals(tjTarget)){
- fsize = fsize*2;
- }
- Double[] feedstr = new Double[fsize];
-
- //动态合计值数组
- Double[] liststr;
- if("0".equals(tjTarget)){
- liststr = new Double[2];
- }else{
- liststr = new Double[1];
- }
-
- for (int i = 0; i < list.size(); i++) {
- int c = 0;
- int listC = 0;
- Map map = (Map) list.get(i);
-
- if("0".equals(tjType)){
- String n1 = (String)map.get("舍栏类别");
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="<%=n1 %>"/></td>
- <%
- }else if("1".equals(tjType)){
- String n1 = (String)map.get("舍栏");
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="<%=n1 %>"/></td>
- <%
- }else if("2".equals(tjType)){
- Date d1 = (Date)map.get("日期");
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="<%=d1 %>"/></td>
- <%
- }else if("3".equals(tjType)){
- String n1 = (String)map.get("TMR");
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="<%=n1 %>"/></td>
- <%
- }else if("4".equals(tjType)){
- String bc = "";
- Integer n1 = (Integer)map.get("班次");
- if(n1 == 1){
- bc = "早班1";
- }else if(n1 == 2){
- bc = "早班2";
- }else if(n1 == 3){
- bc = "中班1";
- }else if(n1 == 4){
- bc = "中班2";
- }else if(n1 == 5){
- bc = "晚班1";
- }else{
- bc = "晚班2";
- }
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="<%=bc %>"/></td>
- <%
- }
- if("0".equals(tjTarget)){
- for (int j = 0; j < feedlist.size(); j++){
- Map fmap = (Map) feedlist.get(j);
- String fname = (String)fmap.get("FNAME");
- String fname1 = fname+"|理论";
- String fname2 = fname+"|实际";
- Double newname1 = (Double)map.get(fname1);
- Double newname2 = (Double)map.get(fname2);
- if(newname1 != null && newname2 != null){
- BigDecimal bg = new BigDecimal(newname1);
- newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
- BigDecimal bg1 = new BigDecimal(newname2);
- newname2 = bg1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
-
- if(feedstr[c]==null){
- feedstr[c] = newname1;
- }else{
- feedstr[c] += newname1;
- }
- c++;
- if(feedstr[c]==null){
- feedstr[c] = newname2;
- }else{
- feedstr[c] += newname2;
- }
- c++;
- %>
- <td><c:out value="<%=newname1 %>"/></td>
- <td><c:out value="<%=newname2 %>"/></td>
- <%
- }else{
- if(feedstr[c]==null){
- feedstr[c] = 0.0;
- }else{
- feedstr[c] += 0.0;
- }
- c++;
- if(feedstr[c]==null){
- feedstr[c] = 0.0;
- }else{
- feedstr[c] += 0.0;
- }
- c++;
- %>
- <td>0.0</td>
- <td>0.0</td>
- <%
- }
- }
- BigDecimal sum1 = (BigDecimal)map.get("合计|理论");
- BigDecimal sum2 = (BigDecimal)map.get("合计|实际");
-
- if(liststr[listC]==null){
- liststr[listC] = sum1.doubleValue();
- }else{
- liststr[listC] += sum1.doubleValue();
- }
- listC++;
- if(liststr[listC]==null){
- liststr[listC] = sum2.doubleValue();
- }else{
- liststr[listC] += sum2.doubleValue();
- }
- listC++;
- %>
- <td><c:out value="<%=sum1 %>"/></td>
- <td><c:out value="<%=sum2 %>"/></td>
- </tr>
- <%
- }else if("1".equals(tjTarget)){
- for (int j = 0; j < feedlist.size(); j++){
- Map fmap = (Map) feedlist.get(j);
- String fname = (String)fmap.get("FNAME");
- String fname1 = fname+"|理论";
- Double newname1 = (Double)map.get(fname1);
- if(newname1 != null){
- BigDecimal bg = new BigDecimal(newname1);
- newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
-
- if(feedstr[c]==null){
- feedstr[c] = newname1;
- }else{
- feedstr[c] += newname1;
- }
- c++;
- %>
- <td><c:out value="<%=newname1 %>"/></td>
- <%
- }else{
- if(feedstr[c]==null){
- feedstr[c] = 0.0;
- }else{
- feedstr[c] += 0.0;
- }
- c++;
- %>
- <td>0.0</td>
- <%
- }
- }
- BigDecimal sum1 = (BigDecimal)map.get("合计|理论");
-
- if(liststr[listC]==null){
- liststr[listC] = sum1.doubleValue();
- }else{
- liststr[listC] += sum1.doubleValue();
- }
- listC++;
- %>
- <td><c:out value="<%=sum1 %>"/></td>
- </tr>
- <%
- }else if("2".equals(tjTarget)){
- for (int j = 0; j < feedlist.size(); j++){
- Map fmap = (Map) feedlist.get(j);
- String fname = (String)fmap.get("FNAME");
- String fname1 = fname+"|实际";
- Double newname1 = (Double)map.get(fname1);
- if(newname1 != null){
- BigDecimal bg = new BigDecimal(newname1);
- newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
-
- if(feedstr[c]==null){
- feedstr[c] = newname1;
- }else{
- feedstr[c] += newname1;
- }
- c++;
- %>
- <td><c:out value="<%=newname1 %>"/></td>
- <%
- }else{
- if(feedstr[c]==null){
- feedstr[c] = 0.0;
- }else{
- feedstr[c] += 0.0;
- }
- c++;
- %>
- <td>0.0</td>
- <%
- }
- }
- BigDecimal sum1 = (BigDecimal)map.get("合计|实际");
-
- if(liststr[listC]==null){
- liststr[listC] = sum1.doubleValue();
- }else{
- liststr[listC] += sum1.doubleValue();
- }
- listC++;
- %>
- <td><c:out value="<%=sum1 %>"/></td>
- </tr>
- <%
- }
- }
- %>
- <tr align="center" class="greb" style="height: 25px;">
- <td><c:out value="合计"/></td>
- <%
- for (int k = 0; k < feedstr.length; k++){
- String newF = String.format("%.2f", feedstr[k]);
- %>
- <td><c:out value="<%=newF %>"/></td>
- <%
- }
- for (int t = 0; t < liststr.length; t++){
- String newL = String.format("%.2f", liststr[t]);
- %>
- <td><c:out value="<%=newL %>"/></td>
- <%
- }
- %>
- </tr>
- <%
- }else{
- if("0".equals(tjTarget)){
- %>
- <tr align="center" class="greb" style="height: 25px;"><td colspan="${feedlistsize*2+3}">没有对应的结果</td></tr>
- <%
- }else{
- %>
- <tr align="center" class="greb" style="height: 25px;"><td colspan="${feedlistsize+2}">没有对应的结果</td></tr>
- <%
- }
- }
- %>
- </tbody>
- </table>
- </div>
- </body>
- </html>
|