From 4d90d0d8f05c2bf10f98957d82b66d9da1dfd417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 16 Dec 2024 10:38:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=BB=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=9F=A5=E7=9C=8B=E6=AC=A1=E8=B4=A6=E5=8F=B7=E5=B7=A5?= =?UTF-8?q?=E8=B5=84=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/mapper/SQLMapper.java | 2 + src/com/engine/salary/mapper/SQLMapper.xml | 5 + .../service/impl/SalarySendServiceImpl.java | 101 +++++------------- 3 files changed, 36 insertions(+), 72 deletions(-) diff --git a/src/com/engine/salary/mapper/SQLMapper.java b/src/com/engine/salary/mapper/SQLMapper.java index 4d998fa88..9afff661a 100644 --- a/src/com/engine/salary/mapper/SQLMapper.java +++ b/src/com/engine/salary/mapper/SQLMapper.java @@ -15,4 +15,6 @@ import java.util.Map; **/ public interface SQLMapper { List runSQL(@Param("sql") String sql); + + List listLong(@Param("sql") String sql); } diff --git a/src/com/engine/salary/mapper/SQLMapper.xml b/src/com/engine/salary/mapper/SQLMapper.xml index bba76972c..b487b3f53 100644 --- a/src/com/engine/salary/mapper/SQLMapper.xml +++ b/src/com/engine/salary/mapper/SQLMapper.xml @@ -4,4 +4,9 @@ + + + diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 0b394d56a..30662220c 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -50,6 +50,7 @@ import com.engine.salary.enums.salarybill.*; import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.SQLMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; @@ -65,6 +66,7 @@ import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; @@ -198,6 +200,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService return ServiceUtil.getService(SalaryBillBaseSetServiceImpl.class, user); } + private SQLMapper getSQLMapper() { + return MapperProxyFactory.getProxy(SQLMapper.class); + } + @Override public SalarySendPO getById(Long salarySendId) { return mapper.getById(salarySendId); @@ -479,9 +485,18 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (salarySendInfo == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); } + Long employeeId = salarySendInfo.getEmployeeId(); + if (currentEmployeeId.compareTo(employeeId) != 0) { - if (currentEmployeeId.compareTo(salarySendInfo.getEmployeeId()) != 0) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "当前账号无法查看此工资单")); + //主账号可以查看次账号工资单 + String sql = "select id from Hrmresource a where belongto= " + currentEmployeeId; + List belongtoIds = getSQLMapper().listLong(sql); + if (CollUtil.isNotEmpty(belongtoIds) && belongtoIds.contains(employeeId)) { + //切换user +// this.user = new User(new Integer(employeeId + "")); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "当前账号无法查看此工资单")); + } } // 获取默认模板信息 @@ -562,7 +577,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService // 获取薪资项目数据 Long salaryAcctRecordId = salarySendInfo.getSalaryAcctRecordId(); - List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeId(currentEmployeeId).build()); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeId(employeeId).build()); if (CollUtil.isEmpty(salaryAcctResultPOS)) { throw new SalaryRunTimeException("薪资核算结果不存在!"); } @@ -641,16 +656,16 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySendInfo.getTaxAgentId()); - DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salarySendInfo.getEmployeeId()); + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(employeeId); SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctResultPOS.get(0).getSalaryAcctEmpId()); SalaryAcctEmployeeBO.copyAcctEmp(simpleEmployee, acctEmployeePO); buildEmployeeInfo(employeeInformation, simpleEmployee, taxAgentPO.getName(), SalaryAcctResultBO.buildEmployeeFieldName()); map.put("employeeInformation", employeeInformation); map.put("salaryGroups", itemSetListDTOS); - salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salaryMonth, currentEmployeeId)); + salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salaryMonth, employeeId)); // 工资单水印文本型动态变量 == 处理 - handleSalaryWatermark(salaryTemplate, salarySendInfo, currentEmployeeId); + handleSalaryWatermark(salaryTemplate, salarySendInfo, employeeId); map.put("salaryTemplate", salaryTemplate); map.put("salaryAcctResult", salaryAcctResultS); @@ -704,7 +719,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService MonthTypeEnum monthType = salaryBillViewingLimitSetting.getMonthType(); LocalDate localDate; if (monthType == MonthTypeEnum.SALARY_DATE) { - localDate = LocalDate.now().plusMonths(-salaryBillViewingLimitSetting.getLimitMonth()+1).withDayOfMonth(1); + localDate = LocalDate.now().plusMonths(-salaryBillViewingLimitSetting.getLimitMonth() + 1).withDayOfMonth(1); } else { localDate = LocalDate.now().plusMonths(-salaryBillViewingLimitSetting.getLimitMonth()); } @@ -720,7 +735,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService * @param salaryTemplate * @param salarySendInfo */ - private void handleSalaryWatermark(SalaryTemplatePO salaryTemplate, SalarySendInfoPO salarySendInfo, Long currentEmployeeId) { + private void handleSalaryWatermark(SalaryTemplatePO salaryTemplate, SalarySendInfoPO salarySendInfo, Long employeeId) { SalaryBillWatermarkDTO salaryBillWatermark = JsonUtil.parseObject(salaryTemplate.getSalaryWatermark(), SalaryBillWatermarkDTO.class); if (Objects.isNull(salaryBillWatermark) || Boolean.FALSE.equals(salaryBillWatermark.getWatermarkStatus())) { return; @@ -734,7 +749,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService boolean needQueryEmp = (boolean) salaryBillWatermark.getWmSetting().getOrDefault("needQueryEmp", false); DataCollectionEmployee simpleEmployee = null; if (needQueryEmp) { - simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(currentEmployeeId); + simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(employeeId); } String wmText = salaryBillWatermark.getWmSetting().getOrDefault("wmText", StringUtils.EMPTY).toString(); @@ -865,12 +880,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService * * @param theme * @param salaryMonth - * @param currentEmployeeId + * @param employeeId * @return */ - private String getBillTitle(String theme, Date salaryMonth, Long currentEmployeeId) { + private String getBillTitle(String theme, Date salaryMonth, Long employeeId) { String companyName = ""; - if (currentEmployeeId != null) { + if (employeeId != null) { ResourceComInfo resourceComInfo = null; SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); try { @@ -879,7 +894,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } catch (Exception e) { log.error("资源异常", e); } - companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(currentEmployeeId + "")); + companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(employeeId + "")); } return theme.replace("${companyName}", companyName) .replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth)) @@ -934,7 +949,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .jobtitleName(simpleEmployee.getJobtitleName()) .jobtitleId(simpleEmployee.getJobtitleId()) .status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus()) - .statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(),"1"))).getDefaultLabel()) + .statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(), "1"))).getDefaultLabel()) .accountTypeName(simpleEmployee.getAccountType() == null ? "" : AccountTypeEnum.parseByValue(simpleEmployee.getAccountType()).getDefaultLabel()) .telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone()) .username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername()) @@ -1328,64 +1343,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } -// /** -// * 发送消息 -// * -// * @param salarySend -// * @param enableSendList -// * @param salaryTemplate -// * @param currentTenantKey -// */ -// private void sendMessage(SalarySendPO salarySend, List> enableSendList, SalaryTemplatePO salaryTemplate, String tenantName, Long currentEmployeeId, String currentTenantKey) { -// if (StringUtils.isNotBlank(salaryTemplate.getBackground())) { -// FileData fileByte = fileDownloadClient.getFileByte(Long.valueOf(salaryTemplate.getBackground()), currentTenantKey); -// String encode = Base64Encoder.encode(fileByte.getData()); -// salaryTemplate.setBackground(encode); -// } -// // 邮箱打开 -// boolean isEmailOpen = salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); -// -// LocalDate salaryMonth = salarySend.getSalaryMonth(); -// String yearI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100325, "年"); -// String monthI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100326, "月"); -// String text = salaryMonth.getYear() + -// yearI18n + -// salaryMonth.getMonth().getValue() + -// monthI18n + -// SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100520, "工资待发明细"); -// -// UserEntity sendUser = null; -// // 标题 -// String title = getBillTitle(salaryTemplate.getTheme(), salaryMonth, tenantName, currentEmployeeId, currentTenantKey); -// -// // 获取所有人员信息 -// List ids = enableSendList.stream().map(e->Long.valueOf(e.get("employeeId").toString())).collect(Collectors.toList()); -// List allEmployees = hrmCommonEmployeeService.getEmployeeByIds(ids, currentTenantKey); -// List listDTOS = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); -// Optional optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); -// SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); -// Map employeeField = SalaryAcctResultBO.buildEmployeeFieldName(); -// enableSendList.forEach(e -> { -// Optional optionalSimpleEmployee = allEmployees.stream().filter(f->f.getEmployeeId().equals(Long.valueOf(e.get("employeeId").toString()))).findFirst(); -// if (optionalSimpleEmployee.isPresent()) { -// buildEmployeeInfo(employeeInformation, optionalSimpleEmployee.get(), e.get("taxAgent").toString(), employeeField); -// } -// -// List receivers = Collections.singletonList( -// SalarySendBO.buildUser(Long.valueOf(e.get("employeeId").toString()), e.get("email") == null ? "" : e.get("email").toString(), currentTenantKey)); -// Entity entity = SalarySendBO.buildEntity(e.get("id").toString(), SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 94626, "工资单")); -// EmailEntity emailInfo = new EmailEntity(); -// // 邮箱打开 -// if (isEmailOpen) { -// String emailContent = SalarySendBO.buildEmailContent(e, employeeInformation, title, salaryTemplate); -// emailInfo = SalarySendBO.buildEmailInfo(text, emailContent, salaryTemplate.getSendEmailId()); -// } -// SendMessageEntity message = SalarySendBO.buildSendMessageEntity(text, sendUser, receivers, entity, emailInfo); -// log.info("开始发送============:{}", JsonUtil.toJsonString(message)); -// // 开始发送 -// log.info("发送结果===:{}", JsonUtil.toJsonString(asyncSystemMessageRest.sendMsg(message))); -// }); -// } @Override public Map withdraw(SalarySendWithdrawParam param) { From 94da3d3a319a38a57b93979a38d328b39df0d44f Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Mon, 16 Dec 2024 17:46:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=EF=BC=8C=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/report/wrapper/SalaryStatisticsReportWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index c516bb229..9d990ea50 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -472,7 +472,7 @@ public class SalaryStatisticsReportWrapper extends Service { SalaryStatisticsItemPO salaryStatisticsItemPO = salaryStatisticsItemMap.get(salaryItemId); if (salaryStatisticsItemPO != null) { Optional textItemOptional = Arrays.stream(salaryStatisticsItemPO.getItemValue().split(",")).filter(itemId -> !numberItemIds.contains(itemId)).findFirst(); - row.add((!textItemOptional.isPresent() && NumberUtils.isCreatable(Utils.null2String(map.get(k)))) ? new BigDecimal(Utils.null2String(map.get(k))) : map.getOrDefault(k, StringUtils.EMPTY)); + row.add((!textItemOptional.isPresent() && NumberUtils.isCreatable(Utils.null2String(map.get(k)).replaceAll(",", ""))) ? new BigDecimal(Utils.null2String(map.get(k)).replaceAll(",", "")) : map.getOrDefault(k, StringUtils.EMPTY)); } else { row.add(map.getOrDefault(k, StringUtils.EMPTY)); }