|
|
@ -13,8 +13,16 @@ import org.springframework.stereotype.Repository; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.sql.*; |
|
|
import java.sql.*; |
|
|
import java.sql.Date; |
|
|
import java.sql.Date; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Calendar; |
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.IdentityHashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
@ -27,15 +35,48 @@ import java.util.logging.Logger; |
|
|
@Repository |
|
|
@Repository |
|
|
public class ProcedureDaoImpl implements ProcedureDao { |
|
|
public class ProcedureDaoImpl implements ProcedureDao { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ProcedureDaoImpl.class); |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private JdbcTemplate jdbcTemplate; |
|
|
private JdbcTemplate jdbcTemplate; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 输出 JDBC/SQL Server 异常链(含 SQLException.getNextException),便于定位库端真实报错。rqrq |
|
|
|
|
|
*/ |
|
|
|
|
|
private void logJdbcThrowableChain(String context, Throwable throwable) { |
|
|
|
|
|
if (throwable == null) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
Throwable t = throwable; |
|
|
|
|
|
Set<Throwable> seen = Collections.newSetFromMap(new IdentityHashMap<>()); |
|
|
|
|
|
int depth = 0; |
|
|
|
|
|
while (t != null && !seen.contains(t) && depth < 50) { |
|
|
|
|
|
seen.add(t); |
|
|
|
|
|
log.error("{} 异常链 depth={} class={} message={}", context, depth, t.getClass().getName(), t.getMessage()); |
|
|
|
|
|
if (t instanceof SQLException) { |
|
|
|
|
|
SQLException next = ((SQLException) t).getNextException(); |
|
|
|
|
|
int nx = 0; |
|
|
|
|
|
while (next != null && nx < 20) { |
|
|
|
|
|
log.error("{} SQLException.getNextException[{}] SQLState={} errorCode={} message={}", context, nx, |
|
|
|
|
|
next.getSQLState(), next.getErrorCode(), next.getMessage()); |
|
|
|
|
|
next = next.getNextException(); |
|
|
|
|
|
nx++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
t = t.getCause(); |
|
|
|
|
|
depth++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<Map<String, Object>> soReceiveFgRmBackflush(String site, String orderNo, Date transDate, |
|
|
public List<Map<String, Object>> soReceiveFgRmBackflush(String site, String orderNo, Date transDate, |
|
|
String transNo, float itemNo, float oldQty, float newQty, String OrderType, String userId, String receiver, |
|
|
String transNo, float itemNo, float oldQty, float newQty, String OrderType, String userId, String receiver, |
|
|
String partnerId) { |
|
|
String partnerId) { |
|
|
|
|
|
final String ctx = "SO_Receive_FG_RMBackflush site=" + site + " orderNo=" + orderNo + " transNo=" + transNo; |
|
|
|
|
|
log.info( |
|
|
|
|
|
"SO_Receive_FG_RMBackflush 入参 site={} orderNo={} transDate={} transNo={} itemNo={} oldQty={} newQty={} OrderType={} userId={} receiver={} partnerId={}", |
|
|
|
|
|
site, orderNo, transDate, transNo, itemNo, oldQty, newQty, OrderType, userId, receiver, partnerId); |
|
|
|
|
|
try { |
|
|
return jdbcTemplate.execute(new CallableStatementCreator() { |
|
|
return jdbcTemplate.execute(new CallableStatementCreator() { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -81,6 +122,11 @@ public class ProcedureDaoImpl implements ProcedureDao { |
|
|
return resultList; |
|
|
return resultList; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
} catch (RuntimeException ex) { |
|
|
|
|
|
log.error("{} 调用失败(即将抛出)", ctx, ex); |
|
|
|
|
|
logJdbcThrowableChain(ctx, ex); |
|
|
|
|
|
throw ex; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|