往期累计情况一键清空和删除所选

This commit is contained in:
Harryxzy 2022-10-31 19:21:13 +08:00
parent e8ac395300
commit 5d97954e48
5 changed files with 61 additions and 70 deletions

View File

@ -23,4 +23,7 @@ public class AddUpSituationDeleteParam {
// 申报月份
private String taxYearMonth;
// 个税扣缴义务人
private String taxAgentId;
}

View File

@ -103,7 +103,7 @@ public interface AddUpSituationService {
* @author Harryxzy
* @date 2022/10/27 22:35
*/
void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam);
void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam);
/**
* @description 获取往期累计情况

View File

@ -1006,57 +1006,57 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
@Override
public void deleteSelectAddUpSituation(AddUpSituationDeleteParam deleteParam) {
// long currentEmployeeId = user.getUID();
// // 获取所有个税扣缴义务人
// Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
// AddUpSituationBiz biz = new AddUpSituationBiz();
// String declareMonthStr = deleteParam.getDeclareMonth();
// List<Long> deleteIds = deleteParam.getIds();
// // 已经核算过的不可操作
// // 获取已经核算的数据
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
// // 判断是否有核算过
// List<Long> deleteList = new ArrayList<>();
// for(int i=0; i<deleteIds.size(); i++){
// Long id = deleteIds.get(i);
// AddUpSituation byId = biz.getById(id);
// if(byId == null){
// throw new SalaryRunTimeException("数据不存在或已被删除!");
// }
// // 判断是否在个税扣缴义务人范围内
// Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst();
// if(!first.isPresent()){
// throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
// }
// // 判断用户是否存在
// if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
// Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst();
// if (optionalAcctEmp.isPresent()) {
// throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!");
// }
// }
// deleteList.add(byId.getId());
// }
// biz.batchDeleteByIDS(deleteList);
long currentEmployeeId = user.getUID();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
AddUpSituationBiz biz = new AddUpSituationBiz();
String declareMonthStr = deleteParam.getTaxYearMonth();
List<Long> deleteIds = deleteParam.getIds();
// 已经核算过的不可操作
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
// 判断是否有核算过
List<Long> deleteList = new ArrayList<>();
for(int i=0; i<deleteIds.size(); i++){
Long id = deleteIds.get(i);
AddUpSituation byId = biz.getById(id);
if(byId == null){
throw new SalaryRunTimeException("数据不存在或已被删除!");
}
// 判断是否在个税扣缴义务人范围内
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst();
if(!first.isPresent()){
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
}
// 判断用户是否存在
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!");
}
}
deleteList.add(byId.getId());
}
biz.batchDeleteByIDS(deleteList);
}
@Override
public void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam) {
String declareMonthStr = deleteParam.getDeclareMonth();
public void deleteAllAddUpSituation(AddUpSituationDeleteParam deleteParam) {
String declareMonthStr = deleteParam.getTaxYearMonth();
long currentEmployeeId = user.getUID();
LocalDate beginLocalDate = LocalDate.of(SalaryEntityUtil.string2Integer(declareMonthStr), 1, 1);
LocalDate endLocalDate = LocalDate.of(SalaryEntityUtil.string2Integer(declareMonthStr), 12, 1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
List<Long> taxAgentIds = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).collect(Collectors.toList());
AddUpSituationBiz biz = new AddUpSituationBiz();
Date beginDate = SalaryDateUtil.localDateToDate(beginLocalDate);
Date endDate = SalaryDateUtil.localDateToDate(endLocalDate);
ArrayList<Date> dateRange = new ArrayList<>();
dateRange.add(beginDate);
dateRange.add(endDate);
Date declareMonthDate = new Date();
try {
declareMonthDate = (sdf.parse(declareMonthStr+"-01"));
}catch (Exception e){
throw new SalaryRunTimeException("日期异常");
}
AddUpSituation queryParam = null;
if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){
// 设置了个税扣缴义务人
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
@ -1066,30 +1066,18 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
}
ArrayList<Long> tai = new ArrayList<>();
tai.add(taxAgentId);
queryParam = AddUpSituation.builder().taxYearMonthRange(dateRange).taxAgentIds(tai).build();
queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(tai).build();
}else {
queryParam = AddUpSituation.builder().taxYearMonthRange(dateRange).taxAgentIds(taxAgentIds).build();
queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(taxAgentIds).build();
}
// 获取所有想要删除的数据
List<AddUpSituation> list = biz.listSome(queryParam);
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = new ArrayList<>();
for(int i=1;i<=12;i++){
String monthStr="";
if(i<10){
monthStr = declareMonthStr + "-0"+i;
}else {
monthStr = declareMonthStr + "-"+i;
}
List<SalaryAcctEmployeePO> employees = getAddUpDeductionService(user).getAccountedEmployeeData(monthStr);
salaryAcctEmployees.addAll(employees);
}
salaryAcctEmployees = salaryAcctEmployees.stream().distinct().collect(Collectors.toList());
List<SalaryAcctEmployeePO> employees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
for(AddUpSituation item : list){
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst();
if (CollectionUtils.isNotEmpty(employees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = employees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!");
}

View File

@ -327,18 +327,18 @@ public class AddUpSituationController {
}
/**
* @description 一键清空 逻辑未确定
* @description 一键清空
* @return String
* @author Harryxzy
* @date 2022/10/27 21:10
*/
// @POST
// @Path("/deleteAllAddUpSituation")
// @Produces(MediaType.APPLICATION_JSON)
// public String deleteAllAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam addUpSituationDeleteParam) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<AddUpDeductionRecordDeleteParam, Map<String, Object>>(user).run(getAddUpSituationWrapper(user)::deleteAllAddUpSituation, addUpSituationDeleteParam);
// }
@POST
@Path("/deleteAllAddUpSituation")
@Produces(MediaType.APPLICATION_JSON)
public String deleteAllAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationDeleteParam addUpSituationDeleteParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AddUpSituationDeleteParam, Map<String, Object>>(user).run(getAddUpSituationWrapper(user)::deleteAllAddUpSituation, addUpSituationDeleteParam);
}
@POST
@Path("/preview")

View File

@ -163,8 +163,8 @@ public class AddUpSituationWrapper extends Service {
* @author Harryxzy
* @date 2022/10/27 22:34
*/
public void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam) {
getAddUpSituationService(user).deleteAllAddUpSituation(deleteParam);
public void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam) {
getAddUpSituationService(user).deleteAllAddUpSituation(addUpSituationDeleteParam);
}
/**