|
@@ -18,6 +18,12 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import net.sourceforge.pinyin4j.PinyinHelper;
|
|
|
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
|
|
+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.StringUtils;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -40,7 +46,6 @@ import org.springblade.manager.service.IWbsTreeService;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.manager.vo.WbsNodeTableVO;
|
|
|
import org.springblade.manager.vo.WbsTreeAllListVO;
|
|
|
-import org.springblade.manager.vo.WbsTreeContractVO;
|
|
|
import org.springblade.manager.vo.WbsTreeVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -237,7 +242,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
baseMapper.insert(wbsTreeZi);
|
|
|
}
|
|
|
- //TODO 暂时未想到好的处理方法来判断重复条新增问题
|
|
|
+ //TODO 暂未处理重复条新增问题
|
|
|
return wbsTrees;
|
|
|
}
|
|
|
|
|
@@ -350,7 +355,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
projectInfoMapper.updateTemplateIdById(pawDTO.getProjectId(), pawDTO.getWbsId());
|
|
|
pawDTO.setTemplateProjectId(pawDTO.getWbsId());
|
|
|
}
|
|
|
-
|
|
|
//引用项目WBS私有库节点
|
|
|
WbsTreePrivate wbsTreePrivate1 = wbsTreePrivateMapper.selectByCondition(id, pawDTO.getTemplateProjectId());
|
|
|
if (wbsTreePrivate1 != null) {
|
|
@@ -384,9 +388,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
} else {
|
|
|
for (String id : diffrent) {
|
|
|
- //逻辑删除当前节点
|
|
|
+ //删除当前节点
|
|
|
wbsTreePrivateMapper.deleteByCondition(id, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
- //逻辑删除当前节点下元素表 id = parentId
|
|
|
+ //删除节点下元素表 id = parentId
|
|
|
wbsTreePrivateMapper.deleteByCondition2(id, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
}
|
|
|
}
|
|
@@ -425,7 +429,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
String filedType = "";
|
|
|
String filedLength = "";
|
|
|
for (WbsFormElement wbsFormElement : formElementDTO.getElementList()) {
|
|
|
- filedName = wbsFormElement.getEName();
|
|
|
+ filedName = getPinyin(wbsFormElement.getEName(), "");
|
|
|
filedType = String.valueOf(wbsFormElement.getEType());
|
|
|
filedLength = String.valueOf(wbsFormElement.getELength());
|
|
|
}
|
|
@@ -433,39 +437,68 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
return R.fail("操作失败,请完整填写元素参数");
|
|
|
}
|
|
|
//初始化表名
|
|
|
- String newTableName = "m_wbs_form_" + DateUtil.time() + "_" + formElementDTO.getDeptName();
|
|
|
+ String realName = getPinyin(formElementDTO.getDeptName(), "");
|
|
|
+ String newTableName = "m_wbs_form_" + DateUtil.time() + "_" + realName;
|
|
|
formElementDTO.setInitTableName(newTableName);
|
|
|
- //创建表单
|
|
|
+ //创建元素表
|
|
|
boolean b1 = submit2(formElementDTO);
|
|
|
- //判重
|
|
|
String tableId = selectTableIdByTableName(formElementDTO.getDeptName());
|
|
|
if (("-1").equals(tableId)) {
|
|
|
return R.fail("表单名已经存在,请重新填写表单名");
|
|
|
}
|
|
|
- //赋值
|
|
|
List<WbsFormElement> elementList = formElementDTO.getElementList();
|
|
|
+ int i = 1;
|
|
|
for (WbsFormElement wbsFormElement : elementList) {
|
|
|
+ //当前元素表中元素对应实体表唯一key值
|
|
|
+ wbsFormElement.setEKey("key_" + i++);
|
|
|
wbsFormElement.setFId(tableId);
|
|
|
}
|
|
|
//新增元素
|
|
|
boolean b2 = wbsFormElementService.saveBatch(elementList);
|
|
|
- //通过fId查找当前表下的所有元素
|
|
|
List<WbsFormElement> list = wbsFormElementService.selectElementListByFid(tableId);
|
|
|
//初始化实体表单
|
|
|
Boolean b3 = wbsFormElementService.initTable(list, newTableName);
|
|
|
if (b1 && b2 && b3) {
|
|
|
- return R.data(formElementDTO, "新增表单,元素,初始化实体表成功");
|
|
|
+ return R.data(formElementDTO, "新增表单、元素、初始化实体表成功");
|
|
|
} else {
|
|
|
throw new RuntimeException("操作失败");
|
|
|
}
|
|
|
- //TODO 初始化元素(动态更新元素-就是当用户编辑新增元素时,实体表也要同步新增一个字段,编辑、删除一样需要同步,需要在写3个接口)
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public R saveEntityTableField(WbsFormElementDTO wbsFormElementDTO) {
|
|
|
- //TODO 新增元素后更新同步wbs元素到实体表
|
|
|
|
|
|
- return null;
|
|
|
+ public static String getPinyin(String text, String separator) {
|
|
|
+ //text 文本, separator 转换后添加的分隔符
|
|
|
+ char[] chars = text.toCharArray();
|
|
|
+ HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
|
|
|
+ // 设置大小写
|
|
|
+ format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
|
|
+ // 设置声调表示方法
|
|
|
+ format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
|
|
+ // 设置字母u表示方法
|
|
|
+ format.setVCharType(HanyuPinyinVCharType.WITH_V);
|
|
|
+ String[] s;
|
|
|
+ String rs = "";
|
|
|
+ try {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for (int i = 0; i < chars.length; i++) {
|
|
|
+ // 判断是否为汉字字符
|
|
|
+ if (String.valueOf(chars[i]).matches("[\\u4E00-\\u9FA5]+")) {
|
|
|
+ s = PinyinHelper.toHanyuPinyinStringArray(chars[i], format);
|
|
|
+ if (s != null) {
|
|
|
+ sb.append(s[0]).append(separator);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sb.append(chars[i]);
|
|
|
+ if ((i + 1 >= chars.length) || String.valueOf(chars[i + 1]).matches("[\\u4E00-\\u9FA5]+")) {
|
|
|
+ sb.append(separator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rs = sb.substring(0, sb.length());
|
|
|
+ } catch (BadHanyuPinyinOutputFormatCombination e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return rs;
|
|
|
}
|
|
|
|
|
|
|