2023-04-23 17:37:06 +08:00
|
|
|
|
package com.engine.salary.maintainer.datacollection;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
|
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
|
|
|
|
|
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper;
|
|
|
|
|
|
import com.engine.salary.service.TaxDeclarationService;
|
|
|
|
|
|
import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
|
|
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
import java.time.YearMonth;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2023/04/23 17:23
|
|
|
|
|
|
* @description 往期累计情况维护类
|
|
|
|
|
|
*/
|
2023-05-11 10:00:21 +08:00
|
|
|
|
public class AddUpSituationManager extends Service {
|
2023-04-23 17:37:06 +08:00
|
|
|
|
|
|
|
|
|
|
private TaxDeclarationMapper getTaxDeclarationMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(TaxDeclarationMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private TaxDeclarationService getTaxDeclarationService() {
|
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-24 09:19:18 +08:00
|
|
|
|
public boolean recoverAddUpHistoryData() {
|
2023-04-23 17:37:06 +08:00
|
|
|
|
// 获取已有的个税申报表记录
|
|
|
|
|
|
List<TaxDeclarationPO> taxDeclarationList = getTaxDeclarationMapper().listSome(new TaxDeclarationPO());
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
2023-05-11 10:00:21 +08:00
|
|
|
|
Map<Long, String> taxDeclarationMap = SalaryEntityUtil.convert2Map(taxDeclarationList, TaxDeclarationPO::getId, PO -> PO.getTaxAgentId() + "-" + sdf.format(PO.getSalaryMonth()));
|
2023-04-23 17:37:06 +08:00
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
List<Long> taxDeclarationIds = taxDeclarationList.stream().map(TaxDeclarationPO::getId).collect(Collectors.toList());
|
2023-05-11 10:00:21 +08:00
|
|
|
|
bb.writeLog("往期累计数据恢复DataIds:" + taxDeclarationIds);
|
|
|
|
|
|
bb.writeLog("往期累计数据恢复DataMap:" + taxDeclarationMap);
|
2023-04-24 09:19:18 +08:00
|
|
|
|
boolean result = true;
|
2023-04-23 17:37:06 +08:00
|
|
|
|
// 循环调用生成申报单接口
|
2023-05-11 10:00:21 +08:00
|
|
|
|
for (int i = 0; i < taxDeclarationList.size(); i++) {
|
2023-04-24 09:19:18 +08:00
|
|
|
|
TaxDeclarationPO po = taxDeclarationList.get(i);
|
2023-05-11 10:00:21 +08:00
|
|
|
|
bb.writeLog("开始删除生成:" + po.getTaxAgentId() + "-" + po.getSalaryMonth());
|
2023-04-23 17:37:06 +08:00
|
|
|
|
// 删除记录
|
2023-04-24 09:19:18 +08:00
|
|
|
|
int delete = getTaxDeclarationMapper().deleteByIdZj(po.getId());
|
|
|
|
|
|
LocalDate localDate = SalaryDateUtil.dateToLocalDate(po.getSalaryMonth());
|
2023-04-23 17:37:06 +08:00
|
|
|
|
// 调用生成申报单接口
|
2023-05-11 10:00:21 +08:00
|
|
|
|
YearMonth yearMonth = YearMonth.of(localDate.getYear(), localDate.getMonth());
|
2023-04-23 17:37:06 +08:00
|
|
|
|
try {
|
2023-04-24 09:19:18 +08:00
|
|
|
|
getTaxDeclarationService().save(TaxDeclarationSaveParam.builder().salaryMonth(yearMonth).taxAgentId(po.getTaxAgentId()).build());
|
2023-05-11 10:00:21 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
bb.writeLog("错误:" + e);
|
2023-04-24 09:19:18 +08:00
|
|
|
|
result = false;
|
2023-04-23 17:37:06 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-05-11 10:00:21 +08:00
|
|
|
|
return result;
|
2023-04-23 17:37:06 +08:00
|
|
|
|
}
|
2023-05-11 10:00:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
2023-04-23 17:37:06 +08:00
|
|
|
|
}
|