BackgroundProcessingServiceImpl.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.BackgroundProcessingMapper;
  3. import com.steerinfo.dil.service.IBackgroundProcessService;
  4. import com.steerinfo.dil.util.DataChange;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import java.math.BigDecimal;
  8. import java.util.ArrayList;
  9. import java.util.Arrays;
  10. import java.util.List;
  11. import java.util.Map;
  12. @Service(value = "backgroundProcessingService")
  13. public class BackgroundProcessingServiceImpl implements IBackgroundProcessService {
  14. @Autowired
  15. private BackgroundProcessingMapper backgroundProcessingMapper;
  16. /**
  17. * 更新订单所属厂区
  18. * @param map
  19. * @return
  20. */
  21. @Override
  22. public int updatePurOrgId(Map<String, Object> map) {
  23. return backgroundProcessingMapper.updatePurOrderOrgId(map);
  24. }
  25. /**
  26. * 删除重复实绩
  27. * @param orderNumber
  28. * @return
  29. */
  30. public int deleteErrorResult(String orderNumber) {
  31. Map<String, Object> orderMes = backgroundProcessingMapper.getOrderMesByOrderNum(orderNumber);
  32. int orderType = DataChange.dataToBigDecimal(orderMes.get("orderType")).intValue();
  33. List<Integer> arrayList = Arrays.asList(11, 15, 16, 21); //没有固定路线不支持此操作
  34. if(arrayList.contains(orderType)){
  35. return 0;
  36. }
  37. BigDecimal resultTotalId = DataChange.dataToBigDecimal(orderMes.get("resultTotalId"));
  38. List<Integer> enFactoryList = backgroundProcessingMapper.enFactoryCheck(resultTotalId);
  39. if(enFactoryList != null && enFactoryList.size() != 0){
  40. //查询出当前顺序号中所有的实绩
  41. for (Integer sqe : enFactoryList) {
  42. List<Map<String, Object>> mesList = backgroundProcessingMapper.getEnFactoryResult(resultTotalId, sqe);
  43. closeWay(mesList, 1);
  44. }
  45. }
  46. List<Integer> loadList = backgroundProcessingMapper.loadCheck(resultTotalId);
  47. if(loadList != null && loadList.size() != 0){
  48. for (Integer sqe : loadList) {
  49. List<Map<String, Object>> mesList = backgroundProcessingMapper.loadResult(resultTotalId, sqe);
  50. closeWay(mesList, 2);
  51. }
  52. }
  53. List<Integer> unloadList = backgroundProcessingMapper.unloadCheck(resultTotalId);
  54. if(unloadList != null && unloadList.size() != 0){
  55. for (Integer sqe : unloadList) {
  56. List<Map<String, Object>> mesList = backgroundProcessingMapper.unloadResult(resultTotalId, sqe);
  57. closeWay( mesList, 3);
  58. }
  59. }
  60. List<Integer> weightList = backgroundProcessingMapper.weightCheck(resultTotalId);
  61. if(weightList != null && weightList.size() != 0){
  62. for (Integer sqe : weightList) {
  63. List<Map<String, Object>> mesList = backgroundProcessingMapper.weightResult(resultTotalId, sqe);
  64. closeWay(mesList, 4);
  65. }
  66. }
  67. List<Integer> outFactoryList = backgroundProcessingMapper.outFactoryCheck(resultTotalId);
  68. if(outFactoryList != null && outFactoryList.size() != 0){
  69. for (Integer sqe : outFactoryList) {
  70. List<Map<String, Object>> mesList = backgroundProcessingMapper.outFactoryResult(resultTotalId, sqe);
  71. closeWay(mesList, 5);
  72. }
  73. }
  74. return 0;
  75. }
  76. /**
  77. * 关闭通用方法
  78. * @param mesList 这些顺序号的实绩信息
  79. * @param type 1:进厂 2:计量 3:装货:4:卸货 5:出厂
  80. */
  81. public void closeWay(List<Map<String, Object>> mesList, int type){
  82. List<Integer> resultList = new ArrayList<>();
  83. for (Map<String, Object> map : mesList) {
  84. //有过操作时间的不做删除
  85. if(map.get("time") == null){
  86. resultList.add(DataChange.dataToBigDecimal(map.get("resultId")).intValue()); //添入列表中
  87. }
  88. }
  89. if(mesList.size() == resultList.size()){
  90. //如果所有的实绩都为空 ,则只保留一条实绩,其余的全部删除
  91. resultList.remove(0);
  92. }
  93. if(resultList.size() != 0){
  94. //删除实绩数据
  95. if(type == 1)
  96. backgroundProcessingMapper.deleteEnFactoryUnnecessaryResult(resultList);
  97. else if(type == 2)
  98. backgroundProcessingMapper.deleteLoadUnnecessaryResult(resultList);
  99. else if(type == 3)
  100. backgroundProcessingMapper.deleteUnloadUnnecessaryResult(resultList);
  101. else if(type == 4)
  102. backgroundProcessingMapper.deleteWeightUnnecessaryResult(resultList);
  103. else if(type == 5)
  104. backgroundProcessingMapper.deleteOutFactoryUnnecessaryResult(resultList);
  105. }
  106. }
  107. }