|
|
|
@ -5,14 +5,13 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import com.dxhy.order.baseservice.config.BaseServiceConfig; |
|
|
|
|
import com.dxhy.order.constant.OrderInfoContentEnum; |
|
|
|
|
import com.dxhy.order.constant.OrderInfoEnum; |
|
|
|
|
import com.dxhy.order.consumer.dao.GsClientMapper; |
|
|
|
|
import com.dxhy.order.consumer.modules.order.model.GsClient; |
|
|
|
|
import com.dxhy.order.consumer.modules.order.service.OrderCommonService; |
|
|
|
|
import com.dxhy.order.consumer.openapi.protocol.po.EsOutput; |
|
|
|
|
import com.dxhy.order.consumer.openapi.protocol.po.IsInput; |
|
|
|
|
import com.dxhy.order.consumer.openapi.protocol.po.PoCommonRequestParam; |
|
|
|
|
import com.dxhy.order.consumer.openapi.protocol.po.PoCommonResponseParam; |
|
|
|
|
|
|
|
|
|
import com.dxhy.order.consumer.openapi.service.GsClientService; |
|
|
|
|
import com.dxhy.order.utils.HttpUtils; |
|
|
|
|
import com.dxhy.order.utils.JsonUtils; |
|
|
|
|
import com.xxl.job.core.biz.model.ReturnT; |
|
|
|
@ -20,7 +19,6 @@ import com.xxl.job.core.handler.annotation.XxlJob; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
@ -41,8 +39,9 @@ public class GetGsClientTask { |
|
|
|
|
private BaseServiceConfig baseServiceConfig; |
|
|
|
|
@Resource |
|
|
|
|
private OrderCommonService apiInvoiceCommonMapperService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GsClientMapper gsClientMapper; |
|
|
|
|
private GsClientService gsClientService; |
|
|
|
|
|
|
|
|
|
@XxlJob("/getGsClient") |
|
|
|
|
public ReturnT<String> execute(String s) { |
|
|
|
@ -54,42 +53,44 @@ public class GetGsClientTask { |
|
|
|
|
String[] clientSplit = poClient.split(","); |
|
|
|
|
for(int i=0;i<clientSplit.length;i++){ |
|
|
|
|
String client = clientSplit[i]; |
|
|
|
|
IsInput isInput = new IsInput(); |
|
|
|
|
isInput.setSYSID(OrderInfoEnum.SYS_SIGN_FP.getKey()); |
|
|
|
|
isInput.setIFYWID(OrderInfoEnum.INTERFACE_BUSINESS_ID_GSCLIENT.getKey()); |
|
|
|
|
isInput.setBSKEY(apiInvoiceCommonMapperService.getGenerateShotKey()); |
|
|
|
|
isInput.setZORG(""); |
|
|
|
|
isInput.setZFILED5(client); |
|
|
|
|
isInput.setZDATA(""); |
|
|
|
|
PoCommonRequestParam poCommonRequestParam = new PoCommonRequestParam(); |
|
|
|
|
poCommonRequestParam.setIS_INPUT(isInput); |
|
|
|
|
String param = JsonUtils.getInstance().toJsonString(poCommonRequestParam); |
|
|
|
|
log.info("{}获取公司client入参:{}",LOGGER_MSG,param); |
|
|
|
|
String result = HttpUtils.sendPo(baseServiceConfig.getPoUrl(), param,baseServiceConfig.getPoUserName(),baseServiceConfig.getPoPassword()); |
|
|
|
|
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(OrderInfoContentEnum.INVOICE_ERROR_CODE_OP_S.getKey().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,client,zmessage); |
|
|
|
|
try { |
|
|
|
|
IsInput isInput = new IsInput(); |
|
|
|
|
isInput.setSYSID(OrderInfoEnum.SYS_SIGN_FP.getKey()); |
|
|
|
|
isInput.setIFYWID(OrderInfoEnum.INTERFACE_BUSINESS_ID_GSCLIENT.getKey()); |
|
|
|
|
isInput.setBSKEY(apiInvoiceCommonMapperService.getGenerateShotKey()); |
|
|
|
|
isInput.setZORG(""); |
|
|
|
|
isInput.setZFILED5(client); |
|
|
|
|
isInput.setZDATA(""); |
|
|
|
|
PoCommonRequestParam poCommonRequestParam = new PoCommonRequestParam(); |
|
|
|
|
poCommonRequestParam.setIS_INPUT(isInput); |
|
|
|
|
String param = JsonUtils.getInstance().toJsonString(poCommonRequestParam); |
|
|
|
|
log.info("{}获取公司client入参:{}",LOGGER_MSG,param); |
|
|
|
|
String result = HttpUtils.sendPo(baseServiceConfig.getPoUrl(), param,baseServiceConfig.getPoUserName(),baseServiceConfig.getPoPassword()); |
|
|
|
|
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(OrderInfoContentEnum.INVOICE_ERROR_CODE_OP_S.getKey().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,client,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); |
|
|
|
|
gsClientService.updateGsClient(list); |
|
|
|
|
long endTime = System.currentTimeMillis(); |
|
|
|
|
log.info("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|