RmsSupplierServiceImpl.java 5.4 KB

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