CodeSkuRelationshipServiceImpl.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.ruoyi.base.service.impl;
  2. import java.util.List;
  3. import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
  4. import com.ruoyi.common.core.domain.AjaxResult;
  5. import com.ruoyi.common.exception.ServiceException;
  6. import com.ruoyi.common.utils.DateUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import com.ruoyi.base.mapper.CodeSkuRelationshipMapper;
  10. import com.ruoyi.base.domain.CodeSkuRelationship;
  11. import com.ruoyi.base.service.ICodeSkuRelationshipService;
  12. /**
  13. * 条码品号关系表Service业务层处理
  14. *
  15. * @author andy
  16. * @date 2022-11-07
  17. */
  18. @Service
  19. public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipService {
  20. @Autowired
  21. private CodeSkuRelationshipMapper codeSkuRelationshipMapper;
  22. /**
  23. * 查询条码品号关系表
  24. *
  25. * @param id 条码品号关系表主键
  26. * @return 条码品号关系表
  27. */
  28. @Override
  29. public CodeSkuRelationship selectCodeSkuRelationshipById(Long id) {
  30. return codeSkuRelationshipMapper.selectCodeSkuRelationshipById(id);
  31. }
  32. /**
  33. * 查询条码品号关系表列表
  34. *
  35. * @param codeSkuRelationship 条码品号关系表
  36. * @return 条码品号关系表
  37. */
  38. @Override
  39. public List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship) {
  40. return codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
  41. }
  42. /**
  43. * 查询条码品号关系表
  44. *
  45. * @param codeSkuRelationship 条码品号关系表
  46. * @return 条码品号关系表
  47. */
  48. @Override
  49. public CodeSkuRelationship selectCodeSkuRelationshipByModel(CodeSkuRelationship codeSkuRelationship) {
  50. List<CodeSkuRelationship> list = codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
  51. if (list != null && list.size() > 0) {
  52. return list.get(0);
  53. } else {
  54. return null;
  55. }
  56. }
  57. /**
  58. * 新增条码品号关系表
  59. *
  60. * @param codeSkuRelationship 条码品号关系表
  61. * @return 结果
  62. */
  63. @Override
  64. public int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
  65. codeSkuRelationship.setCreateTime(DateUtils.getNowDate());
  66. return codeSkuRelationshipMapper.insertCodeSkuRelationship(codeSkuRelationship);
  67. }
  68. /**
  69. * 修改条码品号关系表
  70. *
  71. * @param codeSkuRelationship 条码品号关系表
  72. * @return 结果
  73. */
  74. @Override
  75. public int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
  76. codeSkuRelationship.setUpdateTime(DateUtils.getNowDate());
  77. return codeSkuRelationshipMapper.updateCodeSkuRelationship(codeSkuRelationship);
  78. }
  79. /**
  80. * 批量删除条码品号关系表
  81. *
  82. * @param ids 需要删除的条码品号关系表主键
  83. * @return 结果
  84. */
  85. @Override
  86. public int deleteCodeSkuRelationshipByIds(Long[] ids) {
  87. return codeSkuRelationshipMapper.deleteCodeSkuRelationshipByIds(ids);
  88. }
  89. /**
  90. * 删除条码品号关系表信息
  91. *
  92. * @param id 条码品号关系表主键
  93. * @return 结果
  94. */
  95. @Override
  96. public int deleteCodeSkuRelationshipById(Long id) {
  97. return codeSkuRelationshipMapper.deleteCodeSkuRelationshipById(id);
  98. }
  99. /**
  100. * 条码检测
  101. *
  102. * @param sn 条码
  103. * @return
  104. */
  105. @Override
  106. public AjaxResult snCheck(String sn) {
  107. CodeSkuRelationshipVO codeSkuRelationshipVO = this.checkIsProduct(sn);
  108. return AjaxResult.success("", codeSkuRelationshipVO);
  109. }
  110. /**
  111. * 条码检测
  112. * @param sn
  113. * @return
  114. */
  115. @Override
  116. public CodeSkuRelationshipVO checkIsProduct(String sn) {
  117. List<CodeSkuRelationshipVO> codeSkuRelationshipVO = codeSkuRelationshipMapper.selectCodeSkuRelationshipBySn(sn);
  118. if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() > 1) {
  119. //物料条码
  120. CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
  121. tmp.setProduct(false);
  122. return tmp;
  123. } else if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() == 1) {
  124. //成品条码
  125. CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
  126. tmp.setProduct(true);
  127. return tmp;
  128. } else {
  129. throw new ServiceException("条码不存在");
  130. }
  131. }
  132. }