Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -69,7 +69,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.Cache; import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -101,7 +105,7 @@ /** * 单次sql的最多导入数量 */ @Value("${import.maxNum}") @Value("${batchadd.single_maxnum:500}") private Integer MAX_IMPORT_NUM; /** @@ -153,13 +157,11 @@ @Autowired private FormulaServiceImpl formulaService; /** * 对omd中提供的feign接口进行调用,以及处理相关逻辑 */ @Autowired ICodeReferBtmTypeService codeReferBtmTypeService; /** * 相似项查询规则 @@ -3573,6 +3575,7 @@ void bactchExecuteInsert(String tableName, List<Map<String, String>> maps) throws ServiceException{ ExecutorService executor = Executors.newFixedThreadPool(10); // 创建一个固定大小的线程池 List<Map<String, String>> threadSafeMaps = new CopyOnWriteArrayList<>(maps); for (int i = 0; i < threadSafeMaps.size(); i += MAX_IMPORT_NUM) { final int startIndex = i; final int endIndex = Math.min(i + MAX_IMPORT_NUM, maps.size()); @@ -3583,6 +3586,7 @@ commonsMapper.insertByBaseModel(tableName, threadSafeMaps.get(0), subList); }); } // 关闭线程池 executor.shutdown(); try { Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.protobuf.ServiceException; import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; import com.vci.ubcs.code.bo.AttributeValue; import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; @@ -96,8 +97,12 @@ @Value("${batchadd.exportattr.type:基本信息}") public String BATCHADD_EXCEPORT_ATTR_TYPE; @Value("${batchadd.redis.time:6000000}") public int BATCHADD_REDIS_TIME; @Value("${batchadd.import_data_limit:5001}") private Integer IMPORT_DATA_LIMIT; /** * 主题库分类的服务 */ @@ -794,6 +799,10 @@ || sheetDataSetList.get(i).getRowData().size() < 1) { continue; } // 单次导入数量限制 if(sheetDataSetList.get(i).getRowData().size() > IMPORT_DATA_LIMIT){ throw new ServiceException("为了保证系统的稳定性,请一次不要导入超过"+IMPORT_DATA_LIMIT+"条的数据"); } //历史导入的时候不处理编码 //----逻辑内容---- //1. 分类的路径可以在页面上选择是分类编号还是分类的名称 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java
@@ -36,7 +36,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -80,6 +83,10 @@ */ @Autowired private FormulaServiceImpl formulaService; // 注入事务管理器 @Autowired private TransactionTemplate transactionTemplate; @Override @Transactional(rollbackFor = Exception.class) @@ -265,6 +272,10 @@ if(!CollectionUtils.isEmpty(editCodeDOs)){ codeAllCodeService.updateBatchById(editCodeDOs); } // 获取事务定义 DefaultTransactionDefinition def = new DefaultTransactionDefinition(); // 开始事务 TransactionStatus status = transactionTemplate.getTransactionManager().getTransaction(def); if(!CollectionUtils.isEmpty(addCodeDOs)){ Map<String, String> statusMap = addCodeDOs.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); addCodeDOs.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { @@ -303,10 +314,19 @@ if(takeBack.size()>0){ codeAllCodeService.updateBatchById(takeBack); } codeAllCodeService.saveBatch(addCodeDOs); } mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); try { mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); // 提交事务 transactionTemplate.getTransactionManager().commit(status); }catch (Exception e){ // 出现异常时回滚事务 transactionTemplate.getTransactionManager().rollback(status); } } return codeList; }else {