TmsshipUnloadShipResultServiceImpl.java 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.feign.WmshboundFeign;
  3. import com.steerinfo.dil.mapper.OmsshipInstructionsCapacityMapper;
  4. import com.steerinfo.dil.mapper.TmsshipLoadShipResultMapper;
  5. import com.steerinfo.dil.mapper.TmsshipTotalResultMapper;
  6. import com.steerinfo.dil.model.OmsshipInstructionsCapacity;
  7. import com.steerinfo.dil.model.TmsshipLoadShipResult;
  8. import com.steerinfo.dil.model.TmsshipTotalResult;
  9. import com.steerinfo.dil.model.TmsshipUnloadShipResult;
  10. import com.steerinfo.dil.mapper.TmsshipUnloadShipResultMapper;
  11. import com.steerinfo.dil.service.ITmsshipUnloadShipResultService;
  12. import com.steerinfo.dil.util.DataChange;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import org.springframework.transaction.annotation.Transactional;
  16. import java.math.BigDecimal;
  17. import java.time.LocalDate;
  18. import java.util.Date;
  19. import java.util.HashMap;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * TmsshipUnloadShipResult服务实现:
  24. * @author generator
  25. * @version 1.0-SNAPSHORT 2021-08-19 08:57
  26. * 类描述
  27. * 修订历史:
  28. * 日期:2021-08-19
  29. * 作者:generator
  30. * 参考:
  31. * 描述:TmsshipUnloadShipResult服务实现
  32. * @see null
  33. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  34. */
  35. @Service(value = "tmsshipUnloadShipResultService")
  36. public class TmsshipUnloadShipResultServiceImpl implements ITmsshipUnloadShipResultService {
  37. @Autowired
  38. TmsshipUnloadShipResultMapper tmsshipUnloadShipResultMapper;
  39. @Autowired
  40. TmsshipTotalResultServiceImpl tmsshipTotalResultService;
  41. @Autowired
  42. TmsshipLoadShipResultMapper tmsshipLoadShipResultMapper;
  43. @Autowired
  44. WmshboundFeign wmshboundFeign;
  45. @Autowired
  46. TmsshipTotalResultMapper tmsshipTotalResultMapper;
  47. @Autowired
  48. OmsshipInstructionsCapacityMapper omsshipInstructionsCapacityMapper;
  49. /**
  50. * 得到最大id
  51. * @return
  52. */
  53. @Override
  54. public BigDecimal selectMaxId() {
  55. return tmsshipUnloadShipResultMapper.selectUnloadId();
  56. }
  57. /**
  58. * 新增卸船实绩
  59. * @param map
  60. * @return
  61. */
  62. @Override
  63. @Transactional
  64. public int insertUnloadShip(Map<String, Object> map) {
  65. Map<String,Object> mapVal = (Map<String, Object>) map.get("mapVal");
  66. Map<String,Object> unloadMap = (Map<String, Object>) map.get("unloadMap");
  67. BigDecimal downSwimPortId= DataChange.dataToBigDecimal(unloadMap.get("downSwimPortId"));
  68. BigDecimal portId= DataChange.dataToBigDecimal(unloadMap.get("portId"));
  69. TmsshipUnloadShipResult tmsshipUnloadShipResult = new TmsshipUnloadShipResult();
  70. BigDecimal resultId = selectMaxId();
  71. BigDecimal orderId = new BigDecimal((Integer) unloadMap.get("orderId"));
  72. BigDecimal totalResultId = tmsshipTotalResultService.getResultTotalId(orderId);
  73. //修改船舶状态
  74. TmsshipTotalResult tmsshipTotalResult=new TmsshipTotalResult();
  75. tmsshipTotalResult.setResultId(totalResultId);
  76. tmsshipTotalResult.setShipStatus(new BigDecimal(1));
  77. tmsshipTotalResultMapper.updateByPrimaryKeySelective(tmsshipTotalResult);
  78. if(mapVal.get("resultArrivalDate") != null && !"null".equals(mapVal.get("resultArrivalDate"))){
  79. Date resultArrivalDate = new Date((Long) mapVal.get("resultArrivalDate"));
  80. tmsshipUnloadShipResult.setResultArrivalDate(resultArrivalDate);
  81. }
  82. if(mapVal.get("resultStartTime") != null && !"null".equals(mapVal.get("resultStartTime"))){
  83. Date resultStartTime = new Date((Long) mapVal.get("resultStartTime"));
  84. tmsshipUnloadShipResult.setResultStartTime(resultStartTime);
  85. }
  86. if(mapVal.get("resultEndTime") != null && !"null".equals(mapVal.get("resultEndTime"))){
  87. Date resultEndTime = new Date((Long) mapVal.get("resultEndTime"));
  88. tmsshipUnloadShipResult.setResultEndTime(resultEndTime);
  89. }
  90. String resultStatus = (String) mapVal.get("resultStatus");
  91. // 设置属性值
  92. tmsshipUnloadShipResult.setResultId(resultId);
  93. tmsshipUnloadShipResult.setTotalResultId(totalResultId);
  94. tmsshipUnloadShipResult.setResultStatus(resultStatus);
  95. // 设置常规字段
  96. tmsshipUnloadShipResult.setInsertTime(new Date());
  97. tmsshipUnloadShipResult.setUpdateTime(new Date());
  98. tmsshipUnloadShipResult.setInsertUsername("admin");
  99. tmsshipUnloadShipResult.setUpdateUsername("admin");
  100. tmsshipUnloadShipResult.setInsertUpdateRemark("无");
  101. //锁定船只
  102. OmsshipInstructionsCapacity omsshipInstructionsCapacity=new OmsshipInstructionsCapacity();
  103. omsshipInstructionsCapacity.setInstructionsCapacityId(DataChange.dataToBigDecimal(unloadMap.get("instructionsCapacityId")));
  104. //锁定
  105. omsshipInstructionsCapacity.setDeleted(new BigDecimal(3));
  106. omsshipInstructionsCapacityMapper.updateByPrimaryKeySelective(omsshipInstructionsCapacity);
  107. // 新增出库实绩
  108. Map<String,Object> totalId = new HashMap<>();
  109. totalId.put("totalResultId",totalResultId);
  110. List<Map<String,Object>> tmsshipLoadShipResults = tmsshipLoadShipResultMapper.getBatchIdForOut(totalId);
  111. Map<String,Object> tmsshipLoadShipResult = tmsshipLoadShipResults.get(0);
  112. Map<String,Object> mapValue = new HashMap<>();
  113. mapValue.put("batchId",tmsshipLoadShipResult.get("batchId"));
  114. mapValue.put("portId",portId);
  115. mapValue.put("resultMaterialNumber",tmsshipLoadShipResult.get("resultMaterialNumber"));
  116. wmshboundFeign.addWarehousingResult(mapValue);
  117. return tmsshipUnloadShipResultMapper.insert(tmsshipUnloadShipResult);
  118. }
  119. /**
  120. * 通过主键删除卸船实绩
  121. * @param resultId
  122. * @return
  123. */
  124. @Override
  125. public int deleteUnloadShip(BigDecimal resultId) {
  126. TmsshipUnloadShipResult tmsshipUnloadShipResult = selectUnloadShip(resultId);
  127. tmsshipUnloadShipResult.setDeleted(new BigDecimal(1));
  128. return tmsshipUnloadShipResultMapper.updateByPrimaryKeySelective(tmsshipUnloadShipResult);
  129. }
  130. /**
  131. * 通过主键查询卸船
  132. * @param resultId
  133. * @return
  134. */
  135. @Override
  136. public TmsshipUnloadShipResult selectUnloadShip(BigDecimal resultId) {
  137. return tmsshipUnloadShipResultMapper.selectByPrimaryKey(resultId);
  138. }
  139. /**
  140. * 修改卸船信息
  141. * @param tmsshipUnloadShipResult
  142. * @return
  143. */
  144. @Override
  145. public int updateUnloadShip(TmsshipUnloadShipResult tmsshipUnloadShipResult) {
  146. if(tmsshipUnloadShipResult.getResultEndTime() != null && !"null".equals(tmsshipUnloadShipResult.getResultEndTime())){
  147. //Map<String,Object> totalId = new HashMap<>();
  148. //totalId.put("totalResultId",totalResultId);
  149. //List<TmsshipLoadShipResult> tmsshipLoadShipResults = tmsshipLoadShipResultMapper.selectByParameters(totalId);
  150. //TmsshipLoadShipResult tmsshipLoadShipResult = tmsshipLoadShipResults.get(0);
  151. //Map<String,Object> mapValue = new HashMap<>();
  152. //mapValue.put("batchId",tmsshipLoadShipResult.getBatchId());
  153. //mapValue.put("downSwimPortId",downSwimPortId);
  154. //mapValue.put("resultMaterialNumber",tmsshipLoadShipResult.getResultActualInstallations());
  155. //wmshboundFeign.addWarehousingResult(mapValue);
  156. }
  157. tmsshipUnloadShipResult.setUpdateTime(new Date());
  158. return tmsshipUnloadShipResultMapper.updateByPrimaryKeySelective(tmsshipUnloadShipResult);
  159. }
  160. /**
  161. * 查询所有卸船实绩信息
  162. * @param mapVal
  163. * @return
  164. */
  165. @Override
  166. public List<Map<String, Object>> selectUnloadShipList(Map<String, Object> mapVal) {
  167. return tmsshipUnloadShipResultMapper.selectUnloadShipList(mapVal);
  168. }
  169. /**
  170. * 得到卸船作业表单
  171. * @param resultId
  172. * @return
  173. */
  174. @Override
  175. public List<Map<String, Object>> getUnloadShip(BigDecimal resultId) {
  176. return tmsshipUnloadShipResultMapper.selectUnloadShip(resultId);
  177. }
  178. }