|
|
|
package com.glxp.api.service.collect;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
import com.glxp.api.req.collect.RelCodeDetailRequest;
|
|
|
|
import com.glxp.api.res.collect.RelCodeDetailResponse;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.glxp.api.dao.collect.RelCodeDetailMapper;
|
|
|
|
import com.glxp.api.entity.collect.RelCodeDetail;
|
|
|
|
@Service
|
|
|
|
public class RelCodeDetailService extends ServiceImpl<RelCodeDetailMapper, RelCodeDetail> {
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 扫码获取子集
|
|
|
|
* @param relCodeDetailRequest
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public RelCodeDetailResponse scanCode(RelCodeDetailRequest relCodeDetailRequest) {
|
|
|
|
//todo 查询子集
|
|
|
|
String parentCode = relCodeDetailRequest.getParentCode();
|
|
|
|
if(StrUtil.isBlank(parentCode)){
|
|
|
|
throw new JsonException("父级码不能为空");
|
|
|
|
}
|
|
|
|
RelCodeDetailResponse relCodeDetailResponse = new RelCodeDetailResponse();
|
|
|
|
LambdaQueryWrapper<BasicProductsEntity> qw = new LambdaQueryWrapper<BasicProductsEntity>()
|
|
|
|
.eq(BasicProductsEntity::getNameCode, relCodeDetailRequest.getParentCode())
|
|
|
|
.last("limit 1");
|
|
|
|
BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(qw);
|
|
|
|
if(basicProductsEntity == null){
|
|
|
|
throw new JsonException("");
|
|
|
|
}
|
|
|
|
relCodeDetailResponse.setCurCode(basicProductsEntity.getNameCode());
|
|
|
|
relCodeDetailResponse.setPackLayer(Integer.valueOf(basicProductsEntity.getPackLevel()));
|
|
|
|
relCodeDetailResponse.setParentCode(parentCode);
|
|
|
|
relCodeDetailResponse.setFlag(Integer.valueOf(basicProductsEntity.getMajorStatus()));
|
|
|
|
return relCodeDetailResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 明细列表
|
|
|
|
* @param relCodeDetailRequest
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<RelCodeDetailResponse> filterList(RelCodeDetailRequest relCodeDetailRequest) {
|
|
|
|
if (relCodeDetailRequest == null) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
if (relCodeDetailRequest.getPage() != null) {
|
|
|
|
int offset = (relCodeDetailRequest.getPage() - 1) * relCodeDetailRequest.getLimit();
|
|
|
|
PageHelper.offsetPage(offset, relCodeDetailRequest.getLimit());
|
|
|
|
}
|
|
|
|
return this.baseMapper.filterList(relCodeDetailRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|