流量监控

This commit is contained in:
钱涛 2023-08-28 13:31:11 +08:00
parent c29c032ef5
commit b5f9477c90
32 changed files with 2270 additions and 361 deletions

View File

@ -0,0 +1,47 @@
create table hrsa_tax_api_flow_receiver
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
warn_config_id number not null,
employee_id number not null,
email varchar2(100),
mobile varchar2(50)
);
/
create table hrsa_tax_api_flow_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number not null,
tax_month date not null,
use_time date not null,
deduct int,
employee_id number not null,
business_type int not null,
result_status int not null
);
/
create table hrsa_tax_api_flow_warn_config
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id number default '0' not null
);
/

View File

@ -0,0 +1,47 @@
create table hrsa_tax_api_flow_receiver
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
warn_config_id number not null,
employee_id number not null,
email varchar2(100),
mobile varchar2(50)
);
/
create table hrsa_tax_api_flow_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number not null,
tax_month date not null,
use_time date not null,
deduct int,
employee_id number not null,
business_type int not null,
result_status int not null
);
/
create table hrsa_tax_api_flow_warn_config
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id number default '0' not null
);
/

View File

@ -0,0 +1,47 @@
create table hrsa_tax_api_flow_receiver
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
warn_config_id number not null,
employee_id number not null,
email varchar2(100),
mobile varchar2(50)
);
/
create table hrsa_tax_api_flow_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number not null,
tax_month date not null,
use_time date not null,
deduct int,
employee_id number not null,
business_type int not null,
result_status int not null
);
/
create table hrsa_tax_api_flow_warn_config
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id number default '0' not null
);
/

View File

@ -0,0 +1,46 @@
create table hrsa_tax_api_flow_receiver
(
id bigint primary key comment 'ID' ,
create_time datetime comment '创建时间' ,
update_time datetime comment '修改时间' ,
creator bigint comment '创建人id' ,
delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' ,
warn_config_id bigint not null comment '提醒配置的id' ,
employee_id bigint not null comment '接收人id' ,
email varchar(100) comment '邮箱' ,
mobile varchar(50) comment '手机号'
)
;
create table hrsa_tax_api_flow_record
(
id bigint primary key comment 'ID' ,
create_time datetime comment '创建时间' ,
update_time datetime comment '修改时间' ,
creator bigint comment '创建人id' ,
delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' ,
tax_agent_id bigint not null comment '个税扣缴义务人的主键id' ,
tax_month datetime not null comment '税款所属期' ,
use_time datetime not null comment '使用时间' ,
deduct int comment '是否扣流量(暂时没用)' ,
employee_id bigint not null comment '人员ID' ,
business_type int not null comment '接口业务类型' ,
result_status int not null comment '结果'
)
;
create table hrsa_tax_api_flow_warn_config
(
id bigint primary key comment 'ID' ,
create_time datetime comment '创建时间' ,
update_time datetime comment '修改时间' ,
creator bigint comment '创建人id' ,
delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' ,
enable_warn int default 0 not null comment '是否提醒' ,
threshold int default 0 not null comment '提醒阈值' ,
business_id bigint default '0' not null comment '消息业务ID'
)
;

View File

@ -0,0 +1,48 @@
create table hrsa_tax_api_flow_receiver
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
warn_config_id number not null,
employee_id number not null,
email varchar2(100),
mobile varchar2(50)
)
/
create table hrsa_tax_api_flow_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number not null,
tax_month date not null,
use_time date not null,
deduct int,
employee_id number not null,
business_type int not null,
result_status int not null
)
/
create table hrsa_tax_api_flow_warn_config
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id number default '0' not null
)
/

View File

@ -0,0 +1,46 @@
create table hrsa_tax_api_flow_receiver
(
id bigint primary key ,
create_time timestamp,
update_time timestamp,
creator bigint,
delete_type int default 0,
tenant_key varchar(10),
warn_config_id bigint not null,
employee_id bigint not null,
email varchar(100),
mobile varchar(50)
);
/
create table hrsa_tax_api_flow_record
(
id bigint primary key ,
create_time timestamp,
update_time timestamp,
creator bigint,
delete_type int default 0,
tenant_key varchar(10),
tax_agent_id bigint not null,
tax_month timestamp not null,
use_time timestamp not null,
deduct int,
employee_id bigint not null,
business_type int not null,
result_status int not null
);
/
create table hrsa_tax_api_flow_warn_config
(
id bigint primary key ,
create_time timestamp,
update_time timestamp,
creator bigint,
delete_type int default 0,
tenant_key varchar(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id bigint default '0' not null
);
/

View File

@ -0,0 +1,46 @@
create table hrsa_tax_api_flow_receiver
(
id bigint primary key ,
create_time datetime,
update_time datetime,
creator bigint,
delete_type int default 0,
tenant_key nvarchar(10),
warn_config_id bigint not null,
employee_id bigint not null,
email nvarchar(100),
mobile nvarchar(50)
)
GO
create table hrsa_tax_api_flow_record
(
id bigint primary key ,
create_time datetime,
update_time datetime,
creator bigint,
delete_type int default 0,
tenant_key nvarchar(10),
tax_agent_id bigint not null,
tax_month datetime not null,
use_time datetime not null,
deduct int,
employee_id bigint not null,
business_type int not null,
result_status int not null
)
GO
create table hrsa_tax_api_flow_warn_config
(
id bigint primary key ,
create_time datetime,
update_time datetime,
creator bigint,
delete_type int default 0,
tenant_key nvarchar(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id bigint default '0' not null
)
GO

View File

@ -0,0 +1,47 @@
create table hrsa_tax_api_flow_receiver
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
warn_config_id number not null,
employee_id number not null,
email varchar2(100),
mobile varchar2(50)
);
/
create table hrsa_tax_api_flow_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number not null,
tax_month date not null,
use_time date not null,
deduct int,
employee_id number not null,
business_type int not null,
result_status int not null
);
/
create table hrsa_tax_api_flow_warn_config
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
enable_warn int default 0 not null,
threshold int default 0 not null,
business_id number default '0' not null
);
/

View File

@ -2,13 +2,13 @@ package com.engine.salary.entity.taxapiflow.param;
import com.engine.salary.common.BaseQueryParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
import java.util.Date;
/**
* 流量月度详情查询参数
@ -27,10 +27,10 @@ public class TaxDeclarationApiFlowRecordQueryParam extends BaseQueryParam {
private Long taxAgentId;
//开始时间")
private LocalDate startDate;
private Date startDate;
//结束时间")
private LocalDate endDate;
private Date endDate;
//业务接口类型")
private Integer businessType;

View File

@ -9,6 +9,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
/**
@ -97,4 +98,9 @@ public class TaxDeclarationApiFlowRecordPO implements Serializable {
*/
private String tenantKey;
private Collection<Long> ids;
private Date useTimeStartDate;
private Date useTimeEndDate;
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
/**
@ -29,6 +30,7 @@ public class TaxDeclarationApiFlowWarnReceiverPO implements Serializable {
*/
private Long id;
/**
* 提醒配置的id
*/
@ -73,4 +75,7 @@ public class TaxDeclarationApiFlowWarnReceiverPO implements Serializable {
* 租户ID
*/
private String tenantKey;
private Collection<Long> ids;
}

View File

@ -69,4 +69,10 @@ public interface TaxAgentMapper {
List<TaxAgentEmployeePO> listEmployee();
/**
* 查询包含删除状态的数据
* @param taxAgentIds
* @return
*/
List<TaxAgentPO> listByIdsIncludeDel(@Param("taxAgentIds") Collection<Long> taxAgentIds);
}

View File

@ -238,5 +238,17 @@
where e.status not in (7)
</select>
<select id="listByIdsIncludeDel" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_agent t
WHERE 1=1
<if test="taxAgentIds != null and taxAgentIds.size()>0">
AND id IN
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
</select>
</mapper>

View File

