|
@@ -17,7 +17,6 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
|
@@ -26,11 +25,9 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
|
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
-import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
-import org.springblade.core.log.logger.BladeLogger;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
@@ -55,7 +52,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
@@ -146,31 +142,17 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
public boolean submit3(WbsTree dept) {
|
|
|
- if (Func.isEmpty(dept.getParentId())) {
|
|
|
- dept.setTenantId(AuthUtil.getTenantId());
|
|
|
- dept.setParentId(BladeConstant.TOP_PARENT_ID);
|
|
|
- dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
|
|
|
- }
|
|
|
if (dept.getParentId() > 0) {
|
|
|
- WbsTree parent = getById(dept.getParentId());
|
|
|
- if (Func.toLong(dept.getParentId()) == Func.toLong(dept.getId())) {
|
|
|
- throw new ServiceException("父节点不可选择自身!");
|
|
|
- }
|
|
|
- dept.setTenantId(parent.getTenantId());
|
|
|
- String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId();
|
|
|
- dept.setAncestors(ancestors);
|
|
|
//设置表示该父节点下存在表单
|
|
|
- baseMapper.updateIsExistFormById(parent.getId());
|
|
|
+ baseMapper.updateIsExistFormById(dept.getParentId());
|
|
|
}
|
|
|
- //设置类型默认值为 '2' 表单
|
|
|
- dept.setType(2);
|
|
|
- dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
- return saveOrUpdate(dept);
|
|
|
+ return save(dept);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* wbs元素表、元素批量导入
|
|
|
+ *
|
|
|
* @param excelFile
|
|
|
* @param wbsTree
|
|
|
* @return
|
|
@@ -187,41 +169,55 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
ArrayList<Map<String, String>> result = excelUtil.readExcelToObj(canonicalPath);
|
|
|
List<Map<String, String>> maps = WbsExcelBatchUtil.removeRepeatMapByKey(result, "表名");
|
|
|
assert maps != null;
|
|
|
- //创建表单,获取Id、deptName、initTableName集合
|
|
|
List<WbsTreeBatchImportDTO> list = new ArrayList<>();
|
|
|
+ //初始化
|
|
|
+ wbsTree.setTenantId(wbsTree.getTenantId());
|
|
|
+ wbsTree.setDeptCategory(1);
|
|
|
+ wbsTree.setWbsId(wbsTree.getWbsId());
|
|
|
+ wbsTree.setParentId(wbsTree.getId());
|
|
|
+ String ancestors = wbsTree.getAncestors() + StringPool.COMMA + wbsTree.getId();
|
|
|
+ wbsTree.setAncestors(ancestors);
|
|
|
+ wbsTree.setType(2);
|
|
|
+ wbsTree.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
|
|
for (Map<String, String> map : maps) {
|
|
|
String deptName = map.get("表名");
|
|
|
- if (deptName.length() > 100 || deptName.length() < 1) {
|
|
|
+ /*if (deptName.length() > 100 || deptName.length() < 1) {
|
|
|
throw new ServiceException("表名长度错误,输入范围1-100个字符长度");
|
|
|
- }
|
|
|
- wbsTree.setWbsId(wbsTree.getWbsId());
|
|
|
+ }*/
|
|
|
wbsTree.setDeptName(deptName);
|
|
|
wbsTree.setTableType(getTableType(map.get("表类型")));
|
|
|
- //初始化实体表名
|
|
|
+ //初始化实体表
|
|
|
Long id = SnowFlakeUtil.getId();
|
|
|
- wbsTree.setId(id);
|
|
|
String initTableName = "m_wbs_form_" + DateUtil.time() + "_" + id.toString();
|
|
|
wbsTree.setInitTableName(initTableName);
|
|
|
+ wbsTree.setId(id);
|
|
|
//创建表单
|
|
|
- submit3(wbsTree);
|
|
|
- //创建对应实体表
|
|
|
- initTable(initTableName);
|
|
|
- //返回信息
|
|
|
- WbsTreeBatchImportDTO wbsTreeBatchImportDTO = new WbsTreeBatchImportDTO();
|
|
|
- wbsTreeBatchImportDTO.setId(id);
|
|
|
- wbsTreeBatchImportDTO.setTableName(deptName);
|
|
|
- wbsTreeBatchImportDTO.setInitTableName(initTableName);
|
|
|
- list.add(wbsTreeBatchImportDTO);
|
|
|
+ boolean b = submit3(wbsTree);
|
|
|
+ if (b) {
|
|
|
+ //创建对应实体表
|
|
|
+ initTable(initTableName);
|
|
|
+ //返回信息
|
|
|
+ WbsTreeBatchImportDTO wbsTreeBatchImportDTO = new WbsTreeBatchImportDTO();
|
|
|
+ wbsTreeBatchImportDTO.setId(id);
|
|
|
+ wbsTreeBatchImportDTO.setTableName(deptName);
|
|
|
+ wbsTreeBatchImportDTO.setInitTableName(initTableName);
|
|
|
+ list.add(wbsTreeBatchImportDTO);
|
|
|
+ }
|
|
|
}
|
|
|
- //创建元素、修改新增对应实体表字段
|
|
|
+ //创建元素并新增对应实体表字段
|
|
|
list.forEach(i -> {
|
|
|
+ Long elementTableId = i.getId();
|
|
|
+ String tableName = i.getTableName();
|
|
|
+ String initTableName = i.getInitTableName();
|
|
|
+
|
|
|
for (Map<String, String> map : result) {
|
|
|
- Long elementTableId = i.getId();
|
|
|
- String tableName = i.getTableName();
|
|
|
- String initTableName = i.getInitTableName();
|
|
|
+ System.out.println("i:"+i);
|
|
|
+ System.out.println("map:"+map);
|
|
|
int keyNumb = 0;
|
|
|
if (tableName.equals(map.get("表名"))) {
|
|
|
- keyNumb++;
|
|
|
+ System.out.println(map);
|
|
|
+ //TODO
|
|
|
+ /*keyNumb++;
|
|
|
WbsFormElement wbsFormElement = new WbsFormElement();
|
|
|
wbsFormElement.setEName(map.get("字段名"));
|
|
|
String key = "key_" + keyNumb;
|
|
@@ -233,16 +229,18 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
wbsFormElement.setEAllowDeviation(map.get("允许偏差范围"));
|
|
|
wbsFormElement.setRemark(map.get("备注"));
|
|
|
wbsFormElementService.save(wbsFormElement);
|
|
|
- //初始化实体表字段
|
|
|
+ //新增实体表字段
|
|
|
baseMapper.alterTableFiled(initTableName,
|
|
|
wbsFormElement.getEKey(),
|
|
|
getInitTableFiledType(wbsFormElement.getEType()),
|
|
|
- wbsFormElement.getELength());
|
|
|
+ wbsFormElement.getELength());*/
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
return true;
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (
|
|
|
+ IOException e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
File file2 = new File(canonicalPath);
|