materialslist.jsp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <%@ page contentType="text/html; charset=utf-8" session="false"%>
  2. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
  3. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
  4. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  5. <%@page import="java.util.List"%>
  6. <%@page import="java.util.Map"%>
  7. <%@page import="java.util.Date"%>
  8. <%@page import="java.util.ArrayList"%>
  9. <%@page import="java.math.BigDecimal"%>
  10. <table cellspacing="1" cellpadding="0" border="0" style="width:1400px;" class="tabsty">
  11. <tbody>
  12. <tr align="center" style="height: 25px;">
  13. <th>饲料名称</th>
  14. <c:if test="${tjTarget == 0}">
  15. <c:forEach var="feed" items="${feedlist}">
  16. <th colspan="2"><c:out value="${feed.FNAME}" /></th>
  17. </c:forEach>
  18. <th colspan="2">合计</th>
  19. </c:if>
  20. <c:if test="${tjTarget != 0}">
  21. <c:forEach var="feed" items="${feedlist}">
  22. <th><c:out value="${feed.FNAME}" /></th>
  23. </c:forEach>
  24. <th>合计</th>
  25. </c:if>
  26. </tr>
  27. <tr align="center" style="height: 25px;">
  28. <c:if test="${tjType == 0}">
  29. <th>舍栏类别</th>
  30. </c:if>
  31. <c:if test="${tjType == 1}">
  32. <th>舍栏</th>
  33. </c:if>
  34. <c:if test="${tjType == 2}">
  35. <th>日期</th>
  36. </c:if>
  37. <c:if test="${tjType == 3}">
  38. <th>TM</th>
  39. </c:if>
  40. <c:if test="${tjType == 4}">
  41. <th>班次</th>
  42. </c:if>
  43. <c:if test="${tjType == 5}">
  44. <th>车次</th>
  45. </c:if>
  46. <c:if test="${tjTarget == 0}">
  47. <c:forEach var="feed" items="${feedlist}">
  48. <th>理论</th>
  49. <th>实际</th>
  50. </c:forEach>
  51. <th>理论</th>
  52. <th>实际</th>
  53. </c:if>
  54. <c:if test="${tjTarget == 1}">
  55. <c:forEach var="feed" items="${feedlist}">
  56. <th>理论</th>
  57. </c:forEach>
  58. <th>理论</th>
  59. </c:if>
  60. <c:if test="${tjTarget == 2}">
  61. <c:forEach var="feed" items="${feedlist}">
  62. <th>实际</th>
  63. </c:forEach>
  64. <th>实际</th>
  65. </c:if>
  66. </tr>
  67. <%
  68. List list = (List) request.getAttribute("list");
  69. List feedlist = (List) request.getAttribute("feedlist");
  70. String tjType = (String) request.getAttribute("tjType");
  71. String tjTarget = (String) request.getAttribute("tjTarget");
  72. String strname = "";
  73. if(list.size() == 1){
  74. Map strnameMap = (Map)list.get(0);
  75. strname = (String)strnameMap.get("1");
  76. }
  77. if(list.size() > 0 && !"1".equals(strname)){
  78. //动态列头数组
  79. int fsize = feedlist.size();
  80. if("0".equals(tjTarget)){
  81. fsize = fsize*2;
  82. }
  83. Double[] feedstr = new Double[fsize];
  84. //动态合计值数组
  85. Double[] liststr;
  86. if("0".equals(tjTarget)){
  87. liststr = new Double[2];
  88. }else{
  89. liststr = new Double[1];
  90. }
  91. for (int i = 0; i < list.size(); i++) {
  92. int c = 0;
  93. int listC = 0;
  94. Map map = (Map) list.get(i);
  95. if("0".equals(tjType)){
  96. String n1 = (String)map.get("舍栏类别");
  97. %>
  98. <tr align="center" class="greb" style="height: 25px;">
  99. <td><c:out value="<%=n1 %>"/></td>
  100. <%
  101. }else if("1".equals(tjType)){
  102. String n1 = (String)map.get("舍栏");
  103. %>
  104. <tr align="center" class="greb" style="height: 25px;">
  105. <td><c:out value="<%=n1 %>"/></td>
  106. <%
  107. }else if("2".equals(tjType)){
  108. Date d1 = (Date)map.get("日期");
  109. %>
  110. <tr align="center" class="greb" style="height: 25px;">
  111. <td><c:out value="<%=d1 %>"/></td>
  112. <%
  113. }else if("3".equals(tjType)){
  114. String n1 = (String)map.get("TMR");
  115. %>
  116. <tr align="center" class="greb" style="height: 25px;">
  117. <td><c:out value="<%=n1 %>"/></td>
  118. <%
  119. }else if("4".equals(tjType)){
  120. String bc = "";
  121. Integer n1 = (Integer)map.get("班次");
  122. if(n1 == 1){
  123. bc = "早班1";
  124. }else if(n1 == 2){
  125. bc = "早班2";
  126. }else if(n1 == 3){
  127. bc = "中班1";
  128. }else if(n1 == 4){
  129. bc = "中班2";
  130. }else if(n1 == 5){
  131. bc = "晚班1";
  132. }else{
  133. bc = "晚班2";
  134. }
  135. %>
  136. <tr align="center" class="greb" style="height: 25px;">
  137. <td><c:out value="<%=bc %>"/></td>
  138. <%
  139. }else if("5".equals(tjType)){
  140. String n1 = (String)map.get("车次");
  141. %>
  142. <tr align="center" class="greb" style="height: 25px;">
  143. <td><c:out value="<%=n1 %>"/></td>
  144. <%
  145. }
  146. if("0".equals(tjTarget)){
  147. for (int j = 0; j < feedlist.size(); j++){
  148. Map fmap = (Map) feedlist.get(j);
  149. String fname = (String)fmap.get("FNAME");
  150. String fname1 = fname+"|理论";
  151. String fname2 = fname+"|实际";
  152. Double newname1 = (Double)map.get(fname1);
  153. Double newname2 = (Double)map.get(fname2);
  154. if(newname1 != null && newname2 != null){
  155. BigDecimal bg = new BigDecimal(newname1);
  156. newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
  157. BigDecimal bg1 = new BigDecimal(newname2);
  158. newname2 = bg1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
  159. if(feedstr[c]==null){
  160. feedstr[c] = newname1;
  161. }else{
  162. feedstr[c] += newname1;
  163. }
  164. c++;
  165. if(feedstr[c]==null){
  166. feedstr[c] = newname2;
  167. }else{
  168. feedstr[c] += newname2;
  169. }
  170. c++;
  171. %>
  172. <td><c:out value="<%=newname1 %>"/></td>
  173. <td><c:out value="<%=newname2 %>"/></td>
  174. <%
  175. }else{
  176. if(feedstr[c]==null){
  177. feedstr[c] = 0.0;
  178. }else{
  179. feedstr[c] += 0.0;
  180. }
  181. c++;
  182. if(feedstr[c]==null){
  183. feedstr[c] = 0.0;
  184. }else{
  185. feedstr[c] += 0.0;
  186. }
  187. c++;
  188. %>
  189. <td>0.0</td>
  190. <td>0.0</td>
  191. <%
  192. }
  193. }
  194. BigDecimal sum1 = (BigDecimal)map.get("合计|理论");
  195. BigDecimal sum2 = (BigDecimal)map.get("合计|实际");
  196. if(liststr[listC]==null){
  197. liststr[listC] = sum1.doubleValue();
  198. }else{
  199. liststr[listC] += sum1.doubleValue();
  200. }
  201. listC++;
  202. if(liststr[listC]==null){
  203. liststr[listC] = sum2.doubleValue();
  204. }else{
  205. liststr[listC] += sum2.doubleValue();
  206. }
  207. listC++;
  208. %>
  209. <td><c:out value="<%=sum1 %>"/></td>
  210. <td><c:out value="<%=sum2 %>"/></td>
  211. </tr>
  212. <%
  213. }else if("1".equals(tjTarget)){
  214. for (int j = 0; j < feedlist.size(); j++){
  215. Map fmap = (Map) feedlist.get(j);
  216. String fname = (String)fmap.get("FNAME");
  217. String fname1 = fname+"|理论";
  218. Double newname1 = (Double)map.get(fname1);
  219. if(newname1 != null){
  220. BigDecimal bg = new BigDecimal(newname1);
  221. newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
  222. if(feedstr[c]==null){
  223. feedstr[c] = newname1;
  224. }else{
  225. feedstr[c] += newname1;
  226. }
  227. c++;
  228. %>
  229. <td><c:out value="<%=newname1 %>"/></td>
  230. <%
  231. }else{
  232. if(feedstr[c]==null){
  233. feedstr[c] = 0.0;
  234. }else{
  235. feedstr[c] += 0.0;
  236. }
  237. c++;
  238. %>
  239. <td>0.0</td>
  240. <%
  241. }
  242. }
  243. BigDecimal sum1 = (BigDecimal)map.get("合计|理论");
  244. if(liststr[listC]==null){
  245. liststr[listC] = sum1.doubleValue();
  246. }else{
  247. liststr[listC] += sum1.doubleValue();
  248. }
  249. listC++;
  250. %>
  251. <td><c:out value="<%=sum1 %>"/></td>
  252. </tr>
  253. <%
  254. }else if("2".equals(tjTarget)){
  255. for (int j = 0; j < feedlist.size(); j++){
  256. Map fmap = (Map) feedlist.get(j);
  257. String fname = (String)fmap.get("FNAME");
  258. String fname1 = fname+"|实际";
  259. Double newname1 = (Double)map.get(fname1);
  260. if(newname1 != null){
  261. BigDecimal bg = new BigDecimal(newname1);
  262. newname1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
  263. if(feedstr[c]==null){
  264. feedstr[c] = newname1;
  265. }else{
  266. feedstr[c] += newname1;
  267. }
  268. c++;
  269. %>
  270. <td><c:out value="<%=newname1 %>"/></td>
  271. <%
  272. }else{
  273. if(feedstr[c]==null){
  274. feedstr[c] = 0.0;
  275. }else{
  276. feedstr[c] += 0.0;
  277. }
  278. c++;
  279. %>
  280. <td>0.0</td>
  281. <%
  282. }
  283. }
  284. BigDecimal sum1 = (BigDecimal)map.get("合计|实际");
  285. if(liststr[listC]==null){
  286. liststr[listC] = sum1.doubleValue();
  287. }else{
  288. liststr[listC] += sum1.doubleValue();
  289. }
  290. listC++;
  291. %>
  292. <td><c:out value="<%=sum1 %>"/></td>
  293. </tr>
  294. <%
  295. }
  296. }
  297. %>
  298. <tr align="center" class="greb" style="height: 25px;">
  299. <td><c:out value="合计"/></td>
  300. <%
  301. for (int k = 0; k < feedstr.length; k++){
  302. String newF = String.format("%.2f", feedstr[k]);
  303. %>
  304. <td><c:out value="<%=newF %>"/></td>
  305. <%
  306. }
  307. for (int t = 0; t < liststr.length; t++){
  308. String newL = String.format("%.2f", liststr[t]);
  309. %>
  310. <td><c:out value="<%=newL %>"/></td>
  311. <%
  312. }
  313. %>
  314. </tr>
  315. <%
  316. }else{
  317. if("0".equals(tjTarget)){
  318. %>
  319. <tr align="center" class="greb" style="height: 25px;"><td colspan="${feedlistsize*2+3}">没有对应的结果</td></tr>
  320. <%
  321. }else{
  322. %>
  323. <tr align="center" class="greb" style="height: 25px;"><td colspan="${feedlistsize+2}">没有对应的结果</td></tr>
  324. <%
  325. }
  326. }
  327. %>
  328. </tbody>
  329. </table>