累计专项附加扣除-新增、删除所选、一键清空功能

This commit is contained in:
Harryxzy 2022-10-27 13:59:11 +08:00
parent c0bb94bf71
commit a406eed4b9
8 changed files with 100 additions and 32 deletions

View File

@ -203,4 +203,20 @@ public class AddUpDeductionBiz extends BaseBean {
}
public void batchDeleteByIDS(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
List<List<Long>> partition = Lists.partition(ids, 100);
partition.forEach(mapper::deleteData);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -19,7 +19,7 @@ import java.util.List;
public class AddUpDeductionRecordDeleteParam {
// 删除id
private List<Long> id;
private List<Long> ids;
// 申报月份
private String declareMonth;

View File

@ -62,4 +62,13 @@ public interface AddUpDeductionMapper {
void updateData(@Param("collection") List<AddUpDeduction> updateList);
List<AddUpDeductionRecordDTO> recordList(@Param("param") AddUpDeductionQueryParam param);
/**
* @description 批量删除
* @return void
* @author Harryxzy
* @date 2022/10/27 9:54
*/
void deleteData(@Param("collection")List<Long> longs);
}

View File

@ -42,6 +42,17 @@
, t.add_up_infant_care
</sql>
<!-- 批量删除 -->
<update id="deleteData">
UPDATE hrsa_add_up_deduction t
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="collection" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT

View File

@ -138,5 +138,5 @@ public interface AddUpDeductionService {
* @author Harryxzy
* @date 2022/10/26 16:35
*/
void deleteAllAddUpDeduction(String declareMonthStr);
void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam);
}

View File

@ -417,8 +417,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) {
long currentEmployeeId = user.getUID();
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
Map<String, Object> apidatas = new HashMap<String, Object>();
EmployBiz employBiz = new EmployBiz();
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
@ -452,11 +450,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
.updateTime(now)
.creator((long) user.getUID())
.declareMonth(declareMonth).build();
//相同的姓名
String userName = addUpDeductionRecordParam.getUsername();
Long employeeId = employees.get(0).getEmployeeId();
boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpDeductionRecordParam.getEmployeeId());
if (!employeeSameId) {
throw new SalaryRunTimeException("员工信息不存在");
@ -523,28 +516,67 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
@Override
public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
// AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
// String declareMonthStr = deleteParam.getDeclareMonth();
// // 已经核算过的不可操作
// // 获取已经核算的数据
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
// // 判断是否有核算过
// if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
// Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst();
// if (optionalAcctEmp.isPresent()) {
// throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!");
// }else {
// ArrayList<AddUpDeduction> updateList = new ArrayList<>();
// AddUpDeduction build = AddUpDeduction.builder().id(addUpDeduction.getId()).addUpChildEducation(addUpDeduction.getAddUpChildEducation()).addUpContinuingEducation(addUpDeduction.getAddUpContinuingEducation()).addUpHousingLoanInterest(addUpDeduction.getAddUpHousingLoanInterest()).addUpHousingRent(addUpDeduction.getAddUpHousingRent()).addUpSupportElderly(addUpDeduction.getAddUpSupportElderly()).addUpIllnessMedical(addUpDeduction.getAddUpIllnessMedical()).addUpInfantCare(addUpDeduction.getAddUpInfantCare()).build();
// updateList.add(build);
// addUpDeductionBiz.batchUpdate(updateList);
// }
// }
long currentEmployeeId = user.getUID();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
String declareMonthStr = deleteParam.getDeclareMonth();
List<Long> deleteIds = deleteParam.getIds();
// 已经核算过的不可操作
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
// 判断是否有核算过
List<Long> deleteList = new ArrayList<>();
for(int i=0; i<deleteIds.size(); i++){
Long id = deleteIds.get(i);
AddUpDeduction byId = addUpDeductionBiz.getById(id);
// 判断是否在个税扣缴义务人范围内
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());
}
addUpDeductionBiz.batchDeleteByIDS(deleteList);
}
@Override
public void deleteAllAddUpDeduction(String declareMonthStr) {
public void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
String declareMonthStr = deleteParam.getDeclareMonth();
long currentEmployeeId = user.getUID();
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());
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
ArrayList<Date> declareMonthDate = new ArrayList<>();
try {
declareMonthDate.add(sdf.parse(declareMonthStr+"-01"));
}catch (Exception e){
throw new SalaryRunTimeException("日期异常");
}
AddUpDeductionQueryParam queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxagentIds).build();
// 获取所有想要删除的数据
List<AddUpDeductionDTO> list = addUpDeductionBiz.list(queryParam);
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
for(AddUpDeductionDTO 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 (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("员工:"+item.getUsername()+",在该年月中已经核算过,不能进行一键清空!");
}
}
}
List<Long> deleteIds = list.stream().map(AddUpDeductionDTO::getId).collect(Collectors.toList());
addUpDeductionBiz.batchDeleteByIDS(deleteIds);
}

View File

@ -311,9 +311,9 @@ public class AddUpDeductionController {
@POST
@Path("/deleteAllAddUpDeduction")
@Produces(MediaType.APPLICATION_JSON)
public String deleteAllAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String declareMonth) {
public String deleteAllAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam deleteParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String, Object>>(user).run(getAddUpDeductionWrapper(user)::deleteAllAddUpDeduction, declareMonth);
return new ResponseResult<AddUpDeductionRecordDeleteParam, Map<String, Object>>(user).run(getAddUpDeductionWrapper(user)::deleteAllAddUpDeduction, deleteParam);
}

View File

@ -155,7 +155,7 @@ public class AddUpDeductionWrapper extends Service {
getAddUpDeductionService(user).deleteSelectAddUpDeduction(deleteParam);
}
public void deleteAllAddUpDeduction(String declareMonthStr) {
getAddUpDeductionService(user).deleteAllAddUpDeduction(declareMonthStr);
public void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
getAddUpDeductionService(user).deleteAllAddUpDeduction(deleteParam);
}
}