kimi42345
2020-03-23 5bac93baf5659ce013163f884c9dce41990a860e
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
@@ -259,7 +264,7 @@
    @Override
    public String getTempFields(String tableName) {
        return getTempFields(tableName, Constant.EMPTY);
        return getTempFields(tableName, Constant.EMPTY_Str);
    }
    @Override
    public String getTempFields(String tableName, String alias) {
@@ -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;
    }