Merge remote-tracking branch 'origin/1103-edit_gsClient' into release

release
wangrangrang 2 years ago
commit 65dc4f2480
  1. 16
      dxhy-core/src/main/java/com/dxhy/core/service/gsclient/GsClientService.java
  2. 33
      dxhy-core/src/main/java/com/dxhy/core/service/gsclient/GsClientServiceImpl.java
  3. 83
      dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java

@ -0,0 +1,16 @@
package com.dxhy.core.service.gsclient;
import com.dxhy.core.entity.GsClient;
import java.util.List;
/**
* @title: GsClient
* @Author: wrr
* @Date: 2023/11/3 09:02
* @Description:
*/
public interface GsClientService {
void updateGsClient(List<GsClient> list);
}

@ -0,0 +1,33 @@
package com.dxhy.core.service.gsclient;
import com.dxhy.core.dao.GsClientMapper;
import com.dxhy.core.entity.GsClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* @title: GsClientServiceImpl
* @Author: wrr
* @Date: 2023/11/3 09:03
* @Description:
*/
@Service
@Slf4j
public class GsClientServiceImpl implements GsClientService{
private static final String LOGGER_MSG = "pt(SAP获取公司clientService)";
@Resource
private GsClientMapper gsClientMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGsClient(List<GsClient> list) {
log.info("{}删除gs_client表数据", LOGGER_MSG);
gsClientMapper.deleteAll();
log.info("{}插入gs_client表", LOGGER_MSG);
gsClientMapper.insertList(list);
}
}

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

Loading…
Cancel
Save