|
|
@ -17,6 +17,7 @@ import com.dxhy.erp.service.RequestRecordService; |
|
|
|
import com.dxhy.erp.service.SNPushCheckRecordService; |
|
|
|
import com.dxhy.erp.service.SNPushCheckRecordService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
@ -118,70 +119,79 @@ public class RequestRecordServiceImpl extends MpBaseServiceImpl<RequestRecordDao |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ResponseEntity<?> reCall(RequestRecord requestRecord) { |
|
|
|
public ResponseEntity<?> reCall(RequestRecord requestRecord) { |
|
|
|
DynamicContextHolder.push(dbname+DbConstant.BUSINESS_READ); |
|
|
|
try { |
|
|
|
RequestRecord dbRecord = requestRecordDao.selectById(requestRecord.getId()); |
|
|
|
DynamicContextHolder.push(dbname+DbConstant.BUSINESS_READ); |
|
|
|
log.info("数据库匹配信息:{}", JSONObject.toJSONString(dbRecord)); |
|
|
|
RequestRecord dbRecord = requestRecordDao.selectById(requestRecord.getId()); |
|
|
|
if (dbRecord == null || dbRecord.getStatus() != 0) { |
|
|
|
log.info("数据库匹配信息:{}", JSONObject.toJSONString(dbRecord)); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("请求信息错误,请确认后再发送!"))); |
|
|
|
if (dbRecord == null) { |
|
|
|
} |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("请求信息错误,请确认后再发送!"))); |
|
|
|
if (dbRecord.getIsRecall() == 0) { |
|
|
|
} |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求参数不符合标准,无法进行重调,请校验参数后再申请!"))); |
|
|
|
if (dbRecord.getStatus() == 0) { |
|
|
|
} |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求已成功,无法继续重调!"))); |
|
|
|
|
|
|
|
} |
|
|
|
RequestRecordEnum[] RequestRecordEnums = RequestRecordEnum.values(); |
|
|
|
if (dbRecord.getIsRecall() == 0) { |
|
|
|
log.info("获取到的枚举类型:{}",JSONObject.toJSONString(RequestRecordEnums)); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("该请求参数不符合标准,无法进行重调!"))); |
|
|
|
for (RequestRecordEnum recordenum : RequestRecordEnums) { |
|
|
|
} |
|
|
|
if (recordenum.getMethodName().equals(dbRecord.getActiveCall())) { |
|
|
|
|
|
|
|
snPushCheckRecordService = JSONObject.parseObject(JSONObject.toJSONString(applicationContext.getBean(recordenum.getClassName())),SNPushCheckRecordService.class); |
|
|
|
|
|
|
|
log.info("通过反射获取到的snPushCheckRecordService是否为空:{}",JSONObject.toJSONString(snPushCheckRecordService == null)); |
|
|
|
|
|
|
|
Method method = ReflectUtil.getMethodByName(snPushCheckRecordService.getClass(),recordenum.getMethodName()); |
|
|
|
|
|
|
|
log.info("通过反射获取到的方法是否为空:{}",JSONObject.toJSONString(method == null)); |
|
|
|
|
|
|
|
if (method != null) { |
|
|
|
|
|
|
|
log.info("通过反射获取到的方法名:{}",JSONObject.toJSONString(method.getName())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object invokeResponse = null; |
|
|
|
RequestRecordEnum[] RequestRecordEnums = RequestRecordEnum.values(); |
|
|
|
R data = new R(1000, "default success"); |
|
|
|
log.info("获取到的枚举类型:{}",JSONObject.toJSONString(RequestRecordEnums)); |
|
|
|
try { |
|
|
|
for (RequestRecordEnum recordenum : RequestRecordEnums) { |
|
|
|
DynamicContextHolder.push(dbname+DbConstant.BUSINESS_WRITE); |
|
|
|
if (recordenum.getMethodName().equals(dbRecord.getActiveCall())) { |
|
|
|
if (recordenum.getArgClass().length>1) { |
|
|
|
snPushCheckRecordService = JSONObject.parseObject(JSONObject.toJSONString(applicationContext.getBean(recordenum.getClassName())),SNPushCheckRecordService.class); |
|
|
|
List<String> list = JSONObject.parseObject(dbRecord.getActiveCallRequestDetail(),List.class); |
|
|
|
log.info("通过反射获取到的snPushCheckRecordService是否为空:{}",JSONObject.toJSONString(snPushCheckRecordService == null)); |
|
|
|
invokeResponse = method.invoke(snPushCheckRecordService, JSONObject.parseObject(list.get(0), recordenum.getArgClass()[0]),JSONObject.parseObject(list.get(1), recordenum.getArgClass()[1])); |
|
|
|
Method method = ReflectUtil.getMethodByName(snPushCheckRecordService.getClass(),recordenum.getMethodName()); |
|
|
|
}else { |
|
|
|
log.info("通过反射获取到的方法是否为空:{}",JSONObject.toJSONString(method == null)); |
|
|
|
invokeResponse = method.invoke(snPushCheckRecordService, JSONObject.parseObject(dbRecord.getActiveCallRequestDetail(), recordenum.getArgClass()[0])); |
|
|
|
if (method != null) { |
|
|
|
|
|
|
|
log.info("通过反射获取到的方法名:{}",JSONObject.toJSONString(method.getName())); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("重调后得到的结果:{}",JSONObject.toJSONString(invokeResponse)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,String> map = JSONObject.parseObject(JSONObject.toJSONString(invokeResponse), Map.class); |
|
|
|
Object invokeResponse = null; |
|
|
|
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
DynamicContextHolder.push(dbname+DbConstant.BUSINESS_WRITE); |
|
|
|
|
|
|
|
if (recordenum.getArgClass().length>1) { |
|
|
|
|
|
|
|
List<String> list = JSONObject.parseObject(dbRecord.getActiveCallRequestDetail(),List.class); |
|
|
|
|
|
|
|
invokeResponse = method.invoke(snPushCheckRecordService, JSONObject.parseObject(list.get(0), recordenum.getArgClass()[0]),JSONObject.parseObject(list.get(1), recordenum.getArgClass()[1])); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
invokeResponse = method.invoke(snPushCheckRecordService, JSONObject.parseObject(dbRecord.getActiveCallRequestDetail(), recordenum.getArgClass()[0])); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("重调后得到的结果:{}",JSONObject.toJSONString(invokeResponse)); |
|
|
|
|
|
|
|
|
|
|
|
data.put("data", invokeResponse); |
|
|
|
Map<String,String> map = JSONObject.parseObject(JSONObject.toJSONString(invokeResponse), Map.class); |
|
|
|
|
|
|
|
|
|
|
|
if (map.containsKey("SAPKEY")) { |
|
|
|
data.put("data", invokeResponse); |
|
|
|
if (!map.containsValue("处理成功")) { |
|
|
|
|
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("ZMESSAGE"), 0); |
|
|
|
if (map.containsKey("SAPKEY")) { |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
if (!map.containsValue("处理成功")) { |
|
|
|
|
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("ZMESSAGE"), 0); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (map.containsKey("code")) { |
|
|
|
if (map.containsKey("code")) { |
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("message"), 0); |
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("message"), 0); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (map.containsKey("cyjg")) { |
|
|
|
|
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("cyjgxx"), 0); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (map.containsKey("cyjg")) { |
|
|
|
|
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data), map.get("cyjgxx"), 0); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateSuccessfulRecallRecord(dbRecord, 0, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
log.info("重调出现异常,异常信息:{}",e); |
|
|
|
|
|
|
|
updateFailedRecallRecord(dbRecord, 1, JSONObject.toJSONString(invokeResponse), |
|
|
|
|
|
|
|
JSONObject.toJSONString(data), "重调用失败,异常信息:{}"+JSONObject.toJSONString(e.getMessage()), 0); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateSuccessfulRecallRecord(dbRecord, 0, JSONObject.toJSONString(invokeResponse), JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
log.info("重调出现异常,异常信息:{}",e); |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("请求处理异常,异常信息:{}", JSONObject.toJSONString(e)); |
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("请求处理异常,请校正参数!"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("未找到相应信息!"))); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("未找到相应信息!"))); |
|
|
|