TmstruckLeaveFactoryResultServiceImpl.java 8.1 KB

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