AmsshipDeliveryNoticeServiceImpl.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.feign.WmshboundFeign;
  3. import com.steerinfo.dil.mapper.AmsshipCargoTransferResultMapper;
  4. import com.steerinfo.dil.mapper.DilBatchMapper;
  5. import com.steerinfo.dil.model.AmsshipCargoTransferResult;
  6. import com.steerinfo.dil.model.DilBatch;
  7. import com.steerinfo.dil.model.OmsshipShipmentInstructions;
  8. import com.steerinfo.dil.util.DataChange;
  9. import com.steerinfo.framework.mapper.IBaseMapper;
  10. import com.steerinfo.framework.service.impl.BaseServiceImpl;
  11. import com.steerinfo.dil.model.AmsshipDeliveryNotice;
  12. import com.steerinfo.dil.mapper.AmsshipDeliveryNoticeMapper;
  13. import com.steerinfo.dil.service.IAmsshipDeliveryNoticeService;
  14. import com.steerinfo.framework.utils.misc.IdGenerator;
  15. import com.steerinfo.framework.utils.upload.UploadUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Value;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.transaction.annotation.Transactional;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import java.io.File;
  22. import java.math.BigDecimal;
  23. import java.text.SimpleDateFormat;
  24. import java.util.*;
  25. /**
  26. * AmsshipDeliveryNotice服务实现:
  27. * @author generator
  28. * @version 1.0-SNAPSHORT 2021-08-18 03:54
  29. * 类描述
  30. * 修订历史:
  31. * 日期:2021-08-18
  32. * 作者:generator
  33. * 参考:
  34. * 描述:AmsshipDeliveryNotice服务实现
  35. * @see null
  36. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  37. */
  38. @Service(value = "amsshipDeliveryNoticeService")
  39. public class AmsshipDeliveryNoticeServiceImpl implements IAmsshipDeliveryNoticeService {
  40. @Autowired
  41. private AmsshipDeliveryNoticeMapper amsshipDeliveryNoticeMapper;
  42. @Autowired
  43. private AmsshipCargoTransferResultMapper cargoTransferResultMapper;
  44. @Autowired
  45. private DilBatchServiceImpl dilBatchService;
  46. @Autowired
  47. private DilBatchMapper dilBatchMapper;
  48. @Autowired
  49. private WmshboundFeign wmshboundFeign;
  50. //查询所有数据
  51. @Override
  52. public List<Map<String, Object>> selectShipDeliveryNotice(Map<String, Object> mapVal) {
  53. return amsshipDeliveryNoticeMapper.selectShipDeliveryNotice(mapVal);
  54. }
  55. //新增发货通知
  56. @Override
  57. @Transactional(rollbackFor = {Exception.class})
  58. public int insert(Map<String,Object> map) throws Exception{
  59. int i=0;
  60. String inFactoryShipName=null;
  61. AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
  62. String userId =(String) map.get("userId");
  63. String userName=null;
  64. if (userId!=null){
  65. userName = cargoTransferResultMapper.getUserNameByUserId(userId);
  66. }
  67. BigDecimal noticeId = amsshipDeliveryNoticeMapper.selectNoticeId();
  68. amsshipDeliveryNotice.setNoticeId(noticeId);
  69. amsshipDeliveryNotice.setNoticeCommerceMethod((String) map.get("noticeCommerceMethod"));
  70. amsshipDeliveryNotice.setNoticeHandoverMethod((String) map.get("noticeHandoverMethod"));
  71. if (map.get("portId")!=null) {
  72. amsshipDeliveryNotice.setPortId(DataChange.dataToBigDecimal(map.get("portId")));
  73. }
  74. if (map.get("noticePortConstructionFee")!=null) {
  75. amsshipDeliveryNotice.setNoticePortConstructionFee(DataChange.dataToBigDecimal(map.get("noticePortConstructionFee")));
  76. }
  77. long noticeDeliveryTime =(long) map.get("noticeDeliveryTime");
  78. amsshipDeliveryNotice.setNoticeDeliveryTime(new Date(noticeDeliveryTime));
  79. amsshipDeliveryNotice.setNoticePileFreeDays(DataChange.dataToBigDecimal(map.get("noticePileFreeDays")));
  80. amsshipDeliveryNotice.setNoticeDistributionStatus(new BigDecimal(0));
  81. if (map.get("purchaseContractUnitPrice")!=null) {
  82. amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractUnitPrice")));
  83. }
  84. if (map.get("isNeedBonded")!=null){
  85. amsshipDeliveryNotice.setIsNeedBonded((String) map.get("isNeedBonded"));
  86. }else {
  87. throw new Exception("请选择是否需要宁波报税");
  88. }
  89. if (map.get("purchaseContractMoisture")!=null) {
  90. amsshipDeliveryNotice.setPurchaseContractMoisture((String) map.get("purchaseContractMoisture"));
  91. }
  92. if (map.get("purchaseContractQualityindex")!=null) {
  93. amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractQualityindex")));
  94. }
  95. if (map.get("tfeContent")!=null) {
  96. amsshipDeliveryNotice.setTfeContent((String) map.get("tfeContent"));
  97. }
  98. if (map.get("silicaContent")!=null){
  99. amsshipDeliveryNotice.setSilicaContent((String)map.get("silicaContent"));
  100. }
  101. if (map.get("aluminaContent")!=null){
  102. amsshipDeliveryNotice.setAluminaContent((String)map.get("aluminaContent"));
  103. }
  104. if (map.get("phosphorusContent")!=null){
  105. amsshipDeliveryNotice.setPhosphorusContent((String)map.get("phosphorusContent"));
  106. }
  107. if (map.get("manganeseContent")!=null){
  108. amsshipDeliveryNotice.setManganeseContent((String)map.get("manganeseContent"));
  109. }
  110. //设置S含量
  111. if(map.get("sulfurcontent")!=null){
  112. amsshipDeliveryNotice.setSulfurContent((String) map.get("sulfurcontent"));
  113. }
  114. amsshipDeliveryNotice.setInsertTime(new Date());
  115. amsshipDeliveryNotice.setInsertUsername(userId);
  116. amsshipDeliveryNotice.setDeleted(new BigDecimal(0));
  117. //联系人
  118. amsshipDeliveryNotice.setResultContactPerson((String) map.get("resultContactPerson"));
  119. amsshipDeliveryNotice.setResultTelephoneFax((String) map.get("resultTelephoneFax"));
  120. //货代信息
  121. amsshipDeliveryNotice.setResultFreightForwardingInfo((String) map.get("resultFreightForwardingInfo"));
  122. //备注
  123. amsshipDeliveryNotice.setResultMemo((String) map.get("resultMemo"));
  124. //放货数量
  125. amsshipDeliveryNotice.setResultNumberOfLoans(DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
  126. //货权转移送达单位
  127. amsshipDeliveryNotice.setCargoId(DataChange.dataToBigDecimal(map.get("cargoId")));
  128. //收货人单位
  129. amsshipDeliveryNotice.setGroupId(DataChange.dataToBigDecimal(map.get("groupId")));
  130. amsshipDeliveryNotice.setMaterialTypeId(DataChange.dataToBigDecimal(map.get("materialTypeId")));
  131. amsshipDeliveryNotice.setIsNeedPortFee((String) map.get("isNeedPortFee"));
  132. amsshipDeliveryNotice.setIsNeedPortCharge((String) map.get("isNeedPortDisCharge"));
  133. amsshipDeliveryNotice.setCargoImageUrl((String) map.get("cargoPictureUrl"));
  134. BigDecimal portId= DataChange.dataToBigDecimal(map.get("portId"));
  135. //生成批次
  136. //根据portId查找portName
  137. String portName = dilBatchMapper.getPortName(DataChange.dataToBigDecimal(map.get("portId")));
  138. if (portName==null||portName.equals("")){
  139. throw new Exception("港口不存在");
  140. }
  141. SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  142. Date time =new Date(noticeDeliveryTime);
  143. inFactoryShipName = portName + sdf.format(time);
  144. map.put("inFactoryShipName",inFactoryShipName);
  145. //新增批次
  146. Map<String, Object> map1 = dilBatchService.insertBatchId(map);
  147. BigDecimal batchIdInfacotryId =DataChange.dataToBigDecimal(map1.get("batchIdInfacotryId"));
  148. amsshipDeliveryNotice.setBatchId(batchIdInfacotryId);
  149. //调用港口入库
  150. // Map<String,Object> mapValue = new HashMap<>();
  151. // mapValue.put("batchId",map1.get("batchIds"));
  152. // mapValue.put("portId",portId);
  153. // mapValue.put("resultMaterialNumber",DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
  154. // if(mapValue.get("batchId") ==null || DataChange.dataToBigDecimal(mapValue.get("batchId")).compareTo(new BigDecimal(0))==0){
  155. // //如果是录入批次,则传新增批次的批次id
  156. // mapValue.put("batchId",map1.get("batchId"));
  157. // }
  158. // wmshboundFeign.addWarehousingResult(mapValue);
  159. i += amsshipDeliveryNoticeMapper.insertSelective(amsshipDeliveryNotice);
  160. return i ;
  161. }
  162. @Override
  163. public int sendDeliveryNotice(Map<String, Object> map) {
  164. BigDecimal noticeId =DataChange.dataToBigDecimal(map.get("noticeId"));
  165. AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
  166. amsshipDeliveryNotice.setNoticeId(noticeId);
  167. amsshipDeliveryNotice.setNoticeDistributionStatus(new BigDecimal(1));
  168. return amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
  169. }
  170. @Override
  171. public int deleteByPrimaryKey(BigDecimal noticeId) {
  172. return amsshipDeliveryNoticeMapper.deleteByPrimaryKey(noticeId);
  173. }
  174. @Override
  175. public int updateByPrimaryKey(BigDecimal noticeId) {
  176. return amsshipDeliveryNoticeMapper.updateByPrimaryKey(noticeId);
  177. }
  178. @Override
  179. public AmsshipDeliveryNotice selectByPrimaryKey(BigDecimal noticeId) {
  180. return amsshipDeliveryNoticeMapper.selectByPrimaryKey(noticeId);
  181. }
  182. @Override
  183. public List<Map<String, Object>> getResultNumber() {
  184. return amsshipDeliveryNoticeMapper.getResultNumber();
  185. }
  186. //货权转移下拉框
  187. @Override
  188. public List<Map<String, Object>> getcarrier() {
  189. return amsshipDeliveryNoticeMapper.getcarrier();
  190. }
  191. ////采购订单号下拉框
  192. // @Override
  193. // public List<Map<String, Object>> getOrderNo() {
  194. // return amsshipDeliveryNoticeMapper.getOrderNo();
  195. // }
  196. @Override
  197. public List<Map<String, Object>> getShipper() {
  198. return amsshipDeliveryNoticeMapper.getShipper();
  199. }
  200. @Override
  201. public int deleteDeliveryNotice(Map<String, Object> map) {
  202. AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
  203. amsshipDeliveryNotice.setNoticeId(DataChange.dataToBigDecimal(map.get("noticeId")));
  204. amsshipDeliveryNotice.setDeleted(new BigDecimal(1));
  205. return amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
  206. }
  207. @Override
  208. public List<Map<String, Object>> selectByNoticeId(Integer noticeId) {
  209. return amsshipDeliveryNoticeMapper.selectByNoticeId(noticeId);
  210. }
  211. //更新发货通知
  212. @Override
  213. @Transactional(rollbackFor = {Exception.class})
  214. public int updateAmsDeliveryNotice(Map<String, Object> map) throws Exception {
  215. int i=0;
  216. BigDecimal noticeId = DataChange.dataToBigDecimal(map.get("noticeId"));
  217. AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
  218. if (map.get("noticeId")!=null) {
  219. amsshipDeliveryNotice.setNoticeId(noticeId);
  220. }
  221. //贸易方式
  222. if (map.get("noticeCommerceMethod")!=null) {
  223. amsshipDeliveryNotice.setNoticeHandoverMethod((String) map.get("noticeCommerceMethod"));
  224. }
  225. //交接方式
  226. if (map.get("noticeHandoverMethod")!=null) {
  227. amsshipDeliveryNotice.setNoticeCommerceMethod((String) map.get("noticeHandoverMethod"));
  228. }
  229. //港口id
  230. if (map.get("portId")!=null) {
  231. amsshipDeliveryNotice.setPortId(DataChange.dataToBigDecimal(map.get("portId")));
  232. }
  233. //港建费金额
  234. if (map.get("noticePortConstructionFee")!=null) {
  235. amsshipDeliveryNotice.setNoticePortConstructionFee(DataChange.dataToBigDecimal(map.get("noticePortConstructionFee")));
  236. }
  237. //放货时间
  238. if (map.get("noticeDeliveryTime")!=null) {
  239. long noticeDeliveryTime = (long) map.get("noticeDeliveryTime");
  240. amsshipDeliveryNotice.setNoticeDeliveryTime(new Date(noticeDeliveryTime));
  241. }
  242. //免堆天数
  243. if (map.get("noticePileFreeDays")!=null){
  244. amsshipDeliveryNotice.setNoticePileFreeDays(DataChange.dataToBigDecimal(map.get("noticePileFreeDays")));
  245. }
  246. if (map.get("isNeedBonded")!=null){
  247. amsshipDeliveryNotice.setIsNeedBonded((String) map.get("isNeedBonded"));
  248. }else {
  249. throw new Exception("请选择是否需要宁波报税");
  250. }
  251. //单价
  252. if (map.get("purchaseContractUnitPrice")!=null){
  253. amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractUnitPrice")));
  254. }
  255. //合同水分
  256. if (map.get("purchaseContractMoisture")!=null){
  257. amsshipDeliveryNotice.setPurchaseContractMoisture((String) map.get("purchaseContractMoisture"));
  258. }
  259. //微元素含量
  260. if (map.get("tfeContent")!=null){
  261. amsshipDeliveryNotice.setTfeContent((String) map.get("tfeContent"));
  262. }
  263. if (map.get("silicaContent")!=null){
  264. amsshipDeliveryNotice.setSilicaContent((String) map.get("silicaContent"));
  265. }
  266. if (map.get("aluminaContent")!=null){
  267. amsshipDeliveryNotice.setAluminaContent((String) map.get("aluminaContent"));
  268. }
  269. if (map.get("phosphorusContent")!=null){
  270. amsshipDeliveryNotice.setPhosphorusContent((String) map.get("phosphorusContent"));
  271. }
  272. if (map.get("manganeseContent")!=null){
  273. amsshipDeliveryNotice.setManganeseContent((String) map.get("manganeseContent"));
  274. }
  275. //联系人
  276. if (map.get("resultContactPerson")!=null){
  277. amsshipDeliveryNotice.setResultContactPerson((String) map.get("resultContactPerson"));
  278. }
  279. if (map.get("resultTelephoneFax")!=null){
  280. amsshipDeliveryNotice.setResultTelephoneFax((String) map.get("resultTelephoneFax"));
  281. }
  282. if (map.get("resultFreightForwardingInfo")!=null){
  283. amsshipDeliveryNotice.setResultFreightForwardingInfo((String) map.get("resultFreightForwardingInfo"));
  284. }
  285. if (map.get("resultMemo")!=null){
  286. amsshipDeliveryNotice.setResultMemo((String) map.get("resultMemo"));
  287. }
  288. if (map.get("resultNumberOfLoans")!=null){
  289. amsshipDeliveryNotice.setResultNumberOfLoans(DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
  290. }
  291. if (map.get("cargoId")!=null){
  292. amsshipDeliveryNotice.setCargoId(DataChange.dataToBigDecimal(map.get("cargoId")));
  293. }
  294. if (map.get("groupId")!=null){
  295. amsshipDeliveryNotice.setGroupId(DataChange.dataToBigDecimal(map.get("groupId")));
  296. }
  297. if (map.get("inFactoryShipName")!=null||map.get("materialId")!=null||map.get("foreignShipName")!=null){
  298. //判断如果外轮船名或物资id或进厂船名不为空
  299. //根据物资和外轮船名判断批次是否存在
  300. BigDecimal batchFacotryId = dilBatchMapper.selectBatchIdByName(map);
  301. //如果存在则取批次id
  302. if (batchFacotryId != null && batchFacotryId.intValue() != 0){
  303. amsshipDeliveryNotice.setBatchId(batchFacotryId);
  304. }else {
  305. Map<String, Object> map1 = dilBatchService.insertBatchId(map);
  306. if (map1 != null) {
  307. System.out.println("新增批次成功");
  308. BigDecimal batchIdInfacotryId = DataChange.dataToBigDecimal(map1.get("batchIdInfacotryId"));
  309. amsshipDeliveryNotice.setBatchId(batchIdInfacotryId);
  310. } else {
  311. System.out.println("新增批次失败");
  312. }
  313. }
  314. }
  315. if (map.get("materialTypeId")!=null){
  316. amsshipDeliveryNotice.setMaterialTypeId(DataChange.dataToBigDecimal(map.get("materialTypeId")));
  317. }
  318. if (map.get("isNeedPortDisCharge")!=null){
  319. amsshipDeliveryNotice.setIsNeedPortCharge((String) map.get("isNeedPortDisCharge"));
  320. }
  321. if (map.get("isNeedPortFee")!=null){
  322. amsshipDeliveryNotice.setIsNeedPortFee((String) map.get("isNeedPortFee"));
  323. }
  324. if (map.get("cargoPictureUrl")!=null){
  325. amsshipDeliveryNotice.setCargoImageUrl((String) map.get("cargoPictureUrl"));
  326. }
  327. if (map.get("userId")!=null){
  328. amsshipDeliveryNotice.setUpdateUsername((String) map.get("userId"));
  329. }
  330. amsshipDeliveryNotice.setUpdateTime(new Date());
  331. i += amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
  332. return i;
  333. }
  334. @Override
  335. public String getLoadDeliveryNotice(Integer noticeId) {
  336. return amsshipDeliveryNoticeMapper.getLoadDeliveryNotice(noticeId);
  337. }
  338. }