|
@@ -1,9 +1,19 @@
|
|
|
package com.dragoninfo.dcuc.app.service.sub.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.dragoninfo.dcuc.app.entity.sub.AppColumnRelation;
|
|
|
import com.dragoninfo.dcuc.app.mapper.sub.AppColumnRelationMapper;
|
|
|
import com.dragoninfo.dcuc.app.service.sub.IAppColumnRelationService;
|
|
|
+import com.dragoninfo.dcuc.app.vo.AppColumnRelationVO;
|
|
|
+import com.dragoninfo.dcuc.app.vo.DataLevelVo;
|
|
|
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -19,4 +29,60 @@ public class AppColumnRelationServiceImpl implements IAppColumnRelationService {
|
|
|
@Autowired
|
|
|
private AppColumnRelationMapper appColumnRelationMapper;
|
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ @Override
|
|
|
+ public void sync(List<AppColumnRelationVO> list) {
|
|
|
+ for (AppColumnRelationVO appColumnRelationVO : list) {
|
|
|
+
|
|
|
+ String codeValue = appColumnRelationVO.getCodeValue();
|
|
|
+ String codeName = appColumnRelationVO.getCodeName();
|
|
|
+ AppColumnRelation appColumnRelation = getByCode(codeValue);
|
|
|
+ if (appColumnRelation == null) {
|
|
|
+ appColumnRelation = new AppColumnRelation();
|
|
|
+ appColumnRelation.setDeleted(BooleanEnum.FALSE.value);
|
|
|
+ appColumnRelation.setCodeValue(codeValue);
|
|
|
+ appColumnRelation.setCodeName(codeName);
|
|
|
+
|
|
|
+ String columnOneClassValue = getOneCodeVale(codeValue);
|
|
|
+
|
|
|
+ String columnTwoClassValue = getTwoCodeVale(codeValue);
|
|
|
+ appColumnRelation.setColumnOneClassValue(columnOneClassValue);
|
|
|
+ appColumnRelation.setColumnTwoClassValue(columnTwoClassValue);
|
|
|
+ appColumnRelationMapper.insert(appColumnRelation);
|
|
|
+ } else {
|
|
|
+ appColumnRelation.setCodeName(appColumnRelation.getCodeName());
|
|
|
+ appColumnRelationMapper.updateById(appColumnRelation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public AppColumnRelation getByCode(String code) {
|
|
|
+ LambdaQueryWrapper<AppColumnRelation> lambdaQuery = Wrappers.lambdaQuery();
|
|
|
+ lambdaQuery.eq(AppColumnRelation::getCodeValue, code);
|
|
|
+ return appColumnRelationMapper.selectOne(lambdaQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getOneCodeVale(String relationCodeValue) {
|
|
|
+ if (StrUtil.isBlank(relationCodeValue)) {
|
|
|
+ throw new IllegalArgumentException();
|
|
|
+ }
|
|
|
+ String[] split = relationCodeValue.split("->");
|
|
|
+ String onFullInfo = split[0];
|
|
|
+
|
|
|
+ String[] onFullInfoStrings = onFullInfo.split("_");
|
|
|
+ return onFullInfoStrings[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getTwoCodeVale(String relationCodeValue) {
|
|
|
+ if (StrUtil.isBlank(relationCodeValue)) {
|
|
|
+ throw new IllegalArgumentException();
|
|
|
+ }
|
|
|
+ String[] split = relationCodeValue.split("->");
|
|
|
+ String onFullInfo = split[1];
|
|
|
+
|
|
|
+ String[] onFullInfoStrings = onFullInfo.split("_");
|
|
|
+ return onFullInfoStrings[1];
|
|
|
+ }
|
|
|
+
|
|
|
}
|