|
@@ -10,16 +10,10 @@ import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.StringPool;
|
|
|
-import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.dto.FormElementDTO2;
|
|
|
import org.springblade.manager.dto.WbsFormElementDTO2;
|
|
|
-import org.springblade.manager.entity.TableInfo;
|
|
|
-import org.springblade.manager.entity.WbsFormElement;
|
|
|
-import org.springblade.manager.entity.WbsTabRelationExcelTab;
|
|
|
-import org.springblade.manager.entity.WbsTree;
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.excel.WbsFormElementBatchExcel;
|
|
|
import org.springblade.manager.excel.WbsFormElementExcel;
|
|
|
import org.springblade.manager.mapper.TableInfoMapper;
|
|
@@ -352,38 +346,52 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
if (StringUtils.isEmpty(wbsFormElementVO2.getInitTableName())) {
|
|
|
throw new ServiceException("未获取到实体表名称,操作失败");
|
|
|
}
|
|
|
- //获取当前表所有元素
|
|
|
- List<WbsFormElement> wbsFormElements = baseMapper.selectList(Wrappers.<WbsFormElement>query().lambda()
|
|
|
- .eq(WbsFormElement::getFId, wbsFormElementVO2.getId()));
|
|
|
- List<String> eKeys = new ArrayList<>();
|
|
|
- wbsFormElements.forEach(id -> {
|
|
|
- String eKey1 = id.getEKey();
|
|
|
- eKeys.add(eKey1);
|
|
|
- });
|
|
|
-
|
|
|
- int id;
|
|
|
- if (eKeys.size() == 0) {
|
|
|
- id = 0;
|
|
|
- } else {
|
|
|
- id = Integer.parseInt(eKeys.get(eKeys.size() - 1).split("_")[1]);
|
|
|
+ WbsTree wbsTree = new WbsTree();
|
|
|
+ wbsTree.setInitTableName(wbsFormElementVO2.getInitTableName());
|
|
|
+ Integer integer = baseMapper.showShowTabLike(wbsTree);
|
|
|
+ if (integer != 1) {
|
|
|
+ throw new ServiceException("实体信息表不存在");
|
|
|
}
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, wbsFormElementVO2.getProjectId()).eq(WbsTreePrivate::getId, wbsFormElementVO2.getId()));
|
|
|
+ if (wbsTreePrivate != null && ObjectUtil.isNotEmpty(wbsTreePrivate.getInitTableId())) {
|
|
|
+ //获取当前表所有元素
|
|
|
+ List<WbsFormElement> wbsFormElements = baseMapper.selectList(Wrappers.<WbsFormElement>query().lambda()
|
|
|
+ .eq(WbsFormElement::getFId, wbsTreePrivate.getInitTableId()));
|
|
|
+ List<String> eKeys = new ArrayList<>();
|
|
|
+ wbsFormElements.forEach(id -> {
|
|
|
+ String eKey1 = id.getEKey();
|
|
|
+ eKeys.add(eKey1);
|
|
|
+ });
|
|
|
+
|
|
|
+ int id;
|
|
|
+ if (eKeys.size() == 0) {
|
|
|
+ id = 0;
|
|
|
+ } else {
|
|
|
+ id = Integer.parseInt(eKeys.get(eKeys.size() - 1).split("_")[1]);
|
|
|
+ }
|
|
|
|
|
|
- //新增元素
|
|
|
- List<WbsFormElement> listData = wbsFormElementVO2.getListData();
|
|
|
- for (WbsFormElement listDatum : listData) {
|
|
|
- id++;
|
|
|
- listDatum.setFId(wbsFormElementVO2.getId());
|
|
|
- String initTableFiledType = WbsElementUtil.getInitTableFiledType(listDatum.getEType());
|
|
|
- Integer elementLength = WbsElementUtil.getElementLength2(initTableFiledType);
|
|
|
- listDatum.setELength(elementLength);
|
|
|
- listDatum.setEKey("key_" + id);
|
|
|
- }
|
|
|
+ //新增元素
|
|
|
+ List<WbsFormElement> listData = wbsFormElementVO2.getListData();
|
|
|
+ for (WbsFormElement listDatum : listData) {
|
|
|
+ id++;
|
|
|
|
|
|
- this.saveBatch(listData);
|
|
|
+ listDatum.setFId(wbsTreePrivate.getInitTableId());
|
|
|
|
|
|
- //同步
|
|
|
- return syncDataFiled(wbsFormElementVO2.getInitTableName(), listData);
|
|
|
+ String initTableFiledType = WbsElementUtil.getInitTableFiledType(listDatum.getEType());
|
|
|
+ Integer elementLength = WbsElementUtil.getElementLength2(initTableFiledType);
|
|
|
+ listDatum.setELength(elementLength);
|
|
|
+ listDatum.setEKey("key_" + id);
|
|
|
+ }
|
|
|
|
|
|
+ this.saveBatch(listData);
|
|
|
+
|
|
|
+ //同步
|
|
|
+ syncDataFiled(wbsFormElementVO2.getInitTableName(), listData);
|
|
|
+ return true;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("未获取到对应元素表的initTableId");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -802,7 +810,19 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
// String initTableFiledType = getInitTableFiledType(listDatum.getEType());
|
|
|
// int elementLength = getElementLength(initTableFiledType);
|
|
|
//同步
|
|
|
- baseMapper.addTableFiled(initTableName, listDatum.getEKey(), "varchar", DEFAULT_ELEMENT_LENGTH_VARCHAR);
|
|
|
+ //判断是否存在该Key字段
|
|
|
+ int row1 = wbsTreeMapper.isThereAField(initTableName, listDatum.getEKey());
|
|
|
+ if (row1 == 0) {
|
|
|
+ //追加字段到实体表中
|
|
|
+ wbsTreeMapper.alterTableFiled(initTableName, listDatum.getEKey(), "varchar", DEFAULT_ELEMENT_LENGTH_VARCHAR);
|
|
|
+ //判断是否追加成功
|
|
|
+ int row2 = wbsTreeMapper.isThereAField(initTableName, listDatum.getEKey());
|
|
|
+ if (row2 != 1) {
|
|
|
+ //追加失败,删除元素,跳过
|
|
|
+ baseMapper.deleteElementByfId2(listDatum.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //baseMapper.addTableFiled(initTableName, listDatum.getEKey(), "varchar", DEFAULT_ELEMENT_LENGTH_VARCHAR);
|
|
|
}
|
|
|
return true;
|
|
|
}
|