|
@@ -12,15 +12,18 @@ import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.BuildCodeUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
import com.abi.qms.platform.service.QrVariableService;
|
|
|
+import com.abi.task.common.api.exception.BusinessException;
|
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 码格式变量 Service业务层处理
|
|
@@ -65,19 +68,37 @@ public class QrVariableServiceImpl implements QrVariableService {
|
|
|
*/
|
|
|
@Override
|
|
|
public PreviewQrVariableRes previewQrVariable(PreviewQrVariableReq req) {
|
|
|
+ //校验入参
|
|
|
+ if(CollectionUtils.isEmpty(req.getIds())){
|
|
|
+ throw new BusinessException("码格式入参id为空");
|
|
|
+ }
|
|
|
// 查询码格式变量
|
|
|
- QrVariable qrVariable = qrVariableMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(qrVariable,"码格式变量不存在");
|
|
|
+ QueryWrapper<QrVariable> qrVariableQw = new QueryWrapper<>();
|
|
|
+ qrVariableQw.in("id",req.getIds());
|
|
|
+ List<QrVariable> qrVariableList = qrVariableMapper.selectList(qrVariableQw);
|
|
|
+ if(CollectionUtils.isEmpty(qrVariableList)){
|
|
|
+ throw new BusinessException("码格式变量不存在");
|
|
|
+ }
|
|
|
+ if(qrVariableList.size()!=req.getIds().size()){
|
|
|
+ throw new BusinessException("部分码格式变量不存在");
|
|
|
+ }
|
|
|
|
|
|
// 生成单个码
|
|
|
- String code = BuildCodeUtil.buildSingleCode(qrVariable.getBuildCodeClass(), null);
|
|
|
+ StringBuffer codeSb = new StringBuffer();
|
|
|
+ for(QrVariable qrVariable:qrVariableList){
|
|
|
+ String tempCode = BuildCodeUtil.buildSingleCode(qrVariable.getBuildCodeClass(), null);
|
|
|
+ codeSb.append(tempCode);
|
|
|
+ }
|
|
|
+ String code = codeSb.toString();
|
|
|
PreviewQrVariableRes res = new PreviewQrVariableRes();
|
|
|
res.setCode(code);
|
|
|
|
|
|
// 位数
|
|
|
- res.setDigit(qrVariable.getDigit());
|
|
|
+ res.setDigit(code.length());
|
|
|
|
|
|
// 获得或计算理论不重复数量
|
|
|
+ //TODO 先取一个看看
|
|
|
+ QrVariable qrVariable = qrVariableList.get(0);
|
|
|
String effectiveQuantity = qrVariable.getEffectiveQuantity();
|
|
|
Long maxCount;
|
|
|
Pattern pattern = Pattern.compile("[0-9]*");
|