From db64926ed340724ecbb0e26212c419a487eede7b Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 03 四月 2025 11:23:19 +0800
Subject: [PATCH] 设备导入优化
---
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java | 144 +++++++++++++++++++++++++++++++++--------------
1 files changed, 100 insertions(+), 44 deletions(-)
diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java
index 55ade8f..bf53b75 100644
--- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java
+++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java
@@ -1,26 +1,22 @@
package com.ruoyi.basic.service.impl;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.*;
-import com.ruoyi.basic.enums.BasicTreeEnums;
import com.ruoyi.basic.enums.StandardProductListChcekTypeEnums;
-import com.ruoyi.basic.enums.StandardProductListOperationTypeEnums;
import com.ruoyi.basic.mapper.*;
import com.ruoyi.basic.pojo.*;
import com.ruoyi.basic.service.StandardMethodListService;
-import com.ruoyi.basic.service.StandardMethodService;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.basic.service.StandardProductListService;
import lombok.AllArgsConstructor;
-import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -68,6 +64,9 @@
@Autowired
private StandardProductListUpdateRecordMapper standardProductListUpdateRecordMapper;
+
+ @Autowired
+ private StandardProductListUpdateRecordRelMapper standardProductListUpdateRecordRelMapper;
@Override
@@ -490,6 +489,24 @@
*/
@Override
public boolean updateSection(StandardProductList list) {
+ // 鏍规嵁id 鏌ヨ鍒板師濮嬪��
+ StandardProductList standardProductList = standardProductListMapper.selectById(list.getId());
+ if(ObjectUtils.isEmpty(standardProductList)){
+ throw new RuntimeException("鏇存柊澶辫触,鏈煡鎵惧埌妫�鏌ラ」");
+ }
+ // 鍒ゆ柇褰撳墠鐘舵�� 濡傛灉鏄鏍镐腑
+ if(StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())){
+ throw new RuntimeException("瀹℃牳涓笉鏀寔淇敼");
+ }
+ // 鏌ヨ鏈�鏂扮殑涓�娆″叧鑱斿浠� 濡傛灉瀛樺湪璇存槑鏈鏍稿畬缁х画淇敼浜嗐�備笉鍋氭暟鎹鐞嗐��
+ StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(list.getId());
+ if(ObjectUtils.isEmpty(standardProductListBackupRel)){
+ StandardProductListBackupRel productListBackupRel = new StandardProductListBackupRel();
+ BeanUtils.copyProperties(standardProductList, productListBackupRel);
+ standardProductListBackupRelMapper.insert(productListBackupRel);
+ }
+ // 淇敼鐘舵��
+ list.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode());
standardProductListMapper.updateSection(list);
return true;
}
@@ -644,57 +661,96 @@
}
/**
- * 鏍囧噯鏍戜笅妫�楠岄」澶勭悊
- * @param standardProductListDto
+ * 鏍囧噯鏍戜笅妫�楠岄」鎻愪氦
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public void productListOperate(StandardProductListDto standardProductListDto) {
- StandardProductList standardProductList = new StandardProductList();
- standardProductList.setId(standardProductListDto.getId());
- StandardProductListUpdateRecord standardProductListUpdateRecord = new StandardProductListUpdateRecord();
- // 瀹℃牳閫氳繃
- if(StandardProductListOperationTypeEnums.PASS_CHECK_OP.getCode().equals(standardProductListDto.getOperationStatus())){
- // 鍒犻櫎澶囦唤鏁版嵁
- standardProductListBackupRelMapper.deleteById(standardProductListDto.getId());
- standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.PASS_CHECK.getCode());
- // 瀹℃牳涓嶉�氳繃
- }else if(StandardProductListOperationTypeEnums.NO_PASS_CHECK_OP.getCode().equals(standardProductListDto.getOperationStatus())) {
- // 杩樺師鏁版嵁
- StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(standardProductListDto.getId());
- if(ObjectUtils.isEmpty(standardProductListBackupRel)){
- throw new RuntimeException("澶囦唤鏁版嵁鏌ユ壘澶辫触");
- }
- BeanUtils.copyProperties(standardProductListBackupRel, standardProductList);
- standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode());
- // 鎻愪氦
- }else if(StandardProductListOperationTypeEnums.SUBMIT_OP.getCode().equals(standardProductListDto.getOperationStatus())) {
- standardProductListUpdateRecord.setOperationType(StandardProductListOperationTypeEnums.PASS_CHECK_OP.getCode());
- standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.CHECK_ING.getCode());
- } else {
- throw new RuntimeException("鎿嶄綔鏈夎");
+ public void productListSubmit(StandardProductListUpdateRecord standardProductListUpdateRecord) {
+ // 鏌ヨ鎵�鏈夊緟瀹℃牳鐨勬暟鎹�
+ QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.WAIT_CHECK.getCode());
+ List<StandardProductList> unCheckStandardProductListArray = standardProductListMapper.selectList(queryWrapper);
+ if(CollectionUtils.isEmpty(unCheckStandardProductListArray)){
+ throw new RuntimeException("鏆傛棤淇敼鏁版嵁");
}
- // 鏂板鎿嶄綔璁板綍
- standardProductListUpdateRecord.setStandardProductListId(standardProductListDto.getId());
- standardProductListUpdateRecord.setOperationType(standardProductListDto.getOperationStatus());
+ List<Long> standardProductListIds = new ArrayList<>();
+ // 鎻掑叆淇敼璁板綍
standardProductListUpdateRecordMapper.insert(standardProductListUpdateRecord);
- // 淇敼瀹℃牳鐘舵��
- standardProductList.setCheckStatus(standardProductListDto.getOperationStatus());
- standardProductListMapper.updateById(standardProductList);
+ // 鎻掑叆淇敼璁板綍鍏宠仈琛�
+ List<StandardProductListUpdateRecordRel> standardProductListUpdateRecordRelList = new ArrayList<>();
+ for (StandardProductList standardProductList : unCheckStandardProductListArray) {
+ StandardProductListUpdateRecordRel standardProductListUpdateRecordRel = new StandardProductListUpdateRecordRel();
+ BeanUtils.copyProperties(standardProductList, standardProductListUpdateRecordRel);
+ standardProductListUpdateRecordRel.setId(null);
+ standardProductListUpdateRecordRel.setStandardProductListId(standardProductList.getId());
+ standardProductListUpdateRecordRel.setStandardProductListUpdateRecordId(standardProductListUpdateRecord.getId());
+ standardProductListUpdateRecordRelList.add(standardProductListUpdateRecordRel);
+ standardProductListUpdateRecordRelMapper.insert(standardProductListUpdateRecordRel);
+ standardProductListIds.add(standardProductList.getId());
+ }
+
+ // 淇敼鏍囧噯鏍戜笅妫�鏌ラ」鐘舵�佷负瀹℃牳涓�
+ standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.CHECK_ING.getCode());
}
/**
- * 鏍囧噯鏍戜笅妫�楠岄」淇敼璁板綍鍒嗛〉鏌ヨ
- * @param page
- * @param record
+ * 鏍囧噯鏍戜笅妫�楠岄」瀹℃牳
+ * @param standardProductListUpdateRecord
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void productListCheck(StandardProductListUpdateRecord standardProductListUpdateRecord) {
+ // 鏌ヨ鎵�鏈夊鏍镐腑鐨勬暟鎹�
+ QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode());
+ List<StandardProductList> standardProductListArray = standardProductListMapper.selectList(queryWrapper);
+ if(CollectionUtils.isEmpty(standardProductListArray)){
+ return;
+ }
+ List<Long> standardProductListIds = new ArrayList<>();
+ for (StandardProductList standardProductList : standardProductListArray) {
+ standardProductListIds.add(standardProductList.getId());
+ }
+ // 瀹℃牳閫氳繃
+ if(StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){
+ // 鍒犻櫎澶囦唤鏁版嵁
+ standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds);
+ // 淇敼鐘舵��
+ standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.PASS_CHECK.getCode());
+ }
+ // 瀹℃牳鏈�氳繃
+ if(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){
+ // 鏌ヨ鎵�鏈夌殑澶囦唤鏁版嵁
+ List<StandardProductListBackupRel> standardProductListBackupRelList = standardProductListBackupRelMapper.selectBatchIds(standardProductListIds);
+ // 鍥炴粴鏁版嵁
+ for (StandardProductListBackupRel standardProductListBackupRel : standardProductListBackupRelList) {
+ StandardProductList standardProductList = new StandardProductList();
+ BeanUtils.copyProperties(standardProductListBackupRel, standardProductList);
+ standardProductList.setCheckStatus("");
+ standardProductListMapper.updateById(standardProductList);
+ }
+ // 鍒犻櫎澶囦唤鏁版嵁
+ standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds);
+ }
+ standardProductListUpdateRecordMapper.updateById(standardProductListUpdateRecord);
+ }
+
+ /**
+ * 鏌ヨ鏍囧噯搴撴槸鍚﹀瓨鍦ㄥ鏍镐腑鐘舵��
+ *
* @return
*/
@Override
- public IPage<StandardProductListUpdateRecord> standardProductListRecordPage(Page page, StandardProductListUpdateRecord record) {
- return standardProductListUpdateRecordMapper.standardProductListRecordPage(page,QueryWrappers.queryWrappers(record));
+ public boolean existCheckingRecord() {
+ QueryWrapper<StandardProductListUpdateRecord> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode());
+ List<StandardProductListUpdateRecord> standardProductListUpdateRecordList = standardProductListUpdateRecordMapper.selectList(queryWrapper);
+ if(CollectionUtils.isEmpty(standardProductListUpdateRecordList)){
+ return false;
+ }else {
+ return true;
+ }
}
-
-
}
--
Gitblit v1.9.3