123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package com.ruoyi.base.service.impl;
- import java.util.List;
- import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.exception.ServiceException;
- import com.ruoyi.common.utils.DateUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ruoyi.base.mapper.CodeSkuRelationshipMapper;
- import com.ruoyi.base.domain.CodeSkuRelationship;
- import com.ruoyi.base.service.ICodeSkuRelationshipService;
- /**
- * 条码品号关系表Service业务层处理
- *
- * @author andy
- * @date 2022-11-07
- */
- @Service
- public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipService {
- @Autowired
- private CodeSkuRelationshipMapper codeSkuRelationshipMapper;
- /**
- * 查询条码品号关系表
- *
- * @param id 条码品号关系表主键
- * @return 条码品号关系表
- */
- @Override
- public CodeSkuRelationship selectCodeSkuRelationshipById(Long id) {
- return codeSkuRelationshipMapper.selectCodeSkuRelationshipById(id);
- }
- /**
- * 查询条码品号关系表列表
- *
- * @param codeSkuRelationship 条码品号关系表
- * @return 条码品号关系表
- */
- @Override
- public List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship) {
- return codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
- }
- /**
- * 查询条码品号关系表
- *
- * @param codeSkuRelationship 条码品号关系表
- * @return 条码品号关系表
- */
- @Override
- public CodeSkuRelationship selectCodeSkuRelationshipByModel(CodeSkuRelationship codeSkuRelationship) {
- List<CodeSkuRelationship> list = codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
- if (list != null && list.size() > 0) {
- return list.get(0);
- } else {
- return null;
- }
- }
- /**
- * 新增条码品号关系表
- *
- * @param codeSkuRelationship 条码品号关系表
- * @return 结果
- */
- @Override
- public int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
- codeSkuRelationship.setCreateTime(DateUtils.getNowDate());
- return codeSkuRelationshipMapper.insertCodeSkuRelationship(codeSkuRelationship);
- }
- /**
- * 修改条码品号关系表
- *
- * @param codeSkuRelationship 条码品号关系表
- * @return 结果
- */
- @Override
- public int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
- codeSkuRelationship.setUpdateTime(DateUtils.getNowDate());
- return codeSkuRelationshipMapper.updateCodeSkuRelationship(codeSkuRelationship);
- }
- /**
- * 批量删除条码品号关系表
- *
- * @param ids 需要删除的条码品号关系表主键
- * @return 结果
- */
- @Override
- public int deleteCodeSkuRelationshipByIds(Long[] ids) {
- return codeSkuRelationshipMapper.deleteCodeSkuRelationshipByIds(ids);
- }
- /**
- * 删除条码品号关系表信息
- *
- * @param id 条码品号关系表主键
- * @return 结果
- */
- @Override
- public int deleteCodeSkuRelationshipById(Long id) {
- return codeSkuRelationshipMapper.deleteCodeSkuRelationshipById(id);
- }
- /**
- * 条码检测
- *
- * @param sn 条码
- * @return
- */
- @Override
- public AjaxResult snCheck(String sn) {
- CodeSkuRelationshipVO codeSkuRelationshipVO = this.checkIsProduct(sn);
- return AjaxResult.success("", codeSkuRelationshipVO);
- }
- /**
- * 条码检测
- * @param sn
- * @return
- */
- @Override
- public CodeSkuRelationshipVO checkIsProduct(String sn) {
- List<CodeSkuRelationshipVO> codeSkuRelationshipVO = codeSkuRelationshipMapper.selectCodeSkuRelationshipBySn(sn);
- if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() > 1) {
- //物料条码
- CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
- tmp.setProduct(false);
- return tmp;
- } else if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() == 1) {
- //成品条码
- CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
- tmp.setProduct(true);
- return tmp;
- } else {
- throw new ServiceException("条码不存在");
- }
- }
- }
|