pricelist.jsp 9.0 KB

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