StatisticalReportImpl.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.StatisticalReportMapper;
  3. import com.steerinfo.dil.service.IStatisticalReportService;
  4. import com.steerinfo.dil.util.DataChange;
  5. import oracle.sql.DATE;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import java.math.BigDecimal;
  10. import java.util.ArrayList;
  11. import java.util.Date;
  12. import java.util.List;
  13. import java.util.Map;
  14. /**
  15. * @ author :TXF
  16. * @ time :2021/12/14 15:26
  17. */
  18. @Service
  19. public class StatisticalReportImpl implements IStatisticalReportService {
  20. @Autowired
  21. StatisticalReportMapper statisticalReportMapper;
  22. /**
  23. * 计算相差时间
  24. * @return
  25. */
  26. public void calculateDifferenceTime(Map<String, Object> mesMap){
  27. Object resultEntryGateTime = mesMap.get("resultEntryGateTime");
  28. Object resultOutGateTime = mesMap.get("resultOutGateTime");
  29. if(resultEntryGateTime != null && resultOutGateTime != null){
  30. Date enterDate = (Date) resultEntryGateTime;
  31. Date outDate = (Date) resultOutGateTime;
  32. //计算相差时间
  33. long dTime = outDate.getTime() - enterDate.getTime();
  34. mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟");
  35. }
  36. if(resultEntryGateTime != null && resultOutGateTime == null){
  37. //如果没有出厂时间则以当前时间减去进厂时间
  38. Date enterDate = (Date) resultEntryGateTime;
  39. long dTime = new Date().getTime() - enterDate.getTime();
  40. mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟");
  41. }
  42. }
  43. /**
  44. * 查询采购统计报表
  45. * @Author TXF
  46. * @Date 2022/1/6 9:52
  47. * @param map
  48. * @return
  49. **/
  50. public List<Map<String, Object>> getRLFLReport(Map<String, Object> map){
  51. List<Map<String, Object>> mapList = null;
  52. if(DataChange.dataToBigDecimal(map.get("orderTypee")).intValue() == 5){
  53. mapList = statisticalReportMapper.getFuPurchaseFLRLReport(map);
  54. }else {
  55. mapList = statisticalReportMapper.getAllPurchaseFLRLReport(map);
  56. }
  57. return mapList;
  58. }
  59. @Override
  60. public List<Map<String, Object>> getAllPurchaseFLRLReport(Map<String, Object> map) {
  61. return statisticalReportMapper.getAllPurchaseFLRLReport(map);
  62. }
  63. /**
  64. * 查询销售统计报表
  65. * @param map
  66. * @return
  67. */
  68. @Override
  69. public List<Map<String, Object>> getAllSaleReport(Map<String, Object> map) {
  70. List<Map<String, Object>> mapList = statisticalReportMapper.getAllSaleReport(map);
  71. for(Map<String, Object> map1 : mapList) {
  72. if ( map1.get("resultEntryGateTime") == null) {
  73. map1.put("transportStatus", "未进厂");
  74. continue;
  75. }
  76. if (map1.get("resultOutGateTime") == null) {
  77. map1.put("transportStatus", "已进厂");
  78. continue;
  79. }
  80. if (map1.get("arrivalAddress") == null) {
  81. map1.put("transportStatus", "已出厂");
  82. continue;
  83. }
  84. if (map1.get("receiptAddress") == null) {
  85. map1.put("transportStatus", "已抵达");
  86. continue;
  87. }
  88. else
  89. map1.put("transportStatus", "已签收");
  90. }
  91. for (Map<String, Object> mesMap : mapList) {
  92. calculateDifferenceTime(mesMap);
  93. }
  94. return mapList;
  95. }
  96. @Override
  97. public List<Map<String, Object>> getAllSaleReportNum(Map<String, Object> map) {
  98. List<Map<String, Object>> listMap = statisticalReportMapper.getAllSaleReport(map);
  99. return listMap;
  100. }
  101. /**
  102. * 查询零星物资进厂统计报表
  103. */
  104. @Override
  105. public List<Map<String, Object>> getSporadicSuppliesReportNum1(Map<String, Object> mapValue) {
  106. return statisticalReportMapper.getSporadicSuppliesReport1(mapValue);
  107. }
  108. @Override
  109. public List<Map<String, Object>> getSporadicSuppliesReport1(Map<String, Object> mapValue) {
  110. List<Map<String, Object>> mapList = statisticalReportMapper.getSporadicSuppliesReport1(mapValue);
  111. for (Map<String, Object> mesMap : mapList) {
  112. calculateDifferenceTime(mesMap);
  113. }
  114. return mapList;
  115. }
  116. /**
  117. * 查询零星物资出厂统计报表
  118. */
  119. @Override
  120. public List<Map<String, Object>> getSporadicSuppliesReportNum2(Map<String, Object> mapValue) {
  121. return statisticalReportMapper.getSporadicSuppliesReport2(mapValue);
  122. }
  123. @Override
  124. public List<Map<String, Object>> getSporadicSuppliesReport2(Map<String, Object> mapValue) {
  125. List<Map<String, Object>> mapList = statisticalReportMapper.getSporadicSuppliesReport2(mapValue);
  126. for (Map<String, Object> mesMap : mapList) {
  127. calculateDifferenceTime(mesMap);
  128. }
  129. return mapList;
  130. }
  131. //采购内转统计报表
  132. @Override
  133. public List<Map<String, Object>> getPurInwardReport( Map<String, Object> mapValue) {
  134. List<Map<String, Object>> inwardReportResult = statisticalReportMapper.getInwardReportResult(mapValue);
  135. for (Map<String,Object>inwardReport:inwardReportResult
  136. ) {
  137. BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond"));
  138. BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst"));
  139. BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4);
  140. //第二次净重减第一次净重
  141. inwardReport.put("newTract",netTract);
  142. calculateDifferenceTime(inwardReport);
  143. }
  144. return inwardReportResult;
  145. }
  146. //采购内转统计报表
  147. @Override
  148. public List<Map<String, Object>> getLXInwardReport( Map<String, Object> mapValue) {
  149. List<Map<String, Object>> lxReportResult = statisticalReportMapper.getLXReportResult(mapValue);
  150. for (Map<String,Object>inwardReport:lxReportResult
  151. ) {
  152. BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond"));
  153. BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst"));
  154. BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4);
  155. //第二次净重减第一次净重
  156. inwardReport.put("newTract",netTract);
  157. calculateDifferenceTime(inwardReport);
  158. }
  159. return lxReportResult;
  160. }
  161. @Override
  162. public List<Map<String, Object>> getInwardReport(Map<String, Object> mapValue) {
  163. return statisticalReportMapper.getInwardReport(mapValue);
  164. }
  165. @Override
  166. public List<Map<String, Object>> getLoading(Map<String, Object> mapValue) {
  167. return statisticalReportMapper.getLoading(mapValue);
  168. }
  169. @Override
  170. public List<Map<String, Object>> getUnLoading(Map<String, Object> mapValue) {
  171. return statisticalReportMapper.getUnLoading(mapValue);
  172. }
  173. @Override
  174. public List<Map<String, Object>> getLoaderResult(Map<String, Object> mapValue) {
  175. return statisticalReportMapper.getLoaderResult(mapValue);
  176. }
  177. @Override
  178. public List<Map<String, Object>> getCapacityByDefend(Map<String, Object> map) {
  179. return statisticalReportMapper.getCapacityByDefend(map);
  180. }
  181. }