|
@@ -1,9 +1,12 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
import com.abi.qms.platform.dao.entity.QrFormat;
|
|
|
+import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
|
|
|
import com.abi.qms.platform.dao.enums.QrFormatUseStatusEnum;
|
|
|
import com.abi.qms.platform.dao.enums.QrFormatVerifyUniqueEnum;
|
|
|
import com.abi.qms.platform.dao.mapper.QrFormatMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrRepertoryColumnMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrRepertoryMapper;
|
|
|
import com.abi.qms.platform.dao.vo.result.QrFormatVO;
|
|
|
import com.abi.qms.platform.dto.req.*;
|
|
|
import com.abi.qms.platform.dto.res.GetQrFormatDetailRes;
|
|
@@ -20,6 +23,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -36,6 +40,12 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
@Autowired
|
|
|
private QrFormatMapper qrFormatMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private QrRepertoryMapper qrRepertoryMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QrRepertoryColumnMapper qrRepertoryColumnMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExecutorService executorService;
|
|
|
|
|
@@ -135,8 +145,14 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // TODO 根据是否被码库使用,决定更新状态为未使用还是使用中
|
|
|
- QrFormat update = new QrFormat().setId(id).setUseStatus(QrFormatUseStatusEnum.UN_USE.getCode());
|
|
|
+ // 根据是否被码库使用,决定更新状态为未使用还是使用中
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
@@ -156,6 +172,12 @@ public class QrFormatServiceImpl implements QrFormatService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ // 判断该码格式关联的码库是否全部停用,若否,停用失败
|
|
|
+ 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);
|
|
|
}
|