薪酬系统-福利台账,自动核算并归档任务类开发
This commit is contained in:
parent
e9aba73172
commit
29e5c27ffb
|
|
@ -42,4 +42,7 @@ public class AccountParam {
|
|||
@DataCheck(require = true,message = "个税扣缴义务人不能为空")
|
||||
private Long paymentOrganization;
|
||||
|
||||
// 是否核算后归档
|
||||
private boolean fileFlag = false;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,13 @@ public interface SIAccountService {
|
|||
*/
|
||||
String save(AccountParam param);
|
||||
|
||||
/**
|
||||
* 新建核算并归档
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
String saveAndFile(AccountParam param);
|
||||
|
||||
/**
|
||||
* 正常缴纳页核算
|
||||
* @param saveCommonAccountParam
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,107 @@
|
|||
package com.engine.salary.timer;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.common.SalaryContext;
|
||||
import com.engine.salary.entity.siaccount.param.AccountParam;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.formlua.util.RegularUtil;
|
||||
import com.engine.salary.service.SIAccountService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.impl.SIAccountServiceImpl;
|
||||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: sy
|
||||
* @Description: 福利台账核算并归档任务
|
||||
* @Date: 2024/1/15
|
||||
**/
|
||||
@Slf4j
|
||||
public class AutoSiAccountAndFileJob extends BaseCronJob {
|
||||
|
||||
private String diffToCurrentMonth;
|
||||
|
||||
public String getDiffToCurrentMonth() {
|
||||
return diffToCurrentMonth;
|
||||
}
|
||||
|
||||
public void setDiffToCurrentMonth(String diffToCurrentMonth) {
|
||||
this.diffToCurrentMonth = diffToCurrentMonth;
|
||||
}
|
||||
|
||||
private String taxAgentNames;
|
||||
|
||||
public String getTaxAgentNames() {
|
||||
return taxAgentNames;
|
||||
}
|
||||
|
||||
public void setTaxAgentNames(String taxAgentNames) {
|
||||
this.taxAgentNames = taxAgentNames;
|
||||
}
|
||||
|
||||
private String fileFlag;
|
||||
|
||||
public String getFileFlag() {
|
||||
return fileFlag;
|
||||
}
|
||||
|
||||
public void setFileFlag(String fileFlag) {
|
||||
this.fileFlag = fileFlag;
|
||||
}
|
||||
|
||||
private TaxAgentService getTaxAgentService(User user) {
|
||||
SalaryContext.get().setValue("user",user);
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public SIAccountService getSIAccountService(User user) {
|
||||
SalaryContext.get().setValue("user",user);
|
||||
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (StrUtil.isNotBlank(diffToCurrentMonth) && RegularUtil.isInteger(diffToCurrentMonth)) {
|
||||
User user = new User();
|
||||
user.setUid(1);
|
||||
user.setLoginid("sysadmin");
|
||||
user.setLastname("sysadmin");
|
||||
|
||||
Calendar accountTime= Calendar.getInstance();
|
||||
// prevMonth.setTimeInMillis(System.currentTimeMillis());
|
||||
accountTime.set(Calendar.MONTH, accountTime.get(Calendar.MONTH) + Integer.parseInt(diffToCurrentMonth));
|
||||
SimpleDateFormat s=new SimpleDateFormat("yyyy-MM");
|
||||
|
||||
String accountMonth = s.format(accountTime.getTime());
|
||||
boolean isFile = false;
|
||||
if (StrUtil.isNotBlank(fileFlag) && "true".equals(fileFlag)) {
|
||||
isFile = true;
|
||||
}
|
||||
//核算并归档
|
||||
List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll();
|
||||
//判断是否过滤个税扣缴义务人
|
||||
if (StrUtil.isNotBlank(taxAgentNames)) {
|
||||
List<String> taxAgentNameList = Arrays.stream(taxAgentNames.split(",")).map(String::new).collect(Collectors.toList());
|
||||
taxAgentList = taxAgentList.stream().filter(f -> taxAgentNameList.contains(f.getName())).collect(Collectors.toList());
|
||||
}
|
||||
for (TaxAgentPO po : taxAgentList) {
|
||||
try {
|
||||
getSIAccountService(user).saveAndFile(AccountParam.builder().paymentOrganization(po.getId()).billMonth(accountMonth).flag(true).fileFlag(isFile).build());
|
||||
} catch (Exception e) {
|
||||
log.info("个税扣缴义务人-" + po.getName() + ",新建账单月份" + accountMonth + "的福利核算(并归档)过程失败,原因:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue