commit
75805c5acb
@ -0,0 +1,27 @@ |
||||
package com.dxhy.order.consumer.dao; |
||||
|
||||
|
||||
import com.dxhy.order.consumer.modules.order.model.GsClient; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface GsClientMapper { |
||||
int deleteByPrimaryKey(Integer id); |
||||
|
||||
int deleteAll(); |
||||
|
||||
int insert(GsClient record); |
||||
|
||||
int insertSelective(GsClient record); |
||||
|
||||
int insertList(@Param("list") List<GsClient> recordList); |
||||
|
||||
GsClient selectByPrimaryKey(Integer id); |
||||
|
||||
List<GsClient> selectByGsdm(String gsdm); |
||||
|
||||
int updateByPrimaryKeySelective(GsClient record); |
||||
|
||||
int updateByPrimaryKey(GsClient record); |
||||
} |
@ -0,0 +1,103 @@ |
||||
package com.dxhy.order.consumer.handle; |
||||
|
||||
|
||||
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.utils.HttpUtils; |
||||
import com.dxhy.order.utils.JsonUtils; |
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.IJobHandler; |
||||
import com.xxl.job.core.handler.annotation.JobHandler; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 从SAP拉取公司client |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@JobHandler(value = "/getGsClient") |
||||
public class GetGsClientTask extends IJobHandler { |
||||
|
||||
private static final String LOGGER_MSG = "(SAP获取公司client)"; |
||||
|
||||
@Resource |
||||
private BaseServiceConfig baseServiceConfig; |
||||
@Resource |
||||
private OrderCommonService apiInvoiceCommonMapperService; |
||||
@Resource |
||||
private GsClientMapper gsClientMapper; |
||||
|
||||
@Override |
||||
public ReturnT<String> execute(String s) { |
||||
try { |
||||
log.debug("{}任务开始", LOGGER_MSG); |
||||
long startTime = System.currentTimeMillis(); |
||||
List<GsClient> list = new ArrayList<>(); |
||||
String poClient = baseServiceConfig.getPoClient(); |
||||
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); |
||||
} |
||||
} |
||||
log.info("{}删除gs_client表数据",LOGGER_MSG); |
||||
gsClientMapper.deleteAll(); |
||||
log.info("{}插入gs_client表",LOGGER_MSG); |
||||
gsClientMapper.insertList(list); |
||||
long endTime = System.currentTimeMillis(); |
||||
log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); |
||||
} catch (Exception e) { |
||||
log.error("{}定时任务执行异常:{}", LOGGER_MSG, e); |
||||
return FAIL; |
||||
} |
||||
return SUCCESS; |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.dxhy.order.consumer.modules.order.model; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class GsClient { |
||||
private Integer id; |
||||
|
||||
private String gsdm; |
||||
|
||||
private String gsmc; |
||||
|
||||
private String client; |
||||
|
||||
private Date createTime; |
||||
|
||||
} |
@ -0,0 +1,111 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="com.dxhy.order.consumer.dao.GsClientMapper" > |
||||
<resultMap id="BaseResultMap" type="com.dxhy.order.consumer.modules.order.model.GsClient" > |
||||
<id column="id" property="id" jdbcType="INTEGER" /> |
||||
<result column="gsdm" property="gsdm" jdbcType="VARCHAR" /> |
||||
<result column="gsmc" property="gsmc" jdbcType="VARCHAR" /> |
||||
<result column="client" property="client" jdbcType="VARCHAR" /> |
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> |
||||
</resultMap> |
||||
<sql id="Base_Column_List" > |
||||
id, gsdm, gsmc, client, create_time |
||||
</sql> |
||||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
||||
select |
||||
<include refid="Base_Column_List" /> |
||||
from gs_client |
||||
where id = #{id,jdbcType=INTEGER} |
||||
</select> |
||||
<select id="selectByGsdm" resultMap="BaseResultMap" parameterType="java.lang.String" > |
||||
select |
||||
<include refid="Base_Column_List" /> |
||||
from gs_client |
||||
where gsdm = #{gsdm,jdbcType=VARCHAR} |
||||
</select> |
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > |
||||
delete from gs_client |
||||
where id = #{id,jdbcType=INTEGER} |
||||
</delete> |
||||
<delete id="deleteAll" > |
||||
delete from gs_client |
||||
</delete> |
||||
<insert id="insert" parameterType="com.dxhy.order.consumer.modules.order.model.GsClient" > |
||||
insert into gs_client (id, gsdm, gsmc, |
||||
client, create_time) |
||||
values (#{id,jdbcType=INTEGER}, #{gsdm,jdbcType=VARCHAR}, #{gsmc,jdbcType=VARCHAR}, |
||||
#{client,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}) |
||||
</insert> |
||||
<insert id="insertSelective" parameterType="com.dxhy.order.consumer.modules.order.model.GsClient" > |
||||
insert into gs_client |
||||
<trim prefix="(" suffix=")" suffixOverrides="," > |
||||
<if test="id != null" > |
||||
id, |
||||
</if> |
||||
<if test="gsdm != null" > |
||||
gsdm, |
||||
</if> |
||||
<if test="gsmc != null" > |
||||
gsmc, |
||||
</if> |
||||
<if test="client != null" > |
||||
client, |
||||
</if> |
||||
<if test="createTime != null" > |
||||
create_time, |
||||
</if> |
||||
</trim> |
||||
<trim prefix="values (" suffix=")" suffixOverrides="," > |
||||
<if test="id != null" > |
||||
#{id,jdbcType=INTEGER}, |
||||
</if> |
||||
<if test="gsdm != null" > |
||||
#{gsdm,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="gsmc != null" > |
||||
#{gsmc,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="client != null" > |
||||
#{client,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="createTime != null" > |
||||
#{createTime,jdbcType=TIMESTAMP}, |
||||
</if> |
||||
</trim> |
||||
</insert> |
||||
<update id="updateByPrimaryKeySelective" parameterType="com.dxhy.order.consumer.modules.order.model.GsClient" > |
||||
update gs_client |
||||
<set > |
||||
<if test="gsdm != null" > |
||||
gsdm = #{gsdm,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="gsmc != null" > |
||||
gsmc = #{gsmc,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="client != null" > |
||||
client = #{client,jdbcType=VARCHAR}, |
||||
</if> |
||||
<if test="createTime != null" > |
||||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
||||
</if> |
||||
</set> |
||||
where id = #{id,jdbcType=INTEGER} |
||||
</update> |
||||
<update id="updateByPrimaryKey" parameterType="com.dxhy.order.consumer.modules.order.model.GsClient" > |
||||
update gs_client |
||||
set gsdm = #{gsdm,jdbcType=VARCHAR}, |
||||
gsmc = #{gsmc,jdbcType=VARCHAR}, |
||||
client = #{client,jdbcType=VARCHAR}, |
||||
create_time = #{createTime,jdbcType=TIMESTAMP} |
||||
where id = #{id,jdbcType=INTEGER} |
||||
</update> |
||||
<insert id="insertList" parameterType="java.util.List" useGeneratedKeys="false"> |
||||
insert into gs_client (gsdm,gsmc,client,create_time) |
||||
values |
||||
<foreach collection="list" item="item" index="index" |
||||
separator=","> |
||||
(#{item.gsdm,jdbcType=VARCHAR}, #{item.gsmc,jdbcType=VARCHAR}, |
||||
#{item.client,jdbcType=VARCHAR},#{item.createTime,jdbcType=TIMESTAMP}) |
||||
</foreach> |
||||
</insert> |
||||
</mapper> |
Loading…
Reference in new issue