在线获取累计专项附加扣除
This commit is contained in:
parent
7c5e373b01
commit
c0c29b7472
|
|
@ -1,14 +1,25 @@
|
|||
package com.engine.salary.entity.datacollection.bo;
|
||||
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO;
|
||||
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
||||
import com.engine.salary.enums.SalaryOnOffEnum;
|
||||
import com.engine.salary.enums.employeedeclare.CardTypeEnum;
|
||||
import com.engine.salary.enums.employeedeclare.EmploymentStatusEnum;
|
||||
import com.engine.salary.enums.employeedeclare.EmploymentTypeEnum;
|
||||
import com.engine.salary.enums.employeedeclare.GenderEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnPasswordTypeEnum;
|
||||
import com.engine.salary.service.impl.AddUpDeductionServiceImpl;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import dm.jdbc.util.IdGenerator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -318,34 +329,34 @@ public class DataCollectionBO {
|
|||
return requestParam;
|
||||
}
|
||||
|
||||
// public static List<Map<String, Object>> getEmployeeList(List<EmployeeDeclarePO> declarePOList) {
|
||||
// List<Map<String, Object>> employeeList = new ArrayList<>();
|
||||
// for (EmployeeDeclarePO employeeDeclarePO : declarePOList) {
|
||||
// Map<String, Object> employeeMap = new HashMap<>(32);
|
||||
// employeeMap.put("xm", employeeDeclarePO.getEmployeeName());
|
||||
// employeeMap.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel());
|
||||
// employeeMap.put("zzhm", employeeDeclarePO.getCardNum());
|
||||
// employeeMap.put("lxdh", employeeDeclarePO.getMobile());
|
||||
// employeeMap.put("nsrzt", EmploymentStatusEnum.NORMAL.getDefaultLabel());
|
||||
// employeeMap.put("sfgy", EmploymentTypeEnum.EMPLOYEE.getDefaultLabel());
|
||||
// employeeMap.put("rzsgrq", SalaryDateUtil.DATE_FORMATTER.format(employeeDeclarePO.getEmploymentDate()));
|
||||
// employeeMap.put("xb", GenderEnum.MALE.getValue().equals(employeeDeclarePO.getGender()) ? GenderEnum.MALE.getDefaultLabel() : GenderEnum.FEMALE.getDefaultLabel());
|
||||
// employeeMap.put("csny", SalaryDateUtil.DATE_FORMATTER.format(employeeDeclarePO.getBirthday()));
|
||||
// employeeMap.put("gj", "中国");
|
||||
// employeeMap.put("rydq", "境内");
|
||||
// boolean disability = SalaryOnOffEnum.ON.getValue().equals(employeeDeclarePO.getDisability());
|
||||
// boolean martyrDependents = SalaryOnOffEnum.ON.getValue().equals(employeeDeclarePO.getMartyrDependents());
|
||||
// employeeMap.computeIfAbsent("sfcj", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getDisability()).getDefaultLabel());
|
||||
// employeeMap.computeIfAbsent("cjzh", e -> disability ? employeeDeclarePO.getDisabilityCardNo() : null);
|
||||
// employeeMap.computeIfAbsent("sfls", e->SalaryOnOffEnum.parseByValue(employeeDeclarePO.getMartyrDependents()).getDefaultLabel());
|
||||
// employeeMap.computeIfAbsent("lszh", e-> martyrDependents ? employeeDeclarePO.getMartyrDependentsCardNo() : null);
|
||||
// employeeMap.computeIfAbsent("sfgl", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getLonelyOld()).getDefaultLabel());
|
||||
// employeeMap.computeIfAbsent("sfzdw", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getDeductExpenses()).getDefaultLabel());
|
||||
// employeeList.add(employeeMap);
|
||||
// }
|
||||
// return employeeList;
|
||||
// }
|
||||
//
|
||||
public static List<Map<String, Object>> getEmployeeList(List<EmployeeDeclarePO> declarePOList) {
|
||||
List<Map<String, Object>> employeeList = new ArrayList<>();
|
||||
for (EmployeeDeclarePO employeeDeclarePO : declarePOList) {
|
||||
Map<String, Object> employeeMap = new HashMap<>(32);
|
||||
employeeMap.put("xm", employeeDeclarePO.getEmployeeName());
|
||||
employeeMap.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel());
|
||||
employeeMap.put("zzhm", employeeDeclarePO.getCardNum());
|
||||
employeeMap.put("lxdh", employeeDeclarePO.getMobile());
|
||||
employeeMap.put("nsrzt", EmploymentStatusEnum.NORMAL.getDefaultLabel());
|
||||
employeeMap.put("sfgy", EmploymentTypeEnum.EMPLOYEE.getDefaultLabel());
|
||||
employeeMap.put("rzsgrq", SalaryDateUtil.getFormatYYYYMM(employeeDeclarePO.getEmploymentDate()));
|
||||
employeeMap.put("xb", GenderEnum.MALE.getValue().equals(employeeDeclarePO.getGender()) ? GenderEnum.MALE.getDefaultLabel() : GenderEnum.FEMALE.getDefaultLabel());
|
||||
employeeMap.put("csny", SalaryDateUtil.getFormatYYYYMM(employeeDeclarePO.getBirthday()));
|
||||
employeeMap.put("gj", "中国");
|
||||
employeeMap.put("rydq", "境内");
|
||||
boolean disability = SalaryOnOffEnum.ON.getValue().equals(employeeDeclarePO.getDisability());
|
||||
boolean martyrDependents = SalaryOnOffEnum.ON.getValue().equals(employeeDeclarePO.getMartyrDependents());
|
||||
employeeMap.computeIfAbsent("sfcj", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getDisability()).getDefaultLabel());
|
||||
employeeMap.computeIfAbsent("cjzh", e -> disability ? employeeDeclarePO.getDisabilityCardNo() : null);
|
||||
employeeMap.computeIfAbsent("sfls", e->SalaryOnOffEnum.parseByValue(employeeDeclarePO.getMartyrDependents()).getDefaultLabel());
|
||||
employeeMap.computeIfAbsent("lszh", e-> martyrDependents ? employeeDeclarePO.getMartyrDependentsCardNo() : null);
|
||||
employeeMap.computeIfAbsent("sfgl", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getLonelyOld()).getDefaultLabel());
|
||||
employeeMap.computeIfAbsent("sfzdw", e -> SalaryOnOffEnum.parseByValue(employeeDeclarePO.getDeductExpenses()).getDefaultLabel());
|
||||
employeeList.add(employeeMap);
|
||||
}
|
||||
return employeeList;
|
||||
}
|
||||
|
||||
// public static AddUpDeduction buildAddUpDeductionPO(QuerySpecialAmountFeedbackResponse.Feedback feedback) {
|
||||
// return AddUpDeduction.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
|
|
@ -379,18 +390,18 @@ public class DataCollectionBO {
|
|||
// .tenantKey(requestPO.getTenantKey())
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
// public static AddUpDeductionRequestResultDTO buildRequestResultDTO(Long requestId, AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
// return AddUpDeductionRequestResultDTO.builder()
|
||||
// .requestId(requestId.toString())
|
||||
// .msg(String.format(SalaryI18nUtil.getI18nLabel(184070, "共成功获取数据%s条,失败%s条"),
|
||||
// requestWrapper.getInsertList().size() + requestWrapper.getUpdateList().size(),
|
||||
// requestWrapper.getFailPOList().size()))
|
||||
// .result(requestWrapper.getFailPOList().size() > 0 ? "warning" : "success")
|
||||
// .finish(true)
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
|
||||
public static AddUpDeductionRequestResultDTO buildRequestResultDTO(Long requestId, AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
return AddUpDeductionRequestResultDTO.builder()
|
||||
.requestId(requestId.toString())
|
||||
.msg(String.format(SalaryI18nUtil.getI18nLabel(184070, "共成功获取数据%s条,失败%s条"),
|
||||
requestWrapper.getInsertList().size() + requestWrapper.getUpdateList().size(),
|
||||
requestWrapper.getFailPOList().size()))
|
||||
.result(requestWrapper.getFailPOList().size() > 0 ? "warning" : "success")
|
||||
.finish(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
// public static AddUpDeduction buildAddUpDeductionPO(AddUpDeductionSaveParam saveParam, Long currentEmployeeId, String currentTenantKey) {
|
||||
// return AddUpDeduction.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.engine.salary.entity.datacollection.dto;
|
||||
|
||||
import com.engine.salary.annotation.SalaryTableColumn;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 数据采集-累计专项附加扣除-在线获取失败列表
|
||||
*
|
||||
* @author chengliming
|
||||
* @date 2022-11-07 15:01:25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel("数据采集-累计专项附加扣除-在线获取失败列表")
|
||||
public class AddUpDeductionRequestFailListDTO {
|
||||
|
||||
@SalaryTableColumn(text = "姓名", labelId = 85429, width = "100")
|
||||
@ApiModelProperty("姓名")
|
||||
private String employeeName;
|
||||
|
||||
@ApiModelProperty("员工id")
|
||||
private Long employeeId;
|
||||
|
||||
@ApiModelProperty("id主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("人员类型")
|
||||
private String employeeType;
|
||||
|
||||
@SalaryTableColumn(text = "个税扣缴义务人", labelId = 86184, width = "150")
|
||||
@ApiModelProperty("个税扣缴义务人")
|
||||
private String taxAgentName;
|
||||
|
||||
@SalaryTableColumn(text = "工号", labelId = 86317, width = "100")
|
||||
@ApiModelProperty("工号")
|
||||
private String jobNum;
|
||||
|
||||
@SalaryTableColumn(text = "部门", labelId = 86185, width = "100")
|
||||
@ApiModelProperty("部门")
|
||||
private String departmentName;
|
||||
|
||||
@SalaryTableColumn(text = "身份证件号码", labelId = 102782, width = "150")
|
||||
@ApiModelProperty("证件号码")
|
||||
private String idNo;
|
||||
|
||||
@SalaryTableColumn(text = "失败原因", labelId = 144832, width = "600")
|
||||
@ApiModelProperty("失败原因")
|
||||
private String failReason;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.engine.salary.entity.datacollection.param;
|
||||
|
||||
import com.engine.salary.common.BaseQueryParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 数据采集-累计专项附加扣除-在线获取失败记录查询参数
|
||||
*
|
||||
* @author chengliming
|
||||
* @date 2022-11-01 14:40:36
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel("数据采集-累计专项附加扣除-在线获取失败记录查询参数")
|
||||
public class AddUpDeductionRequestFailQueryParam extends BaseQueryParam {
|
||||
|
||||
@ApiModelProperty("请求ID")
|
||||
private Long requestId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.engine.salary.entity.datacollection.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据采集-累计专项附加扣除在线查询失败表
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//hrsa_add_up_deduction_req_fail")
|
||||
//数据采集-累计专项附加扣除在线查询失败表")
|
||||
public class AddUpDeductionRequestFailPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4950145856639514995L;
|
||||
|
||||
//ID")
|
||||
private Long id;
|
||||
|
||||
//创建时间", ignore = true)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
//修改时间", ignore = true)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
//创建人id", ignore = true)
|
||||
private long creator;
|
||||
|
||||
//是否删除", ignore = true)
|
||||
private int deleteType;
|
||||
|
||||
//租户KEY", ignore = true)
|
||||
private String tenantKey;
|
||||
|
||||
//查询请求ID")
|
||||
private Long requestId;
|
||||
|
||||
//外部查询请求ID")
|
||||
private String outerRequestId;
|
||||
|
||||
//员工Id")
|
||||
private Long employeeId;
|
||||
|
||||
//个税扣缴义务人ID")
|
||||
private Long taxAgentId;
|
||||
|
||||
//失败原因")
|
||||
private String reason;
|
||||
|
||||
//税款所属期")
|
||||
private LocalDate taxYearMonth;
|
||||
|
||||
/**
|
||||
* @see com.weaver.hrm.salary.enums.salaryaccounting.EmployeeTypeEnum
|
||||
*/
|
||||
//人员类型")
|
||||
private Integer employeeType;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.engine.salary.entity.datacollection.po;
|
||||
|
||||
import com.engine.salary.enums.datacollection.EnumAddUpDeductionRequestStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据采集-累计专项附加扣除在线查询表
|
||||
*
|
||||
* @author chengliming
|
||||
* @date: 2022-10-26 16:07:04
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//hrsa_add_up_deduction_request")
|
||||
//数据采集-累计专项附加扣除在线查询表")
|
||||
public class AddUpDeductionRequestPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1452863635879051515L;
|
||||
|
||||
//ID")
|
||||
private long id;
|
||||
|
||||
//创建时间", ignore = true)
|
||||
private Date createTime;
|
||||
|
||||
//修改时间", ignore = true)
|
||||
private Date updateTime;
|
||||
|
||||
//创建人id", ignore = true)
|
||||
private long creator;
|
||||
|
||||
//是否删除", ignore = true)
|
||||
private int deleteType;
|
||||
|
||||
//租户KEY", ignore = true)
|
||||
private String tenantKey;
|
||||
|
||||
//乐观锁版本", ignore = true)
|
||||
private int lockVersion;
|
||||
|
||||
//查询请求ID")
|
||||
private Long requestId;
|
||||
|
||||
//外部接口查询请求ID")
|
||||
private String outerRequestId;
|
||||
|
||||
/**
|
||||
* @see EnumAddUpDeductionRequestStatus
|
||||
*/
|
||||
//请求处理状态")
|
||||
private int requestStatus;
|
||||
|
||||
//税款所属期")
|
||||
private Date taxYearMonth;
|
||||
|
||||
//个税扣缴义务人ID")
|
||||
private Long taxAgentId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.engine.salary.entity.datacollection.po;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据采集-抽象接口-方便使用泛型封装方法(po继承类会导致加密aop报错,原因不知,所以这里使用接口抽象)
|
||||
*
|
||||
* @author chengliming
|
||||
* @date: 2022-09-30 10:55:40
|
||||
*/
|
||||
public interface DataCollectionBaseInfo {
|
||||
|
||||
/**
|
||||
* 获取id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Long getId();
|
||||
|
||||
Long getModifier();
|
||||
|
||||
Long getEmployeeId();
|
||||
|
||||
Long getTaxAgentId();
|
||||
|
||||
Integer getDeleteType();
|
||||
|
||||
String getTenantKey();
|
||||
|
||||
LocalDateTime getCreateTime();
|
||||
|
||||
LocalDateTime getUpdateTime();
|
||||
|
||||
void setId(Long id);
|
||||
|
||||
void setModifier(Long modifier);
|
||||
|
||||
void setEmployeeId(Long employeeId);
|
||||
|
||||
void setTaxAgentId(Long taxAgentId);
|
||||
|
||||
void setDeleteType(Integer deleteType);
|
||||
|
||||
void setTenantKey(String tenantKey);
|
||||
|
||||
void setCreateTime(LocalDateTime createTime);
|
||||
|
||||
void setUpdateTime(LocalDateTime updateTime);
|
||||
|
||||
void setCreator(Long creator);
|
||||
}
|
||||
|
|
@ -2,28 +2,28 @@ package com.engine.salary.entity.datacollection.response;
|
|||
|
||||
import com.engine.salary.entity.taxpayment.response.BaseResponse;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 人员专项附加扣除信息查询结果
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QuerySpecialAmountResponse extends BaseResponse {
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
private QuerySpecialAmountBody body;
|
||||
private Body body;
|
||||
|
||||
/**
|
||||
* 人员专项附加扣除信息查询结果body
|
||||
**/
|
||||
@Data
|
||||
public static class QuerySpecialAmountBody {
|
||||
public static class Body {
|
||||
/**
|
||||
* 请求查询ID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -219,4 +219,5 @@ public class EmployeeDeclarePO {
|
|||
|
||||
private Collection<Long> ids;
|
||||
private Collection<Long> employeeIds;
|
||||
private Collection<Long> taxAgentIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.engine.salary.enums.datacollection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 累计附加扣除请求外部接口处理状态
|
||||
*
|
||||
* @author chengliming
|
||||
* @date 2021-10-26 16:50:52
|
||||
*/
|
||||
@SuppressWarnings("squid:S00115")
|
||||
public enum EnumAddUpDeductionRequestStatus {
|
||||
|
||||
/**
|
||||
* 待处理(废弃)
|
||||
*/
|
||||
READY(10),
|
||||
/**
|
||||
* 处理中
|
||||
*/
|
||||
RUNNING(20),
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
COMPLETED(99),
|
||||
;
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private static final Map<Integer, String> VALUE_NAME_MAP;
|
||||
|
||||
static {
|
||||
final EnumAddUpDeductionRequestStatus[] values = EnumAddUpDeductionRequestStatus.values();
|
||||
VALUE_NAME_MAP = new HashMap<>(values.length);
|
||||
for (EnumAddUpDeductionRequestStatus value : values) {
|
||||
VALUE_NAME_MAP.put(value.getValue(), value.name());
|
||||
}
|
||||
}
|
||||
|
||||
EnumAddUpDeductionRequestStatus(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String getName(int index) {
|
||||
return VALUE_NAME_MAP.get(index);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,6 +202,12 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="taxAgentIds != null and taxAgentIds.size()>0">
|
||||
AND tax_agent_id IN
|
||||
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
|
||||
#{taxAgentId}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package com.engine.salary.service;
|
|||
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestFailListDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO;
|
||||
import com.engine.salary.entity.datacollection.param.*;
|
||||
import com.engine.salary.entity.datacollection.po.AddUpDeductionRequestFailPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
|
@ -183,7 +185,6 @@ public interface AddUpDeductionService {
|
|||
* 获取反馈失败记录
|
||||
*
|
||||
* @param requestId
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
List<AddUpDeductionRequestFailPO> getAddUpDeductionRequestFailPOList(Long requestId);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public abstract class AbstractTaxPaymentService extends Service implements TaxPa
|
|||
.orElse(null);
|
||||
String requestId = Optional.ofNullable(queryResponse)
|
||||
.map(QuerySpecialAmountResponse::getBody)
|
||||
.map(QuerySpecialAmountResponse.QuerySpecialAmountBody::getRequestId)
|
||||
.map(QuerySpecialAmountResponse.Body::getRequestId)
|
||||
.orElse(null);
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode) || StringUtils.isEmpty(requestId)) {
|
||||
log.info("getAsyncQueryResponse4Payment code error:{}", JSON.toJSONString(queryResponse));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.browser.bean.SearchConditionGroup;
|
||||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.api.browser.util.ConditionFactory;
|
||||
|
|
@ -11,35 +12,55 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.AddUpDeductionBiz;
|
||||
import com.engine.salary.common.LocalDateRange;
|
||||
import com.engine.salary.constant.SzyhApiConstant;
|
||||
import com.engine.salary.encrypt.EncryptUtil;
|
||||
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.datacollection.bo.DataCollectionBO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam;
|
||||
import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestFailListDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO;
|
||||
import com.engine.salary.entity.datacollection.param.*;
|
||||
import com.engine.salary.entity.datacollection.po.AddUpDeductionRequestFailPO;
|
||||
import com.engine.salary.entity.datacollection.po.AddUpDeductionRequestPO;
|
||||
import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO;
|
||||
import com.engine.salary.entity.datacollection.response.QuerySpecialAmountFeedbackResponse;
|
||||
import com.engine.salary.entity.datacollection.response.QuerySpecialAmountResponse;
|
||||
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
||||
import com.engine.salary.entity.extemp.po.ExtEmpPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
||||
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
||||
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.bo.TaxApiFlowBO;
|
||||
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.datacollection.EnumAddUpDeductionRequestStatus;
|
||||
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
|
||||
import com.engine.salary.enums.employeedeclare.DeclareStatusEnum;
|
||||
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
||||
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
|
||||
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnStatusEnum;
|
||||
import com.engine.salary.enums.taxdeclaration.EnumDeclareApiBusinessType;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
|
||||
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareMapper;
|
||||
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
||||
import com.engine.salary.report.enums.EmployeeTypeEnum;
|
||||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
||||
import com.engine.salary.sys.entity.vo.OrderRuleVO;
|
||||
import com.engine.salary.sys.service.SalarySysConfService;
|
||||
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.*;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
|
|
@ -48,9 +69,13 @@ import com.engine.salary.util.page.PageInfo;
|
|||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dm.jdbc.util.IdGenerator;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
|
|
@ -61,6 +86,9 @@ import java.io.InputStream;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
||||
|
|
@ -73,6 +101,7 @@ import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TEN
|
|||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class AddUpDeductionServiceImpl extends Service implements AddUpDeductionService {
|
||||
private EncryptUtil encryptUtil = new EncryptUtil();
|
||||
|
||||
|
|
@ -108,6 +137,30 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxAgentTaxReturnService getTaxAgentTaxReturnService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryArchiveService getSalaryArchiveService(User user) {
|
||||
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public TaxDeclarationApiBillingService getTaxDeclarationApiBillingService(User user) {
|
||||
return ServiceUtil.getService(TaxDeclarationApiBillingServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private EmployeeDeclareMapper getEmployeeDeclareMapper() {
|
||||
return MapperProxyFactory.getProxy(EmployeeDeclareMapper.class);
|
||||
}
|
||||
|
||||
private ExtEmpService getExtEmpService(User user) {
|
||||
return ServiceUtil.getService(ExtEmpServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
|
|
@ -410,7 +463,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
throw new SalaryRunTimeException("该数据不存在!");
|
||||
}
|
||||
Long taxAgentId = byId.getTaxAgentId();
|
||||
boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId));
|
||||
boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), taxAgentId));
|
||||
if (!canEdit) {
|
||||
//没有编辑权限
|
||||
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
|
||||
|
|
@ -440,7 +493,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
|
||||
//税款所属期
|
||||
String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth();
|
||||
if (declareMonthStr .equals("")) {
|
||||
if (declareMonthStr.equals("")) {
|
||||
throw new SalaryRunTimeException("税款所属期不能为空!");
|
||||
}
|
||||
// 获取所有个税扣缴义务人
|
||||
|
|
@ -468,7 +521,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
.updateTime(now)
|
||||
.creator((long) user.getUID())
|
||||
.declareMonth(declareMonth).build();
|
||||
boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpDeductionRecordParam.getEmployeeId()));
|
||||
boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), addUpDeductionRecordParam.getEmployeeId()));
|
||||
if (!employeeSameId) {
|
||||
throw new SalaryRunTimeException("员工信息不存在");
|
||||
}
|
||||
|
|
@ -552,7 +605,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
throw new SalaryRunTimeException("数据不存在或已被删除!");
|
||||
}
|
||||
// 判断是否在个税扣缴义务人范围内
|
||||
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst();
|
||||
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())).findFirst();
|
||||
if (!first.isPresent()) {
|
||||
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
|
||||
}
|
||||
|
|
@ -587,7 +640,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) {
|
||||
// 设置了个税扣缴义务人
|
||||
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
|
||||
boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId));
|
||||
boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId));
|
||||
if (!canDelete) {
|
||||
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
|
||||
}
|
||||
|
|
@ -636,12 +689,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
@Override
|
||||
public String autoAddAll(Date yearMonth, Boolean isAdmin) {
|
||||
String cacheKey = "addUpDeduction_autoAddAll_processing";
|
||||
Object objVal = Util_DataCache.getObjVal( cacheKey);
|
||||
if(objVal != null){
|
||||
Object objVal = Util_DataCache.getObjVal(cacheKey);
|
||||
if (objVal != null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "一键累计过于频繁,请稍后再试"));
|
||||
}
|
||||
try {
|
||||
Util_DataCache.setObjVal(cacheKey,true );
|
||||
Util_DataCache.setObjVal(cacheKey, true);
|
||||
//如果是定时任务直接查询所有,isAdmin传true
|
||||
boolean isChief = Boolean.TRUE.equals(isAdmin)
|
||||
|| getTaxAgentService(user).isChief((long) user.getUID());
|
||||
|
|
@ -969,7 +1022,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
if (getTaxAgentService(user).isOpenDevolution() && !isChief) {
|
||||
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentService(user).listTaxAgentAndEmployee(employeeId);
|
||||
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
||||
// List<AddUpDeduction> lastList = getLastListByModifier(employeeId, tenantKey);
|
||||
// List<AddUpDeduction> lastList = getLastListByModifier(employeeId);
|
||||
list = list.stream().filter(f ->
|
||||
// 作为管理员
|
||||
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
||||
|
|
@ -1200,4 +1253,506 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> onlineRequest(AddUpDeductionMonthTaxAgentParam param) {
|
||||
SalaryAssert.notNull(param.getDeclareMonth(), SalaryI18nUtil.getI18nLabel(100586, "税款所属期必传"));
|
||||
// 获取接口配置
|
||||
TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true);
|
||||
// 获取包装类
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper = getAddUpDeductionOnlineRequestWrapper(null, apiConfig);
|
||||
// 获取报税信息
|
||||
List<TaxAgentTaxReturnPO> taxReturnPOList = getTaxAgentTaxReturnService(user).getByTaxAgentIds(requestWrapper.getTaxAgentMap().keySet());
|
||||
List<TaxAgentTaxReturnPO> failReturnPOList = taxReturnPOList.stream().filter(e -> !TaxAgentTaxReturnStatusEnum.SUCCESS.getValue().equals(e.getCheckStatus())).collect(Collectors.toList());
|
||||
SalaryAssert.isFalse(taxReturnPOList.size() == failReturnPOList.size(), SalaryI18nUtil.getI18nLabel(183781, "企业未通过验证,暂时无法获取累计专项附加扣除数据,请先在【个税扣缴义务人】菜单验证企业报税信息"));
|
||||
Map<String, Object> result = new HashMap<>(1);
|
||||
if (!failReturnPOList.isEmpty()) {
|
||||
String failTaxAgentNames = failReturnPOList.stream().map(e -> requestWrapper.getTaxAgentMap().get(e.getTaxAgentId())).collect(Collectors.joining("、"));
|
||||
result.put("msg", String.format(SalaryI18nUtil.getI18nLabel(183782, "%s未通过登记验证,无法在线获取数据"), failTaxAgentNames));
|
||||
}
|
||||
// 获取请求
|
||||
List<AddUpDeductionRequestPO> requestPOList = getAddUpDeductionRequestPOS();
|
||||
SalaryAssert.isEmpty(requestPOList, SalaryI18nUtil.getI18nLabel(153341, "获取中,稍后请点击【获取结果下载】"));
|
||||
// 获取报送成功的人员名单
|
||||
Map<Long, List<EmployeeDeclarePO>> taxAgentEmpDeclareMap = getEmpDeclareMap(requestWrapper.getTaxAgentMap().keySet(), param.getDeclareMonth());
|
||||
// 开始请求接口获取数据
|
||||
List<QuerySpecialAmountResponse.Body> querySpecialAmountBodies = getQuerySpecialAmountBodies(param, requestWrapper, taxAgentEmpDeclareMap, taxReturnPOList);
|
||||
// 持久化数据
|
||||
persistFeedbackData(param, querySpecialAmountBodies);
|
||||
return result;
|
||||
}
|
||||
|
||||
private AddUpDeductionOnlineRequestWrapper getAddUpDeductionOnlineRequestWrapper(List<AddUpDeductionRequestPO> requestPOList, TaxDeclarationApiConfigPO apiConfig) {
|
||||
boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
long employeeId = (long) user.getUID();
|
||||
boolean isChief = getTaxAgentService(user).isChief(employeeId);
|
||||
List<TaxAgentPO> taxAgents = !isOpenDevolution || isChief ? getTaxAgentService(user).listAsChief(isOpenDevolution, isChief) : getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId);
|
||||
Set<Long> taxAgentIdSet = SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId);
|
||||
// 获取薪资档案
|
||||
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveService(user).listByRunStatus(Arrays.asList(
|
||||
SalaryArchiveStatusEnum.FIXED.getValue(),
|
||||
SalaryArchiveStatusEnum.SUSPEND.getValue(),
|
||||
SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue(),
|
||||
SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())
|
||||
);
|
||||
salaryArchiveList = salaryArchiveList.stream().filter(e -> taxAgentIdSet.contains(e.getTaxAgentId())).collect(Collectors.toList());
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper = new AddUpDeductionOnlineRequestWrapper(requestPOList, salaryArchiveList, taxAgents);
|
||||
requestWrapper.setApiConfig(apiConfig);
|
||||
return requestWrapper;
|
||||
}
|
||||
|
||||
private Map<Long, List<EmployeeDeclarePO>> getEmpDeclareMap(Collection<Long> taxAgentIds, Date declareMonth) {
|
||||
List<EmployeeDeclarePO> employeeDeclarePOS = getEmployeeDeclarePOList(taxAgentIds, declareMonth);
|
||||
SalaryAssert.notEmpty(employeeDeclarePOS, SalaryI18nUtil.getI18nLabel(183783, "暂无人员报送状态为正常的数据,请先报送再获取累计专项附加扣除数据。"));
|
||||
return employeeDeclarePOS.stream().collect(Collectors.groupingBy(EmployeeDeclarePO::getTaxAgentId));
|
||||
}
|
||||
|
||||
private List<EmployeeDeclarePO> getEmployeeDeclarePOList(Collection<Long> taxAgentIds, Date declareMonth) {
|
||||
return getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder().declareStatus(DeclareStatusEnum.DECLARE_SUCCESS.getValue()).taxCycle(declareMonth).taxAgentIds(taxAgentIds).build());
|
||||
}
|
||||
|
||||
private List<QuerySpecialAmountResponse.Body> getQuerySpecialAmountBodies(AddUpDeductionMonthTaxAgentParam param,
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper,
|
||||
Map<Long, List<EmployeeDeclarePO>> taxAgentEmployeeDeclareMap,
|
||||
List<TaxAgentTaxReturnPO> taxReturnPOList) {
|
||||
List<QuerySpecialAmountResponse.Body> queryResponseList = new ArrayList<>();
|
||||
for (TaxAgentTaxReturnPO returnPO : taxReturnPOList) {
|
||||
if (!TaxAgentTaxReturnStatusEnum.SUCCESS.getValue().equals(returnPO.getCheckStatus())) {
|
||||
continue;
|
||||
}
|
||||
// 发起请求
|
||||
String taxAgentName = requestWrapper.getTaxAgentMap().get(returnPO.getTaxAgentId());
|
||||
List<EmployeeDeclarePO> declarePOList = taxAgentEmployeeDeclareMap.getOrDefault(returnPO.getTaxAgentId(), new ArrayList<>());
|
||||
if (declarePOList.isEmpty()) {
|
||||
log.info("该主体下没有报送成功的人员,主体名称:{}", taxAgentName);
|
||||
continue;
|
||||
}
|
||||
QuerySpecialAmountResponse queryResponse = getQuerySpecialAmountResponse(returnPO, taxAgentName, declarePOList, param, requestWrapper.getApiConfig());
|
||||
// 校验请求结果
|
||||
String responseCode = Optional.ofNullable(queryResponse)
|
||||
.map(QuerySpecialAmountResponse::getHead)
|
||||
.map(SzyhResponseHead::getCode)
|
||||
.orElse(null);
|
||||
String outerRequestId = Optional.ofNullable(queryResponse)
|
||||
.map(QuerySpecialAmountResponse::getBody)
|
||||
.map(QuerySpecialAmountResponse.Body::getRequestId)
|
||||
.orElse(null);
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode) || StringUtils.isEmpty(outerRequestId)) {
|
||||
log.info("getQuerySpecialAmountBodies error:{}", JSON.toJSONString(queryResponse));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
|
||||
}
|
||||
queryResponse.getBody().setTaxAgentId(returnPO.getTaxAgentId());
|
||||
queryResponseList.add(queryResponse.getBody());
|
||||
}
|
||||
return queryResponseList;
|
||||
}
|
||||
|
||||
private void persistFeedbackData(AddUpDeductionMonthTaxAgentParam param, List<QuerySpecialAmountResponse.Body> queryResponseList) {
|
||||
long requestId = IdGenerator.generate();
|
||||
for (QuerySpecialAmountResponse.Body body : queryResponseList) {
|
||||
AddUpDeductionRequestPO po = AddUpDeductionRequestPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.requestId(requestId)
|
||||
.taxAgentId(body.getTaxAgentId())
|
||||
.requestStatus(EnumAddUpDeductionRequestStatus.RUNNING.getValue())
|
||||
.outerRequestId(body.getRequestId())
|
||||
.taxYearMonth(param.getDeclareMonth())
|
||||
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.tenantKey(DEFAULT_TENANT_KEY)
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.creator(user.getUID())
|
||||
.lockVersion(0)
|
||||
.build();
|
||||
addUpDeductionRequestMapper.insert(po);
|
||||
}
|
||||
}
|
||||
|
||||
private QuerySpecialAmountResponse getQuerySpecialAmountResponse(TaxAgentTaxReturnPO returnPO,
|
||||
String taxAgentName,
|
||||
List<EmployeeDeclarePO> declarePOList,
|
||||
AddUpDeductionMonthTaxAgentParam param,
|
||||
TaxDeclarationApiConfigPO apiConfig) {
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.QUERY_SPECIAL_AMOUNT;
|
||||
Map<String, Object> requestParam = DataCollectionBO.getApiBaseQueryParams(returnPO, taxAgentName, SalaryDateUtil.getFormatYYYYMM(param.getDeclareMonth()));
|
||||
requestParam.put("rylb", DataCollectionBO.getEmployeeList(declarePOList));
|
||||
String reqJson = JsonUtil.toJsonString(requestParam);
|
||||
log.info("getQuerySpecialAmountResponse params --- \n{}\n", reqJson);
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
// 开始请求
|
||||
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
||||
log.info("getQuerySpecialAmountResponse res --- {}", res);
|
||||
return JsonUtil.parseObject(res, QuerySpecialAmountResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddUpDeductionRequestResultDTO onlineFeedback() {
|
||||
TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true);
|
||||
List<AddUpDeductionRequestPO> requestPOList = getAddUpDeductionRequestPOS();
|
||||
// 校验请求是否合法
|
||||
Long requestId = checkRequestPOList(requestPOList);
|
||||
// 前置数据封装为包装类
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper = getAddUpDeductionOnlineRequestWrapper(requestPOList, apiConfig);
|
||||
// 开始请求反馈数据
|
||||
AddUpDeductionRequestResultDTO resultDTO = getQuerySpecialAmountFeedback(requestWrapper);
|
||||
// 判断是否需要继续轮询或者异常退出
|
||||
if (!resultDTO.getFinish()) {
|
||||
return resultDTO;
|
||||
}
|
||||
// 更新请求状态为已完成
|
||||
updateRequestStatus(requestPOList, EnumAddUpDeductionRequestStatus.RUNNING.getValue(), EnumAddUpDeductionRequestStatus.COMPLETED.getValue());
|
||||
// 获取员工信息
|
||||
setEmployeeInfoMap(requestWrapper);
|
||||
// 获取已存在的累计附加扣除数据
|
||||
setExistedDataMap(requestWrapper);
|
||||
// 开始处理反馈结果
|
||||
TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper apiFlowUpdateWrapper
|
||||
= new TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper(requestPOList.get(0).getTaxYearMonth(), requestWrapper.getApiConfig(), EnumDeclareApiBusinessType.ADD_UP_DEDUCTION);
|
||||
handleFeedbackData(requestWrapper, apiFlowUpdateWrapper);
|
||||
// 持久化数据
|
||||
persistFeedbackData(requestWrapper);
|
||||
// 更新流量统计数据
|
||||
getTaxDeclarationApiBillingService(user).updateApiFlowInfo(apiFlowUpdateWrapper);
|
||||
// 返回结果
|
||||
return DataCollectionBO.buildRequestResultDTO(requestId, requestWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AddUpDeductionRequestFailListDTO> onlineFeedbackFail(AddUpDeductionRequestFailQueryParam queryParam) {
|
||||
Page<AddUpDeductionRequestFailPO> page = new LambdaQueryChainWrapper<>(addUpDeductionRequestFailMapper)
|
||||
.eq(AddUpDeductionRequestFailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.eq(AddUpDeductionRequestFailPO::getTenantKey)
|
||||
.eq(AddUpDeductionRequestFailPO::getRequestId, queryParam.getRequestId())
|
||||
.page(new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), queryParam.getTotal(), true));
|
||||
|
||||
// 获取薪资档案
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper = getAddUpDeductionOnlineRequestWrapper(null, null);
|
||||
this.getEmployeeInfoMap(requestWrapper);
|
||||
|
||||
List<AddUpDeductionRequestFailListDTO> listDTOList = page.getRecords().stream()
|
||||
.map(requestWrapper::buildAddUpDeductionRequestFailListDTO).collect(Collectors.toList());
|
||||
PageInfo<AddUpDeductionRequestFailListDTO> listDTOPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), false);
|
||||
listDTOPage.setRecords(listDTOList);
|
||||
return listDTOPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AddUpDeductionRequestFailPO> getAddUpDeductionRequestFailPOList(Long requestId) {
|
||||
return new LambdaQueryChainWrapper<>(addUpDeductionRequestFailMapper)
|
||||
.eq(AddUpDeductionRequestFailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.eq(AddUpDeductionRequestFailPO::getTenantKey)
|
||||
.eq(AddUpDeductionRequestFailPO::getRequestId, requestId)
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportOnlineFeedbackFail(Map<String, Object> map, Long requestId) {
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
// 表头
|
||||
List<Object> headers = new ArrayList<>();
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号码"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(144832, "失败原因"));
|
||||
rows.add(headers);
|
||||
// 获取薪资档案
|
||||
AddUpDeductionOnlineRequestWrapper requestWrapper = getAddUpDeductionOnlineRequestWrapper(null, null);
|
||||
// 获取身份信息map
|
||||
this.getEmployeeInfoMap(requestWrapper);
|
||||
// 获取数据
|
||||
List<AddUpDeductionRequestFailPO> pos = getAddUpDeductionRequestFailPOList(requestId);
|
||||
// 组装数据
|
||||
for (AddUpDeductionRequestFailPO po : pos) {
|
||||
AddUpDeductionRequestFailListDTO failListDTO = requestWrapper.buildAddUpDeductionRequestFailListDTO(po);
|
||||
List<Object> row = new ArrayList<>();
|
||||
row.add(failListDTO.getEmployeeName());
|
||||
row.add(failListDTO.getTaxAgentName());
|
||||
row.add(failListDTO.getJobNum());
|
||||
row.add(failListDTO.getDepartmentName());
|
||||
row.add(failListDTO.getIdNo());
|
||||
row.add(failListDTO.getFailReason());
|
||||
rows.add(row);
|
||||
}
|
||||
// 生成表格
|
||||
ExcelUtil.genWorkbookV2(rows,"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void getEmployeeInfoMap(AddUpDeductionOnlineRequestWrapper wrapper) {
|
||||
// 身份证号
|
||||
List<Long> employeeIds = SalaryEntityUtil.properties(wrapper.getSalaryArchiveList(), SalaryArchivePO::getEmployeeId,Collectors.toList());
|
||||
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).listByIds(employeeIds);
|
||||
Map<Long, DataCollectionEmployee> simpleUserInfoMap = SalaryEntityUtil.convert2Map(simpleUserInfos, DataCollectionEmployee::getEmployeeId);
|
||||
wrapper.setUserInfoUserIdMap(simpleUserInfoMap);
|
||||
// 人员信息
|
||||
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
|
||||
Map<Long, DataCollectionEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
|
||||
wrapper.setSimpleEmployeeMap(simpleEmployeeMap);
|
||||
// 外部人员信息
|
||||
List<ExtEmpPO> extEmployeePOS = getExtEmpService(user).listCanUse(wrapper.getCurrentEmployeeId());
|
||||
Map<Long, ExtEmpPO> extEmployeePOMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmpPO::getId, e -> e);
|
||||
wrapper.setExtEmployeePOMap(extEmployeePOMap);
|
||||
}
|
||||
|
||||
private List<AddUpDeductionRequestPO> getAddUpDeductionRequestPOS() {
|
||||
return new LambdaQueryChainWrapper<>(addUpDeductionRequestMapper)
|
||||
.eq(AddUpDeductionRequestPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.eq(AddUpDeductionRequestPO::getTenantKey)
|
||||
.in(AddUpDeductionRequestPO::getRequestStatus, EnumAddUpDeductionRequestStatus.RUNNING.getValue())
|
||||
.list();
|
||||
}
|
||||
|
||||
private void handleFeedbackData(AddUpDeductionOnlineRequestWrapper requestWrapper, TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper apiFlowUpdateWrapper) {
|
||||
requestWrapper.getRequestFeedBackMap().forEach((outerRequestId, feedbacks) -> feedbacks.forEach(feedback -> {
|
||||
DataCollectionEmployee simpleUserInfo = requestWrapper.getUserInfoIdNoMap().get(feedback.getZzhm());
|
||||
Long extEmpId = requestWrapper.getExtEmployeeIdCardMap().get(feedback.getZzhm());
|
||||
Long employeeId = Optional.ofNullable(simpleUserInfo)
|
||||
.map(DataCollectionEmployee::getUser)
|
||||
.map(IdEntity::getId)
|
||||
.orElse(extEmpId);
|
||||
AddUpDeductionRequestPO requestPO = requestWrapper.getRequestPoMap().get(outerRequestId);
|
||||
|
||||
// 流量使用情况
|
||||
TaxDeclarationApiFlowRecordPO flowRecordPO = TaxApiFlowBO.buildTaxDeclarationApiFlowRecordPO(apiFlowUpdateWrapper, requestPO.getTaxAgentId(), employeeId);
|
||||
|
||||
if (employeeId == null || StringUtils.isNotEmpty(feedback.getSbyy())) {
|
||||
// 处理失败数据
|
||||
AddUpDeductionRequestFailPO failPO = DataCollectionBO.buildAddUpDeductionRequestFailPO(requestWrapper, requestPO, employeeId);
|
||||
failPO.setReason(employeeId == null
|
||||
? String.format("该人员报送成功的身份证号与人事档案下的身份证号不一致,报送人员信息:[%s]|[%s]", feedback.getXm(), feedback.getZzhm())
|
||||
: feedback.getSbyy());
|
||||
failPO.setEmployeeType(simpleUserInfo != null ? EmployeeTypeEnum.ORGANIZATION.getValue() :
|
||||
extEmpId != null ? EmployeeTypeEnum.EXT_EMPLOYEE.getValue() : 2);
|
||||
requestWrapper.getFailPOList().add(failPO);
|
||||
flowRecordPO.setEmployeeId(Optional.ofNullable(employeeId).orElse(0L));
|
||||
flowRecordPO.setResultStatus(TaxAgentTaxReturnStatusEnum.FAIL.getValue());
|
||||
} else {
|
||||
// 处理成功数据
|
||||
AddUpDeduction po = DataCollectionBO.buildAddUpDeductionPO(feedback);
|
||||
Long poId = requestWrapper.getExistedDataMap().get(requestPO.getTaxAgentId() + "-" + employeeId);
|
||||
if (Objects.nonNull(poId)) {
|
||||
po.setId(poId);
|
||||
requestWrapper.getUpdateList().add(po);
|
||||
} else {
|
||||
setBaseInfo2PO(requestWrapper, employeeId, requestPO, po);
|
||||
requestWrapper.getInsertList().add(po);
|
||||
}
|
||||
}
|
||||
apiFlowUpdateWrapper.getApiFlowDetailPOList().add(flowRecordPO);
|
||||
}));
|
||||
}
|
||||
|
||||
private Long checkRequestPOList(List<AddUpDeductionRequestPO> requestPOList) {
|
||||
Map<Integer, List<AddUpDeductionRequestPO>> statusRequestMap = SalaryEntityUtil.group2Map(requestPOList, AddUpDeductionRequestPO::getRequestStatus);
|
||||
if (CollectionUtils.isEmpty(statusRequestMap.get(EnumAddUpDeductionRequestStatus.RUNNING.getValue()))) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(153343, "请先点击【在线获取】按钮,选择税款所属期进行获取数据。"));
|
||||
}
|
||||
Set<Long> requestIds = SalaryEntityUtil.properties(requestPOList, AddUpDeductionRequestPO::getRequestId);
|
||||
if (requestIds.size() != 1) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(153344, "当前同时存在多个任务,请联系管理员进行处理。"));
|
||||
}
|
||||
return requestPOList.get(0).getRequestId();
|
||||
}
|
||||
|
||||
private void setEmployeeInfoMap(AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
// 内部员工(详细信息)
|
||||
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ORG);
|
||||
Map<Long, DataCollectionEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
|
||||
requestWrapper.setSimpleEmployeeMap(simpleEmployeeMap);
|
||||
// 内部员工(身份证信息)
|
||||
List<Long> employeeIds = SalaryEntityUtil.properties(requestWrapper.getSalaryArchiveList(), SalaryArchivePO::getEmployeeId,Collectors.toList());
|
||||
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).listByIds(employeeIds);
|
||||
Map<String, DataCollectionEmployee> simpleUserInfoMap = SalaryEntityUtil.convert2Map(simpleUserInfos, DataCollectionEmployee::getIdNo);
|
||||
requestWrapper.setUserInfoIdNoMap(simpleUserInfoMap);
|
||||
// 外部员工信息
|
||||
List<ExtEmpPO> extEmployeePOS = getExtEmpService(user).listCanUse(requestWrapper.getCurrentEmployeeId(), requestWrapper.getTenantKey());
|
||||
Map<String, Long> extEmployeePOMap = SalaryEntityUtil.convert2Map(extEmployeePOS, ExtEmpPO::getCardNum, ExtEmpPO::getId);
|
||||
requestWrapper.setExtEmployeeIdCardMap(extEmployeePOMap);
|
||||
}
|
||||
|
||||
private void setExistedDataMap(AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
Set<Long> taxAgentIds = SalaryEntityUtil.properties(requestWrapper.getSalaryArchiveList(), SalaryArchivePO::getTaxAgentId);
|
||||
List<AddUpDeduction> poList = new LambdaQueryChainWrapper<>(addUpDeductionMapper)
|
||||
.select(AddUpDeduction::getId, AddUpDeduction::getTaxAgentId, AddUpDeduction::getEmployeeId)
|
||||
.eq(AddUpDeduction::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.eq(AddUpDeduction::getTenantKey, requestWrapper.getTenantKey())
|
||||
.eq(AddUpDeduction::getDeclareMonth, requestWrapper.getRequestPOList().get(0).getTaxYearMonth())
|
||||
.in(AddUpDeduction::getTaxAgentId, taxAgentIds)
|
||||
.list();
|
||||
requestWrapper.setExistedDataMap(SalaryEntityUtil.convert2Map(poList, e -> e.getTaxAgentId() + "-" + e.getEmployeeId(), AddUpDeduction::getId));
|
||||
}
|
||||
|
||||
private AddUpDeductionRequestResultDTO getQuerySpecialAmountFeedback(AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
for (AddUpDeductionRequestPO requestPO : requestWrapper.getRequestPOList()) {
|
||||
QuerySpecialAmountFeedbackResponse response = getQuerySpecialAmountFeedbackResponse(requestWrapper.getApiConfig(), requestPO);
|
||||
// 校验请求结果
|
||||
String responseCode = Optional.ofNullable(response).map(QuerySpecialAmountFeedbackResponse::getHead).map(SzyhResponseHead::getCode).orElse(null);
|
||||
String msg = Optional.ofNullable(response).map(QuerySpecialAmountFeedbackResponse::getHead).map(SzyhResponseHead::getMsg).orElse(null);
|
||||
if (SzyhApiConstant.HANDLING_CODE.equals(responseCode)) {
|
||||
// 如果接口仍在处理中,则继续轮询
|
||||
return AddUpDeductionRequestResultDTO.builder().finish(false).build();
|
||||
}
|
||||
// 获取返回的人员信息列表
|
||||
if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode)) {
|
||||
log.info("getQuerySpecialAmountFeedback not success error:{}", JSON.toJSONString(response));
|
||||
throw new SalaryRunTimeException(msg);
|
||||
}
|
||||
List<QuerySpecialAmountFeedbackResponse.Feedback> feedbacks = Optional.of(response)
|
||||
.map(QuerySpecialAmountFeedbackResponse::getBody)
|
||||
.map(QuerySpecialAmountFeedbackResponse.Body::getRyxxlb)
|
||||
.orElse(new ArrayList<>());
|
||||
if (feedbacks.isEmpty()) {
|
||||
log.info("getQuerySpecialAmountFeedback empty data error:{}", JSON.toJSONString(response));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(175338, "税局接口错误,未返回有效数据"));
|
||||
}
|
||||
requestWrapper.getRequestFeedBackMap().put(requestPO.getOuterRequestId(), feedbacks);
|
||||
requestWrapper.getRequestPoMap().put(requestPO.getOuterRequestId(), requestPO);
|
||||
}
|
||||
return AddUpDeductionRequestResultDTO.builder().finish(true).build();
|
||||
}
|
||||
|
||||
private void persistFeedbackData(AddUpDeductionOnlineRequestWrapper requestWrapper) {
|
||||
if (!requestWrapper.getInsertList().isEmpty()) {
|
||||
List<List<AddUpDeduction>> insertPartition = Lists.partition(requestWrapper.getInsertList(), 1000);
|
||||
insertPartition.forEach(list -> {
|
||||
list = dataSecurityService.encryptBatch(list, AddUpDeduction.class, requestWrapper.getTenantKey());
|
||||
addUpDeductionMapper.insertData(list);
|
||||
});
|
||||
}
|
||||
if (!requestWrapper.getUpdateList().isEmpty()) {
|
||||
List<List<AddUpDeduction>> updatePartition = Lists.partition(requestWrapper.getUpdateList(), 1000);
|
||||
updatePartition.forEach(list -> {
|
||||
list = dataSecurityService.encryptBatch(list, AddUpDeduction.class, requestWrapper.getTenantKey());
|
||||
addUpDeductionMapper.updateData(list);
|
||||
});
|
||||
}
|
||||
if (!requestWrapper.getFailPOList().isEmpty()) {
|
||||
List<List<AddUpDeductionRequestFailPO>> failPartition = Lists.partition(requestWrapper.getFailPOList(), 1000);
|
||||
failPartition.forEach(list -> addUpDeductionRequestFailMapper.batchInsert(list));
|
||||
}
|
||||
}
|
||||
|
||||
private void setBaseInfo2PO(AddUpDeductionOnlineRequestWrapper wrapper, Long employeeId, AddUpDeductionRequestPO requestPO, AddUpDeduction po) {
|
||||
po.setId(IdGenerator.generate());
|
||||
po.setDeclareMonth(wrapper.getRequestPOList().get(0).getTaxYearMonth());
|
||||
po.setTaxAgentId(requestPO.getTaxAgentId());
|
||||
po.setEmployeeId(employeeId);
|
||||
po.setCreateTime(new Date());
|
||||
po.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
|
||||
// po.setModifier(wrapper.getCurrentEmployeeId());
|
||||
po.setTenantKey(wrapper.getTenantKey());
|
||||
po.setCreator(wrapper.getCurrentEmployeeId());
|
||||
}
|
||||
|
||||
public void updateRequestStatus(List<AddUpDeductionRequestPO> requestPOList, Integer oldStatus, Integer newStatus) {
|
||||
for (AddUpDeductionRequestPO requestPO : requestPOList) {
|
||||
boolean update = new LambdaUpdateChainWrapper<>(addUpDeductionRequestMapper)
|
||||
.set(AddUpDeductionRequestPO::getRequestStatus, newStatus)
|
||||
.set(AddUpDeductionRequestPO::getUpdateTime, LocalDateTime.now())
|
||||
.set(AddUpDeductionRequestPO::getLockVersion, requestPO.getLockVersion() + 1)
|
||||
.eq(AddUpDeductionRequestPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
||||
.eq(AddUpDeductionRequestPO::getRequestStatus, oldStatus)
|
||||
.eq(AddUpDeductionRequestPO::getId, requestPO.getId())
|
||||
.eq(AddUpDeductionRequestPO::getLockVersion, requestPO.getLockVersion())
|
||||
.update();
|
||||
SalaryAssert.isTrue(update, SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
|
||||
}
|
||||
}
|
||||
|
||||
public QuerySpecialAmountFeedbackResponse getQuerySpecialAmountFeedbackResponse(TaxDeclarationApiConfigPO apiConfig, AddUpDeductionRequestPO requestPO) {
|
||||
String url = apiConfig.getHost() + SzyhApiConstant.GET_QUERY_SPECIAL_AMOUNT_FEEDBACK;
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
params.put("requestId", requestPO.getOuterRequestId());
|
||||
Map<String, String> header = SingnatureData.initHeader(Collections.emptyMap(), apiConfig.getAppKey(), apiConfig.getAppSecret());
|
||||
String res = HttpUtil.getRequest(url, header, params);
|
||||
log.info("GET_QUERY_SPECIAL_AMOUNT_FEEDBACK res = {}", res);
|
||||
return JsonUtil.parseObject(res, QuerySpecialAmountFeedbackResponse.class);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AddUpDeductionOnlineRequestWrapper {
|
||||
private String tenantKey;
|
||||
private Long currentEmployeeId;
|
||||
// 单次请求对应的反馈数据map
|
||||
private Map<String, List<QuerySpecialAmountFeedbackResponse.Feedback>> requestFeedBackMap;
|
||||
private Map<String, AddUpDeductionRequestPO> requestPoMap;
|
||||
// 查询薪资档案(定薪、待停薪、停薪)
|
||||
private List<SalaryArchivePO> salaryArchiveList;
|
||||
private Map<Long, String> taxAgentMap;
|
||||
// 员工信息map(身份证号 -> 员工ID)
|
||||
private Map<String, DataCollectionEmployee> userInfoIdNoMap;
|
||||
// 员工信息map(员工ID -> 身份证)
|
||||
private Map<Long, DataCollectionEmployee> userInfoUserIdMap;
|
||||
// 员工详细信息map(key = 员工ID)
|
||||
private Map<Long, DataCollectionEmployee> simpleEmployeeMap;
|
||||
// 获取当前库中累计附加扣除的数据
|
||||
private Map<String, Long> existedDataMap;
|
||||
// 需要新增的数据
|
||||
private List<AddUpDeduction> insertList;
|
||||
// 需要更新的数据
|
||||
private List<AddUpDeduction> updateList;
|
||||
// 失败数据(分页)
|
||||
private List<AddUpDeductionRequestFailListDTO> failDTOList;
|
||||
// 失败数据(持久化)
|
||||
private List<AddUpDeductionRequestFailPO> failPOList;
|
||||
// 请求详细信息列表
|
||||
private List<AddUpDeductionRequestPO> requestPOList;
|
||||
// 外部人员(身份证 -> id)
|
||||
private Map<String, Long> extEmployeeIdCardMap;
|
||||
// 外部人员(id -> 实体)
|
||||
private Map<Long, ExtEmpPO> extEmployeePOMap;
|
||||
// api配置
|
||||
private TaxDeclarationApiConfigPO apiConfig;
|
||||
|
||||
public AddUpDeductionOnlineRequestWrapper(List<AddUpDeductionRequestPO> requestPOList,
|
||||
List<SalaryArchivePO> salaryArchiveList,
|
||||
List<TaxAgentPO> taxAgents) {
|
||||
this.requestFeedBackMap = new HashMap<>();
|
||||
this.requestPoMap = new HashMap<>();
|
||||
this.insertList = new ArrayList<>();
|
||||
this.updateList = new ArrayList<>();
|
||||
this.failDTOList = new ArrayList<>();
|
||||
this.failPOList = new ArrayList<>();
|
||||
this.salaryArchiveList = salaryArchiveList;
|
||||
this.requestPOList = requestPOList;
|
||||
this.tenantKey = tenantKey;
|
||||
this.currentEmployeeId = currentEmployeeId;
|
||||
this.taxAgentMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName);
|
||||
}
|
||||
|
||||
public AddUpDeductionRequestFailListDTO buildAddUpDeductionRequestFailListDTO(AddUpDeductionRequestFailPO failPO) {
|
||||
DataCollectionEmployee userInfo = this.userInfoUserIdMap.get(failPO.getEmployeeId());
|
||||
ExtEmpPO extEmployeePO = this.extEmployeePOMap.get(failPO.getEmployeeId());
|
||||
DataCollectionEmployee simpleEmployee = this.simpleEmployeeMap.get(failPO.getEmployeeId());
|
||||
String departmentName = Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getDepartmentName).orElse("");
|
||||
|
||||
AddUpDeductionRequestFailListDTO listDTO = AddUpDeductionRequestFailListDTO.builder()
|
||||
.id(failPO.getId().toString())
|
||||
.employeeId(failPO.getEmployeeId())
|
||||
.employeeType(EmployeeTypeEnum.parseByValue(failPO.getEmployeeType()).toString())
|
||||
.employeeName(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getUsername)
|
||||
.orElse(Optional.ofNullable(extEmployeePO).map(ExtEmpPO::getUsername)
|
||||
.orElse("")))
|
||||
.jobNum(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getWorkcode).orElse(""))
|
||||
.idNo(Optional.ofNullable(userInfo).map(DataCollectionEmployee::getIdNo)
|
||||
.orElse(Optional.ofNullable(extEmployeePO).map(ExtEmpPO::getIdNo)
|
||||
.orElse("")))
|
||||
.departmentName(Optional.ofNullable(departmentName).orElse(""))
|
||||
.failReason(failPO.getReason())
|
||||
.taxAgentName(this.taxAgentMap.get(failPO.getTaxAgentId()))
|
||||
.build();
|
||||
Pattern pattern = Pattern.compile("\\[+[\\u4e00-\\u9fa5]*+]+\\|+\\[+[0-9]*+]");
|
||||
Matcher matcher = pattern.matcher(Optional.ofNullable(failPO.getReason()).orElse(""));
|
||||
if (matcher.find()) {
|
||||
String[] split = failPO.getReason().split("\\|");
|
||||
listDTO.setEmployeeName(split[0].substring(split[0].indexOf('[') + 1, split[0].indexOf(']')));
|
||||
listDTO.setIdNo(split[1].substring(split[1].indexOf('[') + 1, split[1].indexOf(']')));
|
||||
}
|
||||
return listDTO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue