From e3200f79325719d51cdd384596bc8a0ef444fd13 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Fri, 30 Aug 2024 13:35:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=E6=8A=A5=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=80=8F=E8=A7=86=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryStatisticsReportServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index b75c5c413..962e3b135 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -445,8 +445,18 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary // 获取报表统计薪资项目 List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")).flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); // 参数转换 - param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryStartMonth())); - param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryEndMonth())); + String salaryStartMonth = param.getSalaryStartMonth(); + if (salaryStartMonth == null) { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryStartMonth())); + } else { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryStartMonth))); + } + String salaryEndMonth = param.getSalaryEndMonth(); + if (salaryEndMonth == null) { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryEndMonth())); + } else { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryEndMonth))); + } String key = "id"; if (reportPO.getTaxAgentSetting() != null) { param.setTaxAgent(((List) JSON.parseArray(reportPO.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); From c212a2782f35f4ff413da57618249c8fddd01348 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Fri, 13 Sep 2024 14:54:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=B2=97=E4=BD=8D=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryAcctEmployeeServiceImpl.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index 621b2b068..7ca1a1f4d 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -712,19 +712,20 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct // } // list = list.stream().filter(po -> employeeIdsByGradeFilter.contains(po.getEmployeeId())).collect(Collectors.toList()); // } -// // 岗位过滤 -// if (CollectionUtils.isNotEmpty(param.getPosition())) { -// Set employeeIdsByPostionFilter = new HashSet<>(); -// simpleEmployeeList.forEach(simpleEmployee -> { -// if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) { -// employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId()); -// } -// }); -// if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) { -// return Lists.newArrayList(); -// } -// list = list.stream().filter(po -> employeeIdsByPostionFilter.contains(po.getEmployeeId())).collect(Collectors.toList()); -// } + // 岗位过滤 + List position = param.getPosition(); + if (CollectionUtils.isNotEmpty(position)) { + // Set employeeIdsByPostionFilter = new HashSet<>(); + // simpleEmployeeList.forEach(simpleEmployee -> { + // if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) { + // employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId()); + // } + // }); + // if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) { + // return Lists.newArrayList(); + // } + employeeList = employeeList.stream().filter(emp -> position.contains(emp.getJobtitleId())).collect(Collectors.toList()); + } // 人事状态过滤 if (CollectionUtils.isNotEmpty(param.getStatus())) { Set employeeIdsByStatus = new HashSet<>(); From eefd4d1795052991150d0b585c5e50a661e0b7be Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Sat, 14 Sep 2024 15:33:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/report/entity/bo/SalaryStatisticsReportBO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java index 59abb699b..9ad7fb2fc 100644 --- a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java +++ b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java @@ -129,7 +129,9 @@ public class SalaryStatisticsReportBO { 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())); + if (po.getPositionSetting() != null) { + param.setPosition(((List) JSON.parseArray(po.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } if (po.getStatusSetting() != null) { param.setStatus(((List) JSON.parseArray(po.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList())); } From 09042321d1ec8313fba4b957ca31584d5cdad19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 18 Sep 2024 15:59:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1=E3=80=81=E6=94=AF=E6=8C=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=8F=AD=E6=AC=A1=E4=BF=A1=E6=81=AF=202=E3=80=81?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=80=83=E5=8B=A4=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8Cexcel=E5=88=97=E5=92=8C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datacollection/bo/AttendQuoteDataBO.java | 4 ++ .../AttendQuoteFieldMapper.java | 6 +++ .../datacollection/AttendQuoteFieldMapper.xml | 4 ++ .../remote/attend/entity/Attend4Salary.java | 5 +++ .../impl/RemoteAttend4SalaryServiceImpl.java | 34 ++++++++++++++-- .../impl/AttendQuoteDataServiceImpl.java | 40 ++++++++++++++----- 6 files changed, 79 insertions(+), 14 deletions(-) diff --git a/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java index 144ed4c0e..5b67306ca 100644 --- a/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java +++ b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java @@ -36,6 +36,10 @@ public class AttendQuoteDataBO { continue; } String key = field.getCode(); + //兼容出勤班次的key + if(key.startsWith("attendanceSerial_")){ + key = key.replace("attendanceSerial_", ""); + } if (m.containsKey(key)) { Map map = new LinkedHashMap<>(); map.put("employeeId", m.get("resourceId")); diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java index 9392a59f0..01a4f6be6 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java @@ -104,4 +104,10 @@ public interface AttendQuoteFieldMapper { * @return */ List listSome(@Param("param") AttendQuoteFieldPO param); + + /** + * 获取出勤班次 + * @return + */ + List getAttendanceSerials(); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml index 4c1ae10ee..38ad1cf90 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml @@ -486,4 +486,8 @@ + + \ No newline at end of file diff --git a/src/com/engine/salary/remote/attend/entity/Attend4Salary.java b/src/com/engine/salary/remote/attend/entity/Attend4Salary.java index 701d82f69..39703a559 100644 --- a/src/com/engine/salary/remote/attend/entity/Attend4Salary.java +++ b/src/com/engine/salary/remote/attend/entity/Attend4Salary.java @@ -26,4 +26,9 @@ public class Attend4Salary { private List onlyEmpIds; private Map extendParam; + + /** + * 出勤班次 + */ + private String attendanceSerial; } 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 99553f193..95e1618ac 100644 --- a/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java +++ b/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java @@ -4,12 +4,15 @@ import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSONObject; import com.engine.core.impl.Service; import com.engine.kq.cmd.report.GetKQReportCmd; +import com.engine.salary.mapper.datacollection.AttendQuoteFieldMapper; import com.engine.salary.remote.attend.cmd.GetSearchListCmd; import com.engine.salary.remote.attend.entity.Attend4Salary; import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.valid.ValidUtil; +import com.google.common.base.Joiner; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -26,15 +29,22 @@ import java.util.stream.Collectors; public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAttend4SalaryService { private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log")); + private AttendQuoteFieldMapper getAttendQuoteFieldMapper() { + return MapperProxyFactory.getProxy(AttendQuoteFieldMapper.class); + } + @Override public List> getColumns() { + + //兼容获取班次信息字段 + List attendanceSerials = getAttendQuoteFieldMapper().getAttendanceSerials(); + String attendanceSerial = Joiner.on(",").join((Iterable) attendanceSerials); + Map paramsMap = new HashMap(); -// paramsMap.put("pageIndex", 1); -// paramsMap.put("pageSize", 10); paramsMap.put("typeselect", "3"); paramsMap.put("viewScope", "0"); paramsMap.put("isNoAccount", "1"); - paramsMap.put("attendanceSerial", ""); + paramsMap.put("attendanceSerial", attendanceSerial); paramsMap.put("isFromMyAttendance", "1"); Map temp = new HashMap(); temp.put("data", JSONObject.toJSONString(paramsMap)); @@ -60,6 +70,21 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt }); } } + //出勤班次 + else if (dataIndex.equals("attendanceSerial") && column.get("children") != null) { + List list = (List) column.get("children"); + if (CollectionUtils.isNotEmpty(list)) { + list.stream() + .filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString())) + .forEach(leave -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", "attendanceSerial_" + leave.get("dataIndex").toString()); + String unit = "".equals(leave.get("unit").toString()) ? "" : "(" + leave.get("unit").toString() + ")"; + map.put("name", Util.null2String(column.get("title")) + "-" + leave.get("title") + unit); + columns.add(map); + }); + } + } //加班 else if (dataIndex.equals("overtime") && column.get("children") != null) { List list = (List) column.get("children"); @@ -121,7 +146,8 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt List resourceIds = attend4Salary.getOnlyEmpIds().stream().map(String::valueOf).collect(Collectors.toList()); paramsMap.put("resourceId", String.join(",", resourceIds)); paramsMap.put("isNoAccount", "1"); - paramsMap.put("attendanceSerial", ""); + //班次 + paramsMap.put("attendanceSerial", attend4Salary.getAttendanceSerial()); paramsMap.put("isFromMyAttendance", "1"); Map temp = new HashMap(); temp.put("data", JSONObject.toJSONString(paramsMap)); diff --git a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java index 1771b6c09..750f11ec2 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java @@ -70,6 +70,7 @@ import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.file.ImageFileManager; import weaver.general.BaseBean; +import weaver.general.Util; import weaver.hrm.User; import weaver.wechat.util.Utils; @@ -131,7 +132,6 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa } - private RemoteAttend4SalaryService getRemoteAttend4SalaryService(User user) { return ServiceUtil.getService(RemoteAttend4SalaryServiceImpl.class, user); } @@ -250,6 +250,16 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa // 获取最终结果 List> listMaps = getListMaps(attendQuoteDataBases); + + //当前引用的值 + List effectiveColumns = listMaps.stream() + .map(Map::keySet) + .max(Comparator.comparingInt(Set::size)) + .orElse(new HashSet<>()) + .stream() + .map(key -> key.split("_")[0]) + .collect(Collectors.toList()); + // 1.工作簿名称 String sheetName = SalaryI18nUtil.getI18nLabel(93931, "考勤数据"); List header = new ArrayList<>(); @@ -258,10 +268,16 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); // 动态列 + List effectiveFields = new ArrayList<>(); if (CollectionUtils.isNotEmpty(listMaps)) { - for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { - header.add(attendQuoteField.getFieldName()); - } + effectiveFields = attendQuoteFields.stream() + .filter(attendQuoteField -> effectiveColumns.contains(Util.null2String(attendQuoteField.getId()))) + .collect(Collectors.toList()); + + effectiveFields.forEach(attendQuoteField -> { + header.add(attendQuoteField.getFieldName()); + } + ); } List> rows = new ArrayList<>(); @@ -276,7 +292,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa row.add(dto.get("jobNum")); // 动态列 - for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + for (AttendQuoteFieldPO attendQuoteField : effectiveFields) { Object o = dto.get(attendQuoteField.getId().toString() + "_attendQuoteData"); try { if (o != null && NumberUtil.isNumber(o.toString())) { @@ -509,13 +525,17 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa attend4Salary.setBeginDate(attendCycleRange.getFromDate()); attend4Salary.setEndDate(attendCycleRange.getEndDate()); attend4Salary.setOnlyEmpIds(part); + //班次信息 + String attendanceSerial = attendQuoteFields.stream() + .filter(f -> f.getCode() != null && f.getCode().startsWith("attendanceSerial_")) + .map(f -> f.getCode().replace("attendanceSerial_", "")) + .collect(Collectors.joining(",")); + attend4Salary.setAttendanceSerial(attendanceSerial); + List> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary); AttendQuoteDataBO.buildAttendDataFromRemote(attendResult, attendQuoteFields, attendQuoteSyncData); -// attend4Salary.setUnit("day"); -// attendResult = remoteAttend4SalaryService.getWorkTimeSummary(attend4Salary); -// log.info("考勤数据[按天]:{}", JSONUtils.toJSONString(attendResult.getData())); -// AttendQuoteDataBO.buildAttendDataFromRemote("day", attendResult.getData(), attendQuoteFields, attendQuoteSyncData); + } } catch (Exception e) { log.error("salaryAttend获取考勤数据错误失败:{}", String.format("参数:%s,错误信息:%s", JSONObject.toJSONString(attend4Salary), e.getMessage()), e); @@ -663,7 +683,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; // 获取租户下所有的人员 - List employees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + List employees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); // 获取已设置的可同步的考勤字段 List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT); // 生成获取考勤引用