|
@@ -75,6 +75,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -639,6 +640,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
* 保存日志
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public String saveOrUpdateTheLog(List<TableInfo> tableInfoList) {
|
|
|
//查询绑定的节点
|
|
|
WbsTreePrivate tableNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
@@ -678,8 +680,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
//删除旧数据
|
|
|
if (StringUtils.isNotEmpty(businessIds)) {
|
|
|
- //删除实体表数据、关联工序信息
|
|
|
- String delSql = "delete from " + tableNode.getInitTableName() + " where id in(" + businessIds + "); delete from u_contract_log_wbs where business_id in(" + businessIds + ")";
|
|
|
+ //删除实体表数据、
|
|
|
+ String delSql = "delete from " + tableNode.getInitTableName() + " where id in(" + businessIds + ")";
|
|
|
this.jdbcTemplate.execute(delSql);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(ids)) {
|
|
@@ -687,17 +689,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String delSql = "delete from u_contract_log where id in(" + ids + ")";
|
|
|
this.jdbcTemplate.execute(delSql);
|
|
|
//添加操作日志
|
|
|
- String delSqlNew = delSql.replace("\"", "'");
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- sb.append("insert into blade_log_sql (p_key_id,contract_log_id,user_id,create_time,sql_info) VALUES");
|
|
|
- sb.append("(" + tableNode.getPKeyId());
|
|
|
- sb.append("," + ids);
|
|
|
- sb.append(","+ AuthUtil.getUserId());
|
|
|
- sb.append(",SYSDATE()");
|
|
|
- sb.append(",\"");
|
|
|
- sb.append(delSqlNew);
|
|
|
- sb.append("\")");
|
|
|
- jdbcTemplate.execute(sb.toString());
|
|
|
+ try {
|
|
|
+ String delSqlNew = delSql.replace("\"", "'");
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("insert into blade_log_sql (p_key_id,contract_log_id,user_id,create_time,sql_info) VALUES");
|
|
|
+ sb.append("(" + tableNode.getPKeyId());
|
|
|
+ sb.append(",\"" + ids+"\"");
|
|
|
+ sb.append(","+ AuthUtil.getUserId());
|
|
|
+ sb.append(",SYSDATE()");
|
|
|
+ sb.append(",\"");
|
|
|
+ sb.append(delSqlNew);
|
|
|
+ sb.append("\")");
|
|
|
+ jdbcTemplate.execute(sb.toString());
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ log.error("添加操作日志异常:ExcelTabServiceImpl-saveOrUpdateTheLog() 搜索代码:jdbcTemplate.execute(sb.toString());");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
List<String> dataIds = new LinkedList<>();
|
|
@@ -734,6 +740,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String errorMessage = e.getMessage();
|
|
|
if (StringUtils.isNotEmpty(errorMessage)) {
|
|
|
String errorKey = null;
|
|
|
+ if(errorMessage.contains("bad SQL grammar")){
|
|
|
+ throw new ServiceException("存在不规则特殊字符,新增失败");
|
|
|
+ }
|
|
|
if (errorMessage.contains("long for column ") && errorMessage.contains(" at ")) {
|
|
|
errorKey = errorMessage.split("long for column ")[1].split(" at ")[0];
|
|
|
}
|
|
@@ -747,6 +756,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
errorKeyName = tabElement.getEName();
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException("新增数据异常");
|
|
|
}
|
|
|
}
|
|
|
e.printStackTrace();
|
|
@@ -778,22 +789,30 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
parentNode.getMajorDataType(),
|
|
|
recordTime,
|
|
|
logWbsList,
|
|
|
- oldDataId
|
|
|
+ oldDataId,
|
|
|
+ businessIds
|
|
|
));
|
|
|
+ if("新增异常".equals(dataId)){
|
|
|
+ throw new ServiceException("日志文件新增异常");
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(dataId)) {
|
|
|
- for (String insterTataSql : insterTataSqls) {
|
|
|
- //添加操作日志
|
|
|
- String sqlNew = insterTataSql.toString().replace("\"", "'");
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- sb.append("insert into blade_log_sql (p_key_id,contract_log_id,user_id,create_time,sql_info) VALUES ");
|
|
|
- sb.append("("+tableNode.getPKeyId());
|
|
|
- sb.append(","+dataId);
|
|
|
- sb.append(","+AuthUtil.getUserId());
|
|
|
- sb.append(",SYSDATE()");
|
|
|
- sb.append(",\"");
|
|
|
- sb.append(sqlNew);
|
|
|
- sb.append("\")");
|
|
|
- jdbcTemplate.execute(sb.toString());
|
|
|
+ try {
|
|
|
+ for (String insterTataSql : insterTataSqls) {
|
|
|
+ //添加操作日志
|
|
|
+ String sqlNew = insterTataSql.toString().replace("\"", "'");
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("insert into blade_log_sql (p_key_id,contract_log_id,user_id,create_time,sql_info) VALUES ");
|
|
|
+ sb.append("("+tableNode.getPKeyId());
|
|
|
+ sb.append(","+dataId);
|
|
|
+ sb.append(","+AuthUtil.getUserId());
|
|
|
+ sb.append(",SYSDATE()");
|
|
|
+ sb.append(",\"");
|
|
|
+ sb.append(sqlNew);
|
|
|
+ sb.append("\")");
|
|
|
+ jdbcTemplate.execute(sb.toString());
|
|
|
+ }
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ log.error("添加操作日志异常 ExcelTabServiceImpl-saveOrUpdateTheLog()方法 搜索代码:for (String insterTataSql : insterTataSqls) { ");
|
|
|
}
|
|
|
dataIds.add(dataId);
|
|
|
}
|