dateplanreportexcel.jsp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <%@ page language="java" contentType="text/html; charset=gbk"%>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  3. <%@page import="java.util.List"%>
  4. <%@page import="java.util.Map"%>
  5. <%@page import="java.util.ArrayList"%>
  6. <%@ page import="com.kpt.common.Util" %>
  7. <%@page import="java.text.DecimalFormat"%>
  8. <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">
  9. <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
  10. <%
  11. String str = Util.getHeaderType(request,"日计划");
  12. response.setContentType("application/vnd.ms-excel;charset=gbk");response.setHeader("Content-disposition",str);
  13. %>
  14. <head>
  15. <style>
  16. .STYLE1 {color: #FFFFFF}
  17. </style>
  18. <!--[if gte mso 9]><xml>
  19. <x:ExcelWorkbook>
  20. <x:ExcelWorksheets>
  21. <x:ExcelWorksheet>
  22. <x:Name>readers</x:Name>
  23. <x:WorksheetOptions>
  24. <x:Print>
  25. <x:ValidPrinterInfo />
  26. </x:Print>
  27. </x:WorksheetOptions>
  28. </x:ExcelWorksheet>
  29. </x:ExcelWorksheets>
  30. </x:ExcelWorkbook>
  31. </xml><![endif]-->
  32. </head>
  33. <body style="margin:0";>
  34. <div class="content">
  35. <table cellspacing="1" cellpadding="0" border="0" style="width:99%;">
  36. <tr>
  37. <td align="center" colspan="${colListSize}">
  38. <c:if test="${btnType eq 0}">
  39. <h1><c:out value="${beginDate}" />日计划打印表(按每次投料量)</h1>
  40. </c:if>
  41. <c:if test="${btnType eq 1}">
  42. <h1><c:out value="${beginDate}" />日计划打印表(按投料累加量)</h1>
  43. </c:if>
  44. <c:if test="${btnType eq 2}">
  45. <h1><c:out value="${beginDate}" />日计划打印表(按发料量)</h1>
  46. </c:if>
  47. <c:if test="${btnType eq 3}">
  48. <h1>牧场日粮配合表(<c:out value="${beginDate}" />)</h1>
  49. </c:if>
  50. <c:if test="${btnType eq 5}">
  51. <h1>牧场日粮累加配合表(<c:out value="${beginDate}" />)</h1>
  52. </c:if>
  53. <c:if test="${btnType eq 4}">
  54. <h1><c:out value="${beginDate}" />日计划打印表(包装量)</h1>
  55. </c:if>
  56. <c:if test="${btnType eq 6}">
  57. <h1>牧场日粮实发表(<c:out value="${beginDate}" />(单位:公斤))</h1>
  58. </c:if>
  59. </td>
  60. </tr>
  61. </table>
  62. <table cellspacing="1" cellpadding="0" border="1" style="width:99%;" class="tabsty">
  63. <tbody>
  64. <tr align="center" style="height: 25px;">
  65. <c:forEach var="col" items="${colList}">
  66. <c:if test="${col.name != 'TMR'}">
  67. <th><c:out value="${col.name}" /></th>
  68. </c:if>
  69. <c:if test="${col.name == 'TMR'}">
  70. <c:if test="${tmrFlag == true}">
  71. <th><c:out value="${col.name}" /></th>
  72. </c:if>
  73. </c:if>
  74. </c:forEach>
  75. </tr>
  76. <%
  77. Boolean tmrFlag = (Boolean) request.getAttribute("tmrFlag");
  78. String btnType = (String) request.getAttribute("btnType");
  79. List colList = (List) request.getAttribute("colList");
  80. List rsList = (List) request.getAttribute("rsList");
  81. Float lsVale = 0F;
  82. DecimalFormat fnum = new DecimalFormat("##0.0");
  83. if("1".equals(btnType)){
  84. for (int i = 0; i < rsList.size(); i++){
  85. lsVale = 0F;
  86. Map rsMap = (Map) rsList.get(i);
  87. %>
  88. <tr align="center" class="greb" style="height: 25px;">
  89. <%
  90. for (int j = 0; j < colList.size(); j++){
  91. Map colMap = (Map) colList.get(j);
  92. String colName = (String)colMap.get("name");
  93. if("没有数据!".equals(colName)){
  94. %>
  95. <td>没有数据!</td>
  96. <%
  97. }else{
  98. if("车次".equals(colName)||"时间".equals(colName)||"配方模板".equals(colName)||"日系数比例".equals(colName)||"驾驶员".equals(colName)||"班组".equals(colName)){
  99. String colValueOld = (String)rsMap.get(colName);
  100. %>
  101. <td><c:out value="<%=colValueOld %>"/></td>
  102. <%
  103. }else if("TMR".equals(colName)){
  104. if(tmrFlag){
  105. String colValueOld = (String)rsMap.get(colName);
  106. %>
  107. <td><c:out value="<%=colValueOld %>"/></td>
  108. <%
  109. }
  110. }else{
  111. String colValueOld = (String)rsMap.get(colName);
  112. if(!colValueOld.isEmpty()){
  113. Float colValue = Float.valueOf(colValueOld);
  114. if(lsVale == 0){
  115. lsVale = colValue;
  116. }else{
  117. lsVale += colValue;
  118. }
  119. String colValueNew = fnum.format(lsVale);
  120. %>
  121. <td><c:out value="<%=colValueNew %>"/></td>
  122. <%
  123. }else{
  124. %>
  125. <td><c:out value=""/></td>
  126. <%
  127. }
  128. }
  129. }
  130. }
  131. %>
  132. </tr>
  133. <%
  134. }
  135. }else{
  136. for (int i = 0; i < rsList.size(); i++){
  137. Map rsMap = (Map) rsList.get(i);
  138. %>
  139. <tr align="center" class="greb" style="height: 25px;">
  140. <%
  141. for (int j = 0; j < colList.size(); j++){
  142. Map colMap = (Map) colList.get(j);
  143. String colName = (String)colMap.get("name");
  144. if("没有数据!".equals(colName)){
  145. %>
  146. <td>没有数据!</td>
  147. <%
  148. }else{
  149. Object colValueOld = (Object)rsMap.get(colName);
  150. if(!"TMR".equals(colName)){
  151. %>
  152. <td><c:out value="<%=colValueOld %>"/></td>
  153. <%
  154. }else{
  155. if(tmrFlag){
  156. %>
  157. <td><c:out value="<%=colValueOld %>"/></td>
  158. <%
  159. }
  160. }
  161. }
  162. }
  163. %>
  164. </tr>
  165. <%
  166. }
  167. }
  168. %>
  169. </tbody>
  170. </table>
  171. </div>
  172. </body>
  173. </html>