diff --git a/resource/sqlupgrade/DM/sql202311080603.sql b/resource/sqlupgrade/DM/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/DM/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/GS/sql202311080603.sql b/resource/sqlupgrade/GS/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/GS/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/JC/sql202311080603.sql b/resource/sqlupgrade/JC/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/JC/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/resource/sqlupgrade/Mysql/sql202311080603.sql b/resource/sqlupgrade/Mysql/sql202311080603.sql new file mode 100644 index 000000000..024e94be3 --- /dev/null +++ b/resource/sqlupgrade/Mysql/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +; \ No newline at end of file diff --git a/resource/sqlupgrade/Oracle/sql202311080603.sql b/resource/sqlupgrade/Oracle/sql202311080603.sql new file mode 100644 index 000000000..a53c1e2da --- /dev/null +++ b/resource/sqlupgrade/Oracle/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +/ \ No newline at end of file diff --git a/resource/sqlupgrade/PG/sql202311080603.sql b/resource/sqlupgrade/PG/sql202311080603.sql new file mode 100644 index 000000000..afa28833d --- /dev/null +++ b/resource/sqlupgrade/PG/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int; +/ \ No newline at end of file diff --git a/resource/sqlupgrade/SQLServer/sql202311080603.sql b/resource/sqlupgrade/SQLServer/sql202311080603.sql new file mode 100644 index 000000000..005efd521 --- /dev/null +++ b/resource/sqlupgrade/SQLServer/sql202311080603.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_stats_report add time_type int +GO \ No newline at end of file diff --git a/resource/sqlupgrade/ST/sql202311080603.sql b/resource/sqlupgrade/ST/sql202311080603.sql new file mode 100644 index 000000000..f65fcd62b --- /dev/null +++ b/resource/sqlupgrade/ST/sql202311080603.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_stats_report add time_type int; +/ + diff --git a/src/com/engine/salary/action/RehireAction.java b/src/com/engine/salary/action/RehireAction.java new file mode 100644 index 000000000..d0acd6e27 --- /dev/null +++ b/src/com/engine/salary/action/RehireAction.java @@ -0,0 +1,221 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.TaxAgentManageRangeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.TaxAgentManageRangeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +public class RehireAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + User user = new User(1); + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + Map salaryFieldMap = SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue); + String taxAgentName = salaryFieldMap.get("个税扣缴义务人"); + String empIdStr = salaryFieldMap.get("员工id"); + if (StringUtils.isBlank(taxAgentName) || StringUtils.isBlank(empIdStr)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人、或员工id不能为空"); + return FAILURE_AND_CONTINUE; + } + // 获取义务人信息 + List taxAgentPOS = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(taxAgentName).build()); + if (CollectionUtils.isEmpty(taxAgentPOS)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在"); + return FAILURE_AND_CONTINUE; + } + // 先获取该个税扣缴义务人下,该员工的薪资档案 + Long taxAgentId = taxAgentPOS.get(0).getId(); + Long employeeId = Long.valueOf(empIdStr); + List salaryArchivePOS = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).build()); + if (CollectionUtils.isEmpty(salaryArchivePOS)){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下,该员工不存在薪资档案!"); + return FAILURE_AND_CONTINUE; + } else if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())) { + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下,该员工没有发过薪。需取消停薪后,申请定薪流程!"); + return FAILURE_AND_CONTINUE; + } + + if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { + // 停薪来自待停薪 1、取消停薪 + getSalaryArchiveWrapper(user).cancelStop(Collections.singletonList(salaryArchivePOS.get(0).getId())); + } + if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()) || salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) { + // 1、如果不在人员范围内则把他加入义务人的人员范围,2、删除待办 + addTaxAgentRangeIfNotExist(taxAgentId, employeeId, user); + getSalaryArchiveWrapper(user).deleteSuspendTodo(Collections.singletonList(salaryArchivePOS.get(0).getId())); + } + + // 调薪 + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue)); + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(RehireAction.SalaryField::getValue).orElse("1"); + Map map = getSalaryArchiveWrapper(new User(Integer.parseInt(uid))).adjustmentSalaryArchive(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + // 回滚档案状态 + getSalaryArchiveMapper().update(salaryArchivePOS.get(0)); + log.error("调薪存在异常 requestId:{} map:{}", requestInfo.getRequestid(), map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("返聘调薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + + + private void addTaxAgentRangeIfNotExist(Long taxAgentId, Long employeeId, User user){ + // 获取该义务人下人员范围 + Collection empIds = getTaxAgentService(user).listEmployeeIdsInTaxAgent(taxAgentId); + if (!empIds.contains(employeeId)) { + //将人员添加进个税扣缴义务人中 + TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam taxAgentSubAdminRangeTargetParam = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam(); + taxAgentSubAdminRangeTargetParam.setTargetId(employeeId); + taxAgentSubAdminRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE); + + TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam(); + taxAgentRangeSaveParam.setTaxAgentId(taxAgentId); + taxAgentRangeSaveParam.setIncludeType(1); + taxAgentRangeSaveParam.setEmployeeStatus(Arrays.asList("0", "1", "2", "3", "4", "5", "6")); + taxAgentRangeSaveParam.setTargetParams(Collections.singletonList(taxAgentSubAdminRangeTargetParam)); + taxAgentRangeSaveParam.setSync(true); + getTaxAgentManageRangeService(user).save(taxAgentRangeSaveParam); + } + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml index c4a8453de..03facc683 100644 --- a/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml @@ -792,8 +792,7 @@ run_status='FIXED', pay_end_date= null - WHERE run_status = 'SUSPEND' - and id IN + WHERE id IN #{id} diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml index 61a42b1ab..d85fc85bd 100644 --- a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml @@ -16,6 +16,7 @@ + @@ -56,6 +57,7 @@ , t.tax_agent_setting , t.tenant_key , t.update_time + , t.time_type @@ -123,6 +125,9 @@ AND report_name = #{reportName} + + AND time_type = #{timeType} + AND salary_end_month = #{salaryEndMonth} @@ -210,6 +215,9 @@ report_name, + + time_type, + salary_end_month, @@ -284,6 +292,9 @@ #{reportName}, + + #{timeType}, + #{salaryEndMonth}, @@ -334,6 +345,7 @@ position_setting=#{positionSetting}, remark=#{remark}, report_name=#{reportName}, + time_type=#{timeType}, salary_end_month=#{salaryEndMonth}, salary_start_month=#{salaryStartMonth}, second_dimension=#{secondDimension}, @@ -392,6 +404,9 @@ report_name=#{reportName}, + + time_type=#{timeType}, + salary_end_month=#{salaryEndMonth}, diff --git a/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java b/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java index 413aca182..321afe9fc 100644 --- a/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java +++ b/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java @@ -14,6 +14,7 @@ import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import weaver.general.BaseBean; import weaver.general.Util; @@ -131,23 +132,29 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt //假期余额信息 List> balanceOfLeaveDatas = getBalanceOfLeaveDatas(attend4Salary); - Map balanceMap = SalaryEntityUtil.convert2Map(balanceOfLeaveDatas, m -> m.get("id"), m -> m.get("2")); + Map> balanceMap = SalaryEntityUtil.convert2Map(balanceOfLeaveDatas, m -> m.get("id")); //给有考勤的赋值 List attendEmpIds = list.stream().map(attend -> { String resourceId = attend.get("resourceId"); - attend.put("balanceOfLeave2", balanceMap.get(resourceId)); + Map map = balanceMap.getOrDefault(resourceId, new HashMap<>()); + for (String key : map.keySet()) { + attend.put("balanceOfLeave_" + key, map.get(key)); + } return resourceId; }).collect(Collectors.toList()); //没有考勤,但有假期余额的人赋值 - List> balanceOfLeaveList = balanceMap.keySet().stream() + List> balanceOfLeaveList = balanceMap.keySet().stream() .filter(k -> !attendEmpIds.contains(k)) .map(k -> { - Map map = new HashMap<>(); - map.put("resourceId", k); - map.put("balanceOfLeave2", balanceMap.get(k)); - return map; + Map result = new HashMap<>(); + result.put("resourceId", k); + Map map = balanceMap.get(k); + for (String key : map.keySet()) { + result.put("balanceOfLeave_" + key, map.get(key)); + } + return result; }) .collect(Collectors.toList()); list.addAll(balanceOfLeaveList); @@ -167,13 +174,16 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt paramsMap.put("status", "9"); paramsMap.put("isNoAccount", true); List> columns = (List>) commandExecutor.execute(new GetSearchListCmd(paramsMap, user)).get("columns"); - Map map = Maps.newHashMapWithExpectedSize(2); - //年假 - map.put("code", "balanceOfLeave" + 2); - map.put("name", columns.stream().filter(m -> "2".equals(m.get("key"))).findFirst().map(m -> m.get("title")).orElse("年假余额")); - List> balanceOfLeaveColumns = new ArrayList<>(); - balanceOfLeaveColumns.add(map); + List> balanceOfLeaveColumns = columns.stream() + .filter(column -> NumberUtils.isCreatable(column.get("key"))) + .map(column -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", "balanceOfLeave_" + column.get("key")); + map.put("name", "假期余额-" + column.get("title")); + return map; + }).collect(Collectors.toList()); + return balanceOfLeaveColumns; } diff --git a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java index 7088ee9d6..10e42f83a 100644 --- a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java +++ b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java @@ -99,19 +99,39 @@ public class SalaryStatisticsReportBO { * @param po */ public static void poToQueryParam(SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportPO po) { - param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); - param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + String salaryStartMonth = param.getSalaryStartMonth(); + if (salaryStartMonth == null) { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + } else { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryStartMonth))); + } + String salaryEndMonth = param.getSalaryEndMonth(); + if (salaryEndMonth == null) { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + } else { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryEndMonth))); + } String key = "id"; - param.setTaxAgent(((List) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getTaxAgentSetting() != null) { + param.setTaxAgent(((List) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } // param.setIncomeCategory(((List) JSON.parseArray(po.getIncomeCategorySetting(), Map.class)).stream().map(m -> Integer.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setSubCompany(((List) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setDepart(((List) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getSubCompanySetting() != null) { + param.setSubCompany(((List) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getDepartSetting() != null) { + param.setDepart(((List) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } // param.setGrade(((List) JSON.parseArray(po.getGradeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); // param.setPosition(((List) JSON.parseArray(po.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); // param.setStatus(((List) JSON.parseArray(po.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList())); - param.setEmployee(((List) JSON.parseArray(po.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); - param.setHiredate(JSON.parseArray(po.getHiredateSetting(), Date.class)); + if (po.getEmployeeSetting() != null) { + param.setEmployee(((List) JSON.parseArray(po.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getHiredateSetting() != null) { + param.setHiredate(JSON.parseArray(po.getHiredateSetting(), Date.class)); + } // param.setLeavedate(JSON.parseArray(po.getLeavedateSetting(), LocalDate.class)); } @@ -577,7 +597,7 @@ public class SalaryStatisticsReportBO { * @param sameDetail */ private static void calculate4Frequent(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { - SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(item.getFrequentRule(), SalaryStatisticsItemRuleDTO.class); if (frequentRule == null || frequentRule.getTotalValue() != 1) { return; } @@ -611,7 +631,7 @@ public class SalaryStatisticsReportBO { * @param sameDetail */ private static void calculate4Tile(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { - SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(item.getTileRule(), SalaryStatisticsItemRuleDTO.class); if (tileRule == null || tileRule.getTotalValue() != 1) { return; } @@ -812,6 +832,7 @@ public class SalaryStatisticsReportBO { .map(Map.Entry::getKey) .orElse(""); } + /** * 平铺 * diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java index 2ea00c161..ff0bc3964 100644 --- a/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java @@ -28,6 +28,21 @@ public class SalaryStatisticsSearchConditionSaveParam { //统计维度 private Long dimension; + /** + * 1、上月 + * 2、本月 + * 3、一季度 + * 4、二季度 + * 5、三季度 + * 6、四季度 + * 7、上半年 + * 8、下半年 + * 9、本年 + * 10、自定义 + */ + //事件类型 + private Integer timeType; + //薪资所属月-开始月 private Date salaryStartMonth; diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java index a465e7add..cdf364f62 100644 --- a/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java @@ -21,15 +21,15 @@ import java.util.Date; @Builder @NoArgsConstructor @AllArgsConstructor -//hrsa_salary_stats_report") +//hrsa_salary_stats_report public class SalaryStatisticsReportPO implements Serializable { private static final long serialVersionUID = 6526480959578343197L; - //主键id") + //主键id private Long id; - //报表名称") + //报表名称 private String reportName; private String remark; @@ -38,58 +38,61 @@ public class SalaryStatisticsReportPO implements Serializable { private String sortIndex; private String sortType; - //统计维度") + //时间类型 + private Integer timeType; + + //统计维度 private String dimension; - //薪资所属月-起始") + //薪资所属月-起始 private Date salaryStartMonth; - //薪资所属月-截止") + //薪资所属月-截止 private Date salaryEndMonth; - //个税扣缴义务人配置") + //个税扣缴义务人配置 private String taxAgentSetting; - //收入所得项目配置") + //收入所得项目配置 private String incomeCategorySetting; - //分部配置") + //分部配置 private String subCompanySetting; - //部门配置") + //部门配置 private String departSetting; - //职级配置") + //职级配置 private String gradeSetting; - //岗位配置") + //岗位配置 private String positionSetting; - //人员状态配置") + //人员状态配置 private String statusSetting; - //人员配置") + //人员配置 private String employeeSetting; - //入职日期配置") + //入职日期配置 private String hiredateSetting; - //离职日期配置") + //离职日期配置 private String leavedateSetting; - //租户key", ignore = true) + //租户key private String tenantKey; - //创建人id", ignore = true) + //创建人id private Long creator; - //是否删除", ignore = true) + //是否删除 private Integer deleteType; - //创建时间", ignore = true) + //创建时间 private Date createTime; - //更新时间", ignore = true) + //更新时间 private Date updateTime; diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index 14e342ca3..c71f5193c 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -272,6 +272,8 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary po.setLeavedateSetting(JSON.toJSONString(param.getLeavedate())); } + po.setTimeType(param.getTimeType()); + getSalaryStatisticsReportMapper().updateIgnoreNull(po); // 获取自定义统计项目 @@ -370,9 +372,9 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary public PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList) { Map checkMap = SalaryStatisticsReportBO.checkLoad(salaryStatisticsItemList); // 如果一个都没有,直接返回 - if (!checkMap.get("isNow")) { - return new PageInfo>(); - } +// if (!checkMap.get("isNow")) { +// return new PageInfo>(); +// } // 获取本期报表分权后的核算人员 @@ -1050,13 +1052,17 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary Map> lastEmployeeListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId)); Map> sameEmployeeListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId)); + List empIds = accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + Map employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds) + .stream() + .collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o)); + //人员维度扩展属性 EmployeeInfoExpandDTO employeeInfoExpandDTO = getSalaryStatisticsDimensionService(user).getExpandFieldSettings("dim_employee"); List fieldSettings = Optional.ofNullable(Optional.ofNullable(employeeInfoExpandDTO).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>()); + Map> expandEmployeeMap = getSalaryEmployeeService(user).expandEmployeeMap(empIds, employeeInfoExpandDTO); - Map employeeByIdMap = getSalaryEmployeeService(user).expandEmployeeInfo(accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()), employeeInfoExpandDTO) - .stream() - .collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o)); + log.info("扩展属性"+expandEmployeeMap); // List extEmployees = extEmployeeService.listByIdsWithDeleted(accountDetailPOList.stream().filter(e -> EmployeeTypeEnum.EXT_EMPLOYEE.getValue().equals(e.getEmployeeType())).map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()), data.getTenantKey()); // Map employeeExtByIdMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmployeePO::getId, ExtEmployeePO::getUsername); @@ -1069,7 +1075,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, employeeByIdMap.get(k).getUsername()); fieldSettings.forEach( fieldSetting -> { - temp.put(fieldSetting.getField(), employeeByIdMap.get(k).getExtendData().get(fieldSetting.getField())); + temp.put(fieldSetting.getField(), expandEmployeeMap.getOrDefault(k,new HashMap<>()).get(fieldSetting.getField())); } ); temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastEmployeeListMap.get(k), sameEmployeeListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); diff --git a/src/com/engine/salary/report/web/SalaryStatisticsReportController.java b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java index 4ab48ee54..6fa9b5c24 100644 --- a/src/com/engine/salary/report/web/SalaryStatisticsReportController.java +++ b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java @@ -165,6 +165,8 @@ public class SalaryStatisticsReportController { SalaryStatisticsReportDataQueryParam param = SalaryStatisticsReportDataQueryParam.builder() .id(Long.parseLong(request.getParameter("id"))) .dimensionId(Long.parseLong(request.getParameter("dimensionId"))) + .salaryStartMonth(request.getParameter("salaryStartMonth")) + .salaryEndMonth(request.getParameter("salaryEndMonth")) .isShare(StringUtils.equals(request.getParameter("isShare"), "true")) .build(); try { diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index 330a1550a..ce270b1fa 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -130,7 +130,9 @@ public class SalaryStatisticsReportWrapper extends Service { Map temp = new HashMap<>(); temp.put("id", po.getId().toString()); temp.put("reportName", po.getReportName()); - + temp.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); + temp.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + temp.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); List dimNames = Arrays.stream(po.getDimension().split(",")).map(dim -> Optional.ofNullable(salaryStatisticsDimensionMap.get(dim)).orElse("")).collect(Collectors.toList()); temp.put("dimension", StringUtils.join(dimNames, ",")); temp.put("dimensionId", po.getDimension()); @@ -238,6 +240,7 @@ public class SalaryStatisticsReportWrapper extends Service { SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); Map data = new HashMap<>(); + data.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); data.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); data.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); data.put("taxAgent", JSONArray.parseArray(po.getTaxAgentSetting())); diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java index 48077848c..437f99e45 100644 --- a/src/com/engine/salary/service/SalaryEmployeeService.java +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -110,6 +110,8 @@ public interface SalaryEmployeeService { */ List expandEmployeeInfo(List ids, EmployeeInfoExpandDTO param); + Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param); + /** * 保存扩展信息 diff --git a/src/com/engine/salary/service/TaxAgentService.java b/src/com/engine/salary/service/TaxAgentService.java index dfff8f23a..438d41266 100644 --- a/src/com/engine/salary/service/TaxAgentService.java +++ b/src/com/engine/salary/service/TaxAgentService.java @@ -216,6 +216,14 @@ public interface TaxAgentService { */ List listTaxAgentAndEmployee(Long employeeId); + /** + * 获取个税扣缴义务人和可查看的人员列表(扁平型) + * + * @param + * @return + */ + List listAllTaxAgentAndEmployee(); + /** * 获取个税扣缴义务人和可查看的人员列表(树型) * diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index d055ca9b2..7a041e02c 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -1198,7 +1198,8 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe // return StringUtils.EMPTY; // 获取所有个税扣缴义务人 - Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(Long.valueOf(user.getUID())); +// Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(Long.valueOf(user.getUID())); + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(); // 获取删除待停薪信息 List list = getSalaryArchiveMapper().list(SalaryArchiveQueryParam.builder().ids(ids).build()); if (list.size() != ids.size()) { @@ -1248,7 +1249,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } - List taxAgentManageRangeEmployees = getTaxAgentService(user).listTaxAgentAndEmployee((long) user.getUID()); + List taxAgentManageRangeEmployees = getTaxAgentService(user).listAllTaxAgentAndEmployee(); List oldPendingList = oldList.stream().filter(f -> f.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())).collect(Collectors.toList()); boolean isNotExist = oldPendingList.stream().anyMatch(te -> taxAgentManageRangeEmployees.stream().noneMatch(p -> p.getEmployeeId() != null && p.getEmployeeId().equals(te.getEmployeeId()) && p.getTaxAgentId().equals(te.getTaxAgentId()))); if (isNotExist) { diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java index 418d63ae6..2b578377c 100644 --- a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -29,6 +29,7 @@ import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.util.SalaryEntityUtil; import com.google.common.collect.Lists; import dm.jdbc.util.IdGenerator; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -46,6 +47,7 @@ import java.util.stream.Collectors; * @author qiantao * @version 1.0 **/ +@Slf4j public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService { private EmployBiz employBiz = new EmployBiz(); @@ -321,6 +323,41 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee return employees; } + @Override + public Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param) { + if (CollectionUtils.isNotEmpty(ids) && param != null) { + Map> map = new HashMap<>(); + + List> partition = Lists.partition(ids, 5); + for (int i = 0; i < partition.size(); i++) { + List idList = partition.get(i); + RecordSet rs = new RecordSet(); + String sql = param.getExpandSql().replace("=$人员id$", " in (" + StringUtils.join(idList, ",") + ")") + .replace("in($人员id$)", " in (" + StringUtils.join(idList, ",") + ")"); + String primaryKey = param.getPk(); + rs.executeQuery(sql); + + log.info("扩展属性sql" + sql); + + while (rs.next()) { + Map extendData = new HashMap<>(); + param.getFieldSettings().forEach(setting -> { + String field = setting.getField(); + String value = rs.getString(field); + setting.setValue(value); + extendData.put(field, value); + }); + + String id = rs.getString(primaryKey); + map.put(Long.valueOf(id), extendData); + } + } + + return map; + } + return new HashMap<>(); + } + @Override public void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param) { String settings = JSON.toJSONString(param.getFieldSettings()); diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index 167bbfffd..65182baf2 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -619,6 +619,33 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { return listTaxAgentAndEmployee(null, employeeId); } + @Override + public List listAllTaxAgentAndEmployee() { + List taxAgentEmployeeList = Lists.newArrayList(); + + List taxAgentManageRangeEmployeeList = listTaxAgentAndEmployeeTree(); + taxAgentManageRangeEmployeeList.forEach(m -> { + List employeeList = m.getEmployeeList(); + if (CollectionUtils.isEmpty(employeeList)) { + taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(null) + .username(null) + .build()); + } else { + employeeList.forEach(f -> taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(f.getEmployeeId()) + .username(f.getUsername()) + .build())); + } + }); + + return taxAgentEmployeeList; + } + @Override public List listTaxAgentAndEmployeeTree(SalaryEmployeeStatusEnum employeeStatus, Long employeeId) { List taxAgentManageRangeEmployeeList = Lists.newArrayList(); @@ -793,6 +820,8 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { return taxAgentEmployeeList; } + + @Override public Collection listEmployeeIdsInTaxAgent(Long taxAgentId) { List taxAgentEmpPOS = getTaxAgentEmpService(user).listByTaxAgentIds(Collections.singletonList(taxAgentId),UseEmployeeTypeEnum.ALL); diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java index 73cd384dd..345c2187a 100644 --- a/src/com/engine/salary/sys/service/SalarySysConfService.java +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -82,6 +82,7 @@ public interface SalarySysConfService { Map getEncryptProgress(String progressId); boolean encryptIsOpen(); + void cleanEncryptStatus(); /** * @description 获取个税申报功能重启日期 diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index 5f3b87d70..790822d90 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -369,7 +369,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.erkai, "saveEncryptSetting", new LocalRunnable() { @Override public void execute() { - saveSettingByType(isOpenEncrypt, OPEN_APPLICATION_ENCRYPT, "开启加密设置", "app"); + updateEncrypt(isOpenEncrypt); Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId); } }); @@ -378,7 +378,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe @Override public void execute() { Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId); - saveSettingByType(isOpenEncrypt, OPEN_APPLICATION_ENCRYPT, "开启加密设置", "app"); + updateEncrypt(isOpenEncrypt); } }); //不要调换方法的位置 @@ -408,6 +408,12 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return encryptStatus; } + @Override + public void cleanEncryptStatus() { + encryptStatus = null; + } + + @Override public Map getEncryptProgress(String progressId) { Map resultMap = new HashMap<>(); @@ -503,6 +509,36 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } } + /** + * 开启/关闭加解密 + * @param confValue + */ + public void updateEncrypt(String confValue) { + SalarySysConfPO po = getOneByCode(OPEN_APPLICATION_ENCRYPT); + String title = "1".equals(confValue) ? "开启加密设置" : "关闭加密设置"; + if (po == null) { + SalarySysConfPO build = SalarySysConfPO.builder() + .id(IdGenerator.generate()) + .confKey(OPEN_APPLICATION_ENCRYPT) + .confValue(confValue) + .title(title) + .orderWeight(0) + .module("app") + .updateTime(new Date()) + .createTime(new Date()) + .deleteType(0) + .build(); + getSalarySysConfMapper().insertIgnoreNull(build); + } else { + po.setConfValue(confValue); + po.setTitle(title); + po.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(po); + } + //重新获取加解密 + cleanEncryptStatus(); + } + @Override public AppSettingVO appSetting() { AppSettingVO appSettingVO = AppSettingVO.builder().build();