Merge branch 'release/个税版本' into release/个税&业务线
# Conflicts: # src/com/engine/salary/wrapper/TaxDeclarationWrapper.java
This commit is contained in:
commit
3d948a431e
|
|
@ -133,6 +133,20 @@ public class TaxDeclarationController {
|
|||
return new ResponseResult<TaxDeclarationSaveParam, String>(user).run(getTaxDeclareRecordWrapper(user)::save, saveParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个税申报表批量生成
|
||||
*
|
||||
* @param param 批量保存参数
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/batSave")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String batSave(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxDeclarationSaveParam, String>(user).run(getTaxDeclareRecordWrapper(user)::batSave, param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新个税申报表的待刷新标识
|
||||
|
|
@ -486,6 +500,8 @@ public class TaxDeclarationController {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,36 +2,14 @@ package com.engine.salary.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.component.WeaFormOption;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
|
||||
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO;
|
||||
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO;
|
||||
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO;
|
||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationBatParam;
|
||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
|
||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
|
||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.service.SalaryEmployeeService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.TaxDeclarationService;
|
||||
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
|
||||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||||
import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 个税申报表
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -53,125 +31,4 @@ public class TaxDeclarationWrapper extends Service {
|
|||
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
/**
|
||||
* 个税申报表列表
|
||||
*
|
||||
* @param queryParam 列表查询条件
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public PageInfo listPage(TaxDeclarationListQueryParam queryParam) {
|
||||
// 询个税申报表(分页)
|
||||
PageInfo<TaxDeclarationPO> page = getTaxDeclarationService(user).listPageByParam(queryParam);
|
||||
PageInfo<TaxDeclarationListDTO> dtoPage = new PageInfo<TaxDeclarationListDTO>(TaxDeclarationListDTO.class);
|
||||
dtoPage.setPageNum(queryParam.getCurrent());
|
||||
dtoPage.setPageSize(queryParam.getPageSize());
|
||||
dtoPage.setTotal(page.getTotal());
|
||||
List<TaxDeclarationPO> list = page.getList();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 查询人员
|
||||
List<Long> employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getCreator, Collectors.toList());
|
||||
List<DataCollectionEmployee> employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
|
||||
// 查询个税扣缴义务人
|
||||
Set<Long> taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getTaxAgentId);
|
||||
List<TaxAgentPO> taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds);
|
||||
// 转换成列表dto
|
||||
List<TaxDeclarationListDTO> taxDeclarationListDTOS = TaxDeclarationBO.convert2ListDTO(list, employeeComInfos, taxAgentPOS);
|
||||
dtoPage.setList(taxDeclarationListDTOS);
|
||||
}
|
||||
return dtoPage;
|
||||
}
|
||||
|
||||
|
||||
public TaxDeclarationFormDTO getForm(Long id) {
|
||||
TaxDeclarationFormDTO formDTO = new TaxDeclarationFormDTO();
|
||||
if (Objects.nonNull(id)) {
|
||||
// 查询个税申报表
|
||||
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id);
|
||||
if (Objects.isNull(taxDeclaration)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除"));
|
||||
}
|
||||
// 查询个税扣缴义务人
|
||||
TaxAgentPO taxAgent = getTaxAgentService(user).getById(id);
|
||||
//日期转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
||||
String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth());
|
||||
// 转换成个税申报表详情dto
|
||||
formDTO = TaxDeclarationFormDTO.builder().salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgentPO::getName).orElse("")).description(taxDeclaration.getDescription()).build();
|
||||
}
|
||||
// 转换成前端所需的数据格式
|
||||
// WeaForm weaForm = SalaryFormatUtil.<TaxDeclarationFormDTO>getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO);
|
||||
|
||||
// 查询租户所有的个税扣缴义务人
|
||||
Collection<TaxAgentPO> taxAgentListDTOS = getTaxAgentService(user).listAll();
|
||||
// 表单中个税扣缴义务人的可选项
|
||||
List<WeaFormOption> weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size());
|
||||
for (TaxAgentPO taxAgent : taxAgentListDTOS) {
|
||||
weaFormOptions.add(new WeaFormOption("" + taxAgent.getId(), taxAgent.getName()));
|
||||
}
|
||||
// weaForm.getItems().forEach((k, v) -> {
|
||||
// if (StringUtils.equals("taxAgentId", k)) {
|
||||
// v.setOptions(weaFormOptions);
|
||||
// }
|
||||
// if (StringUtils.equals("salaryMonth", k)) {
|
||||
// Map<String, Object> otherParams = new HashMap<>();
|
||||
// otherParams.put("type", "month");
|
||||
// v.setOtherParams(otherParams);
|
||||
// }
|
||||
// });
|
||||
return formDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个税申报表的基本信息
|
||||
*
|
||||
* @param id 个税申报表id
|
||||
* @return
|
||||
*/
|
||||
public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) {
|
||||
// 查询个税申报表
|
||||
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id);
|
||||
if (Objects.isNull(taxDeclaration)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除"));
|
||||
}
|
||||
//日期转换
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
||||
String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth());
|
||||
// 查询个税扣缴义务人
|
||||
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclaration.getTaxAgentId());
|
||||
return TaxDeclarationInfoDTO.builder().salaryMonth(SalaryDateUtil.stringToDate(transformDate+"-01")).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse("")).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param saveParam 保存参数
|
||||
*/
|
||||
public void save(TaxDeclarationSaveParam saveParam) {
|
||||
getTaxDeclarationService(user).save(saveParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回个税申报
|
||||
* @param taxDeclarationId
|
||||
*/
|
||||
public void withDrawTaxDeclaration(Long taxDeclarationId) {
|
||||
getTaxDeclarationService(user).withDrawTaxDeclaration(taxDeclarationId);
|
||||
}
|
||||
|
||||
public void batSave(TaxDeclarationBatParam param) {
|
||||
List<Long> taxAgentIds = param.getTaxAgentIds();
|
||||
for (int i = 0; i < taxAgentIds.size(); i++) {
|
||||
Long taxAgentId = taxAgentIds.get(i);
|
||||
TaxDeclarationSaveParam saveParam = TaxDeclarationSaveParam.builder()
|
||||
.salaryMonth(param.getSalaryMonth())
|
||||
.taxAgentId(taxAgentId)
|
||||
.description(param.getDescription())
|
||||
.taxCycle(param.getTaxCycle())
|
||||
.salaryDate(param.getSalaryDate())
|
||||
.build();
|
||||
save(saveParam);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -416,6 +416,29 @@ public class TaxDeclareRecordWrapper extends Service {
|
|||
return taxDeclarationRate.getIndex();
|
||||
}
|
||||
|
||||
public String batSave(TaxDeclarationSaveParam param) {
|
||||
List<Long> taxAgentIds = param.getTaxAgentIds();
|
||||
int success = 0;
|
||||
int fail = 0;
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (Long taxAgentId : taxAgentIds) {
|
||||
try {
|
||||
param.setTaxAgentId(taxAgentId);
|
||||
getTaxDeclareRecordService(user).save(param);
|
||||
success++;
|
||||
} catch (SalaryRunTimeException e) {
|
||||
msg.append(e.getMessage()).append(";");
|
||||
fail++;
|
||||
} catch (Exception e) {
|
||||
log.error("个税申报表生成报错:{}", e.getMessage(), e);
|
||||
msg.append(e.getMessage()).append(";");
|
||||
fail++;
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
return "成功:" + success + "个,失败:" + fail + "个,失败原因:" + msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新个税申报表的待刷新数据的标识
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue