RmsSupplierServiceImpl.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.RmsSupplierMapper;
  3. import com.steerinfo.dil.model.RmsSupplier;
  4. import com.steerinfo.dil.service.IRmsSupplierService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import java.math.BigDecimal;
  8. import java.util.Date;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * RmsSupplier服务实现:
  14. * @author generator
  15. * @version 1.0-SNAPSHORT 2021-10-22 06:18
  16. * 类描述
  17. * 修订历史:
  18. * 日期:2021-10-22
  19. * 作者:HuJieHuan
  20. * 参考:
  21. * 描述:RmsSupplier服务实现
  22. * @see null
  23. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  24. */
  25. @Service(value = "rmsSupplierService")
  26. public class RmsSupplierServiceImpl implements IRmsSupplierService {
  27. @Autowired
  28. private RmsSupplierMapper rmsSupplierMapper;
  29. /**
  30. * 操作供应商
  31. * @param mapVal
  32. * @return
  33. */
  34. @Override
  35. public int operationSupplier(Map<String, Object> mapVal) {
  36. // 得到金蝶主键供应商id
  37. Integer EASSupplierIdValue = (Integer) mapVal.get("EASSupplierId");
  38. BigDecimal EASSupplierId = new BigDecimal(EASSupplierIdValue);
  39. // 得到供应商名称
  40. String supplierName = (String) mapVal.get("supplierName");
  41. // 得到供应商供应商简称
  42. String supplierAbbreviation = (String) mapVal.get("supplierAbbreviation");
  43. // 得到供应商代码
  44. String supplierDutyParagraph = (String) mapVal.get("supplierDutyParagraph");
  45. // 得到供应商地址
  46. String supplierAddress = (String) mapVal.get("supplierAddress");
  47. // 得到注册时间
  48. Date supplierRegisterDate = (Date) mapVal.get("supplierRegisterDate");
  49. // 得到委托代理人
  50. String supplierContactsName = (String) mapVal.get("supplierAgent");
  51. // 得到联系电话
  52. String supplierContactNumber = (String) mapVal.get("supplierContactNumber");
  53. // 得到数据数据状态
  54. Integer dataStatus = (Integer) mapVal.get("dataStatus");
  55. // 判断是否EASId已存在
  56. Map<String,Object> map1 = new HashMap<>();
  57. map1.put("easSupplierId",EASSupplierId);
  58. BigDecimal deleted = new BigDecimal(0);
  59. map1.put("deleted",deleted);
  60. List<RmsSupplier> rmsSuppliers = rmsSupplierMapper.selectByParameters(map1);
  61. RmsSupplier rmsSupplier = new RmsSupplier();
  62. rmsSupplier.setEasSupplierId(EASSupplierId);
  63. rmsSupplier.setSupplierName(supplierName);
  64. rmsSupplier.setSupplierAbbreviation(supplierAbbreviation);
  65. rmsSupplier.setSupplierDutyParagraph(supplierDutyParagraph);
  66. rmsSupplier.setSupplierAddress(supplierAddress);
  67. rmsSupplier.setSupplierRegisterDate(supplierRegisterDate);
  68. rmsSupplier.setSupplierContactsName(supplierContactsName);
  69. rmsSupplier.setSupplierContactNumber(supplierContactNumber);
  70. int result = 0;
  71. // 新增
  72. if (rmsSuppliers.size() == 0) {
  73. BigDecimal supplierId = rmsSupplierMapper.getSupplierId();
  74. rmsSupplier.setSupplierId(supplierId);
  75. rmsSupplier.setDeleted(new BigDecimal(0));
  76. result = rmsSupplierMapper.insertSelective(rmsSupplier);
  77. }
  78. // 修改
  79. if (rmsSuppliers.size() != 0 && dataStatus == 2) {
  80. RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
  81. rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
  82. result = rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  83. }
  84. // 逻辑删除
  85. if (rmsSuppliers.size() != 0 && dataStatus == 3) {
  86. RmsSupplier rmsSupplier1 = rmsSuppliers.get(0);
  87. rmsSupplier.setSupplierId(rmsSupplier1.getSupplierId());
  88. rmsSupplier.setDeleted(new BigDecimal(1));
  89. result = rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  90. }
  91. return result;
  92. }
  93. /**
  94. * 查询供应商列表
  95. * @param mapVal
  96. * @return
  97. */
  98. @Override
  99. public List<Map<String, Object>> getSupplierList(Map<String, Object> mapVal) {
  100. return rmsSupplierMapper.getSupplierList(mapVal);
  101. }
  102. /**
  103. * 添加供应商列表
  104. * @param rmsSupplier
  105. * @return
  106. */
  107. @Override
  108. public int insertSupplier(RmsSupplier rmsSupplier) {
  109. // 新增用户名和密码将其传到SSO接口
  110. // String username=mapValue.get("username");
  111. // String password="123456";
  112. int i=0;
  113. // 判断用户输入的船名在数据库中是否存在
  114. String supplierName=rmsSupplier.getSupplierName();
  115. int size = rmsSupplierMapper.selectByParametersSupplierName(supplierName);
  116. if (size == 0 ) {
  117. rmsSupplier.setInsertTime(new Date());
  118. rmsSupplier.setInsertUsername("admin");
  119. rmsSupplier.setDeleted(new BigDecimal(0));
  120. rmsSupplier.setSupplierId(rmsSupplierMapper.getSupplierId());
  121. i+=rmsSupplierMapper.insertSelective(rmsSupplier);
  122. }
  123. else{
  124. i=-1;
  125. }
  126. return i;
  127. }
  128. /**
  129. * 修改供应商信息
  130. * @param rmsSupplier
  131. * @return
  132. */
  133. @Override
  134. public int updateSupplier(RmsSupplier rmsSupplier) {
  135. rmsSupplier.setUpdateUsername("admin");
  136. // 增加修改时间
  137. rmsSupplier.setUpdateTime(new Date());
  138. return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  139. }
  140. /**
  141. * 根据id值删除供应商信息
  142. * @param id
  143. * @return
  144. */
  145. @Override
  146. public int deleteSupplier(BigDecimal id) {
  147. // 使用逻辑删除
  148. RmsSupplier rmsSupplier=rmsSupplierMapper.selectByPrimaryKey(id);
  149. // 对于我们要删除的供应商,将他的deleted字段的值变为1
  150. rmsSupplier.setDeleted(new BigDecimal(1));
  151. return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  152. }
  153. /**
  154. * 根据id值展示供应商信息
  155. * @param id
  156. * @return
  157. */
  158. @Override
  159. public List<Map<String, Object>> getSupplierById(BigDecimal id) {
  160. return rmsSupplierMapper.selectSupplierById(id);
  161. }
  162. }