|
@@ -27,15 +27,11 @@ import org.springblade.manager.service.IExcelTabService;
|
|
|
import org.springblade.manager.service.ITableInfoService;
|
|
|
import org.springblade.manager.service.IWbsFormElementService;
|
|
|
import org.springblade.manager.utils.WbsElementUtil;
|
|
|
-import org.springblade.manager.vo.TableInfoVO;
|
|
|
import org.springblade.manager.vo.WbsFormElementVO;
|
|
|
import org.springblade.manager.vo.WbsFormElementVO2;
|
|
|
import org.springblade.manager.vo.WbsNodeTableVO;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
-import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.lang.Nullable;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -95,17 +91,17 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
try {
|
|
|
boolean b = wbsFormElementMapper.createTable(sql, tableName) >= 0;
|
|
|
return b;
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private String createSQL(List<WbsFormElement> elementList) {
|
|
|
StringBuilder sbr = new StringBuilder();
|
|
|
- String datalengh =ELEMENT_LENGTH_ENTITY;
|
|
|
- Integer data = (int) Math.floor(65000/3/elementList.size());
|
|
|
- if(data< Func.toInt(ELEMENT_LENGTH_ENTITY)){
|
|
|
- datalengh = data+"";
|
|
|
+ String datalengh = ELEMENT_LENGTH_ENTITY;
|
|
|
+ Integer data = (int) Math.floor(65000 / 3 / elementList.size());
|
|
|
+ if (data < Func.toInt(ELEMENT_LENGTH_ENTITY)) {
|
|
|
+ datalengh = data + "";
|
|
|
}
|
|
|
for (WbsFormElement wbsFormElement : elementList) {
|
|
|
//默认字段类型varchar 长度255
|
|
@@ -257,7 +253,7 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
baseMapper.deleteElement(wbsFormElement);
|
|
|
- throw new ServiceException("同步元素字段异常,操作失败:"+e.getMessage());
|
|
|
+ throw new ServiceException("同步元素字段异常,操作失败:" + e.getMessage());
|
|
|
}
|
|
|
return wbsFormElement;
|
|
|
}
|
|
@@ -286,22 +282,23 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
public R updateAndSyn(List<WbsFormElement> wbsFormElementList, String initTableName) {
|
|
|
if (StringUtils.isEmpty(initTableName)) {
|
|
|
return R.fail("未获取到initTableName对应实体表名称,操作失败");
|
|
|
}
|
|
|
//校验,不能在同一个表单中,为多个字段配置相同的统计标识
|
|
|
Map<Integer, List<WbsFormElement>> collect = wbsFormElementList.stream()
|
|
|
- .filter(l->Objects.nonNull(l.getDynamicDict()))
|
|
|
- .filter(l-> l.getDynamicDict() != 0)
|
|
|
+ .filter(l -> Objects.nonNull(l.getDynamicDict()))
|
|
|
+ .filter(l -> l.getDynamicDict() != 0)
|
|
|
.collect(Collectors.groupingBy(WbsFormElement::getDynamicDict));
|
|
|
for (Integer index : collect.keySet()) {
|
|
|
- if (collect.get(index).size() >= 2 && index>=12 && index<1){
|
|
|
+ if (collect.get(index).size() >= 2 && index >= 12 && index < 1) {
|
|
|
return R.fail("不能在一张表中,为多个字段配置相同的统计标识,请重新配置");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //修改之前的值
|
|
|
+ String fId1 = wbsFormElementList.get(0).getFId();
|
|
|
+ List<WbsFormElement> beforeUpdateWbsFormElements = baseMapper.selectList(Wrappers.<WbsFormElement>query().lambda().eq(WbsFormElement::getFId, fId1));
|
|
|
//修改元素基础信息
|
|
|
wbsFormElementList.forEach(obj -> obj.setStatus(1));
|
|
|
boolean b = this.updateBatchById(wbsFormElementList);
|
|
@@ -318,36 +315,41 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
|
|
|
for (WbsFormElement wbsFormElement : wbsFormElements) {
|
|
|
String eKey = wbsFormElement.getEKey();
|
|
|
+ String eName = wbsFormElement.getEName();
|
|
|
Integer eLength = wbsFormElement.getELength();
|
|
|
String eType = WbsElementUtil.getInitTableFiledType(wbsFormElement.getEType());
|
|
|
|
|
|
if (eType.equals("bigint") && (eLength > 255 || eLength < 10)) {
|
|
|
- return R.fail(eKey+"请输入正确长度,该类型范围为10-255之间");
|
|
|
- } else if (eType.equals("varchar") && (eLength > 2000 || eLength < 10)) {
|
|
|
- return R.fail(eKey+"请输入正确长度,该类型范围为10-1000之间");
|
|
|
+ this.updateBatchById(beforeUpdateWbsFormElements);
|
|
|
+ return R.fail(eKey+"元素名称:"+eName+"请输入正确长度,该类型范围为10-255之间");
|
|
|
+ } else if (eType.equals("varchar") && (eLength > 3000 || eLength < 10)) {
|
|
|
+ this.updateBatchById(beforeUpdateWbsFormElements);
|
|
|
+ return R.fail(eKey+"元素名称:"+eName+"请输入正确长度,该类型范围为10-3000之间");
|
|
|
} else if (eType.equals("decimal") && (eLength > 65 || eLength < 10)) {
|
|
|
- return R.fail(eKey+"请输入正确长度,该类型范围为10-65之间");
|
|
|
- } else if (eType.equals("datetime") && (eLength > 100 || eLength < 0)) {
|
|
|
- return R.fail(eKey+"请输入正确长度,该类型范围为0-100之间");
|
|
|
+ this.updateBatchById(beforeUpdateWbsFormElements);
|
|
|
+ return R.fail(eKey+"元素名称:"+eName+"请输入正确长度,该类型范围为10-65之间");
|
|
|
+ } else if (eType.equals("datetime") && (eLength > 400 || eLength < 0)) {
|
|
|
+ this.updateBatchById(beforeUpdateWbsFormElements);
|
|
|
+ return R.fail(eKey+"元素名称:"+eName+"请输入正确长度,该类型范围为0-400之间");
|
|
|
}
|
|
|
|
|
|
//设置默认长度
|
|
|
- if (eLength <= 255 && eLength > 65) {
|
|
|
- eLength = DEFAULT_ELEMENT_LENGTH_VARCHAR;
|
|
|
- } else if (eLength <= 1000 && eLength > 500) {
|
|
|
- eLength = DEFAULT_ELEMENT_LENGTH_VARCHAR * 2;
|
|
|
- } else if (eLength >= 0 && eLength <= 65) {
|
|
|
- eLength = DEFAULT_ELEMENT_LENGTH_NUMBER;
|
|
|
- }
|
|
|
+// if (eLength <= 255 && eLength > 65) {
|
|
|
+// eLength = DEFAULT_ELEMENT_LENGTH_VARCHAR;
|
|
|
+// } else if (eLength <= 1000 && eLength > 500) {
|
|
|
+// eLength = DEFAULT_ELEMENT_LENGTH_VARCHAR * 2;
|
|
|
+// } else if (eLength >= 0 && eLength <= 65) {
|
|
|
+// eLength = DEFAULT_ELEMENT_LENGTH_NUMBER;
|
|
|
+// }
|
|
|
|
|
|
//判断是否存在该Key字段
|
|
|
int row1 = wbsTreeMapper.isThereAField(initTableName, eKey);
|
|
|
if (row1 > 0) {
|
|
|
try {
|
|
|
baseMapper.updateFiledType(initTableName, eKey, "varchar", eLength);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return R.fail(eKey+"--"+e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ this.updateBatchById(beforeUpdateWbsFormElements);
|
|
|
+ throw new RuntimeException("字段长度范围超出总最大限制,请尝试缩小当前字段长度或其他字段长度");
|
|
|
}
|
|
|
}
|
|
|
}
|