工伤接口支持在模拟接口和真实接口之间进行切换,通过注释代码的方式实现手动切换。
文件位置: src/main/java/thyyxxk/sizyfeeoprnsystm/service/ExecService.java
切换方法:
// 模拟接口地址(注释掉,需要时手动切换)
// private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
// 真实接口地址(当前使用)
private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
切换步骤:
文件位置: src/main/java/thyyxxk/sizyfeeoprnsystm/service/SiZyFeeService.java
切换方法: 在以下方法中,通过注释切换不同的处理逻辑:
private Integer extractWorkInjuryResultCode(JSONObject result) {
// 模拟接口处理(注释掉,需要时手动切换)
if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
return result.getJSONObject("data").getJSONObject("data").getInteger(RESULT_CODE);
}
// 真实接口处理(当前使用)
else if (result.containsKey("data")) {
return result.getJSONObject("data").getInteger(RESULT_CODE);
}
return null;
}
private JSONArray extractWorkInjuryUploadResult(JSONObject result) {
// 模拟接口处理(注释掉,需要时手动切换)
if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
return result.getJSONObject("data").getJSONObject("data").getJSONArray(OUTPUT);
}
// 真实接口处理(当前使用)
else if (result.containsKey("data")) {
return result.getJSONObject("data").getJSONArray(OUTPUT);
}
return new JSONArray();
}
private JSONObject extractWorkInjuryPreSettlementResult(JSONObject result) {
// 模拟接口处理(注释掉,需要时手动切换)
if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
return result.getJSONObject("data").getJSONObject("data").getJSONObject(OUTPUT);
}
// 真实接口处理(当前使用)
else if (result.containsKey("data")) {
return result.getJSONObject("data").getJSONObject(OUTPUT);
}
return new JSONObject();
}
private String extractWorkInjuryErrorMessage(JSONObject result) {
// 模拟接口处理(注释掉,需要时手动切换)
if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
return result.getJSONObject("data").getJSONObject("data").getString(ERROR_MESSAGE);
}
// 真实接口处理(当前使用)
else if (result.containsKey("data")) {
return result.getJSONObject("data").getString(ERROR_MESSAGE);
}
return "未知错误";
}
{
"code": 1,
"data": {
"success": true,
"code": 200,
"message": "交易成功",
"device": "江苏工伤联网接口(模拟)",
"transactionCode": "2204",
"data": {
"infcode": "0",
"inf_refmsgid": "xxx",
"err_msg": "",
"output": {}
}
}
}
{
"success": true,
"code": 200,
"message": "交易成功",
"device": "江苏工伤联网接口",
"transactionCode": "2204",
"data": {
"infcode": "0",
"inf_refmsgid": "xxx",
"err_msg": "",
"output": {}
}
}
修改URL:
// 注释掉真实接口URL
// private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
// 取消注释模拟接口URL
private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
java
// 注释掉模拟接口URL
// private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
// 取消注释真实接口URL
private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
修改返回结果处理: 在每个提取方法中,注释掉模拟接口处理逻辑,取消注释真实接口处理逻辑。
所有接口都支持模拟接口和真实接口的切换。