|
|
|
@ -14,6 +14,7 @@ import com.dxhy.core.job.entity.SNSAPObject; |
|
|
|
|
import com.dxhy.core.job.entity.ScheduleJobEntity; |
|
|
|
|
import com.dxhy.core.job.service.InvoiceInterfaceService; |
|
|
|
|
import com.dxhy.core.job.service.ScheduleJobService; |
|
|
|
|
import com.dxhy.core.service.gsclient.GsClientService; |
|
|
|
|
import com.dxhy.core.util.HttpUtils; |
|
|
|
|
import com.dxhy.core.util.JsonUtils; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -46,9 +47,6 @@ public class SdnyClientTask extends AbstractController { |
|
|
|
|
@Value("${po.password}") |
|
|
|
|
private String password; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GsClientMapper gsClientMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private InvoiceInterfaceService invoiceInterfaceService; |
|
|
|
|
@Resource |
|
|
|
@ -56,6 +54,9 @@ public class SdnyClientTask extends AbstractController { |
|
|
|
|
@Resource |
|
|
|
|
private ScheduleJobService scheduleJobService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GsClientService gsClientService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 核心线程池大小 |
|
|
|
|
*/ |
|
|
|
@ -84,48 +85,50 @@ public class SdnyClientTask extends AbstractController { |
|
|
|
|
// 需判断 设置不认证状态
|
|
|
|
|
String[] split = client.split(","); |
|
|
|
|
for(int i = 0;i < split.length;i++) { |
|
|
|
|
SNSAPObject object = new SNSAPObject(); |
|
|
|
|
object.setSYSID("FPXT"); |
|
|
|
|
object.setIFYWID("FI846"); |
|
|
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
object.setZFILED5(split[i]); |
|
|
|
|
object.setZDATA(""); |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
log.info("推送山能数据:{}", JSONObject.toJSONString(object)); |
|
|
|
|
JSONObject request = new JSONObject(); |
|
|
|
|
request.put("IS_INPUT", object); |
|
|
|
|
|
|
|
|
|
log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString()); |
|
|
|
|
String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password); |
|
|
|
|
log.info("{}获取公司client出参:{}", LOGGER_MSG, result); |
|
|
|
|
PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); |
|
|
|
|
EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); |
|
|
|
|
String ztype = es_output.getZTYPE(); |
|
|
|
|
String zmessage = es_output.getZMESSAGE(); |
|
|
|
|
Object zdata = es_output.getZDATA(); |
|
|
|
|
if ("S".equals(ztype)) { |
|
|
|
|
List<Map<String, String>> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); |
|
|
|
|
gsClientList.stream().forEach(f -> { |
|
|
|
|
GsClient gsClient = new GsClient(); |
|
|
|
|
gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString()); |
|
|
|
|
gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString()); |
|
|
|
|
gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString()); |
|
|
|
|
gsClient.setCreateTime(new Date()); |
|
|
|
|
list.add(gsClient); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); |
|
|
|
|
try { |
|
|
|
|
SNSAPObject object = new SNSAPObject(); |
|
|
|
|
object.setSYSID("FPXT"); |
|
|
|
|
object.setIFYWID("FI846"); |
|
|
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
object.setZFILED5(split[i]); |
|
|
|
|
object.setZDATA(""); |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
log.info("推送山能数据:{}", JSONObject.toJSONString(object)); |
|
|
|
|
JSONObject request = new JSONObject(); |
|
|
|
|
request.put("IS_INPUT", object); |
|
|
|
|
|
|
|
|
|
log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString()); |
|
|
|
|
String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password); |
|
|
|
|
log.info("{}获取公司client出参:{}", LOGGER_MSG, result); |
|
|
|
|
PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); |
|
|
|
|
EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); |
|
|
|
|
String ztype = es_output.getZTYPE(); |
|
|
|
|
String zmessage = es_output.getZMESSAGE(); |
|
|
|
|
Object zdata = es_output.getZDATA(); |
|
|
|
|
if ("S".equals(ztype)) { |
|
|
|
|
List<Map<String, String>> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); |
|
|
|
|
gsClientList.stream().forEach(f -> { |
|
|
|
|
GsClient gsClient = new GsClient(); |
|
|
|
|
gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString()); |
|
|
|
|
gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString()); |
|
|
|
|
gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString()); |
|
|
|
|
gsClient.setCreateTime(new Date()); |
|
|
|
|
list.add(gsClient); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
//捕获异常 不抛出 一个公司的client出错不能影响其他的
|
|
|
|
|
log.error("{}client:{},获取公司client出现异常:{}",LOGGER_MSG,client,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("{}删除gs_client表数据", LOGGER_MSG); |
|
|
|
|
gsClientMapper.deleteAll(); |
|
|
|
|
log.info("{}插入gs_client表", LOGGER_MSG); |
|
|
|
|
gsClientMapper.insertList(list); |
|
|
|
|
//list中有可能存在已部分有异常的client的公司,因为这些公司是在异常发生之前存到list中的
|
|
|
|
|
gsClientService.updateGsClient(list); |
|
|
|
|
long endTime = System.currentTimeMillis(); |
|
|
|
|
log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} finally { |
|
|
|
|