StatisticalReportImpl.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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.*;
  11. /**
  12. * @ author :TXF
  13. * @ time :2021/12/14 15:26
  14. */
  15. @Service
  16. public class StatisticalReportImpl implements IStatisticalReportService {
  17. @Autowired
  18. StatisticalReportMapper statisticalReportMapper;
  19. /**
  20. * 计算相差时间
  21. * @return
  22. */
  23. public void calculateDifferenceTime(Map<String, Object> mesMap){
  24. Object resultEntryGateTime = mesMap.get("resultEntryGateTime");
  25. Object resultOutGateTime = mesMap.get("resultOutGateTime");
  26. if(resultEntryGateTime != null && resultOutGateTime != null){
  27. Date enterDate = (Date) resultEntryGateTime;
  28. Date outDate = (Date) resultOutGateTime;
  29. //计算相差时间
  30. long dTime = outDate.getTime() - enterDate.getTime();
  31. mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟");
  32. }
  33. if(resultEntryGateTime != null && resultOutGateTime == null){
  34. //如果没有出厂时间则以当前时间减去进厂时间
  35. Date enterDate = (Date) resultEntryGateTime;
  36. long dTime = new Date().getTime() - enterDate.getTime();
  37. mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟");
  38. }
  39. }
  40. /**
  41. * 查询采购统计报表
  42. * @Author TXF
  43. * @Date 2022/1/6 9:52
  44. * @param map
  45. * @return
  46. **/
  47. public List<Map<String, Object>> getRLFLReport(Map<String, Object> map){
  48. List<Map<String, Object>> mapList = null;
  49. if(DataChange.dataToBigDecimal(map.get("orderTypee")).intValue() == 5){
  50. mapList = statisticalReportMapper.getFuPurchaseFLRLReport(map);
  51. }else {
  52. mapList = statisticalReportMapper.getAllPurchaseFLRLReport(map);
  53. }
  54. return mapList;
  55. }
  56. @Override
  57. public List<Map<String, Object>> getAllPurchaseFLRLReport(Map<String, Object> map) {
  58. return statisticalReportMapper.getAllPurchaseFLRLReport(map);
  59. }
  60. /**
  61. * 查询销售统计报表
  62. * @param map
  63. * @return
  64. */
  65. @Override
  66. public List<Map<String, Object>> getAllSaleReport(Map<String, Object> map) {
  67. List<Map<String, Object>> mapList = statisticalReportMapper.getAllSaleReport(map);
  68. /*for(Map<String, Object> map1 : mapList) {
  69. if ( map1.get("resultEntryGateTime") == null) {
  70. map1.put("transportStatus", "未进厂");
  71. continue;
  72. }
  73. if (map1.get("resultOutGateTime") == null) {
  74. map1.put("transportStatus", "已进厂");
  75. continue;
  76. }
  77. if (map1.get("arrivalAddress") == null) {
  78. map1.put("transportStatus", "已出厂");
  79. continue;
  80. }
  81. if (map1.get("receiptAddress") == null) {
  82. map1.put("transportStatus", "已抵达");
  83. continue;
  84. }
  85. else{
  86. map1.put("transportStatus", "已签收");
  87. }
  88. }*/
  89. for (Map<String, Object> mesMap : mapList) {
  90. calculateDifferenceTime(mesMap);
  91. }
  92. return mapList;
  93. }
  94. @Override
  95. public List<Map<String, Object>> getAllSaleReportNum(Map<String, Object> map) {
  96. List<Map<String, Object>> listMap = statisticalReportMapper.getAllSaleReport(map);
  97. return listMap;
  98. }
  99. /**
  100. * 查询零星物资进厂统计报表
  101. */
  102. @Override
  103. public List<Map<String, Object>> getSporadicSuppliesReportNum1(Map<String, Object> mapValue) {
  104. return statisticalReportMapper.getSporadicSuppliesReport1(mapValue);
  105. }
  106. @Override
  107. public List<Map<String, Object>> getSporadicSuppliesReport1(Map<String, Object> mapValue) {
  108. List<Map<String, Object>> mapList = statisticalReportMapper.getSporadicSuppliesReport1(mapValue);
  109. for (Map<String, Object> mesMap : mapList) {
  110. calculateDifferenceTime(mesMap);
  111. }
  112. return mapList;
  113. }
  114. /**
  115. * 查询零星物资出厂统计报表
  116. */
  117. @Override
  118. public List<Map<String, Object>> getSporadicSuppliesReportNum2(Map<String, Object> mapValue) {
  119. return statisticalReportMapper.getSporadicSuppliesReport2(mapValue);
  120. }
  121. @Override
  122. public List<Map<String, Object>> getSporadicSuppliesReport2(Map<String, Object> mapValue) {
  123. List<Map<String, Object>> mapList = statisticalReportMapper.getSporadicSuppliesReport2(mapValue);
  124. for (Map<String, Object> mesMap : mapList) {
  125. calculateDifferenceTime(mesMap);
  126. }
  127. return mapList;
  128. }
  129. //采购内转统计报表
  130. @Override
  131. public List<Map<String, Object>> getPurInwardReport( Map<String, Object> mapValue) {
  132. List<Map<String, Object>> inwardReportResult = statisticalReportMapper.getInwardReportResult(mapValue);
  133. for (Map<String,Object>inwardReport:inwardReportResult
  134. ) {
  135. if(DataChange.dataToBigDecimal(inwardReport.get("orderType")).intValue() == 10){
  136. inwardReport.put("transRange","化工园区铁专线-焦化二厂");
  137. }else{
  138. inwardReport.put("transRange","化工园区铁专线-达钢厂区");
  139. }
  140. BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond"));
  141. BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst"));
  142. BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4);
  143. //第二次净重减第一次净重
  144. inwardReport.put("newTract",netTract);
  145. calculateDifferenceTime(inwardReport);
  146. }
  147. return inwardReportResult;
  148. }
  149. //采购内转统计报表
  150. @Override
  151. public List<Map<String, Object>> getLXInwardReport( Map<String, Object> mapValue) {
  152. List<Map<String, Object>> lxReportResult = statisticalReportMapper.getLXReportResult(mapValue);
  153. for (Map<String,Object>inwardReport:lxReportResult
  154. ) {
  155. BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond"));
  156. BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst"));
  157. BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4);
  158. //第二次净重减第一次净重
  159. inwardReport.put("newTract",netTract);
  160. calculateDifferenceTime(inwardReport);
  161. }
  162. return lxReportResult;
  163. }
  164. @Override
  165. public List<Map<String, Object>> getInwardReport(Map<String, Object> mapValue) {
  166. return statisticalReportMapper.getInwardReport(mapValue);
  167. }
  168. @Override
  169. public List<Map<String, Object>> getLoading(Map<String, Object> mapValue) {
  170. return statisticalReportMapper.getLoading(mapValue);
  171. }
  172. @Override
  173. public List<Map<String, Object>> getUnLoading(Map<String, Object> mapValue) {
  174. return statisticalReportMapper.getUnLoading(mapValue);
  175. }
  176. @Override
  177. public List<Map<String, Object>> getLoaderResult(Map<String, Object> mapValue) {
  178. return statisticalReportMapper.getLoaderResult(mapValue);
  179. }
  180. @Override
  181. public List<Map<String, Object>> getCapacityByDefend(Map<String, Object> map) {
  182. return statisticalReportMapper.getCapacityByDefend(map);
  183. }
  184. @Override
  185. public List<Map<String, Object>> getInwardReportForAssemble(Map<String, Object> mapValue) {
  186. return statisticalReportMapper.getInwardReportForAssemble(mapValue);
  187. }
  188. @Override
  189. public List<Map<String, Object>> getLoaderForResultDetail(Map<String, Object> mapValue) {
  190. //判断是否含有装机备注
  191. return statisticalReportMapper.getLoaderForResultDetail(mapValue);
  192. }
  193. //查看该组织架构下的销售订单统计报表
  194. @Override
  195. public List<Map<String, Object>> getSaleOrderList(Map<String, Object> mapValue) {
  196. return statisticalReportMapper.getSaleOrderList(mapValue);
  197. }
  198. //查看该组织架构下的采购订单统计报表
  199. @Override
  200. public List<Map<String, Object>> getPurchaseOrderList(Map<String, Object> mapValue) {
  201. return statisticalReportMapper.getPurchaseOrderList(mapValue);
  202. }
  203. //查看该组织架构下的采购内转统计报表
  204. @Override
  205. public List<Map<String, Object>> getPurchaseInwardList(Map<String, Object> mapValue) {
  206. return statisticalReportMapper.getPurchaseInwardList(mapValue);
  207. }
  208. //查看该组织架构下的内转统计报表
  209. @Override
  210. public List<Map<String, Object>> getInwardInFactory(Map<String, Object> mapValue) {
  211. return statisticalReportMapper.getInwardInFactory(mapValue);
  212. }
  213. @Override
  214. public List<Map<String, Object>> getOutFactoryInwardList(Map<String, Object> mapValue) {
  215. return statisticalReportMapper.getOutFactoryInwardList(mapValue);
  216. }
  217. @Override
  218. public List<Map<String, Object>> getSaleSteelReport(Map<String, Object> mapValue) {
  219. List<Map<String, Object>> saleSteelReport = statisticalReportMapper.getSaleSteelReport(mapValue);
  220. return saleSteelReport;
  221. }
  222. @Override
  223. public List<Map<String, Object>> getSaleSteelReportNew(Map<String, Object> mapValue) {
  224. List<Map<String, Object>> saleSteelReport = statisticalReportMapper.getSaleSteelReportNew(mapValue);
  225. return saleSteelReport;
  226. }
  227. @Override
  228. public List<Map<String, Object>> getSettledSaleSteelReportNew(Map<String, Object> mapValue) {
  229. List<Map<String, Object>> saleSteelReport = statisticalReportMapper.getSettledSaleSteelReportNew(mapValue);
  230. return saleSteelReport;
  231. }
  232. @Override
  233. public List<Map<String, Object>> getInwardSaleSteelReport(Map<String, Object> map) {
  234. return statisticalReportMapper.getInwardSaleSteelReport(map);
  235. }
  236. @Override
  237. public List<Map<String, Object>> getInwardSaleSteelOrder(Map<String, Object> map) {
  238. List<Map<String, Object>> results=statisticalReportMapper.getInwardSaleSteelOrder(map);
  239. if(results!=null){
  240. //遍历找到所有已使用的分录
  241. Set<BigDecimal> saleMaterialIds=new HashSet<>();
  242. for(Map<String,Object> temp:results){
  243. if(temp.get("orderId")!=null){
  244. saleMaterialIds.add(DataChange.dataToBigDecimal(temp.get("saleMaterialId")));
  245. }
  246. }
  247. //查询分录已使用但订单id为null的记录
  248. List<Map<String, Object>> disResults=new ArrayList<>();
  249. for(Map<String,Object> temp:results){
  250. if(temp.get("orderId")==null && saleMaterialIds.contains(DataChange.dataToBigDecimal(temp.get("saleMaterialId")))){
  251. disResults.add(temp);
  252. }
  253. }
  254. //删除这些记录,防止重复派单
  255. results.removeAll(disResults);
  256. }
  257. return results;
  258. }
  259. @Override
  260. public Map<String,Object> getSteelReportDetailsBySmId(BigDecimal saleOrderMaterialId) {
  261. //获取主表数据
  262. Map<String,Object> map = statisticalReportMapper.getSteelReportDetailsBySmId(saleOrderMaterialId);
  263. //获取子表数据
  264. List<Map<String,Object>> mapList = statisticalReportMapper.getSteelReportDetailsListBySmId(saleOrderMaterialId);
  265. if (map != null){
  266. if(DataChange.dataToBigDecimal(map.get("orderStatu")).intValue() == 5 && map.get("queueStartTime") != null && DataChange.dataToBigDecimal(map.get("lineSqe")).intValue() == 0){
  267. map.put("orderStatus","排队中");
  268. map.put("orderStatusTime",map.get("queueStartTime"));
  269. }else if(DataChange.dataToBigDecimal(map.get("orderStatu")).intValue() == 5 && DataChange.dataToBigDecimal(map.get("lineSqe")).intValue() != 0 && map.get("outGateTime") == null){
  270. map.put("orderStatus","已进厂");
  271. map.put("orderStatusTime",map.get("entryGateTime"));
  272. }else if(DataChange.dataToBigDecimal(map.get("orderStatu")).intValue() == 5 && map.get("outGateTime") != null){
  273. map.put("orderStatus","已出厂");
  274. map.put("orderStatusTime",map.get("outGateTime"));
  275. }
  276. map.put("mapList",mapList);
  277. }
  278. return map;
  279. }
  280. @Override
  281. public String getaddress(BigDecimal addressid) {
  282. String address = statisticalReportMapper.queryAddress(addressid);
  283. return address;
  284. }
  285. //获取单价
  286. @Override
  287. public BigDecimal getHistoryPrice(BigDecimal priceId) {
  288. BigDecimal bigDecimal = statisticalReportMapper.queryHistoryPrice(priceId);
  289. return bigDecimal;
  290. }
  291. @Override
  292. public String getcapacityNumber(BigDecimal capacitynumber) {
  293. String s = statisticalReportMapper.queryCapacityNumber(capacitynumber);
  294. return s;
  295. }
  296. @Override
  297. public List<Map<String, Object>> loadingSaleSteelReport(Map<String, Object> map) {
  298. List<Map<String, Object>> saleSteelReport = statisticalReportMapper.loadingSaleSteelReport(map);
  299. return saleSteelReport;
  300. }
  301. @Override
  302. public String getStatus(BigDecimal orderId) {
  303. return statisticalReportMapper.getStatus(orderId);
  304. }
  305. @Override
  306. public List<String> getSaleAreaRemark(String saler) {
  307. return statisticalReportMapper.getSaleAreaRemark(saler);
  308. }
  309. }