@ -0,0 +1,81 @@
package com.engine.salary.mapper.taxapiflow;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface TaxDeclarationApiFlowWarnConfigMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowWarnConfigPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowWarnConfigPO> listSome(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
TaxDeclarationApiFlowWarnConfigPO getById(Long id);
/**
* 新增忽略null字段
*
* @param taxApiFlowWarnConfig 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig);
/**
* 批量插入
*
* @param taxApiFlowWarnConfig
*/
void batchInsert(@Param("collection") List<TaxDeclarationApiFlowWarnConfigPO> taxApiFlowWarnConfig);
/**
* 修改修改所有字段
*
* @param taxApiFlowWarnConfig 修改的记录
* @return 返回影响行数
*/
int update(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig);
/**
* 修改忽略null字段
*
* @param taxApiFlowWarnConfig 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig);
/**
* 删除记录
*
* @param taxApiFlowWarnConfig 待删除的记录
* @return 返回影响行数
*/
int delete(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig);
/**
* 批量删除记录
* @param ids 主键id集合
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
TaxDeclarationApiFlowWarnConfigPO getOne();
}

View File

@ -0,0 +1,321 @@
<?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.taxapiflow.TaxDeclarationApiFlowWarnConfigMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO">
<result column="business_id" property="businessId"/>
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="enable_warn" property="enableWarn"/>
<result column="id" property="id"/>
<result column="tenant_key" property="tenantKey"/>
<result column="threshold" property="threshold"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
business_id
, t.create_time
, t.creator
, t.delete_type
, t.enable_warn
, t.id
, t.tenant_key
, t.threshold
, t.update_time
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_warn_config t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_warn_config t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_warn_config t
WHERE delete_type = 0
<if test="businessId != null">
AND business_id = #{businessId}
</if>
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="enableWarn != null">
AND enable_warn = #{enableWarn}
</if>
<if test="id != null">
AND id = #{id}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="threshold != null">
AND threshold = #{threshold}
</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.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO">
INSERT INTO hrsa_tax_api_flow_warn_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="businessId != null">
business_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="enableWarn != null">
enable_warn,
</if>
<if test="id != null">
id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="threshold != null">
threshold,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="businessId != null">
#{businessId},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="enableWarn != null">
#{enableWarn},
</if>
<if test="id != null">
#{id},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="threshold != null">
#{threshold},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO hrsa_tax_api_flow_warn_config
(
business_id,
create_time,
creator,
delete_type,
enable_warn,
id,
tenant_key,
threshold,
update_time
)
VALUES
(
<foreach collection="collection" item="item" separator=",">
#{item.businessId},
#{item.createTime},
#{item.creator},
#{item.deleteType},
#{item.enableWarn},
#{item.id},
#{item.tenantKey},
#{item.threshold},
#{item.updateTime}
</foreach>
)
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_api_flow_warn_config (
business_id,
create_time,
creator,
delete_type,
enable_warn,
id,
tenant_key,
threshold,
update_time
)
<foreach collection="collection" item="item" separator="union all">
select
#{item.businessId,jdbcType=DOUBLE},
#{item.createTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.deleteType,jdbcType=INTEGER},
#{item.enableWarn,jdbcType=INTEGER},
#{item.id,jdbcType=DOUBLE},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.threshold,jdbcType=DOUBLE},
#{item.updateTime,jdbcType=DATE}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
<foreach collection="collection" item="item" separator=";">
INSERT INTO hrsa_tax_api_flow_warn_config (
business_id,
create_time,
creator,
delete_type,
enable_warn,
id,
tenant_key,
threshold,
update_time
)
VALUES
(
#{item.businessId},
#{item.createTime},
#{item.creator},
#{item.deleteType},
#{item.enableWarn},
#{item.id},
#{item.tenantKey},
#{item.threshold},
#{item.updateTime}
)
</foreach>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO">
UPDATE hrsa_tax_api_flow_warn_config
<set>
business_id=#{businessId},
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
enable_warn=#{enableWarn},
tenant_key=#{tenantKey},
threshold=#{threshold},
update_time=#{updateTime},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull"
parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO">
UPDATE hrsa_tax_api_flow_warn_config
<set>
<if test="businessId != null">
business_id=#{businessId},
</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="enableWarn != null">
enable_warn=#{enableWarn},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="threshold != null">
threshold=#{threshold},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_tax_api_flow_warn_config
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_tax_api_flow_warn_config
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getOne" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_warn_config t
WHERE delete_type = 0
</select>
</mapper>

View File

@ -0,0 +1,82 @@
package com.engine.salary.mapper.taxapiflow;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface TaxDeclarationApiFlowWarnReceiverMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowWarnReceiverPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowWarnReceiverPO> listSome(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
TaxDeclarationApiFlowWarnReceiverPO getById(Long id);
/**
* 新增忽略null字段
*
* @param taxApiFlowReceiver 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver);
/**
* 批量插入
*
* @param taxApiFlowReceiver
*/
void batchInsert(@Param("collection") List<TaxDeclarationApiFlowWarnReceiverPO> taxApiFlowReceiver);
/**
* 修改修改所有字段
*
* @param taxApiFlowReceiver 修改的记录
* @return 返回影响行数
*/
int update(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver);
/**
* 修改忽略null字段
*
* @param taxApiFlowReceiver 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver);
/**
* 删除记录
*
* @param taxApiFlowReceiver 待删除的记录
* @return 返回影响行数
*/
int delete(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver);
/**
* 批量删除记录
*
* @param ids 主键id集合
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
List<TaxDeclarationApiFlowWarnReceiverPO> filterByEmpId(TaxDeclarationApiFlowWarnReceiverSaveParam param);
}

View File

@ -0,0 +1,347 @@
<?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.taxapiflow.TaxDeclarationApiFlowWarnReceiverMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="email" property="email"/>
<result column="employee_id" property="employeeId"/>
<result column="id" property="id"/>
<result column="mobile" property="mobile"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="warn_config_id" property="warnConfigId"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
create_time
, t.creator
, t.delete_type
, t.email
, t.employee_id
, t.id
, t.mobile
, t.tenant_key
, t.update_time
, t.warn_config_id
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_receiver t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_receiver t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_receiver t
WHERE delete_type = 0
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="email != null">
AND email = #{email}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="id != null">
AND id = #{id}
</if>
<if test="mobile != null">
AND mobile = #{mobile}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="warnConfigId != null">
AND warn_config_id = #{warnConfigId}
</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.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO">
INSERT INTO hrsa_tax_api_flow_receiver
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="email != null">
email,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="id != null">
id,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="warnConfigId != null">
warn_config_id,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="email != null">
#{email},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="id != null">
#{id},
</if>
<if test="mobile != null">
#{mobile},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="warnConfigId != null">
#{warnConfigId},
</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO hrsa_tax_api_flow_receiver
(
create_time,
creator,
delete_type,
email,
employee_id,
id,
mobile,
tenant_key,
update_time,
warn_config_id
)
VALUES
(
<foreach collection="collection" item="item" separator=",">
#{item.createTime},
#{item.creator},
#{item.deleteType},
#{item.email},
#{item.employeeId},
#{item.id},
#{item.mobile},
#{item.tenantKey},
#{item.updateTime},
#{item.warnConfigId}
</foreach>
)
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_api_flow_receiver (
create_time,
creator,
delete_type,
email,
employee_id,
id,
mobile,
tenant_key,
update_time,
warn_config_id
)
<foreach collection="collection" item="item" separator="union all">
select
#{item.createTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.deleteType,jdbcType=INTEGER},
#{item.email,jdbcType=VARCHAR},
#{item.employeeId,jdbcType=DOUBLE},
#{item.id,jdbcType=DOUBLE},
#{item.mobile,jdbcType=VARCHAR},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=DATE},
#{item.warnConfigId,jdbcType=DOUBLE}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
<foreach collection="collection" item="item" separator=";">
INSERT INTO hrsa_tax_api_flow_receiver (
create_time,
creator,
delete_type,
email,
employee_id,
id,
mobile,
tenant_key,
update_time,
warn_config_id
)
VALUES
(
#{item.createTime},
#{item.creator},
#{item.deleteType},
#{item.email},
#{item.employeeId},
#{item.id},
#{item.mobile},
#{item.tenantKey},
#{item.updateTime},
#{item.warnConfigId}
)
</foreach>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO">
UPDATE hrsa_tax_api_flow_receiver
<set>
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
email=#{email},
employee_id=#{employeeId},
mobile=#{mobile},
tenant_key=#{tenantKey},
update_time=#{updateTime},
warn_config_id=#{warnConfigId},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull"
parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO">
UPDATE hrsa_tax_api_flow_receiver
<set>
<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="email != null">
email=#{email},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="mobile != null">
mobile=#{mobile},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="warnConfigId != null">
warn_config_id=#{warnConfigId},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_tax_api_flow_receiver
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_tax_api_flow_receiver
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 条件查询 -->
<select id="filterByEmpId" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_receiver t
WHERE delete_type = 0
AND employee_id = #{employeeId}
AND warn_config_id = #{warnConfigId}
ORDER BY id DESC
</select>
</mapper>

View File

@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* 个税申报-接口流量使用记录
@ -16,6 +17,69 @@ import java.util.Collection;
**/
@Mapper
public interface TaxDeclarationApiFlowRecordMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowRecordPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationApiFlowRecordPO> listSome(TaxDeclarationApiFlowRecordPO taxApiFlowRecord);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
TaxDeclarationApiFlowRecordPO getById(Long id);
/**
* 新增忽略null字段
*
* @param taxApiFlowRecord 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(TaxDeclarationApiFlowRecordPO taxApiFlowRecord);
/**
* 修改修改所有字段
*
* @param taxApiFlowRecord 修改的记录
* @return 返回影响行数
*/
int update(TaxDeclarationApiFlowRecordPO taxApiFlowRecord);
/**
* 修改忽略null字段
*
* @param taxApiFlowRecord 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(TaxDeclarationApiFlowRecordPO taxApiFlowRecord);
/**
* 删除记录
*
* @param taxApiFlowRecord 待删除的记录
* @return 返回影响行数
*/
int delete(TaxDeclarationApiFlowRecordPO taxApiFlowRecord);
/**
* 批量删除记录
* @param ids 主键id集合
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
/**
* 批量插入
*

View File

@ -2,8 +2,290 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.engine.salary.mapper.taxdeclaration.TaxDeclarationApiFlowRecordMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO">
<result column="business_type" property="businessType"/>
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="deduct" property="deduct"/>
<result column="delete_type" property="deleteType"/>
<result column="employee_id" property="employeeId"/>
<result column="id" property="id"/>
<result column="result_status" property="resultStatus"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tax_month" property="taxMonth"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="use_time" property="useTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
business_type
, t.create_time
, t.creator
, t.deduct
, t.delete_type
, t.employee_id
, t.id
, t.result_status
, t.tax_agent_id
, t.tax_month
, t.tenant_key
, t.update_time
, t.use_time
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_record t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_record t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_api_flow_record t
WHERE delete_type = 0
<if test="businessType != null">
AND business_type = #{businessType}
</if>
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="deduct != null">
AND deduct = #{deduct}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="id != null">
AND id = #{id}
</if>
<if test="resultStatus != null">
AND result_status = #{resultStatus}
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="taxMonth != null">
AND tax_month = #{taxMonth}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="useTime != null">
AND use_time = #{useTime}
</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.taxapiflow.po.TaxDeclarationApiFlowRecordPO">
INSERT INTO hrsa_tax_api_flow_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="businessType != null">
business_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deduct != null">
deduct,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="id != null">
id,
</if>
<if test="resultStatus != null">
result_status,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="taxMonth != null">
tax_month,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="useTime != null">
use_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="businessType != null">
#{businessType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deduct != null">
#{deduct},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="id != null">
#{id},
</if>
<if test="resultStatus != null">
#{resultStatus},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="taxMonth != null">
#{taxMonth},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="useTime != null">
#{useTime},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO">
UPDATE hrsa_tax_api_flow_record
<set>
business_type=#{businessType},
create_time=#{createTime},
creator=#{creator},
deduct=#{deduct},
delete_type=#{deleteType},
employee_id=#{employeeId},
result_status=#{resultStatus},
tax_agent_id=#{taxAgentId},
tax_month=#{taxMonth},
tenant_key=#{tenantKey},
update_time=#{updateTime},
use_time=#{useTime},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO">
UPDATE hrsa_tax_api_flow_record
<set>
<if test="businessType != null">
business_type=#{businessType},
</if>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deduct != null">
deduct=#{deduct},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="resultStatus != null">
result_status=#{resultStatus},
</if>
<if test="taxAgentId != null">
tax_agent_id=#{taxAgentId},
</if>
<if test="taxMonth != null">
tax_month=#{taxMonth},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="useTime != null">
use_time=#{useTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_tax_api_flow_record
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_tax_api_flow_record
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsert">
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key, tax_agent_id,
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key,
tax_agent_id,
tax_month, use_time, deduct, employee_id, business_type, result_status)
VALUES
<foreach collection="collection" item="item" separator=",">
@ -24,7 +306,8 @@
</foreach>
</insert>
<insert id="batchInsert" databaseId="postgresql">
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key, tax_agent_id,
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key,
tax_agent_id,
tax_month, use_time, deduct, employee_id, business_type, result_status)
VALUES
<foreach collection="collection" item="item" separator=",">
@ -46,7 +329,8 @@
</foreach>
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key, tax_agent_id,
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key,
tax_agent_id,
tax_month, use_time, deduct, employee_id, business_type, result_status)
<foreach collection="collection" item="item" separator="union all">
@ -68,7 +352,8 @@
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key, tax_agent_id,
INSERT INTO hrsa_tax_api_flow_record (id, create_time, update_time, creator, delete_type, tenant_key,
tax_agent_id,
tax_month, use_time, deduct, employee_id, business_type, result_status)
VALUES
<foreach collection="collection" item="item" separator=",">

View File

@ -1,13 +0,0 @@
package com.engine.salary.mapper.taxdeclaration;
import org.apache.ibatis.annotations.Mapper;
/**
* 流量不足提醒配置
*
* @author chengliming
* @date 2022-11-21 16:39:10
*/
@Mapper
public interface TaxDeclarationApiFlowWarnConfigMapper {
}

View File

@ -15,6 +15,8 @@ import java.util.Map;
public interface ExtEmpService {
List<ExtEmpPO> listAll();
List<ExtEmpPO> list(ExtEmpQueryParam param);
PageInfo<ExtEmpPO> listPage (ExtEmpQueryParam param);

View File

@ -6,12 +6,10 @@ import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.entity.hrm.DeptInfo;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 人员信息
@ -97,4 +95,12 @@ public interface SalaryEmployeeService {
List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams);
/**
* 根据人员id查询身份证
*
* @param employeeIds
* @return
*/
Map<Long, String> mapByEmployeeIds(Collection<Long> employeeIds);
}

View File

@ -250,4 +250,12 @@ public interface TaxAgentService {
* @return
*/
Collection<Long> listEmployeeIdsInTaxAgent(Long taxAgentId);
/**
* 查询包含删除状态的数据
*
* @param taxAgentIds
* @return
*/
List<TaxAgentPO> listByIdsIncludeDel(Collection<Long> taxAgentIds);
}

View File

@ -1,6 +1,11 @@
package com.engine.salary.service;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowRecordListDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowRecordQueryParam;
import com.engine.salary.service.impl.TaxDeclarationApiBillingServiceImpl;
import com.engine.salary.util.page.PageInfo;
import java.util.List;
/**
* 个税申报计费service
@ -19,21 +24,21 @@ public interface TaxDeclarationApiBillingService {
*/
void updateApiFlowInfo(TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper updateWrapper);
// /**
// * 获取流量使用记录(分页)
// *
// * @param queryParam
// * @return
// */
// PageInfo<TaxDeclarationApiFlowRecordListDTO> pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam);
//
// /**
// * 获取流量使用记录不分页
// *
// * @param queryParam
// * @return
// */
// List<TaxDeclarationApiFlowRecordListDTO> listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam);
/**
* 获取流量使用记录(分页)
*
* @param queryParam
* @return
*/
PageInfo<TaxDeclarationApiFlowRecordListDTO> pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam);
/**
* 获取流量使用记录不分页
*
* @param queryParam
* @return
*/
List<TaxDeclarationApiFlowRecordListDTO> listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam);
/**
* 导出流量使用记录

View File

@ -0,0 +1,85 @@
package com.engine.salary.service;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticDetailListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowTotalDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.entity.taxapiflow.response.QueryAccountBalanceResponse;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
import com.engine.salary.util.page.PageInfo;
import java.util.List;
/**
* 个税申报计费service
*
* @author chengliming
* @date 2022-11-11 14:54:14
*/
public interface TaxDeclarationApiFlowStatisticService {
/**
* 获取当前租户的流量统计情况
*
* @return
*/
TaxDeclarationApiFlowTotalDTO getFlowStatistics();
/**
* 获取各主体的流量使用明细分页
*
* @param queryParam
* @return
*/
PageInfo<TaxDeclarationApiFlowStatisticListDTO> pageFlowStatistics(BaseQueryParam queryParam);
/**
* 获取各主体的流量使用明细不分页
*
* @return
*/
List<TaxDeclarationApiFlowStatisticListDTO> listFlowStatistic();
/**
* 获取单个主体的流量月度使用明细(分页)
*
* @param queryParam
* @return
*/
PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO> pageFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam);
/**
* 获取单个主体的流量月度使用明细(不分页)
*
* @param queryParam
* @return
*/
List<TaxDeclarationApiFlowStatisticDetailListDTO> listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam);
// /**
// * 导出流量统计
// *
// * @param map
// * @param dtoList
// */
// void exportFlowStatistics(Map<String, Object> map, List<TaxDeclarationApiFlowStatisticListDTO> dtoList);
//
// /**
// * 导出流量月度统计
// *
// * @param queryParam
// * @param map
// * @param dtoList
// */
// void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map<String, Object> map, List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList);
/**
* 查询流量统计数据
*
* @param apiConfig
* @return
*/
QueryAccountBalanceResponse getQueryAccountBalanceResponse(TaxDeclarationApiConfigPO apiConfig);
}

View File

@ -32,25 +32,21 @@ public interface TaxDeclarationApiFlowWarnService {
* 获取流量不足提醒对象列表
*
* @param warnConfigId
* @param currentTenantKey
* @return
*/
List<TaxDeclarationApiFlowWarnReceiverListDTO> getWarnReceiverList(Long warnConfigId, String currentTenantKey);
List<TaxDeclarationApiFlowWarnReceiverListDTO> getWarnReceiverList(Long warnConfigId);
/**
* 删除流量不足提醒对象
*
* @param id
* @param currentTenantKey
*/
void deleteReceiver(Long id, String currentTenantKey);
void deleteReceiver(Long id);
/**
* 获取提醒对象
*
* @param id
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
TaxDeclarationApiFlowWarnReceiverFormDTO getWarnReceiverFormById(Long id);
@ -59,8 +55,6 @@ public interface TaxDeclarationApiFlowWarnService {
* 保存或编辑提醒对象
*
* @param param
* @param currentEmployeeId
* @param currentTenantKey
*/
void saveWarnReceiver(TaxDeclarationApiFlowWarnReceiverSaveParam param);
@ -68,8 +62,6 @@ public interface TaxDeclarationApiFlowWarnService {
* 创建提醒规则
*
* @param param
* @param currentEmployeeId
* @param currentTenantKey
*/
void createMessageRule(CreateMessageRuleParam param);
@ -77,8 +69,6 @@ public interface TaxDeclarationApiFlowWarnService {
* 保存流量不足提醒配置
*
* @param param
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
String saveWarnConfig(TaxDeclarationApiFlowWarnConfigSaveParam param);

View File

@ -68,6 +68,11 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService {
return MapperProxyFactory.getProxy(EmployMapper.class);
}
@Override
public List<ExtEmpPO> listAll() {
return getExternalEmployeeMapper().listAll();
}
@Override
public List<ExtEmpPO> list(ExtEmpQueryParam param) {
return getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build());

View File

@ -269,4 +269,14 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
}
return result;
}
@Override
public Map<Long, String> mapByEmployeeIds(Collection<Long> employeeIds) {
List<DataCollectionEmployee> simpleUserInfos = getEmployeeByIdsAll((List<Long>) employeeIds);
Map<Long, String> result = new HashMap<>();
simpleUserInfos.forEach(e -> {
result.put(e.getEmployeeId(), e.getIdNo());
});
return result;
}
}

View File

@ -798,5 +798,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
return SalaryEntityUtil.properties(taxAgentEmpPOS, TaxAgentEmpPO::getEmployeeId);
}
@Override
public List<TaxAgentPO> listByIdsIncludeDel(Collection<Long> taxAgentIds) {
return getTaxAgentMapper().listByIdsIncludeDel(taxAgentIds);
}
}

View File

@ -2,16 +2,21 @@ package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.extemp.po.ExtEmpPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxapiflow.bo.TaxApiFlowBO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowRecordListDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowRecordQueryParam;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
import com.engine.salary.enums.taxdeclaration.EnumDeclareApiBusinessType;
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationApiFlowRecordMapper;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.TaxDeclarationApiBillingService;
import com.engine.salary.service.TaxDeclarationApiFlowWarnService;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -19,39 +24,40 @@ import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Slf4j
public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxDeclarationApiBillingService {
public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxDeclarationApiBillingService {
private TaxDeclarationApiFlowRecordMapper getTaxDeclarationApiFlowRecordMapper() {
return MapperProxyFactory.getProxy(TaxDeclarationApiFlowRecordMapper.class);
}
public TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
public SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
// private SalaryBatchService salaryBatchService;
private TaxDeclarationApiFlowWarnService taxDeclarationApiFlowWarnService;
// public TaxDeclarationApiFlowWarnService getTaxDeclarationApiFlowWarnService(User user) {
// return ServiceUtil.getService(TaxDeclarationApiFlowWarnServiceImpl.class, user);
// }
// private ComInfoCache comInfoCache;
// private ExtEmployeeService extEmployeeService;
public TaxDeclarationApiFlowWarnService getTaxDeclarationApiFlowWarnService(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowWarnServiceImpl.class, user);
}
private ExtEmpService extEmployeeService;
@Override
public void updateApiFlowInfo(ApiFlowUpdateWrapper updateWrapper) {
// 保存流量使用详情
// saveApiFlowRecord(updateWrapper);
saveApiFlowRecord(updateWrapper);
// 流量不足提醒
// taxDeclarationApiFlowWarnService.sendFlowWarnMessage(updateWrapper);
getTaxDeclarationApiFlowWarnService(user).sendFlowWarnMessage(updateWrapper);
}
private void saveApiFlowRecord(ApiFlowUpdateWrapper updateWrapper) {
@ -61,63 +67,62 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements Tax
}
}
// @Override
// public PageInfo<TaxDeclarationApiFlowRecordListDTO> pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
// LambdaQueryChainWrapper<TaxDeclarationApiFlowRecordPO> queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam);
// Page<TaxDeclarationApiFlowRecordPO> flowRecordPOPage = queryChainWrapper.page(new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true));
// List<TaxDeclarationApiFlowRecordPO> records = flowRecordPOPage.getRecords();
// if (records.isEmpty()) {
// return new PageInfo<>();
// }
// TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(records);
// // 转换数据
// AtomicInteger indexNum = new AtomicInteger(1);
// List<TaxDeclarationApiFlowRecordListDTO> listDTOS = records.stream().map(e ->
// TaxApiFlowBO.taxDeclarationApiFlowRecordPo2ListDTO(propertiesWrapper, indexNum, e)
// ).collect(Collectors.toList());
// return new SalaryPage<>(queryParam.getCurrent(), queryParam.getPageSize(), flowRecordPOPage.getTotal(), listDTOS);
// }
//
// @Override
// public List<TaxDeclarationApiFlowRecordListDTO> listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
// LambdaQueryChainWrapper<TaxDeclarationApiFlowRecordPO> queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam);
// List<TaxDeclarationApiFlowRecordPO> list = queryChainWrapper.list();
// if (list.isEmpty()) {
// return new ArrayList<>();
// }
// TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(list);
// // 转换数据
// AtomicInteger indexNum = new AtomicInteger(1);
// return list.stream().map(e -> TaxApiFlowBO.taxDeclarationApiFlowRecordPo2ListDTO(propertiesWrapper, indexNum, e)).collect(Collectors.toList());
// }
//
// private TempPropertiesWrapper getUserInfoAndTaxAgentMap(List<TaxDeclarationApiFlowRecordPO> list, String currentTenantKey) {
// Map<Long, Long> employeeTaxAgentMap = SalaryEntityUtil.convert2Map(list, TaxDeclarationApiFlowRecordPO::getEmployeeId, TaxDeclarationApiFlowRecordPO::getTaxAgentId);
// // 获取人员信息
// List<HrmEmployeeComInfo> employeeComInfos = comInfoCache.getCacheList(HrmEmployeeComInfo.class, new ArrayList<>(employeeTaxAgentMap.keySet()));
// Map<Long, String> empNameMap = SalaryEntityUtil.convert2Map(employeeComInfos, HrmEmployeeComInfo::getId, HrmEmployeeComInfo::getUsername);
// Map<Long, String> empIdNoMap = getSalaryEmployeeService(user).mapByEmployeeIds(employeeTaxAgentMap.keySet());
// List<ExtEmployeePO> extEmployeePOS = extEmployeeService.listAll(currentTenantKey);
// Map<Long, ExtEmployeePO> extEmployeeMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmployeePO::getId);
// // 获取个税扣缴义务人信息
// List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(new HashSet<>(employeeTaxAgentMap.values()));
// Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
// return new TempPropertiesWrapper(empNameMap, empIdNoMap, taxAgentNameMap, extEmployeeMap);
// }
//
// private LambdaQueryChainWrapper<TaxDeclarationApiFlowRecordPO> getFlowRecordQueryChainWrapper(TaxDeclarationApiFlowRecordQueryParam queryParam, String currentTenantKey) {
// LambdaQueryChainWrapper<TaxDeclarationApiFlowRecordPO> chainWrapper = new LambdaQueryChainWrapper<>(getTaxDeclarationApiFlowRecordMapper())
// .eq(TaxDeclarationApiFlowRecordPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .eq(TaxDeclarationApiFlowRecordPO::getTenantKey)
// .eq(queryParam.getTaxAgentId() != null, TaxDeclarationApiFlowRecordPO::getTaxAgentId, queryParam.getTaxAgentId())
// .eq(queryParam.getBusinessType() != null, TaxDeclarationApiFlowRecordPO::getBusinessType, queryParam.getBusinessType())
// .eq(queryParam.getResult() != null, TaxDeclarationApiFlowRecordPO::getResultStatus, queryParam.getResult());
// if (queryParam.getStartDate() != null && queryParam.getEndDate() != null) {
// chainWrapper = chainWrapper.ge(TaxDeclarationApiFlowRecordPO::getUseTime, queryParam.getStartDate())
// .le(TaxDeclarationApiFlowRecordPO::getUseTime, queryParam.getEndDate());
// }
// return chainWrapper;
// }
@Override
public PageInfo<TaxDeclarationApiFlowRecordListDTO> pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
TaxDeclarationApiFlowRecordPO queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam);
List<TaxDeclarationApiFlowRecordPO> records = getTaxDeclarationApiFlowRecordMapper().listSome(queryChainWrapper);
if (records.isEmpty()) {
return new PageInfo<>();
}
TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(records);
// 转换数据
AtomicInteger indexNum = new AtomicInteger(1);
List<TaxDeclarationApiFlowRecordListDTO> listDTOS = records.stream().map(e ->
TaxApiFlowBO.taxDeclarationApiFlowRecordPo2ListDTO(propertiesWrapper, indexNum, e)
).collect(Collectors.toList());
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listDTOS, TaxDeclarationApiFlowRecordListDTO.class);
}
@Override
public List<TaxDeclarationApiFlowRecordListDTO> listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
TaxDeclarationApiFlowRecordPO queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam);
List<TaxDeclarationApiFlowRecordPO> list = getTaxDeclarationApiFlowRecordMapper().listSome(queryChainWrapper);
if (list.isEmpty()) {
return new ArrayList<>();
}
TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(list);
// 转换数据
AtomicInteger indexNum = new AtomicInteger(1);
return list.stream().map(e -> TaxApiFlowBO.taxDeclarationApiFlowRecordPo2ListDTO(propertiesWrapper, indexNum, e)).collect(Collectors.toList());
}
private TempPropertiesWrapper getUserInfoAndTaxAgentMap(List<TaxDeclarationApiFlowRecordPO> list) {
Map<Long, Long> employeeTaxAgentMap = SalaryEntityUtil.convert2Map(list, TaxDeclarationApiFlowRecordPO::getEmployeeId, TaxDeclarationApiFlowRecordPO::getTaxAgentId);
// 获取人员信息
List<DataCollectionEmployee> employeeComInfos =getSalaryEmployeeService(user).getEmployeeByIdsAll(new ArrayList<>(employeeTaxAgentMap.keySet()));
Map<Long, String> empNameMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername);
Map<Long, String> empIdNoMap = getSalaryEmployeeService(user).mapByEmployeeIds(employeeTaxAgentMap.keySet());
List<ExtEmpPO> extEmployeePOS = extEmployeeService.listAll();
Map<Long, ExtEmpPO> extEmployeeMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmpPO::getId);
// 获取个税扣缴义务人信息
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(new HashSet<>(employeeTaxAgentMap.values()));
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
return new TempPropertiesWrapper(empNameMap, empIdNoMap, taxAgentNameMap, extEmployeeMap);
}
private TaxDeclarationApiFlowRecordPO getFlowRecordQueryChainWrapper(TaxDeclarationApiFlowRecordQueryParam queryParam) {
TaxDeclarationApiFlowRecordPO build = TaxDeclarationApiFlowRecordPO.builder()
.taxAgentId(queryParam.getTaxAgentId())
.businessType(queryParam.getBusinessType())
.resultStatus(queryParam.getResult())
.build();
if (queryParam.getStartDate() != null && queryParam.getEndDate() != null) {
build.setUseTimeStartDate(queryParam.getStartDate());
build.setUseTimeEndDate(queryParam.getEndDate());
}
return build;
}
// @Override
// public void exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Map<String, Object> map) {
@ -161,6 +166,7 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements Tax
// salaryBatchService.simpleExportExcel(wrapper.buildExportExcelInfo(), wrapper.getSheetList());
// }
//
/**
* 封装一些临时的集合类便于方法复用
*/
@ -191,7 +197,7 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements Tax
// 接口类型
private EnumDeclareApiBusinessType businessType;
public ApiFlowUpdateWrapper( Date taxYearMonth, TaxDeclarationApiConfigPO apiConfig, EnumDeclareApiBusinessType businessType) {
public ApiFlowUpdateWrapper(Date taxYearMonth, TaxDeclarationApiConfigPO apiConfig, EnumDeclareApiBusinessType businessType) {
this.taxYearMonth = taxYearMonth;
this.apiFlowDetailPOList = new ArrayList<>();
this.apiConfig = apiConfig;

View File

@ -0,0 +1,232 @@
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.constant.SzyhApiConstant;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
import com.engine.salary.entity.taxagent.response.SzyhResponseHead;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticDetailListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowTotalDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.entity.taxapiflow.response.QueryAccountBalanceResponse;
import com.engine.salary.entity.taxapiflow.response.QueryDetailsByTaxNumberResponse;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.TaxAgentTaxReturnService;
import com.engine.salary.service.TaxDeclarationApiConfigService;
import com.engine.salary.service.TaxDeclarationApiFlowStatisticService;
import com.engine.salary.util.*;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import dm.jdbc.util.IdGenerator;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author chengliming
* @date 2022-11-11 2:57 PM
**/
@Slf4j
public class TaxDeclarationApiFlowStatisticServiceImpl extends Service implements TaxDeclarationApiFlowStatisticService {
private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) {
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
}
private TaxAgentTaxReturnService getTaxAgentTaxReturnService(User user) {
return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
// private SalaryBatchService salaryBatchService;
@Override
public TaxDeclarationApiFlowTotalDTO getFlowStatistics() {
TaxDeclarationApiConfigPO apiConfigPO = getTaxDeclarationApiConfigService(user).getConfig(true);
QueryAccountBalanceResponse response = getQueryAccountBalanceResponse(apiConfigPO);
apiConfigPO.setTotality(Long.parseLong(response.getBody().getTotal()));
apiConfigPO.setRemain(Long.parseLong(response.getBody().getSurplus()));
apiConfigPO.setLastUpdateTime(new Date());
getTaxDeclarationApiConfigService(user).update(apiConfigPO);
return TaxDeclarationApiFlowTotalDTO.builder()
.total(apiConfigPO.getTotality())
.remain(apiConfigPO.getRemain())
.used(apiConfigPO.getTotality() - apiConfigPO.getRemain())
.lastUpdateTime(SalaryDateUtil.getFormatLocalDateTime(apiConfigPO.getLastUpdateTime()))
.build();
}
@Override
public PageInfo<TaxDeclarationApiFlowStatisticListDTO> pageFlowStatistics(BaseQueryParam queryParam) {
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listFlowStatistic());
}
@Override
public List<TaxDeclarationApiFlowStatisticListDTO> listFlowStatistic() {
TaxDeclarationApiConfigPO config = getTaxDeclarationApiConfigService(user).getConfig(true);
QueryAccountBalanceResponse response = getQueryAccountBalanceResponse(config);
List<QueryAccountBalanceResponse.Detail> details = Optional.of(response).map(e -> e.getBody().getTaxList()).orElse(new ArrayList<>());
if (details.isEmpty()) {
log.info("details is empty");
return new ArrayList<>();
}
Set<String> taxCodes = details.stream().map(QueryAccountBalanceResponse.Detail::getTaxNumber).collect(Collectors.toSet());
List<TaxAgentTaxReturnPO> returnPOList = getTaxAgentTaxReturnService(user).getByTaxCodes(taxCodes);
if (returnPOList.isEmpty()) {
log.info("TaxAgentTaxReturnPO is empty");
return new ArrayList<>();
}
Set<Long> taxAgentIds = returnPOList.stream().map(TaxAgentTaxReturnPO::getTaxAgentId).collect(Collectors.toSet());
List<TaxAgentPO> taxAgentPOList = getTaxAgentService(user).listByIdsIncludeDel(taxAgentIds);
if (taxAgentPOList.isEmpty()) {
log.info("TaxAgentPO is empty");
return new ArrayList<>();
}
Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOList, TaxAgentPO::getId, TaxAgentPO::getName);
Map<String, List<TaxAgentTaxReturnPO>> taxCodeMap = returnPOList.stream().collect(Collectors.groupingBy(TaxAgentTaxReturnPO::getTaxCode));
List<TaxDeclarationApiFlowStatisticListDTO> flowStatisticDTOS = new ArrayList<>();
for (QueryAccountBalanceResponse.Detail detail : details) {
List<TaxAgentTaxReturnPO> list = taxCodeMap.getOrDefault(detail.getTaxNumber(), new ArrayList<>());
for (TaxAgentTaxReturnPO returnPO : list) {
TaxDeclarationApiFlowStatisticListDTO statisticDTO = new TaxDeclarationApiFlowStatisticListDTO();
statisticDTO.setId(IdGenerator.generate());
statisticDTO.setUsed(Integer.parseInt(detail.getUsed()));
statisticDTO.setTaxAgentId(returnPO.getTaxAgentId());
statisticDTO.setTaxAgentName(taxAgentMap.get(returnPO.getTaxAgentId()));
flowStatisticDTOS.add(statisticDTO);
}
}
flowStatisticDTOS.sort((o1, o2) -> o2.getTaxAgentId().compareTo(o1.getTaxAgentId()));
for (int i = 0; i < flowStatisticDTOS.size(); i++) {
flowStatisticDTOS.get(i).setIndexNum(i + 1);
}
return flowStatisticDTOS;
}
@Override
public PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO> pageFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) {
List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList = listFlowStatisticDetail(queryParam);
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), dtoList, TaxDeclarationApiFlowStatisticDetailListDTO.class);
}
@Override
public List<TaxDeclarationApiFlowStatisticDetailListDTO> listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) {
TaxDeclarationApiConfigPO apiConfigPO = getTaxDeclarationApiConfigService(user).getConfig(true);
TaxAgentTaxReturnPO taxReturnPO = getTaxAgentTaxReturnService(user).getByTaxAgentId(queryParam.getTaxAgentId());
SalaryAssert.notNull(taxReturnPO, SalaryI18nUtil.getI18nLabel(184065, "个税扣缴义务人暂无报税信息"));
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIdsIncludeDel(Collections.singleton(taxReturnPO.getTaxAgentId()));
SalaryAssert.notEmpty(taxAgentPOS, SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在"));
QueryDetailsByTaxNumberResponse response = getQueryDetailsByTaxNumberResponse(apiConfigPO, taxReturnPO.getTaxCode());
List<QueryDetailsByTaxNumberResponse.Detail> details = Optional.of(response)
.map(QueryDetailsByTaxNumberResponse::getBody)
.map(QueryDetailsByTaxNumberResponse.Body::getDetail)
.orElse(new ArrayList<>());
if (details.isEmpty()) {
return new ArrayList<>();
}
details.sort((o1, o2) -> Integer.valueOf(o2.getMonth()).compareTo(Integer.valueOf(o1.getMonth())));
details = details.stream().filter(detail -> detail.getMonthValue() >= queryParam.getStartTaxMonth()
&& detail.getMonthValue() <= queryParam.getEndTaxMonth()).collect(Collectors.toList());
return details.stream().map(e -> TaxDeclarationApiFlowStatisticDetailListDTO.builder()
.id(IdGenerator.generate())
.taxAgentId(taxAgentPOS.get(0).getId())
.taxAgentName(taxAgentPOS.get(0).getName())
.taxMonth(LocalDate.parse(e.getMonth() + "01", DateTimeFormatter.ofPattern("yyyyMMdd")).format(SalaryDateUtil.MONTH_FORMATTER))
.used(Integer.valueOf(e.getUsed()))
.build()).collect(Collectors.toList());
}
// @Override
// public void exportFlowStatistics(Map<String, Object> map, List<TaxDeclarationApiFlowStatisticListDTO> dtoList) {
// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey);
// // 表头
// List<String> headers = exportWrapper.getHeaders();
// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159084, "已使用流量"));
// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{})));
// // 组装数据
// for (TaxDeclarationApiFlowStatisticListDTO dto : dtoList) {
// List<Object> row = new ArrayList<>();
// row.add(dto.getTaxAgentName());
// row.add(dto.getUsed());
// exportWrapper.getRows().add(row);
// }
// // 生成表格
// buildExcelData(exportWrapper);
// }
// @Override
// public void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map<String, Object> map, List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList) {
// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey);
// // 表头
// List<String> headers = exportWrapper.getHeaders();
// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 86176, "税款所属期"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159087, "月使用流量数"));
// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{})));
// // 组装数据
// for (TaxDeclarationApiFlowStatisticDetailListDTO dto : dtoList) {
// List<Object> row = new ArrayList<>();
// row.add(dto.getTaxAgentName());
// row.add(dto.getTaxMonth());
// row.add(dto.getUsed());
// exportWrapper.getRows().add(row);
// }
// // 生成表格
// /**
// wrapper.getExcelSheetData().setRows(wrapper.getRows());
// wrapper.getSheetList().add(wrapper.getExcelSheetData());
// salaryBatchService.simpleExportExcel(wrapper.buildExportExcelInfo(), wrapper.getSheetList());
// }}
public QueryAccountBalanceResponse getQueryAccountBalanceResponse(TaxDeclarationApiConfigPO apiConfig) {
String url = apiConfig.getHost() + SzyhApiConstant.QUERY_ACCOUNT_BALANCE;
Map<String, String> params = new HashMap<>(1);
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
String res = HttpUtil.getRequest(url, header, params);
log.info("getQueryAccountBalanceResponse response : {}", res);
QueryAccountBalanceResponse response = JsonUtil.parseObject(res, QueryAccountBalanceResponse.class);
QueryAccountBalanceResponse.Body body = Optional.ofNullable(response).map(QueryAccountBalanceResponse::getBody).orElse(null);
String code = Optional.ofNullable(response)
.map(QueryAccountBalanceResponse::getHead)
.map(SzyhResponseHead::getCode).orElse("error");
String msg = Optional.ofNullable(response)
.map(QueryAccountBalanceResponse::getHead)
.map(SzyhResponseHead::getMsg).orElse(SalaryI18nUtil.getI18nLabel(184014, "税局接口异常,请稍后再试"));
SalaryAssert.isTrue(SzyhApiConstant.SUCCESS_CODE.equals(code), msg);
SalaryAssert.notNull(body, SalaryI18nUtil.getI18nLabel(184014, "税局接口异常,请稍后再试"));
return response;
}
public QueryDetailsByTaxNumberResponse getQueryDetailsByTaxNumberResponse(TaxDeclarationApiConfigPO apiConfig, String taxCode) {
String url = apiConfig.getHost() + SzyhApiConstant.QUERY_DETAILS_BY_TAX_NUMBER;
Map<String, String> params = new HashMap<>(1);
params.put("taxNumber", taxCode);
Map<String, String> header = SingnatureData.initHeader(Collections.emptyMap(), apiConfig.getAppKey(), apiConfig.getAppSecret());
String res = HttpUtil.getRequest(url, header, params);
log.info("getQueryDetailsByTaxNumberResponse response : {}", res);
QueryDetailsByTaxNumberResponse response = JsonUtil.parseObject(res, QueryDetailsByTaxNumberResponse.class);
QueryDetailsByTaxNumberResponse.Body body = Optional.ofNullable(response).map(QueryDetailsByTaxNumberResponse::getBody).orElse(null);
String code = Optional.ofNullable(response)
.map(QueryDetailsByTaxNumberResponse::getHead)
.map(SzyhResponseHead::getCode).orElse("error");
String msg = Optional.ofNullable(response)
.map(QueryDetailsByTaxNumberResponse::getHead)
.map(SzyhResponseHead::getMsg).orElse(SalaryI18nUtil.getI18nLabel(184014, "税局接口异常,请稍后再试"));
SalaryAssert.isTrue(SzyhApiConstant.SUCCESS_CODE.equals(code), msg);
SalaryAssert.notNull(body, SalaryI18nUtil.getI18nLabel(184014, "税局接口异常,请稍后再试"));
return response;
}
}

View File

@ -1,176 +1,159 @@
//package com.engine.salary.service.impl;
//
//import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
//import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
//import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO;
//import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverListDTO;
//import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO;
//import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO;
//import com.engine.salary.mapper.taxdeclaration.TaxDeclarationApiFlowWarnConfigMapper;
//import com.engine.salary.service.SalaryEmployeeService;
//import com.engine.salary.service.TaxDeclarationApiFlowWarnService;
//import com.engine.salary.util.SalaryEntityUtil;
//import com.weaver.common.base.entity.result.WeaResult;
//import com.weaver.common.distribution.genid.IdGenerator;
//import com.weaver.framework.spring.annotation.AopClass;
//import com.weaver.hrm.salary.common.OptionDTO;
//import com.weaver.hrm.salary.dao.TaxDeclarationApiFlowWarnReceiverMapper;
//import com.weaver.hrm.salary.entity.taxapiflow.bo.TaxApiFlowBO;
//import com.weaver.hrm.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverFormDTO;
//import com.weaver.hrm.salary.entity.taxapiflow.param.CreateMessageRuleParam;
//import com.weaver.hrm.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnConfigSaveParam;
//import com.weaver.hrm.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam;
//import com.weaver.hrm.salary.entity.taxapiflow.response.QueryAccountBalanceResponse;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryOnOffEnum;
//import com.weaver.hrm.salary.enums.sicategory.DeleteTypeEnum;
//import com.weaver.hrm.salary.service.TaxAgentService;
//import com.weaver.hrm.salary.service.TaxDeclarationApiFlowStatisticService;
//import com.weaver.hrm.salary.util.SalaryAssert;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.mc.api.async.AsyncSystemMessageRest;
//import com.weaver.mc.api.entity.*;
//import com.weaver.mc.api.rest.RuleRest;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.time.LocalDateTime;
//import java.util.Collections;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author chengliming
// * @date 2022-11-11 2:57 PM
// **/
//@Service
//@Slf4j
//@AopClass
//public class TaxDeclarationApiFlowWarnServiceImpl implements TaxDeclarationApiFlowWarnService {
// private TaxDeclarationApiFlowWarnConfigMapper taxDeclarationApiFlowWarnConfigMapper;
// private TaxDeclarationApiFlowWarnReceiverMapper taxDeclarationApiFlowWarnReceiverMapper;
// private SalaryEmployeeService salaryEmployeeService;
// private RuleRest ruleRest;
// private AsyncSystemMessageRest asyncSystemMessageRest;
// private TaxAgentService taxAgentService;
// private TaxDeclarationApiFlowStatisticService taxDeclarationApiFlowStatisticService;
//
// @Override
// public TaxDeclarationApiFlowWarnConfigPO getWarnConfig(String currentTenantKey) {
// return new LambdaQueryChainWrapper<>(taxDeclarationApiFlowWarnConfigMapper)
// .eq(TaxDeclarationApiFlowWarnConfigPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .eq(TaxDeclarationApiFlowWarnConfigPO::getTenantKey, currentTenantKey)
// .one();
// }
//
// @Override
// public List<TaxDeclarationApiFlowWarnReceiverListDTO> getWarnReceiverList(Long warnConfigId, String currentTenantKey) {
// List<TaxDeclarationApiFlowWarnReceiverPO> receiverPOList = new LambdaQueryChainWrapper<>(taxDeclarationApiFlowWarnReceiverMapper)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getTenantKey, currentTenantKey)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getWarnConfigId, warnConfigId)
// .list();
//
// List<TaxAgentEmployeePO> salaryEmployees = taxAgentService.listEmployees(currentTenantKey);
// Map<Long, String> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, TaxAgentEmployeePO::getEmployeeId, TaxAgentEmployeePO::getUsername);
//
// return receiverPOList.stream().map(e -> TaxDeclarationApiFlowWarnReceiverListDTO.builder()
// .employeeName(salaryEmployeeMap.get(e.getEmployeeId()))
// .employeeId(e.getEmployeeId())
// .mobile(e.getMobile())
// .email(e.getEmail())
// .id(e.getId())
// .build()).collect(Collectors.toList());
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void deleteReceiver(Long id, String currentTenantKey) {
// TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(id, currentTenantKey);
// SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
// new LambdaUpdateChainWrapper<>(taxDeclarationApiFlowWarnReceiverMapper)
// .set(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.DELETED.getValue())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getId, id)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getTenantKey, currentTenantKey)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .update();
// }
//
// @Override
// public TaxDeclarationApiFlowWarnReceiverFormDTO getWarnReceiverFormById(Long id) {
// TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(id, currentTenantKey);
// SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
// // 查找人员信息
// List<SimpleEmployee> simpleEmployees = salaryEmployeeService.listAll(currentTenantKey);
// Map<Long, SimpleEmployee> empMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getEmployeeId);
// SimpleEmployee simpleEmployee = empMap.get(receiverPO.getEmployeeId());
// SalaryAssert.notNull(simpleEmployee, SalaryI18nUtil.getI18nLabel( 139811, "人员不存在"));
//
// return TaxDeclarationApiFlowWarnReceiverFormDTO.builder()
// .id(receiverPO.getId())
// .employee(Collections.singletonList(new OptionDTO(receiverPO.getEmployeeId().toString(), simpleEmployee.getUsername())))
// .email(receiverPO.getEmail())
// .mobile(receiverPO.getMobile())
// .emailOptions(StringUtils.isNotEmpty(simpleEmployee.getEmail()) ? Collections.singletonList(simpleEmployee.getEmail()) : null)
// .build();
// }
//
// private TaxDeclarationApiFlowWarnReceiverPO getWarnReceiverPOById(Long id, String currentTenantKey) {
// return new LambdaQueryChainWrapper<>(taxDeclarationApiFlowWarnReceiverMapper)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getId, id)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getTenantKey, currentTenantKey)
// .one();
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void saveWarnReceiver(TaxDeclarationApiFlowWarnReceiverSaveParam param) {
// if (param.getId() != null) {
// TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(param.getId(), currentTenantKey);
// SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
// if (param.getEmployeeId() != null && !receiverPO.getEmployeeId().equals(param.getEmployeeId())) {
// filterByEmpId(param, currentTenantKey);
// receiverPO.setEmployeeId(param.getEmployeeId());
// }
// receiverPO.setUpdateTime(LocalDateTime.now());
// receiverPO.setEmail(param.getEmail());
// receiverPO.setMobile(param.getMobile());
// taxDeclarationApiFlowWarnReceiverMapper.updateById(receiverPO);
// } else {
// filterByEmpId(param, currentTenantKey);
// TaxDeclarationApiFlowWarnReceiverPO receiverPO = TaxDeclarationApiFlowWarnReceiverPO.builder()
// .id(IdGenerator.generate())
// .email(param.getEmail())
// .mobile(param.getMobile())
// .employeeId(param.getEmployeeId())
// .warnConfigId(param.getWarnConfigId())
// .createTime(LocalDateTime.now())
// .updateTime(LocalDateTime.now())
// .deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
// .tenantKey(currentTenantKey)
// .creator(currentEmployeeId)
// .build();
// taxDeclarationApiFlowWarnReceiverMapper.insert(receiverPO);
// }
// }
//
// private void filterByEmpId(TaxDeclarationApiFlowWarnReceiverSaveParam param, String currentTenantKey) {
// List<TaxDeclarationApiFlowWarnReceiverPO> another = new LambdaQueryChainWrapper<>(taxDeclarationApiFlowWarnReceiverMapper)
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getWarnConfigId, param.getWarnConfigId())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getEmployeeId, param.getEmployeeId())
// .eq(TaxDeclarationApiFlowWarnReceiverPO::getTenantKey, currentTenantKey)
// .list();
// SalaryAssert.isEmpty(another, SalaryI18nUtil.getI18nLabel(184007, "当前人员对应的提醒对象已存在,请更换人员后尝试"));
// }
//
// @Override
// public void createMessageRule(CreateMessageRuleParam param) {
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.common.OptionDTO;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverFormDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverListDTO;
import com.engine.salary.entity.taxapiflow.param.CreateMessageRuleParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnConfigSaveParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnReceiverPO;
import com.engine.salary.entity.taxapiflow.response.QueryAccountBalanceResponse;
import com.engine.salary.enums.SalaryOnOffEnum;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.mapper.taxapiflow.TaxDeclarationApiFlowWarnConfigMapper;
import com.engine.salary.mapper.taxapiflow.TaxDeclarationApiFlowWarnReceiverMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import dm.jdbc.util.IdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author chengliming
* @date 2022-11-11 2:57 PM
**/
@Slf4j
public class TaxDeclarationApiFlowWarnServiceImpl extends Service implements TaxDeclarationApiFlowWarnService {
private TaxDeclarationApiFlowWarnConfigMapper getTaxDeclarationApiFlowWarnConfigMapper() {
return MapperProxyFactory.getProxy(TaxDeclarationApiFlowWarnConfigMapper.class);
}
private TaxDeclarationApiFlowWarnReceiverMapper getTaxDeclarationApiFlowWarnReceiverMapper() {
return MapperProxyFactory.getProxy(TaxDeclarationApiFlowWarnReceiverMapper.class);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private TaxDeclarationApiFlowStatisticService getTaxDeclarationApiFlowStatisticService(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowStatisticServiceImpl.class, user);
}
@Override
public TaxDeclarationApiFlowWarnConfigPO getWarnConfig(String currentTenantKey) {
return getTaxDeclarationApiFlowWarnConfigMapper().getOne();
}
@Override
public List<TaxDeclarationApiFlowWarnReceiverListDTO> getWarnReceiverList(Long warnConfigId) {
List<TaxDeclarationApiFlowWarnReceiverPO> receiverPOList = getTaxDeclarationApiFlowWarnReceiverMapper().listSome(TaxDeclarationApiFlowWarnReceiverPO
.builder()
.warnConfigId(warnConfigId)
.build());
List<TaxAgentEmployeePO> salaryEmployees = getTaxAgentService(user).listEmployees();
Map<Long, String> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, TaxAgentEmployeePO::getEmployeeId, TaxAgentEmployeePO::getUsername);
return receiverPOList.stream().map(e -> TaxDeclarationApiFlowWarnReceiverListDTO.builder()
.employeeName(salaryEmployeeMap.get(e.getEmployeeId()))
.employeeId(e.getEmployeeId())
.mobile(e.getMobile())
.email(e.getEmail())
.id(e.getId())
.build()).collect(Collectors.toList());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteReceiver(Long id) {
TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(id);
SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
getTaxDeclarationApiFlowWarnReceiverMapper().delete(TaxDeclarationApiFlowWarnReceiverPO.builder().id(id).build());
}
@Override
public TaxDeclarationApiFlowWarnReceiverFormDTO getWarnReceiverFormById(Long id) {
TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(id);
SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
// 查找人员信息
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
Map<Long, DataCollectionEmployee> empMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
DataCollectionEmployee simpleEmployee = empMap.get(receiverPO.getEmployeeId());
SalaryAssert.notNull(simpleEmployee, SalaryI18nUtil.getI18nLabel(139811, "人员不存在"));
return TaxDeclarationApiFlowWarnReceiverFormDTO.builder()
.id(receiverPO.getId())
.employee(Collections.singletonList(new OptionDTO(receiverPO.getEmployeeId().toString(), simpleEmployee.getUsername())))
.email(receiverPO.getEmail())
.mobile(receiverPO.getMobile())
.emailOptions(StringUtils.isNotEmpty(simpleEmployee.getEmail()) ? Collections.singletonList(simpleEmployee.getEmail()) : null)
.build();
}
private TaxDeclarationApiFlowWarnReceiverPO getWarnReceiverPOById(Long id) {
return getTaxDeclarationApiFlowWarnReceiverMapper().getById(id);
}
@Override
public void saveWarnReceiver(TaxDeclarationApiFlowWarnReceiverSaveParam param) {
Date now = new Date();
if (param.getId() != null) {
TaxDeclarationApiFlowWarnReceiverPO receiverPO = getWarnReceiverPOById(param.getId());
SalaryAssert.notNull(receiverPO, "该提醒对象不存在,请刷新页面后重试");
if (param.getEmployeeId() != null && !receiverPO.getEmployeeId().equals(param.getEmployeeId())) {
filterByEmpId(param);
receiverPO.setEmployeeId(param.getEmployeeId());
}
receiverPO.setUpdateTime(now);
receiverPO.setEmail(param.getEmail());
receiverPO.setMobile(param.getMobile());
getTaxDeclarationApiFlowWarnReceiverMapper().updateIgnoreNull(receiverPO);
} else {
filterByEmpId(param);
TaxDeclarationApiFlowWarnReceiverPO receiverPO = TaxDeclarationApiFlowWarnReceiverPO.builder()
.id(IdGenerator.generate())
.email(param.getEmail())
.mobile(param.getMobile())
.employeeId(param.getEmployeeId())
.warnConfigId(param.getWarnConfigId())
.createTime(now)
.updateTime(now)
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.creator((long) user.getUID())
.build();
getTaxDeclarationApiFlowWarnReceiverMapper().insertIgnoreNull(receiverPO);
}
}
private void filterByEmpId(TaxDeclarationApiFlowWarnReceiverSaveParam param) {
List<TaxDeclarationApiFlowWarnReceiverPO> another = getTaxDeclarationApiFlowWarnReceiverMapper().filterByEmpId(param);
SalaryAssert.isEmpty(another, SalaryI18nUtil.getI18nLabel(184007, "当前人员对应的提醒对象已存在,请更换人员后尝试"));
}
@Override
public void createMessageRule(CreateMessageRuleParam param) {
// CreateRuleEntity createRule = new CreateRuleEntity()
// .setBusinessId(param.getBusinessId())
// .setEvent(MessageEvent.PAYROLL)
@ -179,37 +162,38 @@
// log.info("RuleRest.createRuleV2 -> config ====== {}", param.getConfig());
// WeaResult<Long> weaResult = ruleRest.createRuleV2(createRule);
// SalaryAssert.isTrue(weaResult.isStatus(), SalaryI18nUtil.getI18nLabel(184008, "RPC接口创建规则失败"));
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public String saveWarnConfig(TaxDeclarationApiFlowWarnConfigSaveParam param) {
// TaxDeclarationApiFlowWarnConfigPO warnConfigPO;
// if (param.getId() != null) {
// warnConfigPO = taxDeclarationApiFlowWarnConfigMapper.selectById(param.getId());
// SalaryAssert.notNull(warnConfigPO, "提醒规则不存在,请先保存");
// warnConfigPO.setThreshold(param.getThreshold());
// warnConfigPO.setEnableWarn(param.getEnable() ? 1 : 0);
// warnConfigPO.setUpdateTime(LocalDateTime.now());
// taxDeclarationApiFlowWarnConfigMapper.updateById(warnConfigPO);
// } else {
// warnConfigPO = TaxDeclarationApiFlowWarnConfigPO.builder()
// .id(IdGenerator.generate())
// .businessId(param.getBusinessId())
// .threshold(param.getThreshold())
// .enableWarn(param.getEnable() ? 1 : 0)
// .createTime(LocalDateTime.now())
// .updateTime(LocalDateTime.now())
// .creator(currentEmployeeId)
// .deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
// .tenantKey(currentTenantKey)
// .build();
// taxDeclarationApiFlowWarnConfigMapper.insert(warnConfigPO);
// }
// if (StringUtils.isNotEmpty(param.getConfig())) {
}
@Override
public String saveWarnConfig(TaxDeclarationApiFlowWarnConfigSaveParam param) {
Date now = new Date();
TaxDeclarationApiFlowWarnConfigPO warnConfigPO;
if (param.getId() != null) {
warnConfigPO = getTaxDeclarationApiFlowWarnConfigMapper().getById(param.getId());
SalaryAssert.notNull(warnConfigPO, "提醒规则不存在,请先保存");
warnConfigPO.setThreshold(param.getThreshold());
warnConfigPO.setEnableWarn(param.getEnable() ? 1 : 0);
warnConfigPO.setUpdateTime(now);
getTaxDeclarationApiFlowWarnConfigMapper().updateIgnoreNull(warnConfigPO);
} else {
warnConfigPO = TaxDeclarationApiFlowWarnConfigPO.builder()
.id(IdGenerator.generate())
.businessId(param.getBusinessId())
.threshold(param.getThreshold())
.enableWarn(param.getEnable() ? 1 : 0)
.createTime(now)
.updateTime(now)
.creator((long) user.getUID())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
getTaxDeclarationApiFlowWarnConfigMapper().insertIgnoreNull(warnConfigPO);
}
if (StringUtils.isNotEmpty(param.getConfig())) {
//todo 消息
// CreateRuleEntity createRule = new CreateRuleEntity()
// .setName(SalaryI18nUtil.getI18nLabel( 159146, "流量不足提醒"))
// .setUser(new UserEntity(currentEmployeeId, currentTenantKey))
// .setName(SalaryI18nUtil.getI18nLabel(159146, "流量不足提醒"))
// .setUser(new UserEntity(currentEmployeeId))
// .setModule(MessageModule.HRSA)
// .setEvent(MessageEvent.PAYROLL)
// .setBusinessId(param.getBusinessId().toString())
@ -217,33 +201,34 @@
// log.info("RuleRest.createRuleV2 -> config ====== {}", param.getConfig());
// WeaResult<Long> weaResult = ruleRest.createRuleV2(createRule);
// SalaryAssert.isTrue(weaResult.isStatus(), SalaryI18nUtil.getI18nLabel(184008, "RPC接口创建规则失败"));
// }
// return warnConfigPO.getId().toString();
// }
//
// @Override
// public Long getRuleBusinessId(String currentTenantKey) {
// TaxDeclarationApiFlowWarnConfigPO warnConfig = this.getWarnConfig(currentTenantKey);
// return warnConfig == null ? IdGenerator.generate() : warnConfig.getBusinessId();
// }
//
// @Override
// public void sendFlowWarnMessage(TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper updateWrapper) {
// TaxDeclarationApiFlowWarnConfigPO warnConfig = getWarnConfig(updateWrapper.getTenantKey());
// // 未配置或开关关闭
// if (Objects.isNull(warnConfig) || SalaryOnOffEnum.OFF.getValue().equals(warnConfig.getEnableWarn())) {
// return;
// }
// QueryAccountBalanceResponse response = taxDeclarationApiFlowStatisticService.getQueryAccountBalanceResponse(updateWrapper.getApiConfig());
// // 剩余流量大于阈值无需提醒
// if (StringUtils.isNotEmpty(response.getBody().getSurplus()) && Long.parseLong(response.getBody().getSurplus()) > warnConfig.getThreshold()) {
// return;
// }
// List<TaxDeclarationApiFlowWarnReceiverListDTO> warnReceiverList = getWarnReceiverList(warnConfig.getId(), updateWrapper.getTenantKey());
// if (warnReceiverList.isEmpty()) {
// log.info("warnReceiverList is empty, send msg fail");
// return;
// }
}
return warnConfigPO.getId().toString();
}
@Override
public Long getRuleBusinessId(String currentTenantKey) {
TaxDeclarationApiFlowWarnConfigPO warnConfig = this.getWarnConfig(currentTenantKey);
return warnConfig == null ? IdGenerator.generate() : warnConfig.getBusinessId();
}
@Override
public void sendFlowWarnMessage(TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper updateWrapper) {
TaxDeclarationApiFlowWarnConfigPO warnConfig = getWarnConfig(updateWrapper.getTenantKey());
// 未配置或开关关闭
if (Objects.isNull(warnConfig) || SalaryOnOffEnum.OFF.getValue().equals(warnConfig.getEnableWarn())) {
return;
}
QueryAccountBalanceResponse response = getTaxDeclarationApiFlowStatisticService(user).getQueryAccountBalanceResponse(updateWrapper.getApiConfig());
// 剩余流量大于阈值无需提醒
if (StringUtils.isNotEmpty(response.getBody().getSurplus()) && Long.parseLong(response.getBody().getSurplus()) > warnConfig.getThreshold()) {
return;
}
List<TaxDeclarationApiFlowWarnReceiverListDTO> warnReceiverList = getWarnReceiverList(warnConfig.getId());
if (warnReceiverList.isEmpty()) {
log.info("warnReceiverList is empty, send msg fail");
return;
}
//todo 消息
// List<UserEntity> receivers = warnReceiverList.stream().map(e ->
// new UserEntity(e.getEmployeeId(), updateWrapper.getTenantKey())
// .setEmail(e.getEmail()).setPhone(e.getMobile()).setLanguage(6)
@ -253,5 +238,5 @@
// // 发送消息
// WeaResult<Long> weaResult = asyncSystemMessageRest.sendMsg(smg);
// SalaryAssert.isTrue(weaResult.isStatus(), SalaryI18nUtil.getI18nLabel(184009, "流量不足提醒发送失败"));
// }
//}
}
}