StatisticalReportImpl.java 6.2 KB

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