|
|
@@ -18,7 +18,6 @@ import com.spire.xls.ExcelPicture;
|
|
|
import com.spire.xls.FileFormat;
|
|
|
import com.spire.xls.Worksheet;
|
|
|
import com.spire.xls.collections.PicturesCollection;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
@@ -45,6 +44,7 @@ import org.springblade.business.feign.TrialSelfInspectionRecordClient;
|
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.manager.util.DataStructureFormatUtils;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.common.vo.DataVO;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
@@ -54,7 +54,6 @@ import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
@@ -75,12 +74,10 @@ import org.springblade.manager.vo.*;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.jdbc.core.RowCallbackHandler;
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -92,7 +89,6 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
-import java.nio.file.Files;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
@@ -401,6 +397,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
List<Map<String, Object>> dataMap = this.jdbcTemplate.queryForList(selSql);
|
|
|
if (dataMap.size() > 0) {
|
|
|
dataMap.forEach(map -> {
|
|
|
+ DataStructureFormatUtils.parseDataByKey(map);
|
|
|
TableInfo e = new TableInfo();
|
|
|
e.setPkeyId(map.get("p_key_id").toString());
|
|
|
e.setDataMap(new LinkedHashMap<>());
|
|
|
@@ -738,19 +735,20 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String tabName = tableNode.getInitTableName();
|
|
|
|
|
|
//拼接SQL
|
|
|
- StringBuilder sql = new StringBuilder("INSERT INTO " + tabName),
|
|
|
- keySql = new StringBuilder("id, group_id"),
|
|
|
- valSql = new StringBuilder("" + tableInfo.getBusinessId() + ", " + tableInfo.getPkeyId());
|
|
|
+// StringBuilder sql = new StringBuilder("INSERT INTO " + tabName),
|
|
|
+// keySql = new StringBuilder("id, group_id"),
|
|
|
+// valSql = new StringBuilder("" + tableInfo.getBusinessId() + ", " + tableInfo.getPkeyId());
|
|
|
|
|
|
//参数
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- updateFieldLength(tabName, dataMap2);
|
|
|
- for (String key : dataMap2.keySet()) {
|
|
|
- keySql.append(", ").append(key);
|
|
|
- valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
- }
|
|
|
-
|
|
|
- sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+ dataMap2.remove("p_key_id");
|
|
|
+ StringBuilder sql = buildMTableInsertSql(tabName, dataMap2, tableInfo.getBusinessId(), tableInfo.getPkeyId(), null);
|
|
|
+// for (String key : dataMap2.keySet()) {
|
|
|
+// keySql.append(", ").append(key);
|
|
|
+// valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
+// }
|
|
|
+//
|
|
|
+// sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
|
|
|
//新增数据
|
|
|
try {
|
|
|
@@ -1116,18 +1114,17 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
for (TableInfo tableInfo : tableInfoList) {
|
|
|
//获取字段信息
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- updateFieldLength(table.getTabEnName(),dataMap2);
|
|
|
- //拼接SQL
|
|
|
- StringBuilder sql = new StringBuilder("INSERT INTO " + table.getTabEnName()),
|
|
|
- keySql = new StringBuilder("id, group_id"),
|
|
|
- valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
-
|
|
|
- for (String key : dataMap2.keySet()) {
|
|
|
- keySql.append(", ").append(key);
|
|
|
- valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
- }
|
|
|
-
|
|
|
- sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+ StringBuilder sql = buildMTableInsertSql(table.getTabEnName(), dataMap2, SnowFlakeUtil.getId(), firstId, null);
|
|
|
+// // 拼接SQL
|
|
|
+// StringBuilder sql = new StringBuilder("INSERT INTO " + table.getTabEnName()),
|
|
|
+// keySql = new StringBuilder("id, group_id"),
|
|
|
+// valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
+// for (String key : dataMap2.keySet()) {
|
|
|
+// keySql.append(", ").append(key);
|
|
|
+// valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
+// }
|
|
|
+//
|
|
|
+// sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
|
|
|
//新增数据
|
|
|
try {
|
|
|
@@ -1221,7 +1218,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R<Object> saveOrUpdateInfo(List<TableInfo> tableInfoList,String sigType) {
|
|
|
+ public R<Object> saveOrUpdateInfo(List<TableInfo> tableInfoList,String sigType,Boolean flag) {
|
|
|
List<TableInfo> tableInfoList2 = new ArrayList<>();
|
|
|
String fileName1="";
|
|
|
if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
|
@@ -1233,6 +1230,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
for (TableInfo tableInfo : tableInfoList) {
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, tableInfo.getPkeyId()));
|
|
|
+ StringBuilder tableName = new StringBuilder("");
|
|
|
if (wbsTreeContract == null) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -1244,21 +1242,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
|
|
|
String sqlInfo = "";
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- updateFieldLength(tabName, dataMap2);
|
|
|
/*检查发现有p_key_id缺失的情况,导致表单数据丢失,所以强制覆盖*/
|
|
|
dataMap2.put("p_key_id", tableInfo.getPkeyId());
|
|
|
+ sqlInfo = buildMTableInsertSql(tabName, dataMap2, SnowFlakeUtil.getId(), null, null).toString();
|
|
|
//统计保存的字段
|
|
|
|
|
|
- sqlInfo = "INSERT INTO " + tabName + " ( ";
|
|
|
- String keyStr = "id,";
|
|
|
- String valStr = SnowFlakeUtil.getId() + ",";
|
|
|
- for (String keys : dataMap2.keySet()) {
|
|
|
- keyStr += keys + ",";
|
|
|
- valStr += "'" + dataMap2.get(keys) + "',";
|
|
|
- }
|
|
|
- keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
|
|
|
- valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
- sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
+// sqlInfo = "INSERT INTO " + tabName + " ( ";
|
|
|
+// String keyStr = "id,";
|
|
|
+// String valStr = SnowFlakeUtil.getId() + ",";
|
|
|
+// for (String keys : dataMap2.keySet()) {
|
|
|
+// keyStr += keys + ",";
|
|
|
+// valStr += "'" + dataMap2.get(keys) + "',";
|
|
|
+// }
|
|
|
+// keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
|
|
|
+// valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
+// sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
|
|
|
WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId, tableInfo.getContractId()));
|
|
|
@@ -1305,13 +1303,18 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
transactionManager1.commit(transactionStatus);
|
|
|
} catch (Exception e) {
|
|
|
- transactionManager1.rollback(transactionStatus);
|
|
|
- log.append(e.getMessage()).append("@@");
|
|
|
- e.printStackTrace();
|
|
|
- return R.fail(reason(e.getMessage()));
|
|
|
+ //是否回滚
|
|
|
+ if(flag){
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+ log.append(e.getMessage()).append("@@");
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail(reason(e.getMessage()));
|
|
|
+ }else {
|
|
|
+ tableName.append(wbsTreeContract.getNodeName()+",");
|
|
|
+ RandomNumberHolder.setLogMessage(tableName.toString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//获取节点
|
|
|
WbsTreeContract wbsTreeContract = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
@@ -1354,60 +1357,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return R.data(tableInfoList2);
|
|
|
// return R.success(fileName1);
|
|
|
}
|
|
|
-
|
|
|
- public void updateFieldLength(String tableName, Map<String, String> fieldNameAndLengthMap) {
|
|
|
- if (fieldNameAndLengthMap == null || fieldNameAndLengthMap.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- String fields = fieldNameAndLengthMap.keySet().stream().filter(key -> !key.equals("id") && !key.equals("p_key_id") && !key.equals("group_id")).map(key -> "'" + key + "'").collect(Collectors.joining(","));
|
|
|
- if (fields.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<Map<String, Object>> fieldMap = jdbcTemplate.queryForList("select distinct COLUMN_NAME as fieldName, CHARACTER_MAXIMUM_LENGTH as fieldLength from information_schema.COLUMNS where TABLE_NAME = '" + tableName +
|
|
|
- "' and COLUMN_NAME in (" + fields + ")");
|
|
|
- Map<String, Integer> map = fieldMap.stream().collect(toMap(k -> k.get("fieldName") + "", v -> {
|
|
|
- try {
|
|
|
- return Integer.parseInt(v.get("fieldLength") + "");
|
|
|
- } catch (Exception e) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }, Math::max));
|
|
|
-
|
|
|
- List<WbsFormElement> elementList = jdbcTemplate.query("SELECT id,e_key,e_length from m_wbs_form_element WHERE f_id = (SELECT id from m_table_info WHERE tab_en_name = '" + tableName
|
|
|
- +"' and is_deleted = 0 limit 1) and is_deleted = 0 and e_key in ( " + fields + ")", new BeanPropertyRowMapper<>(WbsFormElement.class));
|
|
|
- StringBuilder sql = new StringBuilder();
|
|
|
- sql.append("alter table ").append(tableName);
|
|
|
- elementList.forEach(element -> {
|
|
|
- String data = fieldNameAndLengthMap.get(element.getEKey());
|
|
|
- Integer fieldLength = map.get(element.getEKey());
|
|
|
- if (data != null && element.getELength() != null && data.length() > fieldLength) {
|
|
|
- int length = data.length();
|
|
|
- // 取整
|
|
|
- length = (length / 10 + 1) * 10;
|
|
|
- if (length < element.getELength()) {
|
|
|
- length = element.getELength();
|
|
|
- element.setELength(null);
|
|
|
- } else {
|
|
|
- element.setELength(length);
|
|
|
- }
|
|
|
- sql.append(" modify column ").append(element.getEKey()).append(" ").append("varchar").append("(").append(length).append("),");
|
|
|
- }
|
|
|
- });
|
|
|
- if (sql.indexOf("modify") > 0) {
|
|
|
- sql.deleteCharAt(sql.length() - 1);
|
|
|
- TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
- try {
|
|
|
- jdbcTemplate.batchUpdate("update m_wbs_form_element set e_length = ? where id = ?", elementList.stream().filter(element -> element.getELength() != null).map(element -> new Object[]{element.getELength(), element.getId()}).collect(Collectors.toList()));
|
|
|
- jdbcTemplate.execute(sql.toString());
|
|
|
- transactionManager1.commit(transactionStatus);
|
|
|
- } catch (Exception e) {
|
|
|
- transactionManager1.rollback(transactionStatus);
|
|
|
- log.error("更新字段长度失败, error: " + e.getMessage());
|
|
|
- throw new ServiceException("字段长度超出限制, 系统无法进行扩容,请尝试缩小字段长度或者联系系统管理员处理");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public String reason(String log) {
|
|
|
/*保存的时候错误提示例如:字段过短提示 yangyj*/
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
@@ -1428,6 +1377,110 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
return sb.append("保存异常,请联系管理员").toString();
|
|
|
}
|
|
|
+ public StringBuilder buildMTableInsertSql(String tabName, Map<String, String> dataMap2, Object id, Object groupId, Object pKeyId) {
|
|
|
+ if (dataMap2 == null || dataMap2.isEmpty() || tabName == null || tabName.isEmpty()) {
|
|
|
+ return new StringBuilder();
|
|
|
+ }
|
|
|
+ //拼接SQL
|
|
|
+ StringBuilder sql = new StringBuilder("INSERT INTO " + tabName),
|
|
|
+ keySql = new StringBuilder(),
|
|
|
+ valSql = new StringBuilder();
|
|
|
+ if (id == null) {
|
|
|
+ if (dataMap2.containsKey("id")) {
|
|
|
+ id = dataMap2.get("id");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ keySql.append("id");
|
|
|
+ valSql.append(id == null ? SnowFlakeUtil.getId() : id);
|
|
|
+ if (groupId == null) {
|
|
|
+ groupId = dataMap2.get("group_id");
|
|
|
+ }
|
|
|
+ if (groupId != null) {
|
|
|
+ keySql.append(", group_id");
|
|
|
+ valSql.append(", ").append(groupId);
|
|
|
+ }
|
|
|
+ if (pKeyId == null) {
|
|
|
+ pKeyId = dataMap2.get("p_key_id");
|
|
|
+ }
|
|
|
+ if (pKeyId != null) {
|
|
|
+ keySql.append(", p_key_id");
|
|
|
+ valSql.append(", ").append(pKeyId);
|
|
|
+ }
|
|
|
+ //参数
|
|
|
+ Map<String, String> opsParamMap = new HashMap<>();
|
|
|
+ dataMap2.remove("id");
|
|
|
+ dataMap2.remove("group_id");
|
|
|
+ dataMap2.remove("p_key_id");
|
|
|
+ String key201 = dataMap2.remove("key_201");
|
|
|
+ String fields = dataMap2.keySet().stream().map(key -> "'" + key + "'").collect(Collectors.joining(","));
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ if (!fields.isEmpty()) {
|
|
|
+ try {
|
|
|
+ fields = fields + ", 'key_201'";
|
|
|
+ List<Map<String, Object>> fieldMap = jdbcTemplate.queryForList("select distinct COLUMN_NAME as fieldName, CHARACTER_MAXIMUM_LENGTH as fieldLength from information_schema.COLUMNS where TABLE_NAME = '" + tabName +
|
|
|
+ "' and COLUMN_NAME in (" + fields + ")");
|
|
|
+ map = fieldMap.stream().collect(toMap(k -> k.get("fieldName") + "", v -> {
|
|
|
+ try {
|
|
|
+ return Integer.parseInt(v.get("fieldLength") + "");
|
|
|
+ } catch (Exception e) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }, Math::min));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (key201 != null) {
|
|
|
+ Map<String, String> map1 = DataStructureFormatUtils.parseDataByKey(key201);
|
|
|
+ if (!map1.isEmpty()) {
|
|
|
+ opsParamMap.putAll(map1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String key : dataMap2.keySet()) {
|
|
|
+ String[] split = key.split("_");
|
|
|
+ if (split.length > 1 && Integer.parseInt(split[1]) > 80) {
|
|
|
+ // 大于80则保留在扩展字段中
|
|
|
+ opsParamMap.put(key, dataMap2.get(key));
|
|
|
+ } else {
|
|
|
+ String value = dataMap2.get(key);
|
|
|
+ if (value != null) {
|
|
|
+ Integer i = map.get(key);
|
|
|
+ // 长度超过数据库长度也保留在扩展字段中
|
|
|
+ if (i != null && value.length() > i) {
|
|
|
+ opsParamMap.put(key, dataMap2.get(key));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ keySql.append(", ").append(key);
|
|
|
+ valSql.append(", '").append(value).append("'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!opsParamMap.isEmpty()) {
|
|
|
+ keySql.append(", key_201");
|
|
|
+ String data = DataStructureFormatUtils.buildData(opsParamMap);
|
|
|
+ try {
|
|
|
+ if (!map.containsKey( "key_201")) {
|
|
|
+ jdbcTemplate.execute("alter table " + tabName + " add column key_201 text");
|
|
|
+ } else {
|
|
|
+ Integer i = map.get("key_201");
|
|
|
+ if (data.length() > i) {
|
|
|
+ if (i < 10000) {
|
|
|
+ // 65535 byte
|
|
|
+ jdbcTemplate.execute("alter table " + tabName + " modify column key_201 text");
|
|
|
+ }else {
|
|
|
+ // 16777215 byte
|
|
|
+ jdbcTemplate.execute("alter table " + tabName + " modify column key_201 mediumtext");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ valSql.append(", '").append(data).append("'");
|
|
|
+ }
|
|
|
+ sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+ return sql;
|
|
|
+ }
|
|
|
|
|
|
// 获取用户
|
|
|
@Override
|
|
|
@@ -1690,6 +1743,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (dataIn != null && dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
@@ -1979,6 +2033,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (dataIn != null && dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
@@ -2838,6 +2893,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//实体数据
|
|
|
String querySql = "select * from " + wbsTreePrivate.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + groupId;
|
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
String keyNames="";
|
|
|
//匹配关联
|
|
|
try {
|
|
|
@@ -2854,6 +2912,20 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
+
|
|
|
+
|
|
|
+ // 获取默认值
|
|
|
+ Elements elements = doc.getElementsByAttribute("defText");
|
|
|
+ if(Func.isNotEmpty(elements) && elements.size()>=1){
|
|
|
+ for(Element eleme: elements){
|
|
|
+ String id = Func.isNull(eleme.attr("id"))?eleme.attr("keyname"):eleme.attr("id");
|
|
|
+ if(Func.isNotEmpty(id)){
|
|
|
+
|
|
|
+ reData.put(id, eleme.attr("defText"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
keyNames= getKeyNameList(doc);
|
|
|
TrialSelfInspectionRecord record = jdbcTemplate.query("select * from u_trial_self_inspection_record where id = " + groupId, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
|
|
|
// 优先使用试验记录中的委托单和样品
|
|
|
@@ -3070,11 +3142,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
reData1=new HashMap<>(reData);
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
|
|
|
if ((tabVal.contains("BG-") || tabVal.contains("JL-")) && Func.isNotEmpty(contractInfo.getIsTestRecord()) && contractInfo.getIsTestRecord()==1) {
|
|
|
//重新生成自己的编号,不引用旧编号
|
|
|
+
|
|
|
continue;
|
|
|
}
|
|
|
// 时间段处理
|
|
|
@@ -3150,25 +3224,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- // 获取默认值
|
|
|
- QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.select("col_key", "sig_role_name");
|
|
|
- queryWrapper.eq("type", 4);
|
|
|
- queryWrapper.eq("tab_id", wbsTreePrivate.getPKeyId());
|
|
|
- final List<TextdictInfo> textDictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
- if (!textDictInfos.isEmpty()) {
|
|
|
- for (TextdictInfo textdictInfo : textDictInfos) {
|
|
|
- if (reData.containsKey(textdictInfo.getColKey())) {
|
|
|
- String keyVal = reData.get(textdictInfo.getColKey()) + "";
|
|
|
- } else {
|
|
|
- reData.put(textdictInfo.getColKey() + "", textdictInfo.getSigRoleName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// 移除Id 和 p_key_id
|
|
|
reData.remove("id");
|
|
|
@@ -3196,13 +3259,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(reData1.size()>0){
|
|
|
+ /*if(reData1.size()>0){
|
|
|
for (Map.Entry<String, Object> entry : reData1.entrySet()) {
|
|
|
if(reData.containsKey(entry.getKey())){
|
|
|
reData.put(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
list.add(reData);
|
|
|
return list;
|
|
|
}
|
|
|
@@ -3351,6 +3414,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
|
|
|
@@ -4013,22 +4077,22 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//新增SQL
|
|
|
String sqlInfo = "";
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- updateFieldLength(wbsTreePrivate.getInitTableName() ,dataMap2);
|
|
|
if(!dataMap2.containsKey("p_key_id")){
|
|
|
if(tableInfo.getPkeyId()!=null&&!tableInfo.getPkeyId().equals("")){
|
|
|
dataMap2.put("p_key_id",tableInfo.getPkeyId());
|
|
|
}
|
|
|
}
|
|
|
- sqlInfo = "INSERT INTO " + wbsTreePrivate.getInitTableName() + " ( ";
|
|
|
- String keyStr = "id,group_id,";
|
|
|
- String valStr = SnowFlakeUtil.getId() + "," + groupId + ",";
|
|
|
- for (String keys : dataMap2.keySet()) {
|
|
|
- keyStr += keys + ",";
|
|
|
- valStr += "'" + dataMap2.get(keys) + "',";
|
|
|
- }
|
|
|
- keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
|
|
|
- valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
- sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
+ sqlInfo = buildMTableInsertSql(wbsTreePrivate.getInitTableName(), dataMap2, SnowFlakeUtil.getId(), groupId, tableInfo.getPkeyId()).toString();
|
|
|
+// sqlInfo = "INSERT INTO " + wbsTreePrivate.getInitTableName() + " ( ";
|
|
|
+// String keyStr = "id,group_id,";
|
|
|
+// String valStr = SnowFlakeUtil.getId() + "," + groupId + ",";
|
|
|
+// for (String keys : dataMap2.keySet()) {
|
|
|
+// keyStr += keys + ",";
|
|
|
+// valStr += "'" + dataMap2.get(keys) + "',";
|
|
|
+// }
|
|
|
+// keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
|
|
|
+// valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
+// sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
try {
|
|
|
//删除
|
|
|
@@ -5281,6 +5345,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
@@ -5402,6 +5467,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
format= simpleDateFormat.format(mobilizationDate);
|
|
|
}
|
|
|
+ String jingchang;
|
|
|
+ if(StringUtils.isNotEmpty(format)&&StringUtils.isNotEmpty(representativeCount)){
|
|
|
+ jingchang=format+"/"+representativeCount;
|
|
|
+ } else if (StringUtils.isNotEmpty(format)&&StringUtils.isEmpty(representativeCount)) {
|
|
|
+ jingchang=format;
|
|
|
+ }else {
|
|
|
+ jingchang=representativeCount;
|
|
|
+ }
|
|
|
setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData,isCancelList);
|
|
|
setFirstData(doc,"生产批号",sampleInfo.getBatchNumber(),reData,isCancelList);
|
|
|
setFirstData(doc,"生产厂家",sampleInfo.getSupplierUnit(),reData,isCancelList);
|
|
|
@@ -5431,7 +5504,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
setFirstData(doc,"用途(使用在何工程部位)",sampleInfo.getProposedPosition(),reData,isCancelList);
|
|
|
setFirstData(doc,"成型日期",null,reData,isCancelList);
|
|
|
// setFirstData(doc,"试件编号",sampleInfo.getSpecificationNumber(),reData,isCancel,isCancelList);
|
|
|
- setFirstData(doc,"进场日期代表数量",format+"/"+representativeCount+calculationUnit,reData,isCancelList);
|
|
|
+ setFirstData(doc,"进场日期/ 代表数量",jingchang,reData,isCancelList);
|
|
|
setFirstData(doc,"材料进场日期",format,reData,isCancelList);
|
|
|
|
|
|
if(entrustInfo != null){
|
|
|
@@ -5509,66 +5582,56 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
* @param reData
|
|
|
*/
|
|
|
private static void setFirstData(Document doc, String elementValue,Object value,Map<String, Object> reData,List<String> isCancelList) {
|
|
|
-
|
|
|
if(value==null){
|
|
|
value="";
|
|
|
}
|
|
|
Elements select = doc.select("[placeholderxx=" + elementValue + "]");
|
|
|
-
|
|
|
if(select.isEmpty()){//没找到加上:继续找
|
|
|
String elementValueNew = elementValue + ":";
|
|
|
select = doc.select("[placeholderxx=" + elementValueNew + "]");
|
|
|
}
|
|
|
- if(select.isEmpty()){// 以传入的参数为结尾 继续找
|
|
|
- select = doc.select("[placeholderxx$=" + elementValue + "]");
|
|
|
+ if(select.isEmpty()){
|
|
|
+ if(!elementValue.equals("代表数量")){
|
|
|
+ // 以传入的参数为结尾 继续找
|
|
|
+ select = doc.select("[placeholderxx$=" + elementValue + "]");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
if (!select.isEmpty()) {//找到元素后 获取输入框
|
|
|
-
|
|
|
Element textareaElement = select.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
|
|
|
if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){//特殊处理日期 没有id属性获取keyName
|
|
|
textareaElement = select.first();
|
|
|
String keyName = textareaElement.attr("keyName");
|
|
|
if(ObjectUtil.isNotEmpty(value)){
|
|
|
- reData.put(keyName, value);
|
|
|
+ if(!reData.containsKey(keyName)||reData.get(keyName)==null||reData.get(keyName).equals("")){
|
|
|
+ reData.put(keyName, value);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return ;
|
|
|
}
|
|
|
if(textareaElement != null){//正常情况
|
|
|
String id = textareaElement.attr("id");
|
|
|
isCancelList.add(id);
|
|
|
if(ObjectUtil.isNotEmpty(value)){
|
|
|
- reData.put(id, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {// 没有找到 可能格式不同 换一种方式找
|
|
|
- Elements select2 = doc.select("[titlexx$="+elementValue+"]");
|
|
|
- if(select2.isEmpty()){//还是没找到 进入特殊情况
|
|
|
- if(elementValue.equals("进场日期代表数量")){
|
|
|
- Elements select1 = doc.select("[titlexx=\"进场日期/ 代表数量\"]");
|
|
|
- Element textareaElement = select1.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
|
|
|
- if(textareaElement != null){
|
|
|
- List<Node> nodes = textareaElement.childNodes();
|
|
|
- Node node = nodes.get(1);
|
|
|
- String id = node.attributes().get("id");
|
|
|
- if(ObjectUtil.isNotEmpty(value)){
|
|
|
- reData.put(id, value);
|
|
|
- }
|
|
|
-
|
|
|
+ if(!reData.containsKey(id)||reData.get(id)==null||reData.get(id).equals("")){
|
|
|
+ reData.put(id, value);
|
|
|
}
|
|
|
- }else {
|
|
|
- System.out.println("没有找到[" + elementValue + "]的元素");
|
|
|
}
|
|
|
- }else {
|
|
|
- //另一种方式找到后 获取id的值并赋值到map
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Elements select2 = null;
|
|
|
+ if(!elementValue.equals("代表数量")){
|
|
|
+ // 没有找到 可能格式不同 换一种方式找
|
|
|
+ select2= doc.select("[titlexx$="+elementValue+"]");
|
|
|
+ }
|
|
|
+ if(select2!=null&&!select2.isEmpty()){
|
|
|
Element textareaElement = select2.first();
|
|
|
if(textareaElement != null){//正常情况
|
|
|
String id = textareaElement.attr("id");
|
|
|
isCancelList.add(id);
|
|
|
if(ObjectUtil.isNotEmpty(value)){
|
|
|
- reData.put(id, value);
|
|
|
+ if(!reData.containsKey(id)||reData.get(id)==null||reData.get(id).equals("")){
|
|
|
+ reData.put(id, value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -5705,6 +5768,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey(mysqlData);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
@@ -6363,7 +6427,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
//表单排序
|
|
|
- resultList.sort(new ExcelTabServiceImpl.WbsTreeContractComparator());
|
|
|
+ resultList.sort(new WbsTreeContractComparator());
|
|
|
//根据规则生成编号
|
|
|
List<String> numbers = generateNumbers(dto);
|
|
|
//构造入库数据
|