RmsSupplierServiceImpl.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.RmsCarrierMapper;
  3. import com.steerinfo.dil.mapper.RmsSupplierMapper;
  4. import com.steerinfo.dil.model.RmsCarrier;
  5. import com.steerinfo.dil.model.RmsSupplier;
  6. import com.steerinfo.dil.service.IRmsSupplierService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.math.BigDecimal;
  10. import java.util.Date;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import java.util.Map;
  14. /**
  15. * RmsSupplier服务实现:
  16. * @author generator
  17. * @version 1.0-SNAPSHORT 2021-10-22 06:18
  18. * 类描述
  19. * 修订历史:
  20. * 日期:2021-10-22
  21. * 作者:generator
  22. * 参考:
  23. * 描述:RmsSupplier服务实现
  24. * @see null
  25. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  26. */
  27. @Service(value = "rmsSupplierService")
  28. public class RmsSupplierServiceImpl implements IRmsSupplierService {
  29. @Autowired
  30. private RmsSupplierMapper rmsSupplierMapper;
  31. @Autowired
  32. RmsCarrierMapper rmsCarrierMapper;
  33. /**
  34. * 操作供应商
  35. * @param mapVal
  36. * @return
  37. */
  38. @Override
  39. public int operationSupplier(Map<String, Object> mapVal) {
  40. // 得到金蝶主键供应商id
  41. String EASSupplierId = (String) mapVal.get("EASSupplierId");
  42. // 得到供应商名称
  43. String supplierName = (String) mapVal.get("supplierName");
  44. // 得到供应商供应商简称
  45. String supplierAbbreviation = (String) mapVal.get("supplierAbbreviation");
  46. // 得到供应商代码
  47. String supplierDutyParagraph = (String) mapVal.get("supplierDutyParagraph");
  48. // 得到供应商地址
  49. String supplierAddress = (String) mapVal.get("supplierAddress");
  50. // 得到联系人
  51. String supplierContactsName = (String) mapVal.get("supplierAgent");
  52. // 得到联系电话
  53. String supplierContactNumber = (String) mapVal.get("supplierContactNumber");
  54. // 得到数据数据状态
  55. Integer dataStatus = (Integer) mapVal.get("dataStatus");
  56. // // 判断是供应商还是承运商
  57. // String dataType = (String) mapVal.get("dataType");
  58. // 判断是否EASId已存在
  59. Map<String,Object> map1 = new HashMap<>();
  60. map1.put("easSupplierId",EASSupplierId);
  61. Map<String,Object> map2 = new HashMap<>();
  62. BigDecimal deleted = new BigDecimal(0);
  63. map1.put("deleted",deleted);
  64. map2.put("easCarrierId",EASSupplierId);
  65. map2.put("deleted",deleted);
  66. List<RmsCarrier> rmsCarriers = rmsCarrierMapper.selectByParameters(map2);
  67. List<RmsSupplier> rmsSuppliers = rmsSupplierMapper.selectByParameters(map1);
  68. // 供应商
  69. RmsSupplier rmsSupplier = new RmsSupplier();
  70. rmsSupplier.setEasSupplierId(EASSupplierId);
  71. rmsSupplier.setSupplierName(supplierName);
  72. rmsSupplier.setSupplierAbbreviation(supplierAbbreviation);
  73. rmsSupplier.setSupplierDutyParagraph(supplierDutyParagraph);
  74. rmsSupplier.setSupplierAddress(supplierAddress);
  75. rmsSupplier.setSupplierContactsName(supplierContactsName);
  76. rmsSupplier.setSupplierContactNumber(supplierContactNumber);
  77. rmsSupplier.setInsertTime(new Date());
  78. rmsSupplier.setInsertUsername("admin");
  79. rmsSupplier.setUpdateTime(new Date());
  80. rmsSupplier.setUpdateUsername("admin");
  81. rmsSupplier.setInsertUpdateRemark("无");
  82. // 承运商
  83. RmsCarrier rmsCarrier = new RmsCarrier();
  84. rmsCarrier.setCarrierName(supplierName);
  85. rmsCarrier.setCarrierAbbreviation(supplierAbbreviation);
  86. rmsCarrier.setCarrierAddress(supplierAddress);
  87. rmsCarrier.setCarrierDutyParagraph(supplierDutyParagraph);
  88. rmsCarrier.setCarrierContactNumber(supplierContactNumber);
  89. rmsCarrier.setCarrierAgent(supplierContactsName);
  90. rmsCarrier.setEasCarrierId(EASSupplierId);
  91. rmsCarrier.setInsertTime(new Date());
  92. rmsCarrier.setInsertUsername("admin");
  93. rmsCarrier.setUpdateTime(new Date());
  94. rmsCarrier.setUpdateUsername("admin");
  95. rmsCarrier.setInsertUpdateRemark("无");
  96. int result = 0;
  97. // 新增
  98. if (rmsSuppliers.size() == 0) {
  99. BigDecimal supplierId = rmsSupplierMapper.getSupplierId();
  100. BigDecimal carrierId = rmsCarrierMapper.getCarrierId();
  101. rmsCarrier.setCarrierId(carrierId);
  102. rmsCarrier.setDeleted(new BigDecimal(0));
  103. rmsSupplier.setSupplierId(supplierId);
  104. rmsSupplier.setDeleted(new BigDecimal(0));
  105. result += rmsSupplierMapper.insertSelective(rmsSupplier);
  106. result += rmsCarrierMapper.insertSelective(rmsCarrier);
  107. }
  108. // 修改
  109. if (rmsSuppliers.size() != 0 && dataStatus == 1) {
  110. RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
  111. RmsCarrier rmsCarrier1 = rmsCarriers.get(0);
  112. rmsCarrier.setCarrierId(rmsCarrier1.getCarrierId());
  113. rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
  114. result += rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  115. result += rmsCarrierMapper.updateByPrimaryKeySelective(rmsCarrier);
  116. }
  117. // 逻辑删除
  118. if (rmsSuppliers.size() != 0 && dataStatus == 2) {
  119. RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
  120. RmsCarrier rmsCarrier1 = rmsCarriers.get(0);
  121. rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
  122. rmsCarrier.setCarrierId(rmsCarrier1.getCarrierId());
  123. rmsSupplier.setDeleted(new BigDecimal(1));
  124. rmsCarrier.setDeleted(new BigDecimal(1));
  125. result += rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  126. result += rmsCarrierMapper.updateByPrimaryKeySelective(rmsCarrier);
  127. }
  128. return result;
  129. }
  130. /**
  131. * 查询供应商列表
  132. * @param mapVal
  133. * @return
  134. */
  135. @Override
  136. public List<Map<String, Object>> getSupplierList(Map<String, Object> mapVal) {
  137. return rmsSupplierMapper.getSupplierList(mapVal);
  138. }
  139. }