parent
5cffdbc8e6
commit
de257568f1
|
|
@ -0,0 +1,14 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id number primary key ,
|
||||
source varchar2(500) ,
|
||||
api varchar2(500),
|
||||
param clob ,
|
||||
response clob,
|
||||
create_time date,
|
||||
update_time date,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar2(10)
|
||||
);
|
||||
/
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id number primary key ,
|
||||
source varchar2(500) ,
|
||||
api varchar2(500),
|
||||
param clob ,
|
||||
response clob,
|
||||
create_time date,
|
||||
update_time date,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar2(10)
|
||||
);
|
||||
/
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id number primary key ,
|
||||
source varchar2(500) ,
|
||||
api varchar2(500),
|
||||
param clob ,
|
||||
response clob,
|
||||
create_time date,
|
||||
update_time date,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar2(10)
|
||||
);
|
||||
/
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
CREATE TABLE hrsa_api_task_record (
|
||||
id bigint(0) NOT NULL ,
|
||||
source varchar(500) ,
|
||||
api varchar(500),
|
||||
param text ,
|
||||
response text,
|
||||
tenant_key varchar(255) ,
|
||||
delete_type int(0) ,
|
||||
create_time datetime(0),
|
||||
update_time datetime(0),
|
||||
PRIMARY KEY (id) USING BTREE
|
||||
);
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id number primary key ,
|
||||
source varchar2(500) ,
|
||||
api varchar2(500),
|
||||
param clob ,
|
||||
response clob,
|
||||
create_time date,
|
||||
update_time date,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar2(10)
|
||||
)
|
||||
/
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id bigint primary key ,
|
||||
source varchar(500) ,
|
||||
api varchar(500),
|
||||
param text ,
|
||||
response text,
|
||||
create_time timestamp,
|
||||
update_time timestamp,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar(10)
|
||||
);
|
||||
/
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id bigint primary key ,
|
||||
source varchar(500) ,
|
||||
api varchar(500),
|
||||
param ntext ,
|
||||
response ntext,
|
||||
create_time datetime,
|
||||
update_time datetime,
|
||||
delete_type int default 0,
|
||||
tenant_key nvarchar(10)
|
||||
)
|
||||
GO
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
create table hrsa_api_task_record
|
||||
(
|
||||
id number primary key ,
|
||||
source varchar2(500) ,
|
||||
api varchar2(500),
|
||||
param clob ,
|
||||
response clob,
|
||||
create_time date,
|
||||
update_time date,
|
||||
delete_type int default 0,
|
||||
tenant_key varchar2(10)
|
||||
);
|
||||
/
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.engine.salary.entity.api;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ApiTaskRecordPO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* api操作
|
||||
*/
|
||||
private String api;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String param;
|
||||
/**
|
||||
* 反馈
|
||||
*/
|
||||
private String response;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer deleteType;
|
||||
|
||||
/**
|
||||
* 租户key
|
||||
*/
|
||||
private String tenantKey;
|
||||
|
||||
//主键id集合
|
||||
private Collection<Long> ids;
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.entity.taxagent.response;
|
||||
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -11,11 +12,7 @@ import lombok.Data;
|
|||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
public class CheckPasswordResponse {
|
||||
/**
|
||||
* 接口状态
|
||||
*/
|
||||
private SzyhResponseHead head;
|
||||
public class CheckPasswordResponse extends BaseResponse {
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.entity.taxagent.response;
|
||||
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -13,11 +14,8 @@ import java.util.List;
|
|||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
public class CompanyRegisterInfoResponse {
|
||||
/**
|
||||
* 接口状态
|
||||
*/
|
||||
private SzyhResponseHead head;
|
||||
public class CompanyRegisterInfoResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
package com.engine.salary.mapper.api;
|
||||
|
||||
import com.engine.salary.entity.api.ApiTaskRecordPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ApiTaskRecordMapper {
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<ApiTaskRecordPO> listAll();
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<ApiTaskRecordPO> listSome(ApiTaskRecordPO apiTaskRecord);
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 返回记录,没有返回null
|
||||
*/
|
||||
ApiTaskRecordPO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增,忽略null字段
|
||||
*
|
||||
* @param apiTaskRecord 新增的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int insertIgnoreNull(ApiTaskRecordPO apiTaskRecord);
|
||||
|
||||
/**
|
||||
* 修改,修改所有字段
|
||||
*
|
||||
* @param apiTaskRecord 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int update(ApiTaskRecordPO apiTaskRecord);
|
||||
|
||||
/**
|
||||
* 修改,忽略null字段
|
||||
*
|
||||
* @param apiTaskRecord 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int updateIgnoreNull(ApiTaskRecordPO apiTaskRecord);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param apiTaskRecord 待删除的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int delete(ApiTaskRecordPO apiTaskRecord);
|
||||
|
||||
/**
|
||||
* 批量删除记录
|
||||
* @param ids 主键id集合
|
||||
*/
|
||||
void deleteByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
<?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.engine.salary.mapper.api.ApiTaskRecordMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.api.ApiTaskRecordPO">
|
||||
<result column="api" property="api"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="id" property="id"/>
|
||||
<result column="param" property="param"/>
|
||||
<result column="response" property="response"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="tenant_key" property="tenantKey"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
api
|
||||
, t.create_time
|
||||
, t.delete_type
|
||||
, t.id
|
||||
, t.param
|
||||
, t.response
|
||||
, t.source
|
||||
, t.tenant_key
|
||||
, t.update_time
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="listAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_api_task_record t
|
||||
WHERE delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据主键获取单条记录 -->
|
||||
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_api_task_record t
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 条件查询 -->
|
||||
<select id="listSome" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.api.ApiTaskRecordPO">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_api_task_record t
|
||||
WHERE delete_type = 0
|
||||
<if test="api != null">
|
||||
AND api = #{api}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
AND create_time = #{createTime}
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
AND delete_type = #{deleteType}
|
||||
</if>
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="param != null">
|
||||
AND param = #{param}
|
||||
</if>
|
||||
<if test="response != null">
|
||||
AND response = #{response}
|
||||
</if>
|
||||
<if test="source != null">
|
||||
AND source = #{source}
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
AND tenant_key = #{tenantKey}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
AND update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="ids != null and ids.size()>0">
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 插入不为NULL的字段 -->
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.api.ApiTaskRecordPO">
|
||||
INSERT INTO hrsa_api_task_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
<if test="api != null">
|
||||
api,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type,
|
||||
</if>
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="param != null">
|
||||
param,
|
||||
</if>
|
||||
<if test="response != null">
|
||||
response,
|
||||
</if>
|
||||
<if test="source != null">
|
||||
source,
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
tenant_key,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="api != null">
|
||||
#{api},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
#{deleteType},
|
||||
</if>
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="param != null">
|
||||
#{param},
|
||||
</if>
|
||||
<if test="response != null">
|
||||
#{response},
|
||||
</if>
|
||||
<if test="source != null">
|
||||
#{source},
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
#{tenantKey},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新,更新全部字段 -->
|
||||
<update id="update" parameterType="com.engine.salary.entity.api.ApiTaskRecordPO">
|
||||
UPDATE hrsa_api_task_record
|
||||
<set>
|
||||
api=#{api},
|
||||
create_time=#{createTime},
|
||||
delete_type=#{deleteType},
|
||||
param=#{param},
|
||||
response=#{response},
|
||||
source=#{source},
|
||||
tenant_key=#{tenantKey},
|
||||
update_time=#{updateTime},
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 更新不为NULL的字段 -->
|
||||
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.api.ApiTaskRecordPO">
|
||||
UPDATE hrsa_api_task_record
|
||||
<set>
|
||||
<if test="api != null">
|
||||
api=#{api},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time=#{createTime},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator=#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type=#{deleteType},
|
||||
</if>
|
||||
<if test="param != null">
|
||||
param=#{param},
|
||||
</if>
|
||||
<if test="response != null">
|
||||
response=#{response},
|
||||
</if>
|
||||
<if test="source != null">
|
||||
source=#{source},
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
tenant_key=#{tenantKey},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time=#{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 根据主键删除记录 -->
|
||||
<delete id="delete">
|
||||
UPDATE hrsa_api_task_record
|
||||
SET delete_type=1
|
||||
WHERE id = #{id}
|
||||
AND delete_type = 0
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByIds">
|
||||
UPDATE hrsa_api_task_record
|
||||
SET delete_type = 1
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.engine.salary.remote.tax.client;
|
||||
|
||||
import com.engine.salary.constant.SzyhApiConstant;
|
||||
import com.engine.salary.entity.taxagent.response.CheckPasswordResponse;
|
||||
import com.engine.salary.entity.taxagent.response.CompanyRegisterInfoResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class CompanyClient extends TaxBaseClient {
|
||||
|
||||
|
||||
public CompanyClient(Long taxAgentId, User user) {
|
||||
super(taxAgentId, user);
|
||||
}
|
||||
|
||||
public CompanyRegisterInfoResponse getCompanyRegisterInfo(Map<String, Object> requestParam) {
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.GET_REGISTER_INFO_URL;
|
||||
String requestId = request(url, requestParam);
|
||||
|
||||
String getRegisterInfoFeedbackUrl = apiConfig.getHost() + SzyhApiConstant.GET_REGISTER_INFO_FEEDBACK_URL;
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("requestId", requestId);
|
||||
return response(getRegisterInfoFeedbackUrl, map, CompanyRegisterInfoResponse.class);
|
||||
}
|
||||
|
||||
public CheckPasswordResponse checkPassword(Map<String, Object> requestParam) {
|
||||
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.CHECK_PASSWORD_URL;
|
||||
String requestId = request(url, requestParam);
|
||||
|
||||
String checkPasswordFeedbackUrl = apiConfig.getHost() + SzyhApiConstant.CHECK_PASSWORD_FEEDBACK_URL;
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("requestId", requestId);
|
||||
return response(checkPasswordFeedbackUrl, map, CheckPasswordResponse.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,21 @@
|
|||
package com.engine.salary.remote.tax.client;
|
||||
|
||||
import com.engine.salary.constant.SzyhApiConstant;
|
||||
import com.engine.salary.remote.tax.response.RequestIdResponse;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.taxagent.TaxAgentTaxReturnMapper;
|
||||
import com.engine.salary.mapper.taxdeclaration.TaxDeclareApiConfigMapper;
|
||||
import com.engine.salary.util.Sm4Utils;
|
||||
import com.engine.salary.util.*;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class TaxBaseClient {
|
||||
|
|
@ -20,8 +29,9 @@ public class TaxBaseClient {
|
|||
}
|
||||
|
||||
public Long taxAgentId;
|
||||
public TaxDeclarationApiConfigPO apiConfig ;
|
||||
public TaxAgentTaxReturnPO returnPO ;
|
||||
public User user;
|
||||
public TaxDeclarationApiConfigPO apiConfig;
|
||||
public TaxAgentTaxReturnPO returnPO;
|
||||
|
||||
public TaxBaseClient(Long taxAgentId) {
|
||||
this.taxAgentId = taxAgentId;
|
||||
|
|
@ -35,4 +45,61 @@ public class TaxBaseClient {
|
|||
}
|
||||
this.returnPO = taxReturnPO;
|
||||
}
|
||||
|
||||
public TaxBaseClient(Long taxAgentId, User user) {
|
||||
this.taxAgentId = taxAgentId;
|
||||
this.apiConfig = getTaxDeclareApiConfigMapper().getOne();
|
||||
TaxAgentTaxReturnPO taxReturnPO = getTaxAgentTaxReturnMapper().selectOneByTaxAgentId(taxAgentId);
|
||||
try {
|
||||
// 密码解密
|
||||
taxReturnPO.setPwd(Sm4Utils.decryptEcb(apiConfig.getAppSecret(), taxReturnPO.getPwd()));
|
||||
} catch (Exception e) {
|
||||
log.error("Sm4Utils.decryptEcb ---- error: {}", e.getMessage());
|
||||
}
|
||||
this.returnPO = taxReturnPO;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String request(String url, Map<String, Object> requestParam) {
|
||||
String reqJson = JsonUtil.toJsonString(requestParam);
|
||||
Map<String, String> header = SingnatureData.initHeader(new HashMap<>(1), apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
||||
//记录接口
|
||||
TaskUtil taskUtil = new TaskUtil();
|
||||
taskUtil.writeApiTaskRecord(Util.null2String(taxAgentId), url, reqJson, res);
|
||||
|
||||
RequestIdResponse response = JsonUtil.parseObject(res, RequestIdResponse.class);
|
||||
if (response == null || response.getHead() == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
|
||||
}
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(response.getHead().getCode()) || response.getBody() == null) {
|
||||
// 如果返回错误
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, response.getHead().getMsg()));
|
||||
}
|
||||
return response.getBody().getRequestId();
|
||||
}
|
||||
|
||||
public <T extends BaseResponse> T response(String url, Map<String, String> param, Class<T> clazz) {
|
||||
TaskUtil taskUtil = new TaskUtil();
|
||||
T response = null;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Map<String, String> header = SingnatureData.initHeader(new HashMap<>(1), apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.getRequest(url, header, param);
|
||||
response = JsonUtil.parseBean(res, clazz);
|
||||
//记录接口
|
||||
taskUtil.writeApiTaskRecord(Util.null2String(taxAgentId), url, JsonUtil.toJsonString(param), res);
|
||||
// 如果税友返回错误信息
|
||||
String code = response.getHead().getCode();
|
||||
if (SzyhApiConstant.HANDLING_CODE.equals(code)) {
|
||||
try {
|
||||
Thread.sleep(5 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("", e);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.entity.taxagent.response;
|
||||
package com.engine.salary.remote.tax.response;
|
||||
|
||||
import com.engine.salary.entity.taxagent.response.SzyhResponseHead;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -11,7 +12,7 @@ import lombok.Data;
|
|||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
public class GetRequestIdResponse {
|
||||
public class RequestIdResponse {
|
||||
/**
|
||||
* 接口状态
|
||||
*/
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
public interface ApiTaskService {
|
||||
|
||||
void writeApiTaskRecord (String source,String api,String param,String response);
|
||||
|
||||
}
|
||||
|
|
@ -10,18 +10,16 @@ import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
|||
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
||||
import com.engine.salary.entity.taxagent.response.CheckPasswordResponse;
|
||||
import com.engine.salary.entity.taxagent.response.CompanyRegisterInfoResponse;
|
||||
import com.engine.salary.entity.taxagent.response.GetRequestIdResponse;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
|
||||
import com.engine.salary.enums.SalaryOnOffEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnPasswordTypeEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnStatusEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.taxagent.TaxAgentTaxReturnMapper;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.TaxAgentTaxReturnCheckService;
|
||||
import com.engine.salary.service.TaxAgentTaxReturnService;
|
||||
import com.engine.salary.service.TaxDeclarationApiConfigService;
|
||||
import com.engine.salary.util.*;
|
||||
import com.engine.salary.remote.tax.client.CompanyClient;
|
||||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.util.SalaryAssert;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -57,6 +55,10 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
|
||||
}
|
||||
|
||||
protected ApiTaskService getApiTaskService(User user) {
|
||||
return ServiceUtil.getService(ApiTaskServiceImpl.class, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证类型
|
||||
*
|
||||
|
|
@ -83,9 +85,7 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
po.setUpdateTime(new Date());
|
||||
// 如果税友返回错误信息
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(response.getHead().getCode()) || CollectionUtils.isEmpty(response.getBody())) {
|
||||
po.setCheckStatus(TaxAgentTaxReturnStatusEnum.FAIL.getValue());
|
||||
po.setFailReason(response.getHead().getMsg());
|
||||
return new ArrayList<>();
|
||||
throw new SalaryRunTimeException(response.getHead().getMsg());
|
||||
}
|
||||
// 如果税友返回验证信息
|
||||
List<TaxAgentTaxReturnCheckFormDTO> checkFormDTOList = buildCheckDTO(saveParam, response.getBody());
|
||||
|
|
@ -109,11 +109,11 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
* @return
|
||||
*/
|
||||
protected CompanyRegisterInfoResponse getCompanyRegisterInfo(TaxDeclarationApiConfigPO apiConfig, TaxAgentTaxReturnPO taxAgentTaxReturnPO, TaxAgentTaxReturnSaveParam saveParam) {
|
||||
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxAgentTaxReturnPO.getTaxAgentId());
|
||||
Long taxAgentId = taxAgentTaxReturnPO.getTaxAgentId();
|
||||
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxAgentId);
|
||||
if (taxAgentPO == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在"));
|
||||
}
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.GET_REGISTER_INFO_URL;
|
||||
Map<String, Object> requestParam = new HashMap<>(4);
|
||||
requestParam.put("bizNo", IdGenerator.generate());
|
||||
requestParam.put("qymc", taxAgentPO.getName());
|
||||
|
|
@ -122,40 +122,11 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
if (StringUtils.isNotEmpty(saveParam.getTaxRegistrationNumber())) {
|
||||
requestParam.put("djxhid", saveParam.getTaxRegistrationNumber());
|
||||
}
|
||||
String reqJson = JsonUtil.toJsonString(requestParam);
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
||||
log.info("getCompanyRegisterInfo1 === params:{} === res : {}", reqJson, res);
|
||||
GetRequestIdResponse getRequestIdResponse = JsonUtil.parseBean(res, GetRequestIdResponse.class);
|
||||
|
||||
if (getRequestIdResponse == null || getRequestIdResponse.getHead() == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
|
||||
}
|
||||
taxAgentTaxReturnPO.setCheckStatus(TaxAgentTaxReturnStatusEnum.NOT_COMMIT.getValue());
|
||||
taxAgentTaxReturnPO.setUpdateTime(new Date());
|
||||
// 如果税友返回错误信息
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(getRequestIdResponse.getHead().getCode()) || getRequestIdResponse.getBody() == null) {
|
||||
taxAgentTaxReturnPO.setCheckStatus(TaxAgentTaxReturnStatusEnum.FAIL.getValue());
|
||||
taxAgentTaxReturnPO.setFailReason(getRequestIdResponse.getHead().getMsg());
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(5 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String requestId = getRequestIdResponse.getBody().getRequestId();
|
||||
String getRegisterInfoFeedbackUrl = apiConfig.getHost() + SzyhApiConstant.GET_REGISTER_INFO_FEEDBACK_URL;
|
||||
Map<String, String> feedbackHeader = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("requestId", requestId);
|
||||
String companyRegisterInfoResponseRes = HttpUtil.getRequest(getRegisterInfoFeedbackUrl, feedbackHeader, map);
|
||||
log.info("getCompanyRegisterInfo2 === requestId:{} === res : {}", requestId, companyRegisterInfoResponseRes);
|
||||
return JsonUtil.parseBean(companyRegisterInfoResponseRes, CompanyRegisterInfoResponse.class);
|
||||
return new CompanyClient(taxAgentId, user).getCompanyRegisterInfo(requestParam);
|
||||
}
|
||||
|
||||
|
||||
private List<TaxAgentTaxReturnCheckFormDTO> buildCheckDTO(TaxAgentTaxReturnSaveParam saveParam, List<CompanyRegisterInfoResponse.CompanyRegisterInfo> registerInfos) {
|
||||
List<TaxAgentTaxReturnCheckFormDTO> checkFormDTOList = new ArrayList<>();
|
||||
for (int i = 1; i <= registerInfos.size(); i++) {
|
||||
|
|
@ -194,7 +165,7 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
if (taxAgentPO == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在"));
|
||||
}
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.CHECK_PASSWORD_URL;
|
||||
Long taxAgentId = taxAgentPO.getId();
|
||||
Map<String, Object> requestParam = new HashMap<>(16);
|
||||
requestParam.put("bizNo", IdGenerator.generate());
|
||||
requestParam.put("qymc", taxAgentPO.getName());
|
||||
|
|
@ -214,38 +185,8 @@ public abstract class AbstractTaxAgentTaxReturnCheckService extends Service impl
|
|||
requestParam.put("bmbh", saveParam.getDepartmentCode());
|
||||
requestParam.put("bmmc", saveParam.getDepartmentName());
|
||||
}
|
||||
String reqJson = JsonUtil.toJsonString(requestParam);
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
||||
log.info("checkPassword1 === reqJson :{} === res : {}", reqJson, res);
|
||||
|
||||
GetRequestIdResponse response = JsonUtil.parseObject(res, GetRequestIdResponse.class);
|
||||
if (response == null || response.getHead() == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
|
||||
}
|
||||
taxAgentTaxReturnPO.setUpdateTime(new Date());
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(response.getHead().getCode()) || response.getBody() == null) {
|
||||
// 如果返回错误
|
||||
taxAgentTaxReturnPO.setCheckStatus(TaxAgentTaxReturnStatusEnum.FAIL.getValue());
|
||||
taxAgentTaxReturnPO.setFailReason(response.getHead().getMsg());
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(5 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String checkPasswordFeedbackUrl = apiConfig.getHost() + SzyhApiConstant.CHECK_PASSWORD_FEEDBACK_URL;
|
||||
Map<String, String> feedbackHeader = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
String requestId = response.getBody().getRequestId();
|
||||
map.put("requestId", requestId);
|
||||
res = HttpUtil.getRequest(checkPasswordFeedbackUrl, feedbackHeader, map);
|
||||
log.info("checkPassword2 === requestId :{} === res : {}", requestId, res);
|
||||
return JsonUtil.parseBean(res, CheckPasswordResponse.class);
|
||||
return new CompanyClient(taxAgentId, user).checkPassword(requestParam);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.api.ApiTaskRecordPO;
|
||||
import com.engine.salary.mapper.api.ApiTaskRecordMapper;
|
||||
import com.engine.salary.service.ApiTaskService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* api任务调度服务
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class ApiTaskServiceImpl extends Service implements ApiTaskService {
|
||||
|
||||
private ApiTaskRecordMapper getApiTaskRecordMapper() {
|
||||
return MapperProxyFactory.getProxy(ApiTaskRecordMapper.class);
|
||||
}
|
||||
|
||||
private TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeApiTaskRecord(String source, String api, String param, String response) {
|
||||
log.info("source:{} , api:{} , param:{} , response : {}", source, api, param, response);
|
||||
Date now = new Date();
|
||||
ApiTaskRecordPO build = ApiTaskRecordPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.source(source)
|
||||
.api(api)
|
||||
.param(param)
|
||||
.response(response)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
getApiTaskRecordMapper().insertIgnoreNull(build);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import com.engine.salary.entity.salarysob.po.SalarySobTaxReportRulePO;
|
|||
import com.engine.salary.entity.taxagent.bo.TaxAgentTaxReturnBO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
||||
import com.engine.salary.entity.taxagent.response.GetRequestIdResponse;
|
||||
import com.engine.salary.remote.tax.response.RequestIdResponse;
|
||||
import com.engine.salary.entity.taxapiflow.bo.TaxApiFlowBO;
|
||||
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO;
|
||||
import com.engine.salary.entity.taxdeclaration.bo.*;
|
||||
|
|
@ -1008,6 +1008,9 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
requestParam.put("skssq", SalaryDateUtil.getFormatYYYYMM(taxDeclareRecord.getTaxCycle()));
|
||||
// 申报类型
|
||||
requestParam.put("sblx", reportType + "");
|
||||
|
||||
|
||||
|
||||
// 请求
|
||||
String reqJson = JsonUtil.toJsonString(requestParam);
|
||||
|
||||
|
|
@ -1015,7 +1018,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
|||
Map<String, String> params = new HashMap<>(1);
|
||||
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
||||
GetRequestIdResponse getRequestIdResponse = JsonUtil.parseObject(res, GetRequestIdResponse.class);
|
||||
RequestIdResponse getRequestIdResponse = JsonUtil.parseObject(res, RequestIdResponse.class);
|
||||
log.info("更正申报请求数据1:=== params:{} ,getRequestIdResponse:{}", res, getRequestIdResponse);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.engine.salary.util;
|
||||
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.api.ApiTaskRecordPO;
|
||||
import com.engine.salary.mapper.api.ApiTaskRecordMapper;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
public class TaskUtil {
|
||||
|
||||
private ApiTaskRecordMapper getApiTaskRecordMapper() {
|
||||
return MapperProxyFactory.getProxy(ApiTaskRecordMapper.class);
|
||||
}
|
||||
|
||||
public void writeApiTaskRecord(String source, String api, String param, String response) {
|
||||
log.info("source:{} , api:{} , param:{} , response : {}", source, api, param, response);
|
||||
Date now = new Date();
|
||||
ApiTaskRecordPO build = ApiTaskRecordPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.source(source)
|
||||
.api(api)
|
||||
.param(param)
|
||||
.response(response)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
getApiTaskRecordMapper().insertIgnoreNull(build);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue