diff --git a/resource/sqlupgrade/DM/sql202308280203.sql b/resource/sqlupgrade/DM/sql202308280203.sql new file mode 100644 index 000000000..77273e99e --- /dev/null +++ b/resource/sqlupgrade/DM/sql202308280203.sql @@ -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 +); +/ + diff --git a/resource/sqlupgrade/GS/sql202308280203.sql b/resource/sqlupgrade/GS/sql202308280203.sql new file mode 100644 index 000000000..77273e99e --- /dev/null +++ b/resource/sqlupgrade/GS/sql202308280203.sql @@ -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 +); +/ + diff --git a/resource/sqlupgrade/JC/sql202308280203.sql b/resource/sqlupgrade/JC/sql202308280203.sql new file mode 100644 index 000000000..77273e99e --- /dev/null +++ b/resource/sqlupgrade/JC/sql202308280203.sql @@ -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 +); +/ + diff --git a/resource/sqlupgrade/Mysql/sql202308280203.sql b/resource/sqlupgrade/Mysql/sql202308280203.sql new file mode 100644 index 000000000..ef5d03136 --- /dev/null +++ b/resource/sqlupgrade/Mysql/sql202308280203.sql @@ -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' +) +; diff --git a/resource/sqlupgrade/Oracle/sql202308280203.sql b/resource/sqlupgrade/Oracle/sql202308280203.sql new file mode 100644 index 000000000..20bac3295 --- /dev/null +++ b/resource/sqlupgrade/Oracle/sql202308280203.sql @@ -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 +) +/ \ No newline at end of file diff --git a/resource/sqlupgrade/PG/sql202308280203.sql b/resource/sqlupgrade/PG/sql202308280203.sql new file mode 100644 index 000000000..0f9b2c00b --- /dev/null +++ b/resource/sqlupgrade/PG/sql202308280203.sql @@ -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 +); +/ \ No newline at end of file diff --git a/resource/sqlupgrade/SQLServer/sql202308280203.sql b/resource/sqlupgrade/SQLServer/sql202308280203.sql new file mode 100644 index 000000000..d5a06b580 --- /dev/null +++ b/resource/sqlupgrade/SQLServer/sql202308280203.sql @@ -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 \ No newline at end of file diff --git a/resource/sqlupgrade/ST/sql202308280203.sql b/resource/sqlupgrade/ST/sql202308280203.sql new file mode 100644 index 000000000..77273e99e --- /dev/null +++ b/resource/sqlupgrade/ST/sql202308280203.sql @@ -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 +); +/ + diff --git a/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowRecordQueryParam.java b/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowRecordQueryParam.java index d0a508a08..ef66fa4f4 100644 --- a/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowRecordQueryParam.java +++ b/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowRecordQueryParam.java @@ -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; diff --git a/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowRecordPO.java b/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowRecordPO.java index ef1c9ba5b..a4fd29999 100644 --- a/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowRecordPO.java +++ b/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowRecordPO.java @@ -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 ids; + private Date useTimeStartDate; + private Date useTimeEndDate; + } diff --git a/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowWarnReceiverPO.java b/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowWarnReceiverPO.java index 5ac94d180..350a88160 100644 --- a/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowWarnReceiverPO.java +++ b/src/com/engine/salary/entity/taxapiflow/po/TaxDeclarationApiFlowWarnReceiverPO.java @@ -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; + /** * 鎻愰啋閰嶇疆鐨刬d */ @@ -73,4 +75,7 @@ public class TaxDeclarationApiFlowWarnReceiverPO implements Serializable { * 绉熸埛ID */ private String tenantKey; + + + private Collection ids; } diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java index 8a2155271..cae7bcb7e 100644 --- a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java @@ -69,4 +69,10 @@ public interface TaxAgentMapper { List listEmployee(); + /** + * 鏌ヨ鍖呭惈鍒犻櫎鐘舵佺殑鏁版嵁 + * @param taxAgentIds + * @return + */ + List listByIdsIncludeDel(@Param("taxAgentIds") Collection taxAgentIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml index 84e424805..2d9d361d5 100644 --- a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml @@ -238,5 +238,17 @@ where e.status not in (7) + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.java b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.java new file mode 100644 index 000000000..c72078fe6 --- /dev/null +++ b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.java @@ -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 listAll(); + + /** + * 鏉′欢鏌ヨ + * + * @return 杩斿洖闆嗗悎锛屾病鏈夎繑鍥炵┖List + */ + List listSome(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig); + + + /** + * 鏍规嵁涓婚敭鏌ヨ + * + * @param id 涓婚敭 + * @return 杩斿洖璁板綍锛屾病鏈夎繑鍥瀗ull + */ + TaxDeclarationApiFlowWarnConfigPO getById(Long id); + + /** + * 鏂板锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowWarnConfig 鏂板鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int insertIgnoreNull(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig); + + /** + * 鎵归噺鎻掑叆 + * + * @param taxApiFlowWarnConfig + */ + void batchInsert(@Param("collection") List taxApiFlowWarnConfig); + + /** + * 淇敼锛屼慨鏀规墍鏈夊瓧娈 + * + * @param taxApiFlowWarnConfig 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int update(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig); + + /** + * 淇敼锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowWarnConfig 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int updateIgnoreNull(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig); + + /** + * 鍒犻櫎璁板綍 + * + * @param taxApiFlowWarnConfig 寰呭垹闄ょ殑璁板綍 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int delete(TaxDeclarationApiFlowWarnConfigPO taxApiFlowWarnConfig); + + /** + * 鎵归噺鍒犻櫎璁板綍 + * @param ids 涓婚敭id闆嗗悎 + */ + void deleteByIds(@Param("ids") Collection ids); + + TaxDeclarationApiFlowWarnConfigPO getOne(); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.xml b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.xml new file mode 100644 index 000000000..190783ccb --- /dev/null +++ b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnConfigMapper.xml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + t + . + business_id + , t.create_time + , t.creator + , t.delete_type + , t.enable_warn + , t.id + , t.tenant_key + , t.threshold + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_api_flow_warn_config + + + + business_id, + + + create_time, + + + creator, + + + delete_type, + + + enable_warn, + + + id, + + + tenant_key, + + + threshold, + + + update_time, + + + + + #{businessId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{enableWarn}, + + + #{id}, + + + #{tenantKey}, + + + #{threshold}, + + + #{updateTime}, + + + + + + + + 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} + + ) + + + + + INSERT INTO hrsa_tax_api_flow_warn_config ( + business_id, + create_time, + creator, + delete_type, + enable_warn, + id, + tenant_key, + threshold, + update_time + ) + + + 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 + + + + + + + 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} + ) + + + + + + UPDATE hrsa_tax_api_flow_warn_config + + business_id=#{businessId}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + enable_warn=#{enableWarn}, + tenant_key=#{tenantKey}, + threshold=#{threshold}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_warn_config + + + business_id=#{businessId}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + enable_warn=#{enableWarn}, + + + tenant_key=#{tenantKey}, + + + threshold=#{threshold}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_warn_config + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_api_flow_warn_config + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.java b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.java new file mode 100644 index 000000000..26384e3b4 --- /dev/null +++ b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.java @@ -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 listAll(); + + /** + * 鏉′欢鏌ヨ + * + * @return 杩斿洖闆嗗悎锛屾病鏈夎繑鍥炵┖List + */ + List listSome(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver); + + + /** + * 鏍规嵁涓婚敭鏌ヨ + * + * @param id 涓婚敭 + * @return 杩斿洖璁板綍锛屾病鏈夎繑鍥瀗ull + */ + TaxDeclarationApiFlowWarnReceiverPO getById(Long id); + + /** + * 鏂板锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowReceiver 鏂板鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int insertIgnoreNull(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver); + + /** + * 鎵归噺鎻掑叆 + * + * @param taxApiFlowReceiver + */ + void batchInsert(@Param("collection") List taxApiFlowReceiver); + + /** + * 淇敼锛屼慨鏀规墍鏈夊瓧娈 + * + * @param taxApiFlowReceiver 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int update(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver); + + /** + * 淇敼锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowReceiver 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int updateIgnoreNull(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver); + + /** + * 鍒犻櫎璁板綍 + * + * @param taxApiFlowReceiver 寰呭垹闄ょ殑璁板綍 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int delete(TaxDeclarationApiFlowWarnReceiverPO taxApiFlowReceiver); + + /** + * 鎵归噺鍒犻櫎璁板綍 + * + * @param ids 涓婚敭id闆嗗悎 + */ + void deleteByIds(@Param("ids") Collection ids); + + List filterByEmpId(TaxDeclarationApiFlowWarnReceiverSaveParam param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.xml b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.xml new file mode 100644 index 000000000..5c9942e40 --- /dev/null +++ b/src/com/engine/salary/mapper/taxapiflow/TaxDeclarationApiFlowWarnReceiverMapper.xml @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_api_flow_receiver + + + + create_time, + + + creator, + + + delete_type, + + + email, + + + employee_id, + + + id, + + + mobile, + + + tenant_key, + + + update_time, + + + warn_config_id, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{email}, + + + #{employeeId}, + + + #{id}, + + + #{mobile}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{warnConfigId}, + + + + + + + + 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} + + ) + + + + + INSERT INTO hrsa_tax_api_flow_receiver ( + create_time, + creator, + delete_type, + email, + employee_id, + id, + mobile, + tenant_key, + update_time, + warn_config_id + ) + + + 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 + + + + + + + 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} + ) + + + + + + UPDATE hrsa_tax_api_flow_receiver + + 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}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_receiver + + + 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}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_receiver + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_api_flow_receiver + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.java index 0f6194282..f430e1eb2 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.java @@ -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 listAll(); + + /** + * 鏉′欢鏌ヨ + * + * @return 杩斿洖闆嗗悎锛屾病鏈夎繑鍥炵┖List + */ + List listSome(TaxDeclarationApiFlowRecordPO taxApiFlowRecord); + + + /** + * 鏍规嵁涓婚敭鏌ヨ + * + * @param id 涓婚敭 + * @return 杩斿洖璁板綍锛屾病鏈夎繑鍥瀗ull + */ + TaxDeclarationApiFlowRecordPO getById(Long id); + + /** + * 鏂板锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowRecord 鏂板鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int insertIgnoreNull(TaxDeclarationApiFlowRecordPO taxApiFlowRecord); + + /** + * 淇敼锛屼慨鏀规墍鏈夊瓧娈 + * + * @param taxApiFlowRecord 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int update(TaxDeclarationApiFlowRecordPO taxApiFlowRecord); + + /** + * 淇敼锛屽拷鐣ull瀛楁 + * + * @param taxApiFlowRecord 淇敼鐨勮褰 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int updateIgnoreNull(TaxDeclarationApiFlowRecordPO taxApiFlowRecord); + + /** + * 鍒犻櫎璁板綍 + * + * @param taxApiFlowRecord 寰呭垹闄ょ殑璁板綍 + * @return 杩斿洖褰卞搷琛屾暟 + */ + int delete(TaxDeclarationApiFlowRecordPO taxApiFlowRecord); + + /** + * 鎵归噺鍒犻櫎璁板綍 + * @param ids 涓婚敭id闆嗗悎 + */ + void deleteByIds(@Param("ids") Collection ids); + /** * 鎵归噺鎻掑叆 * diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.xml index 3db4b36b3..6dbe947bb 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowRecordMapper.xml @@ -2,8 +2,290 @@ + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_api_flow_record + + + + business_type, + + + create_time, + + + creator, + + + deduct, + + + delete_type, + + + employee_id, + + + id, + + + result_status, + + + tax_agent_id, + + + tax_month, + + + tenant_key, + + + update_time, + + + use_time, + + + + + #{businessType}, + + + #{createTime}, + + + #{creator}, + + + #{deduct}, + + + #{deleteType}, + + + #{employeeId}, + + + #{id}, + + + #{resultStatus}, + + + #{taxAgentId}, + + + #{taxMonth}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{useTime}, + + + + + + + + UPDATE hrsa_tax_api_flow_record + + 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}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_record + + + 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}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_api_flow_record + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_api_flow_record + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + - 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 @@ -24,7 +306,8 @@ - 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 @@ -46,7 +329,8 @@ - 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) @@ -68,7 +352,8 @@ - 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 diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowWarnConfigMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowWarnConfigMapper.java deleted file mode 100644 index 93cde6c3b..000000000 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationApiFlowWarnConfigMapper.java +++ /dev/null @@ -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 { -} diff --git a/src/com/engine/salary/service/ExtEmpService.java b/src/com/engine/salary/service/ExtEmpService.java index 63c9729e6..8eef60d3e 100644 --- a/src/com/engine/salary/service/ExtEmpService.java +++ b/src/com/engine/salary/service/ExtEmpService.java @@ -15,6 +15,8 @@ import java.util.Map; public interface ExtEmpService { + List listAll(); + List list(ExtEmpQueryParam param); PageInfo listPage (ExtEmpQueryParam param); diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java index 297b455c5..aeb1020ed 100644 --- a/src/com/engine/salary/service/SalaryEmployeeService.java +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -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 listByParams(List includeQueryParams); + /** + * 鏍规嵁浜哄憳id鏌ヨ韬唤璇 + * + * @param employeeIds + * @return + */ + Map mapByEmployeeIds(Collection employeeIds); + } diff --git a/src/com/engine/salary/service/TaxAgentService.java b/src/com/engine/salary/service/TaxAgentService.java index 2890f94b8..8dd73f1c4 100644 --- a/src/com/engine/salary/service/TaxAgentService.java +++ b/src/com/engine/salary/service/TaxAgentService.java @@ -250,4 +250,12 @@ public interface TaxAgentService { * @return */ Collection listEmployeeIdsInTaxAgent(Long taxAgentId); + + /** + * 鏌ヨ鍖呭惈鍒犻櫎鐘舵佺殑鏁版嵁 + * + * @param taxAgentIds + * @return + */ + List listByIdsIncludeDel(Collection taxAgentIds); } diff --git a/src/com/engine/salary/service/TaxDeclarationApiBillingService.java b/src/com/engine/salary/service/TaxDeclarationApiBillingService.java index 7c7801cdb..409b99903 100644 --- a/src/com/engine/salary/service/TaxDeclarationApiBillingService.java +++ b/src/com/engine/salary/service/TaxDeclarationApiBillingService.java @@ -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 pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam); -// -// /** -// * 鑾峰彇娴侀噺浣跨敤璁板綍锛堜笉鍒嗛〉锛 -// * -// * @param queryParam -// * @return -// */ -// List listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam); + /** + * 鑾峰彇娴侀噺浣跨敤璁板綍(鍒嗛〉) + * + * @param queryParam + * @return + */ + PageInfo pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam); + + /** + * 鑾峰彇娴侀噺浣跨敤璁板綍锛堜笉鍒嗛〉锛 + * + * @param queryParam + * @return + */ + List listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam); /** * 瀵煎嚭娴侀噺浣跨敤璁板綍 diff --git a/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java b/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java new file mode 100644 index 000000000..960bcd23c --- /dev/null +++ b/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java @@ -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 pageFlowStatistics(BaseQueryParam queryParam); + + /** + * 鑾峰彇鍚勪富浣撶殑娴侀噺浣跨敤鏄庣粏锛堜笉鍒嗛〉锛 + * + * @return + */ + List listFlowStatistic(); + + /** + * 鑾峰彇鍗曚釜涓讳綋鐨勬祦閲忔湀搴︿娇鐢ㄦ槑缁(鍒嗛〉) + * + * @param queryParam + * @return + */ + PageInfo pageFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam); + + /** + * 鑾峰彇鍗曚釜涓讳綋鐨勬祦閲忔湀搴︿娇鐢ㄦ槑缁(涓嶅垎椤) + * + * @param queryParam + * @return + */ + List listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam); + +// /** +// * 瀵煎嚭娴侀噺缁熻 +// * +// * @param map +// * @param dtoList +// */ +// void exportFlowStatistics(Map map, List dtoList); +// +// /** +// * 瀵煎嚭娴侀噺鏈堝害缁熻 +// * +// * @param queryParam +// * @param map +// * @param dtoList +// */ +// void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map map, List dtoList); + + /** + * 鏌ヨ娴侀噺缁熻鏁版嵁 + * + * @param apiConfig + * @return + */ + QueryAccountBalanceResponse getQueryAccountBalanceResponse(TaxDeclarationApiConfigPO apiConfig); + +} diff --git a/src/com/engine/salary/service/TaxDeclarationApiFlowWarnService.java b/src/com/engine/salary/service/TaxDeclarationApiFlowWarnService.java index ae981ddd3..c530bdd1a 100644 --- a/src/com/engine/salary/service/TaxDeclarationApiFlowWarnService.java +++ b/src/com/engine/salary/service/TaxDeclarationApiFlowWarnService.java @@ -32,25 +32,21 @@ public interface TaxDeclarationApiFlowWarnService { * 鑾峰彇娴侀噺涓嶈冻鎻愰啋瀵硅薄鍒楄〃 * * @param warnConfigId - * @param currentTenantKey * @return */ - List getWarnReceiverList(Long warnConfigId, String currentTenantKey); + List 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); diff --git a/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java index c311d6086..fe7671522 100644 --- a/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java +++ b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java @@ -68,6 +68,11 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService { return MapperProxyFactory.getProxy(EmployMapper.class); } + @Override + public List listAll() { + return getExternalEmployeeMapper().listAll(); + } + @Override public List list(ExtEmpQueryParam param) { return getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java index fb2567f0c..5fda44b47 100644 --- a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -269,4 +269,14 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee } return result; } + + @Override + public Map mapByEmployeeIds(Collection employeeIds) { + List simpleUserInfos = getEmployeeByIdsAll((List) employeeIds); + Map result = new HashMap<>(); + simpleUserInfos.forEach(e -> { + result.put(e.getEmployeeId(), e.getIdNo()); + }); + return result; + } } diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index d3cbc3999..ea7fb6fbb 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -798,5 +798,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { return SalaryEntityUtil.properties(taxAgentEmpPOS, TaxAgentEmpPO::getEmployeeId); } + @Override + public List listByIdsIncludeDel(Collection taxAgentIds) { + return getTaxAgentMapper().listByIdsIncludeDel(taxAgentIds); + } + } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java index 8288c1565..ce9dc1efa 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java @@ -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 pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) { -// LambdaQueryChainWrapper queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam); -// Page flowRecordPOPage = queryChainWrapper.page(new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true)); -// List records = flowRecordPOPage.getRecords(); -// if (records.isEmpty()) { -// return new PageInfo<>(); -// } -// TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(records); -// // 杞崲鏁版嵁 -// AtomicInteger indexNum = new AtomicInteger(1); -// List 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 listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) { -// LambdaQueryChainWrapper queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam); -// List 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 list, String currentTenantKey) { -// Map employeeTaxAgentMap = SalaryEntityUtil.convert2Map(list, TaxDeclarationApiFlowRecordPO::getEmployeeId, TaxDeclarationApiFlowRecordPO::getTaxAgentId); -// // 鑾峰彇浜哄憳淇℃伅 -// List employeeComInfos = comInfoCache.getCacheList(HrmEmployeeComInfo.class, new ArrayList<>(employeeTaxAgentMap.keySet())); -// Map empNameMap = SalaryEntityUtil.convert2Map(employeeComInfos, HrmEmployeeComInfo::getId, HrmEmployeeComInfo::getUsername); -// Map empIdNoMap = getSalaryEmployeeService(user).mapByEmployeeIds(employeeTaxAgentMap.keySet()); -// List extEmployeePOS = extEmployeeService.listAll(currentTenantKey); -// Map extEmployeeMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmployeePO::getId); -// // 鑾峰彇涓◣鎵g即涔夊姟浜轰俊鎭 -// List taxAgentPOS = getTaxAgentService(user).listByIds(new HashSet<>(employeeTaxAgentMap.values())); -// Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName); -// return new TempPropertiesWrapper(empNameMap, empIdNoMap, taxAgentNameMap, extEmployeeMap); -// } -// -// private LambdaQueryChainWrapper getFlowRecordQueryChainWrapper(TaxDeclarationApiFlowRecordQueryParam queryParam, String currentTenantKey) { -// LambdaQueryChainWrapper 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 pageFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) { + TaxDeclarationApiFlowRecordPO queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam); + List records = getTaxDeclarationApiFlowRecordMapper().listSome(queryChainWrapper); + + if (records.isEmpty()) { + return new PageInfo<>(); + } + TempPropertiesWrapper propertiesWrapper = getUserInfoAndTaxAgentMap(records); + // 杞崲鏁版嵁 + AtomicInteger indexNum = new AtomicInteger(1); + List 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 listFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) { + TaxDeclarationApiFlowRecordPO queryChainWrapper = getFlowRecordQueryChainWrapper(queryParam); + List 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 list) { + Map employeeTaxAgentMap = SalaryEntityUtil.convert2Map(list, TaxDeclarationApiFlowRecordPO::getEmployeeId, TaxDeclarationApiFlowRecordPO::getTaxAgentId); + // 鑾峰彇浜哄憳淇℃伅 + List employeeComInfos =getSalaryEmployeeService(user).getEmployeeByIdsAll(new ArrayList<>(employeeTaxAgentMap.keySet())); + Map empNameMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + Map empIdNoMap = getSalaryEmployeeService(user).mapByEmployeeIds(employeeTaxAgentMap.keySet()); + List extEmployeePOS = extEmployeeService.listAll(); + Map extEmployeeMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmpPO::getId); + // 鑾峰彇涓◣鎵g即涔夊姟浜轰俊鎭 + List taxAgentPOS = getTaxAgentService(user).listByIds(new HashSet<>(employeeTaxAgentMap.values())); + Map 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 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; diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java new file mode 100644 index 000000000..26bb2777f --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java @@ -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 pageFlowStatistics(BaseQueryParam queryParam) { + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listFlowStatistic()); + } + + @Override + public List listFlowStatistic() { + TaxDeclarationApiConfigPO config = getTaxDeclarationApiConfigService(user).getConfig(true); + QueryAccountBalanceResponse response = getQueryAccountBalanceResponse(config); + List details = Optional.of(response).map(e -> e.getBody().getTaxList()).orElse(new ArrayList<>()); + if (details.isEmpty()) { + log.info("details is empty"); + return new ArrayList<>(); + } + Set taxCodes = details.stream().map(QueryAccountBalanceResponse.Detail::getTaxNumber).collect(Collectors.toSet()); + List returnPOList = getTaxAgentTaxReturnService(user).getByTaxCodes(taxCodes); + if (returnPOList.isEmpty()) { + log.info("TaxAgentTaxReturnPO is empty"); + return new ArrayList<>(); + } + Set taxAgentIds = returnPOList.stream().map(TaxAgentTaxReturnPO::getTaxAgentId).collect(Collectors.toSet()); + List taxAgentPOList = getTaxAgentService(user).listByIdsIncludeDel(taxAgentIds); + if (taxAgentPOList.isEmpty()) { + log.info("TaxAgentPO is empty"); + return new ArrayList<>(); + } + + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOList, TaxAgentPO::getId, TaxAgentPO::getName); + Map> taxCodeMap = returnPOList.stream().collect(Collectors.groupingBy(TaxAgentTaxReturnPO::getTaxCode)); + List flowStatisticDTOS = new ArrayList<>(); + for (QueryAccountBalanceResponse.Detail detail : details) { + List 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 pageFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) { + List dtoList = listFlowStatisticDetail(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), dtoList, TaxDeclarationApiFlowStatisticDetailListDTO.class); + } + + @Override + public List listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) { + TaxDeclarationApiConfigPO apiConfigPO = getTaxDeclarationApiConfigService(user).getConfig(true); + TaxAgentTaxReturnPO taxReturnPO = getTaxAgentTaxReturnService(user).getByTaxAgentId(queryParam.getTaxAgentId()); + SalaryAssert.notNull(taxReturnPO, SalaryI18nUtil.getI18nLabel(184065, "涓◣鎵g即涔夊姟浜烘殏鏃犳姤绋庝俊鎭")); + List taxAgentPOS = getTaxAgentService(user).listByIdsIncludeDel(Collections.singleton(taxReturnPO.getTaxAgentId())); + SalaryAssert.notEmpty(taxAgentPOS, SalaryI18nUtil.getI18nLabel(100545, "涓◣鎵g即涔夊姟浜轰笉瀛樺湪")); + QueryDetailsByTaxNumberResponse response = getQueryDetailsByTaxNumberResponse(apiConfigPO, taxReturnPO.getTaxCode()); + List 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 map, List dtoList) { +// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey); +// // 琛ㄥご +// List headers = exportWrapper.getHeaders(); +// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "涓◣鎵g即涔夊姟浜")); +// headers.add(SalaryI18nUtil.getI18nLabel( 159084, "宸蹭娇鐢ㄦ祦閲")); +// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{}))); +// // 缁勮鏁版嵁 +// for (TaxDeclarationApiFlowStatisticListDTO dto : dtoList) { +// List row = new ArrayList<>(); +// row.add(dto.getTaxAgentName()); +// row.add(dto.getUsed()); +// exportWrapper.getRows().add(row); +// } +// // 鐢熸垚琛ㄦ牸 +// buildExcelData(exportWrapper); +// } + +// @Override +// public void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map map, List dtoList) { +// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey); +// // 琛ㄥご +// List headers = exportWrapper.getHeaders(); +// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "涓◣鎵g即涔夊姟浜")); +// headers.add(SalaryI18nUtil.getI18nLabel( 86176, "绋庢鎵灞炴湡")); +// headers.add(SalaryI18nUtil.getI18nLabel( 159087, "鏈堜娇鐢ㄦ祦閲忔暟")); +// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{}))); +// // 缁勮鏁版嵁 +// for (TaxDeclarationApiFlowStatisticDetailListDTO dto : dtoList) { +// List 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 params = new HashMap<>(1); + Map 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 params = new HashMap<>(1); + params.put("taxNumber", taxCode); + Map 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; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java index 8eeeabbd2..5ecd2e175 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java @@ -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 getWarnReceiverList(Long warnConfigId, String currentTenantKey) { -// List receiverPOList = new LambdaQueryChainWrapper<>(taxDeclarationApiFlowWarnReceiverMapper) -// .eq(TaxDeclarationApiFlowWarnReceiverPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) -// .eq(TaxDeclarationApiFlowWarnReceiverPO::getTenantKey, currentTenantKey) -// .eq(TaxDeclarationApiFlowWarnReceiverPO::getWarnConfigId, warnConfigId) -// .list(); -// -// List salaryEmployees = taxAgentService.listEmployees(currentTenantKey); -// Map 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 simpleEmployees = salaryEmployeeService.listAll(currentTenantKey); -// Map 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 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 getWarnReceiverList(Long warnConfigId) { + List receiverPOList = getTaxDeclarationApiFlowWarnReceiverMapper().listSome(TaxDeclarationApiFlowWarnReceiverPO + .builder() + .warnConfigId(warnConfigId) + .build()); + + List salaryEmployees = getTaxAgentService(user).listEmployees(); + Map 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 simpleEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Map 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 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 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 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 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 warnReceiverList = getWarnReceiverList(warnConfig.getId()); + if (warnReceiverList.isEmpty()) { + log.info("warnReceiverList is empty, send msg fail"); + return; + } + //todo 娑堟伅 // List receivers = warnReceiverList.stream().map(e -> // new UserEntity(e.getEmployeeId(), updateWrapper.getTenantKey()) // .setEmail(e.getEmail()).setPhone(e.getMobile()).setLanguage(6) @@ -253,5 +238,5 @@ // // 鍙戦佹秷鎭 // WeaResult weaResult = asyncSystemMessageRest.sendMsg(smg); // SalaryAssert.isTrue(weaResult.isStatus(), SalaryI18nUtil.getI18nLabel(184009, "娴侀噺涓嶈冻鎻愰啋鍙戦佸け璐")); -// } -//} + } +}