RmsSupplierServiceImpl.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. int i=0;
  110. // 判断用户输入的船名在数据库中是否存在
  111. String supplierName=rmsSupplier.getSupplierName();
  112. Map<String,Object> map = new HashMap<>();
  113. map.put("supplierName",supplierName);
  114. List<RmsSupplier> rmsSuppliers = rmsSupplierMapper.selectByParameters(map);
  115. if (rmsSuppliers.size() != 0 ) {
  116. RmsSupplier rmsSupplier1=rmsSuppliers.get(0);
  117. // 当供应商编号存在的时候,直接返回已经存在数据就行了
  118. if (rmsSupplier1.getDeleted().equals(new BigDecimal(1))){
  119. rmsSupplier.setInsertTime(new Date());
  120. rmsSupplier.setInsertUsername("admin");
  121. rmsSupplier.setDeleted(new BigDecimal(0));
  122. rmsSupplier.setSupplierId(rmsSupplierMapper.getSupplierId());
  123. i+=rmsSupplierMapper.insertSelective(rmsSupplier);
  124. }
  125. else{
  126. i=-1;
  127. }
  128. }
  129. else {
  130. // 当供应商编号不存在的话,就直接加入
  131. rmsSupplier.setInsertTime(new Date());
  132. rmsSupplier.setInsertUsername("admin");
  133. rmsSupplier.setDeleted(new BigDecimal(0));
  134. rmsSupplier.setSupplierId(rmsSupplierMapper.getSupplierId());
  135. i+=rmsSupplierMapper.insertSelective(rmsSupplier);
  136. }
  137. return i;
  138. }
  139. /**
  140. * 修改供应商信息
  141. * @param rmsSupplier
  142. * @return
  143. */
  144. @Override
  145. public int updateSupplier(RmsSupplier rmsSupplier) {
  146. rmsSupplier.setUpdateUsername("admin");
  147. // 增加修改时间
  148. rmsSupplier.setUpdateTime(new Date());
  149. return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  150. }
  151. /**
  152. * 根据id值删除供应商信息
  153. * @param id
  154. * @return
  155. */
  156. @Override
  157. public int deleteSupplier(BigDecimal id) {
  158. // 使用逻辑删除
  159. RmsSupplier rmsSupplier=rmsSupplierMapper.selectByPrimaryKey(id);
  160. // 对于我们要删除的供应商,将他的deleted字段的值变为1
  161. rmsSupplier.setDeleted(new BigDecimal(1));
  162. return rmsSupplierMapper.updateByPrimaryKeySelective(rmsSupplier);
  163. }
  164. /**
  165. * 根据id值展示供应商信息
  166. * @param id
  167. * @return
  168. */
  169. @Override
  170. public List<Map<String, Object>> getSupplierById(BigDecimal id) {
  171. return rmsSupplierMapper.selectSupplierById(id);
  172. }
  173. }