txlcn-tc/src/main/java/com/codingapi/txlcn/tc/core/transaction/txc/analy/TxcServiceImpl.java
private void resolveModifiedRecords(List<ModifiedRecord> modifiedRecords, int sqlType) throws TxcLogicException {

        TableRecordList tableRecords = new TableRecordList();
        Set<String> lockIdSet = new HashSet<>();

        // Build reverse sql
        for (ModifiedRecord modifiedRecord : modifiedRecords) {
            for (Map.Entry<String, FieldCluster> entry : modifiedRecord.getFieldClusters().entrySet()) {
                TableRecord tableRecord = new TableRecord();
                tableRecord.setTableName(entry.getKey());
                tableRecord.setFieldCluster(entry.getValue());

                tableRecords.getTableRecords().add(tableRecord);

                lockIdSet.add(hex(tableRecord.getFieldCluster().getPrimaryKeys().toString()));
            }
        }

        // 受影响记录为0
        if (lockIdSet.isEmpty()) {
            return;
        }

        String groupId = DTXLocalContext.cur().getGroupId();
        String unitId = DTXLocalContext.cur().getUnitId();

        // lock
        lockDataLine(groupId, unitId, lockIdSet, true);

        // save to h2db
        saveUndoLog(groupId, unitId, sqlType, tableRecords);
    }
private void resolveModifiedRecords(List<ModifiedRecord> modifiedRecords, int sqlType) throws TxcLogicException {

        TableRecordList tableRecords = new TableRecordList();
        Set<String> lockIdSet = new HashSet<>();

        // Build reverse sql
        for (ModifiedRecord modifiedRecord : modifiedRecords) {
            for (Map.Entry<String, FieldCluster> entry : modifiedRecord.getFieldClusters().entrySet()) {
                TableRecord tableRecord = new TableRecord();
                tableRecord.setTableName(entry.getKey());
                tableRecord.setFieldCluster(entry.getValue());

                tableRecords.getTableRecords().add(tableRecord);

                lockIdSet.add(hex(tableRecord.getFieldCluster().getPrimaryKeys().toString()));
            }
        }

        // 受影响记录为0
        if (lockIdSet.isEmpty()) {
            return;
        }

        String groupId = DTXLocalContext.cur().getGroupId();
        String unitId = DTXLocalContext.cur().getUnitId();

        // lock
        lockDataLine(groupId, unitId, lockIdSet, true);

        // save to h2db
        saveUndoLog(groupId, unitId, sqlType, tableRecords);
    }
private void resolveModifiedRecords ( List < ModifiedRecord > modifiedRecords , int sqlType ) throws TxcLogicException { TableRecordList tableRecords = new TableRecordList ( ) ; Set < String > lockIdSet = new HashSet <> ( ) ; // Build reverse sql for ( ModifiedRecord modifiedRecord : modifiedRecords ) { for ( Map . Entry < String , FieldCluster > entry : modifiedRecord . getFieldClusters ( ) . entrySet ( ) ) { TableRecord tableRecord = new TableRecord ( ) ; tableRecord . setTableName ( entry . getKey ( ) ) ; tableRecord . setFieldCluster ( entry . getValue ( ) ) ; tableRecords . getTableRecords ( ) . add ( tableRecord ) ; lockIdSet . add ( hex ( tableRecord . getFieldCluster ( ) . getPrimaryKeys ( ) . toString ( ) ) ) ; } } // 受影响记录为0 if ( lockIdSet . isEmpty ( ) ) { return ; } String groupId = DTXLocalContext . cur ( ) . getGroupId ( ) ; String unitId = DTXLocalContext . cur ( ) . getUnitId ( ) ; // lock lockDataLine ( groupId , unitId , lockIdSet , true ) ; // save to h2db saveUndoLog ( groupId , unitId , sqlType , tableRecords ) ; }
解决受影响数据

@param modifiedRecords 受影响的数据
@param sqlType         SQL 类型
@throws TxcLogicException 业务异常
解决受影响数据