This commit is contained in:
钱涛 2022-05-27 15:43:38 +08:00
parent be4ed2229d
commit 71ea4b8609
3 changed files with 38 additions and 26 deletions

View File

@ -21,6 +21,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
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.taxrate.TaxAgent;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
@ -164,6 +165,8 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
@Override
public Map<String, Object> importAddUpDeduction(AddUpDeductionImportParam importParam) {
long currentEmployeeId = user.getUID();
Map<String, Object> apidatas = new HashMap<String, Object>();
EmployBiz employBiz = new EmployBiz();
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
@ -171,24 +174,23 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
//检验参数
checkImportParam(importParam);
//税款所属期
String declareMonthStr = importParam.getDeclareMonth();
//excel文件id
String imageId = Util.null2String(importParam.getImageId());
Validate.notBlank(imageId, "imageId为空");
//税款所属期
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentV2Service(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
//个税扣缴义务人
String taxAgentId = Util.null2String(importParam.getTaxAgentId());
// 获取租户下所有的人员
List<DataCollectionEmployeePO> employees = addUpDeductionMapper.listEmployee(tenantKey);
List<DataCollectionEmployee> employees = employBiz.listEmployee();
// 已经核算过的不可操作
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonth, tenantKey);
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
// 查询已有数据
List<AddUpDeductionPO> list = new LambdaQueryChainWrapper<>(addUpDeductionMapper)
.eq(AddUpDeductionPO::getDeleteType, 0)
.eq(AddUpDeductionPO::getTenantKey, tenantKey)
.eq(AddUpDeductionPO::getDeclareMonth, LocalDate.parse(declareMonth+"-01", SalaryDateUtil.DATE_FORMATTER))
.list();
Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER));
List<AddUpDeduction> list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build());
InputStream fileInputStream = null;
try {
@ -201,20 +203,14 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
int errorCount = 0;
//人员信息
List<DataCollectionEmployee> employees = employBiz.listEmployee();
List<TaxAgent> taxAgents = new TaxAgentBiz().listAll();
//税款所属期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
// 错误excel内容
List<Map> errorData = new ArrayList<>();
//合规数据
List<AddUpDeduction> eligibleData = new ArrayList<>();
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = Lists.newArrayList();
for (int i = 0; i < addUpDeductions.size(); i++) {
AddUpDeductionDTO dto = addUpDeductions.get(i);
@ -276,16 +272,17 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
errorData.add(errorMessageMap);
errorSum += 1;
} else {
Optional<TaxAgent> optionalTemp = taxAgents.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst();
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
if (optionalTemp.isPresent()) {
if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getId().equals(Long.valueOf(taxAgentId))) {
if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) {
//个税扣缴义务人与导入时选择的不一致
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致");
errorData.add(errorMessageMap);
errorSum += 1;
} else {
addUpDeduction.setTaxAgentId(optionalTemp.get().getId());
addUpDeduction.setTaxAgentId(optionalTemp.get().getTaxAgentId());
taxAgentEmployees = optionalTemp.get().getEmployeeList();
}
} else {
//个税扣缴义务人不存在
@ -297,8 +294,25 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
// 分权判断
Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst();
if (!optionalTaxAgentEmp.isPresent()) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + "该条数据不在数据权限范围内,不可导入");
errorData.add(errorMessageMap);
errorSum += 1;
}
// 判断是否有核算过
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst();
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId()));
if (optionalAcctEmp.isPresent() && isExist) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入");
errorData.add(errorMessageMap);
errorSum += 1;
}
}
//累计子女教育

View File

@ -254,9 +254,7 @@ public class AddUpDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionImportParam importParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("importParam", importParam);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getAddUpDeductionWrapper(user)::importAddUpDeduction, map);
return new ResponseResult<AddUpDeductionImportParam, Map<String, Object>>(user).run(getAddUpDeductionWrapper(user)::importAddUpDeduction, importParam);
}
@POST

View File

@ -140,8 +140,8 @@ public class AddUpDeductionWrapper extends Service {
}
public Map<String, Object> importAddUpDeduction(Map<String, Object> params) {
return getAddUpDeductionService(user).importAddUpDeduction(params);
public Map<String, Object> importAddUpDeduction(AddUpDeductionImportParam importParam) {
return getAddUpDeductionService(user).importAddUpDeduction(importParam);
}