From 2ceeeb165f513f1349bb5e1ee045170dfdec7c51 Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 29 Nov 2022 15:33:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E7=A4=BE=E4=BF=9D=E8=B0=83?= =?UTF-8?q?=E5=B7=AE=E5=88=97=E8=A1=A8v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/InsuranceCompensationDTO.java | 4 +- .../InsuranceCompensationConfigMapper.java | 4 + .../InsuranceCompensationConfigMapper.xml | 9 ++ .../InsuranceCompensationMapper.java | 3 + .../siaccount/InsuranceCompensationMapper.xml | 9 ++ .../salary/service/ColumnBuildService.java | 6 + .../salary/service/SICompensationService.java | 5 + .../service/impl/ColumnBuildServiceImpl.java | 19 +++ .../impl/SICompensationServiceImpl.java | 127 ++++++++++++++++-- .../salary/web/SIAccountController.java | 12 ++ .../salary/wrapper/SIAccountWrapper.java | 7 + 11 files changed, 194 insertions(+), 11 deletions(-) diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java index 445c6b40c..e100e69ed 100644 --- a/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java @@ -30,7 +30,7 @@ public class InsuranceCompensationDTO { private String originId; /** - * 只读 + * 只读,true为实际调差记录,false为调差配置数据(非实际调差记录) * */ private Boolean status; @@ -88,7 +88,7 @@ public class InsuranceCompensationDTO { /** * 对象选项 */ - private List> targetOptions; + private Map targetOptions; /** * 账单月份 diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java index 5aa6e5863..2228e7f37 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java @@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO; import org.apache.ibatis.annotations.Param; import java.util.Collection; +import java.util.List; public interface InsuranceCompensationConfigMapper { @@ -12,4 +13,7 @@ public interface InsuranceCompensationConfigMapper { void insert(InsuranceCompensationConfigPO compensationConfigPO); void deleteByPayOrg(Long paymentOrganization); + + List queryByBillMonthAndPayOrg(String billMonth, Long paymentOrganization); + } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml index 690d59f57..8153657d8 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml @@ -159,4 +159,13 @@ WHERE payment_organization = #{paymentOrganization} AND delete_type = 0 + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java index c3aa3ee20..2ee45f10d 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java @@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; import org.apache.ibatis.annotations.Param; import java.util.Collection; +import java.util.List; public interface InsuranceCompensationMapper { @@ -13,5 +14,7 @@ public interface InsuranceCompensationMapper { InsuranceCompensationPO getById(Long id); + List queryByBillMonthAndPayOrg(String billMonth, Long paymentOrganization); + void deleteById(Long id); } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml index 1dae2c343..2a62fcc5e 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml @@ -201,6 +201,15 @@ WHERE t.id = #{id} AND t.delete_type = 0 + + UPDATE hrsa_compensation_log SET delete_type = 1 diff --git a/src/com/engine/salary/service/ColumnBuildService.java b/src/com/engine/salary/service/ColumnBuildService.java index 9ec02d2e6..c1aec0b1b 100644 --- a/src/com/engine/salary/service/ColumnBuildService.java +++ b/src/com/engine/salary/service/ColumnBuildService.java @@ -3,6 +3,7 @@ package com.engine.salary.service; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; import java.util.List; @@ -26,5 +27,10 @@ public interface ColumnBuildService { List buildCommonColumns(List pos); List buildInspectColumns(List pos, Long paymentOrganization); + + /** + * 调差详情表头元素 + */ + List buildCompensationColumns(); } diff --git a/src/com/engine/salary/service/SICompensationService.java b/src/com/engine/salary/service/SICompensationService.java index fdd8265a2..a4ade6b5f 100644 --- a/src/com/engine/salary/service/SICompensationService.java +++ b/src/com/engine/salary/service/SICompensationService.java @@ -28,4 +28,9 @@ public interface SICompensationService { * 社保调差撤回 */ String compensationRevert(InsuranceCompensationDTO param); + + /** + * 社保调差历史记录列表 + */ + Map compensationList(String billMonth, Long paymentOrganization); } diff --git a/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java index 93eedcbd7..9c008d7a2 100644 --- a/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java +++ b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java @@ -388,4 +388,23 @@ public class ColumnBuildServiceImpl extends Service implements ColumnBuildServic result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); return result; } + + @Override + public List buildCompensationColumns() { + List list = new ArrayList<>(); + + WeaTableColumn weaTableNameColumn = new WeaTableColumn("300px",SalaryI18nUtil.getI18nLabel( 87000, "调差对象"), "target"); + weaTableNameColumn.setFixed("left"); + + list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利"), "welfareType")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利类型(单位)"), "categoryType")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87002, "国家核算金额(单位)"), "countryTotal")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87003, "公司核算金额(单位)"), "companyTotal")); + list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87004, "应调差金额"), "adjustmentTotal")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87005, "调差到(单位)"), "adjustTo")); + + + return list; + } + } diff --git a/src/com/engine/salary/service/impl/SICompensationServiceImpl.java b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java index a097da227..92407ad33 100644 --- a/src/com/engine/salary/service/impl/SICompensationServiceImpl.java +++ b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java @@ -2,10 +2,12 @@ package com.engine.salary.service.impl; import com.alibaba.fastjson.JSON; import com.alipay.oceanbase.jdbc.StringUtils; +import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.hrm.dto.HrmInfoDTO; import com.engine.salary.entity.hrm.param.HrmQueryParam; import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO; @@ -13,13 +15,16 @@ import com.engine.salary.entity.siaccount.param.CompensationParam; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO; import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; -import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.enums.siaccount.PaymentStatusEnum; import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceCompensationConfigMapper; import com.engine.salary.mapper.siaccount.InsuranceCompensationMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.service.ColumnBuildService; import com.engine.salary.service.SIAccountService; import com.engine.salary.service.SICategoryService; import com.engine.salary.service.SICompensationService; @@ -31,11 +36,12 @@ import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import com.google.common.collect.Lists; import dm.jdbc.util.IdGenerator; +import org.springframework.beans.BeanUtils; import weaver.hrm.User; import java.math.BigDecimal; -import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -68,6 +74,11 @@ public class SICompensationServiceImpl extends Service implements SICompensation private InsuranceCompensationConfigMapper getInsuranceCompensationConfigMapper() { return MapperProxyFactory.getProxy(InsuranceCompensationConfigMapper.class); } + + public ColumnBuildService getColumnBuildService(User user) { + return ServiceUtil.getService(ColumnBuildServiceImpl.class, user); + } + /** * 可调差人员 */ @@ -306,30 +317,30 @@ public class SICompensationServiceImpl extends Service implements SICompensation String num = entry.getValue(); if (Objects.equals(String.valueOf(insuranceCompensationPO.getAdjustTo()), insuranceId)) { BigDecimal adjustmentTo = new BigDecimal(insuranceCompensationPO.getAdjustmentTotal()); - //回退补单位缴纳明细 + //回退调差单位缴纳明细 BigDecimal insuranceNum = new BigDecimal(num); insuranceNum = insuranceNum.subtract(adjustmentTo); socialJson.replace(insuranceId, insuranceNum.toPlainString()); insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson)); - //回退补差单位合计 + //回退调差单位合计 BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum()); comSum = comSum.subtract(adjustmentTo); insuranceAccountDetailPO.setComSum(comSum.toPlainString()); - //回退补差社保单位合计 + //回退调差社保单位合计 BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); socialComSum = socialComSum.subtract(adjustmentTo); insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); - //回退补差社保合计 + //回退调差社保合计 BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum()); socialSum = socialSum.subtract(adjustmentTo); insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString()); - //回退补差合计 + //回退调差合计 BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal()); totalSum = totalSum.subtract(adjustmentTo); insuranceAccountDetailPO.setTotal(totalSum.toPlainString()); - //更新社保补差后的明细 + //更新社保调差后的明细 getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO); - //删除补差记录 + //删除调差记录 getInsuranceCompensationMapper().deleteById(param.getId()); } @@ -340,4 +351,102 @@ public class SICompensationServiceImpl extends Service implements SICompensation } return "撤回成功"; } + + @Override + public Map compensationList(String billMonth, Long paymentOrganization) { + + Map datas = new HashMap<>(); + + //入参判断 + if (paymentOrganization == null || StringUtils.isBlank(billMonth)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + //设置调差详情列表头 + List weaTableColumn = getColumnBuildService(user).buildCompensationColumns(); + + //处理调差数据 + List compensationDTOList = dealCompensationData(billMonth, paymentOrganization); + + datas.put("columns", weaTableColumn); + datas.put("data", compensationDTOList); + + return datas; + } + + private List dealCompensationData(String billMonth, Long paymentOrganization) { + + //获取调差历史记录数据 + List compensationPOList = getInsuranceCompensationMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization); + //获取调差配置数据 + List compensationConfigPOList = getInsuranceCompensationConfigMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization); + + List compensationDTOList = new ArrayList<>(); + + List detailPOList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(billMonth, paymentOrganization); + Map detailPOMap = detailPOList.stream().collect(Collectors.toMap(InsuranceAccountDetailPO::getEmployeeId, Function.identity())); + + List allEmployees = getEmployMapper().listAll(); + Map usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + + List allCategoryList = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); + Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); + + boolean haveCompensation = compensationPOList != null && compensationPOList.size() > 0; + //存在调差历史记录时,输出记录数据 + if (haveCompensation) { + for (InsuranceCompensationPO po : compensationPOList) { + InsuranceCompensationDTO dto = new InsuranceCompensationDTO(); + BeanUtils.copyProperties(po, dto); + dto.setStatus(true); + //设置targetOptions + Map targetOptions = new HashMap<>(); + targetOptions.put("name", usernameMap.get(po.getEmployeeId())); + targetOptions.put("id", detailPOMap.get(po.getEmployeeId()).getId().toString()); + + dto.setTargetOptions(targetOptions); + + //设置categoryTypeOptions + List> categoryTypeOptions = new ArrayList<>(); + List categoryTypeList = Arrays.asList(po.getCategoryType().split(",")); + Map categoryTypeMap = new HashMap<>(); + for (String categoryType : categoryTypeList) { + categoryTypeMap.put("id", categoryType); + categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType))); + categoryTypeOptions.add(categoryTypeMap); + } + + dto.setCategoryTypeOptions(categoryTypeOptions); + } + } + //不存在调差历史记录时,输出调差配置数据 + if (!haveCompensation && compensationConfigPOList.size() > 0) { + for (InsuranceCompensationConfigPO configPO : compensationConfigPOList) { + InsuranceCompensationDTO dto = new InsuranceCompensationDTO(); + BeanUtils.copyProperties(configPO, dto); + dto.setStatus(false); + //设置targetOptions + Map targetOptions = new HashMap<>(); + targetOptions.put("name", usernameMap.get(configPO.getEmployeeId())); + targetOptions.put("id", detailPOMap.get(configPO.getEmployeeId()).getId().toString()); + + dto.setTargetOptions(targetOptions); + + //设置categoryTypeOptions + List> categoryTypeOptions = new ArrayList<>(); + List categoryTypeList = Arrays.asList(configPO.getCategoryType().split(",")); + Map categoryTypeMap = new HashMap<>(); + for (String categoryType : categoryTypeList) { + categoryTypeMap.put("id", categoryType); + categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType))); + categoryTypeOptions.add(categoryTypeMap); + } + + dto.setCategoryTypeOptions(categoryTypeOptions); + } + } + + return compensationDTOList; + } + } diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index 8257119ce..bf4515621 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -773,5 +773,17 @@ public class SIAccountController { return new ResponseResult(user).run(getSIAccountWrapper(user)::compensationBack, param); } + /** + * 社保调差列表 + */ + @POST + @Path("/compensationList") + @Produces(MediaType.APPLICATION_JSON) + public String compensationList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceCompensationDTO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSIAccountWrapper(user)::compensationList, param); + } + // **********************************调差 end*********************************/ } diff --git a/src/com/engine/salary/wrapper/SIAccountWrapper.java b/src/com/engine/salary/wrapper/SIAccountWrapper.java index b20840943..f5bdc8678 100644 --- a/src/com/engine/salary/wrapper/SIAccountWrapper.java +++ b/src/com/engine/salary/wrapper/SIAccountWrapper.java @@ -107,4 +107,11 @@ public class SIAccountWrapper extends Service { return getSICompensationService(user).compensationRevert(param); } + + /** + * 社保调差列表 + */ + public Map compensationList(InsuranceCompensationDTO param) { + return getSICompensationService(user).compensationList(param.getBillMonth(), param.getPaymentOrganization()); + } }