From 5bac93baf5659ce013163f884c9dce41990a860e Mon Sep 17 00:00:00 2001
From: kimi42345 <kimi42345@outlook.com>
Date: 星期一, 23 三月 2020 08:49:41 +0800
Subject: [PATCH] no message

---
 src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java |   41 ++++++++++++++++++-----------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java b/src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java
index 98e53f6..5bf0349 100644
--- a/src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java
+++ b/src/main/java/com/highdatas/mdm/service/impl/MasterDataServiceImpl.java
@@ -14,9 +14,12 @@
 import org.apache.commons.lang3.StringUtils;
 import org.mybatis.spring.SqlSessionTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.sql.DataSource;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.text.MessageFormat;
@@ -43,10 +46,10 @@
     IMaintainDetailService maintainDetailService;
     @Autowired
     IFlowsService flowsService;
-    @Autowired
 
     @Resource
-    protected SqlSessionTemplate sqlSessionTemplate;
+    protected DataSource dataSource;
+
     @Override
     public Result selectById(String tableName, String id) {
         try{
@@ -138,6 +141,8 @@
             return null;
         }
     }
+
+    @Override
     public Long getCountByVersion (String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) {
         try{
             Maintain maintain = maintainService.selectById(maintainId);
@@ -185,7 +190,7 @@
 
     @Override
     public String getFields(String tableName) {
-        return getFields(tableName, Constant.EMPTY);
+        return getFields(tableName, Constant.EMPTY_Str);
     }
 
     @Override
@@ -466,6 +471,7 @@
 
     @Override
     public Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId) {
+
         MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("table_name",tableName));
         SysOperateLog operateLog = new SysOperateLog();
 
@@ -503,18 +509,18 @@
         maintain.setTableName(tableName);
         maintain.setCreateTime(new Date());
 
-        Connection connection = sqlSessionTemplate.getConnection();
+        Connection connection;
         try {
+            connection = dataSource.getConnection();
+            connection.setAutoCommit(false);
             mapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD , DbUtils.quotedStr(Operate.create.toString()));
-            connection.commit();
             mapper.updateStdId( maintain.getTableName() + Constant.RECORD);
-            connection.commit();
             Integer aLong = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId()));
-            connection.commit();
             if (aLong == null) {
                 maintain.setDesp("涓婁紶鏁版嵁");
+            }else {
+                maintain.setDesp(MessageFormat.format("涓婁紶鏁版嵁{0}鏉�", aLong));
             }
-            maintain.setDesp(MessageFormat.format("涓婁紶鏁版嵁{0}鏉�", aLong));
 
             if (uploadType.equals(SysAssembleUpdateType.All)) {
                 List<TableSchemaResult> tableField = mapper.getTableField(tableName);
@@ -524,17 +530,15 @@
                         .map(s -> s.equalsIgnoreCase(Constant.STD_ID) ? MessageFormat.format(Constant.FieldAsAlias, Constant.ID, Constant.STD_ID) : s).collect(Collectors.joining(Constant.COMMA));
 
                 mapper.insertRecordFromStandrad(maintain.getTableName(), maintain.getTableName() + Constant.RECORD, collect);
-                connection.commit();
                 mapper.insertMatintainDetailFromStandrad(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD);
-                connection.commit();
                 Integer standradCnt = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId()));
-                connection.commit();
+
                 if (standradCnt != null) {
                     maintain.setDesp(maintain.getDesp() + MessageFormat.format("鍒犻櫎鍘熸暟鎹畕0}鏉�", standradCnt));
                 }else {
                     maintain.setDesp(maintain.getDesp() + "鍒犻櫎鍘熸暟鎹�");
                 }
-                maintain.setDesp(maintain.getDesp() + MessageFormat.format("鍒犻櫎鍘熸暟鎹畕0}鏉�", standradCnt));
+
             }
 
             operateLog.setCreateTime(new Date())
@@ -542,7 +546,7 @@
                     .setId(DbUtils.getUUID())
                     .setMaintainId(menuMapping.getId())
                     .setOperate("open")
-                    .setDesp(MessageFormat.format("涓婁紶鏁版嵁{0}鏉�", aLong));
+                    .setDesp("鎵归噺涓婁紶鏁版嵁");
 
             maintain.insert();
             connection.commit();
@@ -550,17 +554,8 @@
         catch (Exception e) {
             e.printStackTrace();
 
+        }
 
-        }
-        finally {
-            if (connection != null) {
-                try {
-                    connection.commit();
-                } catch (SQLException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
         return maintain;
     }
 

--
Gitblit v1.8.0