TmstruckLeaveFactoryResultServiceImpl.java 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.feign.BmsShipFeign;
  3. import com.steerinfo.dil.feign.BmsTruckFeign;
  4. import com.steerinfo.dil.feign.OmsFeign;
  5. import com.steerinfo.dil.mapper.TmstruckEnfactoryResultMapper;
  6. import com.steerinfo.dil.mapper.TmstruckLeaveFactoryResultMapper;
  7. import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
  8. import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
  9. import com.steerinfo.dil.service.IUtilsService;
  10. import com.steerinfo.dil.util.DataChange;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import java.math.BigDecimal;
  15. import java.text.SimpleDateFormat;
  16. import java.util.Date;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. /**
  21. * TmstruckLeaveFactoryResult服务实现:
  22. * @author generator
  23. * @version 1.0-SNAPSHORT 2021-09-11 10:32
  24. * 类描述
  25. * 修订历史:
  26. * 日期:2021-09-11
  27. * 作者:generator
  28. * 参考:
  29. * 描述:TmstruckLeaveFactoryResult服务实现
  30. * @see null
  31. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  32. */
  33. @Service(value = "tmstruckLeaveFactoryResultService")
  34. public class TmstruckLeaveFactoryResultServiceImpl implements ITmstruckLeaveFactoryResultService {
  35. @Autowired
  36. private TmstruckLeaveFactoryResultMapper tmstruckLeaveFactoryResultMapper;
  37. @Autowired
  38. private TmstruckEnfactoryResultMapper tmstruckEnfactoryResultMapper;
  39. @Autowired
  40. private IUtilsService utilsService;
  41. @Autowired
  42. private BmsShipFeign bmsShipFeign;
  43. @Autowired
  44. private BmsTruckFeign bmsTruckFeign;
  45. @Autowired
  46. OmsFeign omsFeign;
  47. /**
  48. * 查看运输线路是否为出厂
  49. * @param orderNumber
  50. * @return
  51. */
  52. @Override
  53. public Integer selectTransportRoute(String orderNumber) {
  54. return tmstruckLeaveFactoryResultMapper.selectTransportRoute(orderNumber);
  55. }
  56. /**
  57. * 派单后新增出厂实绩
  58. * 总实绩ID、线路终点
  59. * @param map
  60. * @return
  61. */
  62. @Override
  63. public int addLeaveFactory(Map<String, Object> map) {
  64. TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
  65. //添加主键
  66. tmstruckLeaveFactoryResult.setId(tmstruckLeaveFactoryResultMapper.selectMaxId());
  67. //添加总实绩ID
  68. tmstruckLeaveFactoryResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultTotalId")));
  69. //添加路段顺序号
  70. tmstruckLeaveFactoryResult.setSegmentSqe(DataChange.dataToBigDecimal(map.get("segmentSqe")));
  71. //添加门岗ID 出厂门岗为线路的终点
  72. // tmstruckLeaveFactoryResult.setGatepostId(DataChange.dataToBigDecimal(map.get("lineEndNodeId")));
  73. return tmstruckLeaveFactoryResultMapper.insertSelective(tmstruckLeaveFactoryResult);
  74. }
  75. @Override
  76. public Map<String, Object> getTruckFactoryResult(String nu) {
  77. return tmstruckLeaveFactoryResultMapper.getTruckFactoryResult(nu);
  78. }
  79. /**
  80. * APP查询出厂信息
  81. * @param orderNumber
  82. * @return
  83. */
  84. @Override
  85. public List<Map<String, Object>> getLeaveFactoryList(String orderNumber) {
  86. return tmstruckLeaveFactoryResultMapper.getLeaveFactoryList(orderNumber);
  87. }
  88. /**
  89. * 查询所有的出厂实绩
  90. * 1:销售订单;2:焦炭发运计划;3:水渣发运计划;4:内转到异地库;5:采购辅料订单;6:采购老区燃料订单;
  91. * 7:采购新区燃料订单;8:采购进口矿(万州-厂内);9:采购内转(达州-厂内);10:采购内转(老区-厂内); 11:厂内内转
  92. * @param map
  93. * @return
  94. */
  95. @Override
  96. public List<Map<String, Object>> getLeaveFactoryResult(Map<String, Object> map) {
  97. Integer orderType = (Integer) map.get("orderTypee");
  98. switch (orderType){
  99. case 1:
  100. case 2:
  101. case 3:
  102. return tmstruckLeaveFactoryResultMapper.selectAllLeaveFacatoryForSale(map);
  103. case 4:
  104. return tmstruckLeaveFactoryResultMapper.selectSteelNzLeaveFactory(map);
  105. case 5:
  106. case 6:
  107. case 7:
  108. case 8:
  109. return tmstruckLeaveFactoryResultMapper.getCGLeaveFactoryResult(map); //apiId:110
  110. case 9:
  111. return tmstruckLeaveFactoryResultMapper.getImportedDomesticNzEnFactoryResult(map); //apiId:110
  112. case 10:
  113. break;
  114. case 11:
  115. return tmstruckLeaveFactoryResultMapper.getInFactoryOutFactoryResult(map); //apiId:361
  116. }
  117. return null;
  118. }
  119. /**
  120. * 通过 PDA 出厂
  121. * 1:销售订单;2:焦炭发运计划;3:水渣发运计划;4:内转到异地库;5:采购辅料订单;6:采购老区燃料订单;
  122. * 7:采购新区燃料订单;8:采购进口矿(万州-厂内);9:采购内转(达州-厂内);10:采购内转(老区-厂内); 11:厂内内转
  123. * @param map
  124. * @return
  125. */
  126. public int leaveFactoryByPDA(Map<String, Object> map){
  127. int i = 0;
  128. String orderNumber = (String) map.get("orderNumber");
  129. String substring = orderNumber.substring(0, orderNumber.length() - 1);
  130. map.putAll(tmstruckLeaveFactoryResultMapper.selectResultId(substring));
  131. BigDecimal orderType = DataChange.dataToBigDecimal(map.get("orderTypee"));
  132. i += updateLeaveResultByPDA(map); //更新出厂实绩
  133. switch (orderType.intValue()){
  134. case 1:
  135. break;
  136. case 2:
  137. break;
  138. case 3:
  139. break;
  140. case 4:
  141. break;
  142. case 5:
  143. case 6:
  144. case 7:
  145. case 8:
  146. case 9:
  147. i += utilsService.updateOrderStatus(map, 2); // 修改运输订单状态 2:已结束
  148. // i += utilsService.updateCapacityStatus(map, 0); //修改运力状态 0:空闲中
  149. //采购出厂 通过feign调用新增详单
  150. // try {
  151. // bmsShipFeign.addDetailsOrder(DataChange.dataToBigDecimal(map.get("resultId"))); // 出厂实绩Id
  152. // bmsTruckFeign.addDetailsOrder(DataChange.dataToBigDecimal(map.get("orderId"))); // 运单ID
  153. // } catch (Exception e) {
  154. // e.printStackTrace();
  155. // }
  156. break;
  157. case 10:
  158. break;
  159. case 11:
  160. }
  161. //路段顺序号 + 1
  162. i += utilsService.updateOrderLineSequence(map, 1);
  163. omsFeign.pushMesToWebsocket(map);
  164. return i;
  165. }
  166. /**
  167. * 更新出厂实绩
  168. * @param mapValue {运输订单号:orderNumber 门岗名称:gatepostName}
  169. * @return
  170. */
  171. public int updateLeaveResultByPDA(Map<String, Object> mapValue){
  172. TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
  173. tmstruckLeaveFactoryResult.setResultId(DataChange.dataToBigDecimal(mapValue.get("resultId")));
  174. //通过门岗名称获取门岗ID
  175. Integer gatepostId = tmstruckEnfactoryResultMapper.selectGatepostIdByGatepostName((String) mapValue.get("gatepostName"));
  176. if(gatepostId != null){
  177. tmstruckLeaveFactoryResult.setGatepostId(new BigDecimal(gatepostId));
  178. }
  179. //设置常规字段 添加 出厂时间 和 出厂方式
  180. tmstruckLeaveFactoryResult.setResultOutGateTime(new Date());
  181. tmstruckLeaveFactoryResult.setResultOutMode("手动抬杠");
  182. tmstruckLeaveFactoryResult.setInsertUsername("admin");
  183. tmstruckLeaveFactoryResult.setInsertTime(new Date());
  184. return tmstruckLeaveFactoryResultMapper.updateByPrimaryKeySelective(tmstruckLeaveFactoryResult);
  185. }
  186. /**
  187. * 通过总实绩Id修改出厂实绩出厂门岗
  188. * @param resultTotalId
  189. * @param gatepostId
  190. * @return
  191. */
  192. public int updateLeaveFactoryGatepostId(Integer resultTotalId, Integer gatepostId){
  193. TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
  194. //通过总实绩ID查询出产实绩
  195. BigDecimal resultId = tmstruckLeaveFactoryResultMapper.getResultIdByTotalId(resultTotalId);
  196. tmstruckLeaveFactoryResult.setResultId(resultId);
  197. tmstruckLeaveFactoryResult.setGatepostId(new BigDecimal(gatepostId));
  198. return tmstruckLeaveFactoryResultMapper.updateByPrimaryKeySelective(tmstruckLeaveFactoryResult);
  199. }
  200. }