TmstruckWeightResultServiceImpl.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.feign.OmsFeign;
  3. import com.steerinfo.dil.feign.QmsFeign;
  4. import com.steerinfo.dil.mapper.RulesMapper;
  5. import com.steerinfo.dil.mapper.TmstruckReceiptResultMapper;
  6. import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
  7. import com.steerinfo.dil.mapper.UtilsMapper;
  8. import com.steerinfo.dil.model.TmstruckReceiptResult;
  9. import com.steerinfo.dil.model.TmstruckWeightResult;
  10. import com.steerinfo.dil.service.ITmstruckWeightResultService;
  11. import com.steerinfo.dil.util.DataChange;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. import java.math.BigDecimal;
  16. import java.text.DecimalFormat;
  17. import java.text.ParseException;
  18. import java.text.SimpleDateFormat;
  19. import java.util.Date;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * TmstruckWeightResult服务实现:
  25. * @author generator
  26. * @version 1.0-SNAPSHORT 2021-09-09 02:21
  27. * 类描述
  28. * 修订历史:
  29. * 日期:2021-09-09
  30. * 作者:generator
  31. * 参考:
  32. * 描述:TmstruckWeightResult服务实现
  33. * @see null
  34. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  35. */
  36. @Service(value = "tmstruckWeightResultService")
  37. public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultService {
  38. @Autowired
  39. private TmstruckWeightResultMapper tmstruckWeightResultMapper;
  40. @Autowired
  41. private TmstruckReceiptResultMapper tmstruckReceiptResultMapper;
  42. @Autowired
  43. private UtilsServiceImpl utilsService;
  44. @Autowired
  45. private UtilsMapper utilsMapper;
  46. @Autowired
  47. private QmsFeign qmsFeign;
  48. @Autowired
  49. private RulesServiceImpl rulesService;
  50. @Autowired
  51. private RulesMapper rulesMapper;
  52. @Autowired
  53. OmsFeign omsFeign;
  54. @Autowired
  55. private TmstruckLoadResultServiceImpl tmstruckLoadResultService;
  56. @Autowired
  57. private TmstruckLeaveFactoryResultServiceImpl tmstruckLeaveFactoryResultService;
  58. /**
  59. * 查询所有计毛实绩
  60. * @param map
  61. * @return
  62. */
  63. @Override
  64. public List<Map<String, Object>> getAllJiMaoResult(Map<String, Object> map) {
  65. Integer orderType = (Integer) map.get("orderTypee");
  66. switch (orderType){
  67. case 1:
  68. case 2:
  69. case 3:
  70. return tmstruckWeightResultMapper.getXSAllJiMaoResult(map); // apiID:212
  71. case 4:
  72. return tmstruckWeightResultMapper.getSteelNzJiMaoResult(map); //apiId:264
  73. case 5:
  74. case 6:
  75. case 7:
  76. case 8:
  77. return tmstruckWeightResultMapper.getCGAllJiMaoResult(map); //apiId:102
  78. case 9:
  79. return tmstruckWeightResultMapper.getImportedDomesticNzJiMaoResult(map); // apiID:354
  80. case 10:
  81. return tmstruckWeightResultMapper.getImportedDomesticNzJiMao2Result(map); // apiID:354
  82. case 11:
  83. return tmstruckWeightResultMapper.getInFactoryJiLiangResult(map); //apiId: 358
  84. case 12:
  85. return tmstruckWeightResultMapper.getSporadicSuppliesJiMiaoResult(map);//apiId:405
  86. case 13:
  87. return tmstruckWeightResultMapper.getFactorySkinSporadicJiMiao(map);//apiId:422
  88. }
  89. return null;
  90. }
  91. /**
  92. * 查询所有计皮实绩
  93. * @param map
  94. * @return
  95. */
  96. @Override
  97. public List<Map<String, Object>> getAllJiPiResult(Map<String, Object> map) {
  98. Integer orderType = (Integer) map.get("orderTypee");
  99. switch (orderType){
  100. case 1:
  101. case 2:
  102. case 3:
  103. return tmstruckWeightResultMapper.getXSAllJiPiResult(map); //apiId:211
  104. case 4:
  105. return tmstruckWeightResultMapper.getSteelNzJiPiResult(map); //apiId:262
  106. case 5:
  107. case 6:
  108. case 7:
  109. case 8:
  110. return tmstruckWeightResultMapper.getCGAllJiPiResult(map); // apiId: 104
  111. case 9:
  112. return tmstruckWeightResultMapper.getImportedDomesticNzJiPiResult(map);// apiId: 104
  113. case 10:
  114. return tmstruckWeightResultMapper.getImportedDomesticNzJiPi2Result(map);// apiId: 104
  115. case 11:
  116. break;
  117. case 12:
  118. return tmstruckWeightResultMapper.getSporadicSuppliesJiPiResult(map);//apiId:392
  119. case 13:
  120. return tmstruckWeightResultMapper.getFactorySkinSporadicJIPi(map); //apiId=401
  121. }
  122. return null;
  123. }
  124. /**
  125. * 派单时新增计重实绩
  126. * 总实绩ID、计皮点、计毛点
  127. * @return
  128. */
  129. @Override
  130. public int addWeightResult(Map<String, Object> map) {
  131. TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
  132. //生成最大主键ID
  133. tmstruckWeightResult.setWeightTaskResultId(tmstruckWeightResultMapper.selectMaxId());
  134. BigDecimal resultTotalId = DataChange.dataToBigDecimal(map.get("resultTotalId"));
  135. tmstruckWeightResult.setResultTotalId(resultTotalId);
  136. //通过总实绩ID查询订单类型
  137. if(map.get("isdeduct") == null){
  138. //添加是否需要扣水扣杂
  139. Integer orderType = tmstruckWeightResultMapper.getOrderTypeByTotalId(resultTotalId);
  140. if("67".contains(orderType.toString()) || orderType == 10){
  141. tmstruckWeightResult.setIsdeduct(new BigDecimal(1));
  142. }
  143. }else {
  144. tmstruckWeightResult.setIsdeduct(DataChange.dataToBigDecimal(map.get("isdeduct")));
  145. }
  146. // 添加物资Id (销售、内转到异地库)
  147. if(map.get("materialId") != null)
  148. tmstruckWeightResult.setMaterialId(DataChange.dataToBigDecimal(map.get("materialId")));
  149. // 添加路段顺序号
  150. if(map.get("grossSegmentSqe") != null) //毛重路段顺序号
  151. tmstruckWeightResult.setGrossSegmentSqe(DataChange.dataToBigDecimal(map.get("grossSegmentSqe")));
  152. if(map.get("tareSegmentSqe") != null) //皮重路段顺序号
  153. tmstruckWeightResult.setTareSegmentSqe(DataChange.dataToBigDecimal(map.get("tareSegmentSqe")));
  154. return tmstruckWeightResultMapper.insertSelective(tmstruckWeightResult);
  155. }
  156. /**
  157. * 更新计量实绩 计皮点 计毛点 皮重
  158. * @param map
  159. */
  160. public int updateWeightResult(Map<String, Object> map){
  161. TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
  162. //通过订单Id 查询路段顺序号为最小的 且没有净重的计量实绩ID
  163. BigDecimal id = tmstruckWeightResultMapper.getWeightIdBySQEAndOrderId(map);
  164. tmstruckWeightResult.setId(id);
  165. if(map.get("tarePlaceId") != null){ //如果皮重汽车衡不为空 更新皮重汽车衡
  166. tmstruckWeightResult.setResultTarePlaceId(DataChange.dataToBigDecimal(map.get("tarePlaceId")));
  167. }
  168. if(map.get("grossPlaceId") != null){//如果毛重汽车衡不为空 更新毛重汽车衡
  169. tmstruckWeightResult.setResultGrossPlaceId(DataChange.dataToBigDecimal(map.get("grossPlaceId")));
  170. }
  171. if(map.get("resultTareWeight")!= null){ //如果皮重不为空 更新皮重
  172. tmstruckWeightResult.setResultTareWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight")));
  173. }
  174. return tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult);
  175. }
  176. /**
  177. * 自动签收
  178. * @return
  179. */
  180. public int autoReceipt(BigDecimal resultTotalId){
  181. TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
  182. tmstruckReceiptResult.setResultTotalId(resultTotalId);
  183. tmstruckReceiptResult.setStatus(new BigDecimal(1));
  184. tmstruckReceiptResult.setInsertUsername("admin");
  185. tmstruckReceiptResult.setInsertTime(new Date());
  186. return tmstruckReceiptResultMapper.updateByTotalResultId(tmstruckReceiptResult);
  187. }
  188. /**
  189. * 多拼计算计毛汽车衡
  190. * @param map
  191. */
  192. public int calculateTruckCalculate(Map<String, Object> map, Integer resultTotalId){
  193. //通过总实绩ID查询订单Id
  194. Integer orderId = utilsService.getOrderIdByTotalId(resultTotalId);
  195. //查询未装车的装车实绩
  196. List<Map<String, Object>> list = rulesService.judgeLastMaterial(new BigDecimal(orderId));
  197. Map<String, Object> mesMap = new HashMap<>(); //用于查询更新存放数据map
  198. mesMap.put("orderId", orderId);
  199. int i = 0;
  200. if(list.size() == 0){
  201. //如果是最后一拼则走出厂称 计算出厂称
  202. mesMap.put("materialId", map.get("materialId"));
  203. mesMap.put("nature", 1);
  204. Integer calculate = rulesService.calculateWeighbridge(mesMap);
  205. //更新汽车衡
  206. mesMap.put("grossPlaceId", calculate);
  207. i += updateWeightResult(mesMap);
  208. }else {
  209. //如果后面还有物资未装车 则走拼装秤 10号秤 (固定数据)
  210. mesMap.put("materialId", map.get("materialId"));
  211. mesMap.put("grossPlaceId", 10);
  212. i += updateWeightResult(mesMap);
  213. }
  214. return i;
  215. }
  216. /**
  217. * 单拼销售计算汽车衡
  218. * @return
  219. */
  220. public int calculateTruckCalculateByOne(Map<String, Object> map, Integer type){
  221. String orderNumber = (String) map.get("orderNumber");
  222. //通过运输订单号查找物资ID、订单ID
  223. Map<String, Object> oIdAndMidMap = tmstruckWeightResultMapper.getOrderIdAndMaterialIdByOrderNum(orderNumber);
  224. //通过物资ID计算汽车衡
  225. if(type == 1){
  226. //1:进厂
  227. oIdAndMidMap.put("nature", type); //1: 进厂秤
  228. int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
  229. oIdAndMidMap.put("tarePlaceId", calculateId);
  230. }else if(type == 2){
  231. //2:出厂
  232. oIdAndMidMap.put("nature", type); //2: 出厂称
  233. int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
  234. oIdAndMidMap.put("grossPlaceId", calculateId);
  235. }
  236. return updateWeightResult(oIdAndMidMap);
  237. }
  238. }