|
@@ -19,6 +19,7 @@ import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
@@ -41,6 +42,7 @@ import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.common.vo.DataVO;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseEntity;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
@@ -310,9 +312,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
} else {
|
|
|
String dataVal = dataInfo2.getString(dataMap.get(k).get(0));
|
|
|
if (StringUtils.isNotEmpty(dataVal)) {
|
|
|
- if (dataVal.contains("Ljava")){
|
|
|
+ if (dataVal.contains("Ljava")) {
|
|
|
Object o = dataInfo2.get(dataMap.get(k).get(0));
|
|
|
- dataVal = JSON.toJSONString(o).replace("\"","");
|
|
|
+ dataVal = JSON.toJSONString(o).replace("\"", "");
|
|
|
}
|
|
|
dataMap2.put(k, dataVal + "_^_" + dataMap.get(k).get(0).split("__")[1]);
|
|
|
}
|
|
@@ -341,9 +343,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Map<String, Map<String, String>> coordinateMap = createCoordinateMap(keyMappers, type);
|
|
|
stopWatch.start("公式处理");
|
|
|
List<Formula> formulas = this.formulaService.getFormulaList(keyMappers);
|
|
|
- WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
|
|
|
- if (wtc != null) {
|
|
|
- CurrentNode currentNode = createCurrentNode(wtc);
|
|
|
+
|
|
|
+ CurrentNode currentNode = null;
|
|
|
+ Long pKeyId = null;
|
|
|
+ if (type.equals(ExecuteType.INSPECTION)) {
|
|
|
+ WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
|
|
|
+ pKeyId = wtc.getPKeyId();
|
|
|
+ currentNode = createCurrentNode(wtc);
|
|
|
+ } else if (type.equals(ExecuteType.TESTING)) {
|
|
|
+ WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, nodeId));
|
|
|
+ pKeyId = wtp.getPKeyId();
|
|
|
+ currentNode = createCurrentNode(wtp);
|
|
|
+ }
|
|
|
+ if (currentNode != null) {
|
|
|
TableElementConverter tec = new TableElementConverter(tableInfoList, keyMappers, formulas, coordinateMap, currentNode, tableAll);
|
|
|
tec.setExecuteType(type);
|
|
|
tec.setLog(log);
|
|
@@ -358,7 +370,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Long totalTime = stopWatch.getTotalTimeMillis();
|
|
|
log.append("公式执行消耗时间:").append(totalTime);
|
|
|
StaticLog.info("公式执行用时:{}", totalTime);
|
|
|
- updateFormulaLog(log, wtc);
|
|
|
+ updateFormulaLog(log, pKeyId);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -399,11 +411,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return coordinateMap;
|
|
|
}
|
|
|
|
|
|
- private void updateFormulaLog(StringBuilder log, WbsTreeContract wtc) {
|
|
|
+ private void updateFormulaLog(StringBuilder log, Long pKeyId) {
|
|
|
try {
|
|
|
String[] sql = new String[]{
|
|
|
- "delete from m_formula_log where id =" + wtc.getPKeyId(),
|
|
|
- "INSERT INTO m_formula_log (id,content) VALUES (" + wtc.getPKeyId() + ", '" + log + "')"
|
|
|
+ "delete from m_formula_log where id =" + pKeyId,
|
|
|
+ "INSERT INTO m_formula_log (id,content) VALUES (" + pKeyId + ", '" + log + "')"
|
|
|
};
|
|
|
this.jdbcTemplate.batchUpdate(sql);
|
|
|
} catch (Exception e) {
|
|
@@ -429,6 +441,39 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public <T extends BaseEntity> CurrentNode createCurrentNode(T entity) {
|
|
|
+ if (entity instanceof WbsTreeContract) {
|
|
|
+ WbsTreeContract wtc = (WbsTreeContract) entity;
|
|
|
+ /*当前工序节点*/
|
|
|
+ CurrentNode currentNode = new CurrentNode();
|
|
|
+ currentNode.setPkId(wtc.getPKeyId());
|
|
|
+ currentNode.setParentId(wtc.getParentId());
|
|
|
+ currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
|
|
|
+ currentNode.setId(StringUtils.isNotEmpty(wtc.getOldId()) ? Long.valueOf(wtc.getOldId()) : wtc.getId());
|
|
|
+ currentNode.setRelateId(wtc.getId());
|
|
|
+ List<Long> privateIds = this.jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_private where id=" + currentNode.getRelateId() + " and project_id=" + wtc.getProjectId() + " and wbs_id=" + wtc.getWbsId(), Long.class);
|
|
|
+ if (Func.isNotEmpty(privateIds)) {
|
|
|
+ currentNode.setPrivateId(privateIds.get(0));
|
|
|
+ }
|
|
|
+ return currentNode;
|
|
|
+ } else if (entity instanceof WbsTreePrivate) {
|
|
|
+ WbsTreePrivate wtc = (WbsTreePrivate) entity;
|
|
|
+ /*当前工序节点*/
|
|
|
+ CurrentNode currentNode = new CurrentNode();
|
|
|
+ currentNode.setPkId(wtc.getPKeyId());
|
|
|
+ currentNode.setParentId(wtc.getParentId());
|
|
|
+ currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
|
|
|
+ currentNode.setId(wtc.getId()); //数据源
|
|
|
+ currentNode.setRelateId(wtc.getId());
|
|
|
+ List<Long> privateIds = this.jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_private where id=" + currentNode.getRelateId() + " and project_id=" + wtc.getProjectId() + " and wbs_id=" + wtc.getWbsId(), Long.class);
|
|
|
+ if (Func.isNotEmpty(privateIds)) {
|
|
|
+ currentNode.setPrivateId(privateIds.get(0));
|
|
|
+ }
|
|
|
+ return currentNode;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存日志
|
|
|
*/
|
|
@@ -2453,40 +2498,36 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- //删除SQL
|
|
|
- String delSql = "delete from " + wbsTreePrivate.getInitTableName() + " where p_key_id='" + tableInfo.getPkeyId() + "' and group_id = '" + groupId + "'";
|
|
|
-
|
|
|
- //新增SQL
|
|
|
- String sqlInfo = "";
|
|
|
- LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
- 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 {
|
|
|
- //删除
|
|
|
- jdbcTemplate.execute(delSql);
|
|
|
- //新增
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
- //提交事务
|
|
|
- transactionManager1.commit(transactionStatus);
|
|
|
- } catch (Exception e) {
|
|
|
- //回滚
|
|
|
- transactionManager1.rollback(transactionStatus);
|
|
|
+ //删除SQL
|
|
|
+ String delSql = "delete from " + wbsTreePrivate.getInitTableName() + " where p_key_id='" + tableInfo.getPkeyId() + "' and group_id = '" + groupId + "'";
|
|
|
+
|
|
|
+ //新增SQL
|
|
|
+ String sqlInfo = "";
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+ 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 + ")";
|
|
|
|
|
|
- throw new ServiceException("字段过长,新增失败");
|
|
|
- }
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
+ try {
|
|
|
+ //删除
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
+ //新增
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
+ //提交事务
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ //回滚
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+
|
|
|
+ throw new RuntimeException("字段过长,新增失败");
|
|
|
}
|
|
|
}
|
|
|
}
|