|
@@ -28,6 +28,7 @@ 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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -43,6 +44,7 @@ import java.util.concurrent.ExecutorService;
|
|
|
* @date 2021-04-19
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class QrFormatServiceImpl implements QrFormatService {
|
|
|
|
|
|
@Autowired
|
|
@@ -71,6 +73,10 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
public void saveQrFormat(SaveQrFormatReq req) {
|
|
|
Long qrFormatId = req.getId();
|
|
|
//1-校验入参
|
|
|
+ //码格式位数不在规定区间内
|
|
|
+ if (null == req.getDigit() || req.getDigit() <= 0 || req.getDigit() > 32){
|
|
|
+ throw new BusinessException("码格式位数不在0~32位之内");
|
|
|
+ }
|
|
|
// 修改码格式时的条件限制
|
|
|
QrFormat qrFormat;
|
|
|
if (qrFormatId != null) {
|
|
@@ -179,22 +185,36 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
public void enableQrFormat(EnableQrFormatReq req) {
|
|
|
List<Long> idList = req.getIds();
|
|
|
for (Long id : idList) {
|
|
|
- QrFormat qrFormat = qrFormatMapper.selectById(id);
|
|
|
- AssertUtil.isNull(qrFormat, "码格式不存在");
|
|
|
- // 如果不是停用状态的码格式,跳过循环
|
|
|
- if (!QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
|
|
|
- continue;
|
|
|
+ try{
|
|
|
+ QrFormat qrFormat = qrFormatMapper.selectById(id);
|
|
|
+ AssertUtil.isNull(qrFormat, "码格式不存在");
|
|
|
+ // 如果不是停用状态的码格式,跳过循环
|
|
|
+ if (!QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //不是验证通过的码格式,跳过循环,不可启用
|
|
|
+ if (!QrFormatUniqueStatusEunm.VERIFY_SUCCESS.is(qrFormat.getUniqueStatus())){
|
|
|
+ throw new BusinessException("码格式不是验证通过,不可启用");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据是否被码库使用,决定更新状态为未使用还是使用中
|
|
|
+ QueryWrapper<QrRepertoryColumn> qrRepertoryColumnQw = new QueryWrapper<>();
|
|
|
+ qrRepertoryColumnQw.eq("is_delete", 0);
|
|
|
+ qrRepertoryColumnQw.eq("qr_format_id", id);
|
|
|
+ Integer count = qrRepertoryColumnMapper.selectCount(qrRepertoryColumnQw);
|
|
|
+ Integer useStatus = count.compareTo(0) > 0 ? QrFormatUseStatusEnum.USING.getCode() : QrFormatUseStatusEnum.UN_USE.getCode();
|
|
|
+
|
|
|
+ QrFormat update = new QrFormat().setId(id).setUseStatus(useStatus);
|
|
|
+ qrFormatMapper.updateById(update);
|
|
|
+ }catch(BusinessException e){
|
|
|
+ //单条不通过通知前端
|
|
|
+ if (idList.size() == 1){
|
|
|
+ throw e;
|
|
|
+ }else{
|
|
|
+ log.info("批量处理发现异常",e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 根据是否被码库使用,决定更新状态为未使用还是使用中
|
|
|
- QueryWrapper<QrRepertoryColumn> qrRepertoryColumnQw = new QueryWrapper<>();
|
|
|
- qrRepertoryColumnQw.eq("is_delete", 0);
|
|
|
- qrRepertoryColumnQw.eq("qr_format_id", id);
|
|
|
- Integer count = qrRepertoryColumnMapper.selectCount(qrRepertoryColumnQw);
|
|
|
- Integer useStatus = count.compareTo(0) > 0 ? QrFormatUseStatusEnum.USING.getCode() : QrFormatUseStatusEnum.UN_USE.getCode();
|
|
|
-
|
|
|
- QrFormat update = new QrFormat().setId(id).setUseStatus(useStatus);
|
|
|
- qrFormatMapper.updateById(update);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -205,22 +225,36 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void disableQrFormat(DisableQrFormatReq req) {
|
|
|
List<Long> idList = req.getIds();
|
|
|
- for (Long id : idList) {
|
|
|
- QrFormat qrFormat = qrFormatMapper.selectById(id);
|
|
|
- AssertUtil.isNull(qrFormat, "码格式不存在");
|
|
|
- // 如果是停用状态的码格式,跳过循环
|
|
|
- if (QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
|
|
|
- continue;
|
|
|
+ try{
|
|
|
+ for (Long id : idList) {
|
|
|
+ QrFormat qrFormat = qrFormatMapper.selectById(id);
|
|
|
+ AssertUtil.isNull(qrFormat, "码格式不存在");
|
|
|
+ // 如果是停用状态的码格式,跳过循环
|
|
|
+ if (QrFormatUseStatusEnum.DISABLE.is(qrFormat.getUseStatus())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //不是验证通过的码格式,跳过循环,不可禁用
|
|
|
+ if (!QrFormatUniqueStatusEunm.VERIFY_SUCCESS.is(qrFormat.getUniqueStatus())){
|
|
|
+ throw new BusinessException("码格式不是验证通过,不可禁用");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断该码格式关联的码库是否全部停用,若否,停用失败
|
|
|
+ List<String> notDisabledQrRepertoryList = qrRepertoryMapper.selectNotDisabledQrRepertory(id);
|
|
|
+ if (!CollectionUtils.isEmpty(notDisabledQrRepertoryList)) {
|
|
|
+ throw new BusinessException("该码格式已与码库" + notDisabledQrRepertoryList + "关联,请停用码库后再试");
|
|
|
+ }
|
|
|
+
|
|
|
+ QrFormat update = new QrFormat().setId(id).setUseStatus(QrFormatUseStatusEnum.DISABLE.getCode());
|
|
|
+ qrFormatMapper.updateById(update);
|
|
|
}
|
|
|
-
|
|
|
- // 判断该码格式关联的码库是否全部停用,若否,停用失败
|
|
|
- List<String> notDisabledQrRepertoryList = qrRepertoryMapper.selectNotDisabledQrRepertory(id);
|
|
|
- if (!CollectionUtils.isEmpty(notDisabledQrRepertoryList)) {
|
|
|
- throw new BusinessException("该码格式已与码库" + notDisabledQrRepertoryList + "关联,请停用码库后再试");
|
|
|
+ }catch(BusinessException e){
|
|
|
+ //单条不通过通知前端
|
|
|
+ if (idList.size() == 1){
|
|
|
+ throw e;
|
|
|
+ }else{
|
|
|
+ log.info("批量处理发现异常",e);
|
|
|
}
|
|
|
-
|
|
|
- QrFormat update = new QrFormat().setId(id).setUseStatus(QrFormatUseStatusEnum.DISABLE.getCode());
|
|
|
- qrFormatMapper.updateById(update);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -251,7 +285,7 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
ListFormatSelectRes res = new ListFormatSelectRes();
|
|
|
|
|
|
QueryWrapper<QrFormat> qw = new QueryWrapper<>();
|
|
|
- qw.eq("unique_status", QrFormatUniqueStatusEunm.VERIFY_FAIL.getCode());
|
|
|
+ qw.eq("unique_status", QrFormatUniqueStatusEunm.VERIFY_SUCCESS.getCode());
|
|
|
qw.eq("is_delete", 0);
|
|
|
qw.eq("is_sys",0);
|
|
|
List<QrFormat> formatList = qrFormatMapper.selectList(qw);
|