BackgroundProcessingServiceImpl.java 5.8 KB

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