|
@@ -7,10 +7,21 @@ import com.abi.qms.platform.dao.enums.QrRepertoryTypeEnum;
|
|
|
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.QrRepertorySelectDetailVO;
|
|
|
import com.abi.qms.platform.dao.vo.result.QrRepertoryVO;
|
|
|
-import com.abi.qms.platform.dto.req.*;
|
|
|
+import com.abi.qms.platform.dto.req.BatchInsertQrRepertoryColumnReq;
|
|
|
+import com.abi.qms.platform.dto.req.DeleteQrRepertoryReq;
|
|
|
+import com.abi.qms.platform.dto.req.DisableQrRepertoryReq;
|
|
|
+import com.abi.qms.platform.dto.req.EnableQrRepertoryReq;
|
|
|
+import com.abi.qms.platform.dto.req.GetQrRepertoryDetailReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListQrRepertoryReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListQrRepertorySelectDetailReq;
|
|
|
+import com.abi.qms.platform.dto.req.SaveQrRepertoryColumnReq;
|
|
|
+import com.abi.qms.platform.dto.req.SaveQrRepertoryReq;
|
|
|
import com.abi.qms.platform.dto.res.GetQrRepertoryDetailRes;
|
|
|
import com.abi.qms.platform.dto.res.ListQrRepertoryRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListQrRepertorySelectDetailRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListQrRepertorySelectRes;
|
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.UserUtil;
|
|
@@ -36,205 +47,229 @@ import java.util.stream.Collectors;
|
|
|
* @date 2021-04-25
|
|
|
*/
|
|
|
@Service
|
|
|
-public class QrRepertoryServiceImpl implements QrRepertoryService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QrRepertoryMapper qrRepertoryMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QrRepertoryColumnMapper qrRepertoryColumnMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QrFormatMapper qrFormatMapper;
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存码库
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveQrRepertory(SaveQrRepertoryReq req) {
|
|
|
- Long qrRepertoryId = req.getId();
|
|
|
- // 修改码库时的条件限制
|
|
|
- QrRepertory qrRepertory;
|
|
|
- if (qrRepertoryId != null) {
|
|
|
- qrRepertory = qrRepertoryMapper.selectById(qrRepertoryId);
|
|
|
- AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
- // 只有待生成、待导入状态下才可编辑
|
|
|
- Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
- if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.WAIT_IMPORT.is(qrRepertoryStatus)) {
|
|
|
- throw new BusinessException("码库不可编辑");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 码库名称不可重复
|
|
|
- QueryWrapper<QrRepertory> qrRepertoryQw = new QueryWrapper<>();
|
|
|
- qrRepertoryQw.eq("name", req.getName());
|
|
|
- qrRepertoryQw.eq("is_delete", 0);
|
|
|
- if (qrRepertoryId != null) {
|
|
|
- qrRepertoryQw.ne("id", qrRepertoryId);
|
|
|
- }
|
|
|
- Integer count = qrRepertoryMapper.selectCount(qrRepertoryQw);
|
|
|
- if (!count.equals(0)) {
|
|
|
- throw new BusinessException("码库名称已存在");
|
|
|
- }
|
|
|
-
|
|
|
- // 验证:1.码库类型为系统生成时,码格式必填 2.同一个码库内的列别名不可重复
|
|
|
- List<SaveQrRepertoryColumnReq> qrRepertoryColumnList = req.getQrRepertoryColumnList();
|
|
|
- Set<String> notRepeat = new HashSet<>();
|
|
|
- SaveQrRepertoryColumnReq qrRepertoryColumn;
|
|
|
- for (int i = 0; i < qrRepertoryColumnList.size(); i++) {
|
|
|
- qrRepertoryColumn = qrRepertoryColumnList.get(i);
|
|
|
- if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(req.getType()) && qrRepertoryColumn.getQrFormatId() == null) {
|
|
|
- throw new BusinessException("码格式为空");
|
|
|
- }
|
|
|
- if (!notRepeat.add(qrRepertoryColumn.getAlias())) {
|
|
|
- throw new BusinessException("列名称已存在");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // copy属性值
|
|
|
- qrRepertory = PojoConverterUtils.copy(req, QrRepertory.class);
|
|
|
- Integer qrRepertoryType = qrRepertory.getType();
|
|
|
- // 文本导入类型设置状态为待导入,其他两种类型设置状态为待生成
|
|
|
- if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
|
|
|
- qrRepertory.setStatus(QrRepertoryStatusEnum.WAIT_IMPORT.getCode());
|
|
|
- } else {
|
|
|
- qrRepertory.setStatus(QrRepertoryStatusEnum.WAIT_GENERATE.getCode());
|
|
|
- }
|
|
|
-
|
|
|
- // 新增or修改
|
|
|
- Long userId = UserUtil.getUser().getId();
|
|
|
- qrRepertory.setUpdateBy(userId);
|
|
|
- if (qrRepertoryId != null) {
|
|
|
- qrRepertoryMapper.updateById(qrRepertory);
|
|
|
- // 逻辑删除码库的列
|
|
|
- qrRepertoryColumnMapper.deleteByQrRepertoryId(qrRepertoryId);
|
|
|
- } else {
|
|
|
- qrRepertory.setCreateBy(userId);
|
|
|
- qrRepertoryMapper.insert(qrRepertory);
|
|
|
- }
|
|
|
-
|
|
|
- // 批量插入码库的列
|
|
|
- BatchInsertQrRepertoryColumnReq batchInsertQrRepertoryColumnReq = new BatchInsertQrRepertoryColumnReq(qrRepertory, qrRepertoryColumnList);
|
|
|
- qrRepertoryColumnMapper.batchInsert(batchInsertQrRepertoryColumnReq);
|
|
|
-
|
|
|
- // 将使用到的码格式状态改为使用中
|
|
|
- List<Long> ids = qrRepertoryColumnList.stream().map(col -> col.getQrFormatId()).collect(Collectors.toList());
|
|
|
- qrFormatMapper.updateUseStatusByIds(ids, QrFormatUseStatusEnum.USING.getCode());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 码库查询分页
|
|
|
- */
|
|
|
- @Override
|
|
|
- public ListQrRepertoryRes listQrRepertory(ListQrRepertoryReq req) {
|
|
|
- // 分页查询
|
|
|
- IPage<QrRepertoryVO> iPage = qrRepertoryMapper.listQrRepertory(PageUtil.createPage(req), req);
|
|
|
- List<QrRepertoryVO> qrRepertoryList = iPage.getRecords();
|
|
|
- qrRepertoryList.forEach(qrRepertoryVO -> {
|
|
|
- String dataComposition = qrRepertoryVO.getQrRepertoryColumnList().stream().map(col -> col.getAlias()).collect(Collectors.joining(","));
|
|
|
- qrRepertoryVO.setDataComposition(dataComposition);
|
|
|
- });
|
|
|
-
|
|
|
- // 封装出参、放入分页信息
|
|
|
- ListQrRepertoryRes res = new ListQrRepertoryRes();
|
|
|
- PageUtil.copyPageInfo(res, iPage);
|
|
|
- List<ListQrRepertoryRes.QrRepertoryBean> qrRepertoryBeanList = PojoConverterUtils.copyList(qrRepertoryList, ListQrRepertoryRes.QrRepertoryBean.class);
|
|
|
- res.setQrRepertoryBeanList(qrRepertoryBeanList);
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 码库查询详情
|
|
|
- */
|
|
|
- @Override
|
|
|
- public GetQrRepertoryDetailRes getQrRepertoryDetail(GetQrRepertoryDetailReq req) {
|
|
|
- // 查询码库对象
|
|
|
- QrRepertoryVO qrRepertoryVO = qrRepertoryMapper.selectQrRepertoryDetailById(req.getId());
|
|
|
- AssertUtil.isNull(qrRepertoryVO, "码库不存在");
|
|
|
-
|
|
|
- return PojoConverterUtils.copy(qrRepertoryVO, GetQrRepertoryDetailRes.class);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 码库启用:针对的是系统生成和FTP接入,文本导入不存在启用的概念
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void enableQrRepertory(EnableQrRepertoryReq req) {
|
|
|
- List<Long> idList = req.getIds();
|
|
|
- for (Long id : idList) {
|
|
|
- QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
|
|
|
- AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
-
|
|
|
- // 启用针对的是系统生成和FTP接入类型的码库
|
|
|
- Integer qrRepertoryType = qrRepertory.getType();
|
|
|
- if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 在状态为待生成、停用时可启用
|
|
|
- Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
- if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.DISABLE.is(qrRepertoryStatus)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 启用时需判断其关联的码格式是否停用,若是,则启用失败
|
|
|
- if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(qrRepertoryType)) {
|
|
|
- List<String> disabledQrFormatList = qrFormatMapper.selectDisabledQrFormat(id);
|
|
|
- if (!CollectionUtils.isEmpty(disabledQrFormatList)) {
|
|
|
- throw new BusinessException("该码库关联的码格式" + disabledQrFormatList + "已停用,码库启用失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.GENERATING.getCode());
|
|
|
- qrRepertoryMapper.updateById(update);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 码库禁用
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void disableQrRepertory(DisableQrRepertoryReq req) {
|
|
|
- List<Long> idList = req.getIds();
|
|
|
- for (Long id : idList) {
|
|
|
- QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
|
|
|
- AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
-
|
|
|
- // 在状态为已导入、自动生成时可停用
|
|
|
- Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
- if (!QrRepertoryStatusEnum.GENERATING.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.IMPORTED.is(qrRepertoryStatus)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.DISABLE.getCode());
|
|
|
- qrRepertoryMapper.updateById(update);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除码库
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void deleteQrRepertory(DeleteQrRepertoryReq req) {
|
|
|
- QrRepertory qrRepertory = qrRepertoryMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
- // 只有待生成、待导入状态下才可删除
|
|
|
- Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
- if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.WAIT_IMPORT.is(qrRepertoryStatus)) {
|
|
|
- throw new BusinessException("码库不可删除");
|
|
|
- }
|
|
|
-
|
|
|
- // 逻辑删除
|
|
|
- QrRepertory update = new QrRepertory().setId(req.getId()).setIsDelete(1);
|
|
|
- qrRepertoryMapper.updateById(update);
|
|
|
-
|
|
|
- // 逻辑删除码库的列
|
|
|
- qrRepertoryColumnMapper.deleteByQrRepertoryId(req.getId());
|
|
|
- }
|
|
|
+public class QrRepertoryServiceImpl implements QrRepertoryService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QrRepertoryMapper qrRepertoryMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QrRepertoryColumnMapper qrRepertoryColumnMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QrFormatMapper qrFormatMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存码库
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveQrRepertory(SaveQrRepertoryReq req) {
|
|
|
+ Long qrRepertoryId = req.getId();
|
|
|
+ // 修改码库时的条件限制
|
|
|
+ QrRepertory qrRepertory;
|
|
|
+ if (qrRepertoryId != null) {
|
|
|
+ qrRepertory = qrRepertoryMapper.selectById(qrRepertoryId);
|
|
|
+ AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
+ // 只有待生成、待导入状态下才可编辑
|
|
|
+ Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
+ if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.WAIT_IMPORT.is(qrRepertoryStatus)) {
|
|
|
+ throw new BusinessException("码库不可编辑");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 码库名称不可重复
|
|
|
+ QueryWrapper<QrRepertory> qrRepertoryQw = new QueryWrapper<>();
|
|
|
+ qrRepertoryQw.eq("name", req.getName());
|
|
|
+ qrRepertoryQw.eq("is_delete", 0);
|
|
|
+ if (qrRepertoryId != null) {
|
|
|
+ qrRepertoryQw.ne("id", qrRepertoryId);
|
|
|
+ }
|
|
|
+ Integer count = qrRepertoryMapper.selectCount(qrRepertoryQw);
|
|
|
+ if (!count.equals(0)) {
|
|
|
+ throw new BusinessException("码库名称已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证:1.码库类型为系统生成时,码格式必填 2.同一个码库内的列别名不可重复
|
|
|
+ List<SaveQrRepertoryColumnReq> qrRepertoryColumnList = req.getQrRepertoryColumnList();
|
|
|
+ Set<String> notRepeat = new HashSet<>();
|
|
|
+ SaveQrRepertoryColumnReq qrRepertoryColumn;
|
|
|
+ for (int i = 0; i < qrRepertoryColumnList.size(); i++) {
|
|
|
+ qrRepertoryColumn = qrRepertoryColumnList.get(i);
|
|
|
+ if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(req.getType()) && qrRepertoryColumn.getQrFormatId() == null) {
|
|
|
+ throw new BusinessException("码格式为空");
|
|
|
+ }
|
|
|
+ if (!notRepeat.add(qrRepertoryColumn.getAlias())) {
|
|
|
+ throw new BusinessException("列名称已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // copy属性值
|
|
|
+ qrRepertory = PojoConverterUtils.copy(req, QrRepertory.class);
|
|
|
+ Integer qrRepertoryType = qrRepertory.getType();
|
|
|
+ // 文本导入类型设置状态为待导入,其他两种类型设置状态为待生成
|
|
|
+ if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
|
|
|
+ qrRepertory.setStatus(QrRepertoryStatusEnum.WAIT_IMPORT.getCode());
|
|
|
+ } else {
|
|
|
+ qrRepertory.setStatus(QrRepertoryStatusEnum.WAIT_GENERATE.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增or修改
|
|
|
+ Long userId = UserUtil.getUser().getId();
|
|
|
+ qrRepertory.setUpdateBy(userId);
|
|
|
+ if (qrRepertoryId != null) {
|
|
|
+ qrRepertoryMapper.updateById(qrRepertory);
|
|
|
+ // 逻辑删除码库的列
|
|
|
+ qrRepertoryColumnMapper.deleteByQrRepertoryId(qrRepertoryId);
|
|
|
+ } else {
|
|
|
+ qrRepertory.setCreateBy(userId);
|
|
|
+ qrRepertoryMapper.insert(qrRepertory);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量插入码库的列
|
|
|
+ BatchInsertQrRepertoryColumnReq batchInsertQrRepertoryColumnReq = new BatchInsertQrRepertoryColumnReq(qrRepertory, qrRepertoryColumnList);
|
|
|
+ qrRepertoryColumnMapper.batchInsert(batchInsertQrRepertoryColumnReq);
|
|
|
+
|
|
|
+ // 将使用到的码格式状态改为使用中
|
|
|
+ List<Long> ids = qrRepertoryColumnList.stream().map(col -> col.getQrFormatId()).collect(Collectors.toList());
|
|
|
+ qrFormatMapper.updateUseStatusByIds(ids, QrFormatUseStatusEnum.USING.getCode());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 码库查询分页
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ListQrRepertoryRes listQrRepertory(ListQrRepertoryReq req) {
|
|
|
+ // 分页查询
|
|
|
+ IPage<QrRepertoryVO> iPage = qrRepertoryMapper.listQrRepertory(PageUtil.createPage(req), req);
|
|
|
+ List<QrRepertoryVO> qrRepertoryList = iPage.getRecords();
|
|
|
+ qrRepertoryList.forEach(qrRepertoryVO -> {
|
|
|
+ String dataComposition = qrRepertoryVO.getQrRepertoryColumnList().stream().map(col -> col.getAlias()).collect(Collectors.joining(","));
|
|
|
+ qrRepertoryVO.setDataComposition(dataComposition);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 封装出参、放入分页信息
|
|
|
+ ListQrRepertoryRes res = new ListQrRepertoryRes();
|
|
|
+ PageUtil.copyPageInfo(res, iPage);
|
|
|
+ List<ListQrRepertoryRes.QrRepertoryBean> qrRepertoryBeanList = PojoConverterUtils.copyList(qrRepertoryList, ListQrRepertoryRes.QrRepertoryBean.class);
|
|
|
+ res.setQrRepertoryBeanList(qrRepertoryBeanList);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 码库查询详情
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public GetQrRepertoryDetailRes getQrRepertoryDetail(GetQrRepertoryDetailReq req) {
|
|
|
+ // 查询码库对象
|
|
|
+ QrRepertoryVO qrRepertoryVO = qrRepertoryMapper.selectQrRepertoryDetailById(req.getId());
|
|
|
+ AssertUtil.isNull(qrRepertoryVO, "码库不存在");
|
|
|
+
|
|
|
+ return PojoConverterUtils.copy(qrRepertoryVO, GetQrRepertoryDetailRes.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 码库启用:针对的是系统生成和FTP接入,文本导入不存在启用的概念
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void enableQrRepertory(EnableQrRepertoryReq req) {
|
|
|
+ List<Long> idList = req.getIds();
|
|
|
+ for (Long id : idList) {
|
|
|
+ QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
|
|
|
+ AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
+
|
|
|
+ // 启用针对的是系统生成和FTP接入类型的码库
|
|
|
+ Integer qrRepertoryType = qrRepertory.getType();
|
|
|
+ if (QrRepertoryTypeEnum.FILE_IMPORT.is(qrRepertoryType)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 在状态为待生成、停用时可启用
|
|
|
+ Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
+ if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.DISABLE.is(qrRepertoryStatus)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 启用时需判断其关联的码格式是否停用,若是,则启用失败
|
|
|
+ if (QrRepertoryTypeEnum.SYSTEM_GENERATE.is(qrRepertoryType)) {
|
|
|
+ List<String> disabledQrFormatList = qrFormatMapper.selectDisabledQrFormat(id);
|
|
|
+ if (!CollectionUtils.isEmpty(disabledQrFormatList)) {
|
|
|
+ throw new BusinessException("该码库关联的码格式" + disabledQrFormatList + "已停用,码库启用失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.GENERATING.getCode());
|
|
|
+ qrRepertoryMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 码库禁用
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void disableQrRepertory(DisableQrRepertoryReq req) {
|
|
|
+ List<Long> idList = req.getIds();
|
|
|
+ for (Long id : idList) {
|
|
|
+ QrRepertory qrRepertory = qrRepertoryMapper.selectById(id);
|
|
|
+ AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
+
|
|
|
+ // 在状态为已导入、自动生成时可停用
|
|
|
+ Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
+ if (!QrRepertoryStatusEnum.GENERATING.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.IMPORTED.is(qrRepertoryStatus)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ QrRepertory update = new QrRepertory().setId(id).setStatus(QrRepertoryStatusEnum.DISABLE.getCode());
|
|
|
+ qrRepertoryMapper.updateById(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除码库
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deleteQrRepertory(DeleteQrRepertoryReq req) {
|
|
|
+ QrRepertory qrRepertory = qrRepertoryMapper.selectById(req.getId());
|
|
|
+ AssertUtil.isNull(qrRepertory, "码库不存在");
|
|
|
+ // 只有待生成、待导入状态下才可删除
|
|
|
+ Integer qrRepertoryStatus = qrRepertory.getStatus();
|
|
|
+ if (!QrRepertoryStatusEnum.WAIT_GENERATE.is(qrRepertoryStatus) && !QrRepertoryStatusEnum.WAIT_IMPORT.is(qrRepertoryStatus)) {
|
|
|
+ throw new BusinessException("码库不可删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 逻辑删除
|
|
|
+ QrRepertory update = new QrRepertory().setId(req.getId()).setIsDelete(1);
|
|
|
+ qrRepertoryMapper.updateById(update);
|
|
|
+
|
|
|
+ // 逻辑删除码库的列
|
|
|
+ qrRepertoryColumnMapper.deleteByQrRepertoryId(req.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ListQrRepertorySelectRes listQrRepertorySelectRes() {
|
|
|
+
|
|
|
+ ListQrRepertorySelectRes res = new ListQrRepertorySelectRes();
|
|
|
+
|
|
|
+ QueryWrapper<QrRepertory> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("is_delete", 0);
|
|
|
+ List<QrRepertory> repertoryList = qrRepertoryMapper.selectList(queryWrapper);
|
|
|
+ List<ListQrRepertorySelectRes.QrRepertoryBean> beanList = PojoConverterUtils.copyList(repertoryList, ListQrRepertorySelectRes.QrRepertoryBean.class);
|
|
|
+ res.setQrRepertoryBeanList(beanList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ListQrRepertorySelectDetailRes listQrRepertorySelectDetail(ListQrRepertorySelectDetailReq req) {
|
|
|
+
|
|
|
+ ListQrRepertorySelectDetailRes res = new ListQrRepertorySelectDetailRes();
|
|
|
+
|
|
|
+ List<QrRepertorySelectDetailVO> voList = qrRepertoryMapper.listQrRepertorySelectDetail(req.getId());
|
|
|
+ List<ListQrRepertorySelectDetailRes.QrRepertorySelectDetailBean> beanList = PojoConverterUtils.copyList(voList, ListQrRepertorySelectDetailRes.QrRepertorySelectDetailBean.class);
|
|
|
+ res.setQrRepertorySelectDetailBeanList(beanList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|