2024-10-11 15:34:17 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
|
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.entity.setting.dto.PageListTemplateDTO;
|
2024-12-04 09:13:41 +08:00
|
|
|
|
import com.engine.salary.entity.setting.dto.PageListTemplateDetailDTO;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.entity.setting.param.*;
|
|
|
|
|
|
import com.engine.salary.entity.setting.po.PageLinkPO;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import com.engine.salary.entity.setting.po.PageListSettingPO;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.entity.setting.po.PageListTemplatePO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2024-12-03 10:45:03 +08:00
|
|
|
|
import com.engine.salary.enums.SalaryOnOffEnum;
|
|
|
|
|
|
import com.engine.salary.enums.common.SharedTypeEnum;
|
2024-11-04 19:49:46 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.mapper.setting.PageLinkMapper;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import com.engine.salary.mapper.setting.PageListSettingMapper;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.mapper.setting.PageListTemplateMapper;
|
|
|
|
|
|
import com.engine.salary.report.common.constant.SalaryConstant;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import com.engine.salary.service.SalaryItemService;
|
|
|
|
|
|
import com.engine.salary.service.SettingService;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
import com.engine.salary.service.TaxAgentService;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import com.engine.salary.util.db.IdGenerator;
|
|
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2025-02-08 09:52:32 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelUtilPlus;
|
2024-12-04 09:13:41 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2024-11-04 19:49:46 +08:00
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2025-02-08 09:52:32 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2025-02-07 10:13:29 +08:00
|
|
|
|
import weaver.file.ImageFileManager;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
2024-11-04 19:49:46 +08:00
|
|
|
|
import static com.engine.salary.enums.setting.PageListSettingPageEnum.SALARY_DETAILS_REPORT;
|
2024-10-11 15:34:17 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-11-26 13:50:10 +08:00
|
|
|
|
* 页面显示
|
2024-10-11 15:34:17 +08:00
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SettingServiceImpl extends Service implements SettingService {
|
|
|
|
|
|
|
|
|
|
|
|
private PageListSettingMapper getPageListSettingMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(PageListSettingMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
private PageListTemplateMapper getPageListTemplateMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(PageListTemplateMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private PageLinkMapper getPageLinkMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(PageLinkMapper.class);
|
2024-10-11 15:34:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService() {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-11 15:34:17 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void savePageListSetting(PageListSettingSaveParam pageListSettingSaveParam) {
|
2024-11-25 16:04:19 +08:00
|
|
|
|
ValidUtil.doValidator(pageListSettingSaveParam);
|
|
|
|
|
|
|
2024-10-11 15:34:17 +08:00
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
2024-11-25 18:05:18 +08:00
|
|
|
|
//是否保存默认设置
|
|
|
|
|
|
Integer defaultSetting = pageListSettingSaveParam.getDefaultSetting();
|
|
|
|
|
|
PageListSettingPO pageListSettingPO;
|
|
|
|
|
|
if (defaultSetting == 0) {
|
|
|
|
|
|
pageListSettingPO = getPageListSettingMapper().getByPage(pageListSettingSaveParam.getPage(), defaultSetting, (long) user.getUID());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
pageListSettingPO = getPageListSettingMapper().getByPage(pageListSettingSaveParam.getPage(), defaultSetting, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-25 16:04:19 +08:00
|
|
|
|
List<String> checked = pageListSettingSaveParam.getSetting().stream().distinct().collect(Collectors.toList());
|
2024-10-11 15:34:17 +08:00
|
|
|
|
if (pageListSettingPO != null) {
|
2024-11-19 09:48:13 +08:00
|
|
|
|
pageListSettingPO.setSetting(checked);
|
2024-10-11 15:34:17 +08:00
|
|
|
|
pageListSettingPO.setUpdateTime(now);
|
|
|
|
|
|
getPageListSettingMapper().updateIgnoreNull(pageListSettingPO);
|
|
|
|
|
|
} else {
|
2024-11-25 18:05:18 +08:00
|
|
|
|
pageListSettingPO = PageListSettingPO.builder().id(IdGenerator.generate()).page(pageListSettingSaveParam.getPage()).setting(checked).defaultSetting(defaultSetting).creator((long) user.getUID()).createTime(now).updateTime(now).deleteType(0).tenantKey(DEFAULT_TENANT_KEY).build();
|
2024-10-11 15:34:17 +08:00
|
|
|
|
getPageListSettingMapper().insertIgnoreNull(pageListSettingPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-04 09:13:41 +08:00
|
|
|
|
public PageListTemplateDetailDTO getDefaultPageListSetting(PageListSettingQueryParam param) {
|
2024-10-11 17:04:13 +08:00
|
|
|
|
String page = param.getPage();
|
2024-11-04 19:49:46 +08:00
|
|
|
|
if (SALARY_DETAILS_REPORT.getValue().equals(page)) {
|
2024-11-25 16:04:19 +08:00
|
|
|
|
List<WeaTableColumn> columns = new ArrayList<>();
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "userName"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subCompany"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "部门"), "department"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "岗位"), "jobTitle"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "工号"), "workCode"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE));
|
|
|
|
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
|
|
|
|
columns = columns.stream().filter(column -> column.getText().contains(param.getName())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-11 15:34:17 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listAll();
|
2024-11-25 18:05:18 +08:00
|
|
|
|
List<WeaTableColumn> collect = salaryItemList.stream().filter(po -> {
|
|
|
|
|
|
String name = param.getName();
|
|
|
|
|
|
if (StrUtil.isNotEmpty(name)) {
|
|
|
|
|
|
return po.getName() != null && po.getName().contains(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}).sorted((o1, o2) -> {
|
|
|
|
|
|
if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) {
|
|
|
|
|
|
Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType();
|
|
|
|
|
|
Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType();
|
|
|
|
|
|
return systemType1.compareTo(systemType2);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex();
|
|
|
|
|
|
Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex();
|
|
|
|
|
|
return sortedIndex2.compareTo(sortedIndex1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).map(item -> new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX)).collect(Collectors.toList());
|
2024-11-25 16:04:19 +08:00
|
|
|
|
|
|
|
|
|
|
columns.addAll(collect);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, WeaTableColumn> columnMap = SalaryEntityUtil.convert2Map(columns, WeaTableColumn::getColumn);
|
|
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
//默认设置
|
|
|
|
|
|
PageListSettingPO pageListSettingPO = getPageListSettingMapper().getByPage(page, 1, null);
|
2024-11-25 16:04:19 +08:00
|
|
|
|
|
2024-11-25 18:05:18 +08:00
|
|
|
|
//查询选中的项目
|
2024-12-03 10:45:03 +08:00
|
|
|
|
List<WeaTableColumn> checkedList = new ArrayList<>();
|
2024-11-25 18:05:18 +08:00
|
|
|
|
if (pageListSettingPO != null) {
|
|
|
|
|
|
checkedList = Optional.ofNullable(pageListSettingPO.getSetting()).orElse(new ArrayList<>()).stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList());
|
|
|
|
|
|
} else {
|
2024-11-25 16:04:19 +08:00
|
|
|
|
checkedList = columns;
|
|
|
|
|
|
}
|
2024-12-04 09:13:41 +08:00
|
|
|
|
return PageListTemplateDetailDTO.builder().setting(columns).checked(checkedList).build();
|
2024-10-11 15:34:17 +08:00
|
|
|
|
}
|
2024-11-25 16:04:19 +08:00
|
|
|
|
|
2024-12-04 09:13:41 +08:00
|
|
|
|
return PageListTemplateDetailDTO.builder().setting(new ArrayList<>()).checked(new ArrayList<>()).build();
|
2024-10-11 15:34:17 +08:00
|
|
|
|
}
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-11-26 13:50:10 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void resetPageListSetting(PageListSettingResetParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
|
|
|
|
|
|
String page = param.getPage();
|
|
|
|
|
|
|
|
|
|
|
|
//个人设置
|
|
|
|
|
|
PageListSettingPO selfSetting = getPageListSettingMapper().getByPage(page, 0, (long) user.getUID());
|
|
|
|
|
|
|
|
|
|
|
|
if (selfSetting != null) {
|
|
|
|
|
|
getPageListSettingMapper().delete(selfSetting);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-04 19:49:46 +08:00
|
|
|
|
@Override
|
2024-12-04 09:13:41 +08:00
|
|
|
|
public PageListTemplateDetailDTO getPageListTemplate(PageListTemplateQueryParam param) {
|
2024-11-07 17:45:17 +08:00
|
|
|
|
String page = param.getPage();
|
|
|
|
|
|
if (SALARY_DETAILS_REPORT.getValue().equals(page)) {
|
|
|
|
|
|
List<WeaTableColumn> columns = new ArrayList<>();
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "userName"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subCompany"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "部门"), "department"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "岗位"), "jobTitle"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "工号"), "workCode"));
|
2024-12-09 14:34:57 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "证件号码"), "idNo"));
|
2024-11-07 17:45:17 +08:00
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE));
|
|
|
|
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
|
|
|
|
columns = columns.stream().filter(column -> column.getText().contains(param.getName())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listAll();
|
2024-12-03 10:45:03 +08:00
|
|
|
|
List<WeaTableColumn> salaryItemCols = salaryItemList.stream().filter(po -> {
|
2024-11-25 18:05:18 +08:00
|
|
|
|
String name = param.getName();
|
|
|
|
|
|
if (StrUtil.isNotEmpty(name)) {
|
|
|
|
|
|
return po.getName() != null && po.getName().contains(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}).sorted((o1, o2) -> {
|
|
|
|
|
|
if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) {
|
|
|
|
|
|
Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType();
|
|
|
|
|
|
Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType();
|
|
|
|
|
|
return systemType1.compareTo(systemType2);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex();
|
|
|
|
|
|
Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex();
|
|
|
|
|
|
return sortedIndex2.compareTo(sortedIndex1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).map(item -> new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX)).collect(Collectors.toList());
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
columns.addAll(salaryItemCols);
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
Map<String, WeaTableColumn> columnMap = SalaryEntityUtil.convert2Map(columns, WeaTableColumn::getColumn);
|
2024-12-03 10:45:03 +08:00
|
|
|
|
List<WeaTableColumn> checkedList = columns;
|
|
|
|
|
|
Long id = param.getId();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
if (id != null) {
|
2024-12-03 10:45:03 +08:00
|
|
|
|
//编辑模板,指定模板id
|
2024-11-07 17:45:17 +08:00
|
|
|
|
PageListTemplatePO po = getPageListTemplateMapper().getById(id);
|
|
|
|
|
|
if (po != null) {
|
2024-11-25 18:05:18 +08:00
|
|
|
|
checkedList = Optional.ofNullable(po.getSetting()).orElse(new ArrayList<>()).stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList());
|
2024-12-03 10:45:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//打开选中的模板
|
|
|
|
|
|
List<PageListTemplatePO> pageListTemplates = getPageListTemplates(PageListTemplateQueryParam.builder().page(page).build());
|
|
|
|
|
|
List<WeaTableColumn> columnList = pageListTemplates.stream()
|
|
|
|
|
|
.filter(PageListTemplatePO::getChecked).map(PageListTemplatePO::getSetting).findFirst().orElse(new ArrayList<>())
|
|
|
|
|
|
.stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(columnList)) {
|
|
|
|
|
|
checkedList = columnList;
|
2024-11-07 17:45:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-04 09:13:41 +08:00
|
|
|
|
return PageListTemplateDetailDTO.builder().setting(columns).checked(checkedList).build();
|
2024-11-04 19:49:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-04 09:13:41 +08:00
|
|
|
|
return PageListTemplateDetailDTO.builder().build();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
}
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<PageListTemplatePO> getPageListTemplates(PageListTemplateQueryParam param) {
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
Date now = new Date();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
String page = param.getPage();
|
|
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
//个人配置模板
|
2024-11-07 17:45:17 +08:00
|
|
|
|
PageListTemplatePO build = PageListTemplatePO.builder().page(page).build();
|
|
|
|
|
|
List<PageListTemplatePO> pos = getPageListTemplateMapper().listSome(build);
|
|
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
//如果查不到不到系统模板,创建系统模板
|
|
|
|
|
|
PageListTemplatePO systemTemplate = pos.stream().filter(po -> po.getSystemType() != null && po.getSystemType() == 1).findFirst().orElse(null);
|
|
|
|
|
|
if (systemTemplate == null) {
|
|
|
|
|
|
//查询系统默认配置
|
2024-12-04 09:13:41 +08:00
|
|
|
|
PageListTemplateDetailDTO pageListSetting = getDefaultPageListSetting(PageListSettingQueryParam.builder().page(SALARY_DETAILS_REPORT.getValue()).build());
|
2024-12-03 10:45:03 +08:00
|
|
|
|
|
|
|
|
|
|
systemTemplate = PageListTemplatePO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.page(param.getPage())
|
|
|
|
|
|
.name("系统模板")
|
|
|
|
|
|
.sharedType(SharedTypeEnum.PUBLIC.getValue())
|
|
|
|
|
|
.systemType(SalaryOnOffEnum.ON.getValue())
|
|
|
|
|
|
.setting(pageListSetting.getChecked().stream().map(WeaTableColumn::getColumn).collect(Collectors.toList()))
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY).build();
|
|
|
|
|
|
getPageListTemplateMapper().insertIgnoreNull(systemTemplate);
|
|
|
|
|
|
pos.add(systemTemplate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
//获取当前选择的模板
|
2024-12-03 10:45:03 +08:00
|
|
|
|
PageLinkPO link = getPageLinkMapper().listSome(PageLinkPO.builder().employeeId((long) user.getUID()).page(SALARY_DETAILS_REPORT.getValue()).build()).stream().findFirst().orElse(null);
|
|
|
|
|
|
if (link == null) {
|
|
|
|
|
|
link = PageLinkPO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.employeeId((long) user.getUID())
|
|
|
|
|
|
.page(param.getPage())
|
|
|
|
|
|
.templateId(systemTemplate.getId())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(0).build();
|
|
|
|
|
|
getPageLinkMapper().insertIgnoreNull(link);
|
|
|
|
|
|
}
|
|
|
|
|
|
Long templateId = link.getTemplateId();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
|
2024-12-03 10:45:03 +08:00
|
|
|
|
//权限控制
|
2024-11-07 17:45:17 +08:00
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService().listAllTaxAgents((long) user.getUID());
|
2024-12-02 15:01:06 +08:00
|
|
|
|
List<Long> taxIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList());
|
2024-12-05 10:17:12 +08:00
|
|
|
|
Boolean chief = getTaxAgentService().isChief((long) user.getUID());
|
2024-11-25 18:05:18 +08:00
|
|
|
|
pos = pos.stream().filter(po -> {
|
2024-12-04 17:45:56 +08:00
|
|
|
|
SharedTypeEnum sharedTypeEnum = SharedTypeEnum.parseByValue(po.getSharedType());
|
|
|
|
|
|
//系统模板直接可见
|
2024-12-05 10:17:12 +08:00
|
|
|
|
if (chief || po.getSystemType() == 1) {
|
2024-12-04 17:45:56 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//私有,只能自己看到
|
|
|
|
|
|
if (sharedTypeEnum == SharedTypeEnum.PRIVATE) {
|
|
|
|
|
|
return Objects.equals((long) user.getUID(), po.getCreator());
|
|
|
|
|
|
}
|
|
|
|
|
|
//共享
|
|
|
|
|
|
if (sharedTypeEnum == SharedTypeEnum.PUBLIC) {
|
2024-12-02 15:01:06 +08:00
|
|
|
|
List<Long> limitIds = po.getLimitIds();
|
2024-12-04 17:45:56 +08:00
|
|
|
|
return CollectionUtil.isEmpty(limitIds) || CollectionUtil.intersection(limitIds, taxIds).size() != 0;
|
2024-11-25 18:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}).peek(po -> {
|
2024-12-03 10:45:03 +08:00
|
|
|
|
po.setChecked(po.getId().equals(templateId));
|
2024-11-25 18:05:18 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2024-11-07 17:45:17 +08:00
|
|
|
|
return pos;
|
2024-11-04 19:49:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-11-07 17:45:17 +08:00
|
|
|
|
public PageListTemplatePO savePageListTemplate(PageListTemplateSaveParam param) {
|
2024-11-04 19:49:46 +08:00
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
PageListTemplatePO po;
|
2024-11-04 19:49:46 +08:00
|
|
|
|
if (id == null) {
|
2024-12-04 09:13:41 +08:00
|
|
|
|
po = PageListTemplatePO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.page(param.getPage())
|
|
|
|
|
|
.name(param.getName())
|
|
|
|
|
|
.sharedType(param.getSharedType())
|
|
|
|
|
|
.systemType(0)
|
|
|
|
|
|
.limitIds(param.getLimitIds())
|
|
|
|
|
|
.setting(param.getSetting())
|
2025-02-06 16:11:39 +08:00
|
|
|
|
.fileId(param.getFileId())
|
2024-12-04 09:13:41 +08:00
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY).build();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
getPageListTemplateMapper().insertIgnoreNull(po);
|
2024-11-04 19:49:46 +08:00
|
|
|
|
} else {
|
2024-11-07 17:45:17 +08:00
|
|
|
|
po = getPageListTemplateMapper().getById(id);
|
2024-11-04 19:49:46 +08:00
|
|
|
|
if (po == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("模板不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
po.setName(param.getName());
|
2024-11-07 17:45:17 +08:00
|
|
|
|
po.setSharedType(param.getSharedType());
|
|
|
|
|
|
po.setLimitIds(param.getLimitIds());
|
|
|
|
|
|
po.setSetting(param.getSetting());
|
2025-02-06 16:11:39 +08:00
|
|
|
|
po.setFileId(param.getFileId());
|
2024-11-04 19:49:46 +08:00
|
|
|
|
po.setUpdateTime(now);
|
2024-11-07 17:45:17 +08:00
|
|
|
|
getPageListTemplateMapper().updateIgnoreNull(po);
|
2024-11-04 19:49:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return po;
|
|
|
|
|
|
}
|
2024-11-07 17:45:17 +08:00
|
|
|
|
|
2025-02-08 09:52:32 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook downloadPageExportTemplateFile(DownloadTemplateParam param) {
|
2025-02-08 15:12:21 +08:00
|
|
|
|
List<List<String>> rowList = new ArrayList<>();
|
2025-02-08 09:52:32 +08:00
|
|
|
|
List<String> heads = param.getHeads();
|
|
|
|
|
|
List<String> setting = param.getSetting();
|
2025-02-08 15:12:21 +08:00
|
|
|
|
if (CollUtil.isEmpty(heads)||CollUtil.isEmpty(setting)||!Objects.equals(heads.size(), setting.size())){
|
2025-02-08 09:52:32 +08:00
|
|
|
|
throw new SalaryRunTimeException("未选择字段");
|
|
|
|
|
|
}
|
|
|
|
|
|
setting = setting.stream().map(s -> String.format("{.%s}", s)).collect(Collectors.toList());
|
2025-02-08 15:12:21 +08:00
|
|
|
|
rowList.add(heads);
|
|
|
|
|
|
rowList.add(setting);
|
2025-02-08 09:52:32 +08:00
|
|
|
|
|
2025-02-08 15:12:21 +08:00
|
|
|
|
return ExcelUtilPlus.genWorkbook(rowList, "薪资明细");
|
2025-02-08 09:52:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void changePageListTemplate(PageListTemplateChangeParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
|
|
|
|
|
|
List<PageLinkPO> pageLinkPOS = getPageLinkMapper().listSome(PageLinkPO.builder().employeeId((long) user.getUID()).page(param.getPage()).build());
|
|
|
|
|
|
if (CollUtil.isNotEmpty(pageLinkPOS)) {
|
|
|
|
|
|
Set<Long> ids = SalaryEntityUtil.properties(pageLinkPOS, PageLinkPO::getId);
|
|
|
|
|
|
getPageLinkMapper().deleteByIds(ids);
|
|
|
|
|
|
}
|
2024-11-25 18:05:18 +08:00
|
|
|
|
PageLinkPO pageLinkPO = PageLinkPO.builder().id(IdGenerator.generate()).employeeId((long) user.getUID()).page(param.getPage()).templateId(param.getTemplateId()).tenantKey(DEFAULT_TENANT_KEY).createTime(new Date()).updateTime(new Date()).creator((long) user.getUID()).deleteType(0).build();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
|
|
|
|
|
|
getPageLinkMapper().insertIgnoreNull(pageLinkPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<WeaTableColumn> getPageListColumns(String page) {
|
2024-12-04 09:13:41 +08:00
|
|
|
|
PageListTemplateDetailDTO pageListTemplate = getPageListTemplate((PageListTemplateQueryParam.builder().page(page).build()));
|
2024-12-03 10:45:03 +08:00
|
|
|
|
return pageListTemplate.getChecked();
|
2024-11-07 17:45:17 +08:00
|
|
|
|
}
|
2024-12-04 09:13:41 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<PageListTemplateDTO> getTemplates(PageListTemplateQueryParam param) {
|
|
|
|
|
|
PageListTemplatePO build = PageListTemplatePO.builder().page(param.getPage()).build();
|
|
|
|
|
|
List<PageListTemplatePO> pos = getPageListTemplateMapper().listSome(build);
|
|
|
|
|
|
|
|
|
|
|
|
//权限控制
|
2024-12-05 10:17:12 +08:00
|
|
|
|
List<TaxAgentPO> agentPOList = getTaxAgentService().listAll();
|
|
|
|
|
|
Map<Long, String> idNameMap = SalaryEntityUtil.convert2Map(agentPOList, TaxAgentPO::getId, TaxAgentPO::getName);
|
2024-12-04 09:13:41 +08:00
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService().listAllTaxAgents((long) user.getUID());
|
|
|
|
|
|
Boolean chief = getTaxAgentService().isChief((long) user.getUID());
|
|
|
|
|
|
List<Long> taxIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList());
|
|
|
|
|
|
List<PageListTemplateDTO> templateDTOS = pos.stream()
|
|
|
|
|
|
.filter(po -> {
|
2024-12-04 17:45:56 +08:00
|
|
|
|
SharedTypeEnum sharedTypeEnum = SharedTypeEnum.parseByValue(po.getSharedType());
|
|
|
|
|
|
//系统模板直接可见
|
2024-12-05 10:17:12 +08:00
|
|
|
|
if (chief || po.getSystemType() == 1) {
|
2024-12-04 17:45:56 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//私有,只能自己看到
|
|
|
|
|
|
if (sharedTypeEnum == SharedTypeEnum.PRIVATE) {
|
|
|
|
|
|
return Objects.equals((long) user.getUID(), po.getCreator());
|
|
|
|
|
|
}
|
|
|
|
|
|
//共享
|
|
|
|
|
|
if (sharedTypeEnum == SharedTypeEnum.PUBLIC) {
|
2024-12-04 09:13:41 +08:00
|
|
|
|
List<Long> limitIds = po.getLimitIds();
|
2024-12-04 17:45:56 +08:00
|
|
|
|
return CollectionUtil.isEmpty(limitIds) || CollectionUtil.intersection(limitIds, taxIds).size() != 0;
|
2024-12-04 09:13:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
return true;
|
2025-02-07 10:13:29 +08:00
|
|
|
|
}).map(po -> {
|
|
|
|
|
|
Integer fileId = po.getFileId();
|
|
|
|
|
|
String fileName = "";
|
|
|
|
|
|
if (fileId != null) {
|
|
|
|
|
|
ImageFileManager imageFileManager = new ImageFileManager();
|
|
|
|
|
|
imageFileManager.getImageFileInfoById(fileId);
|
|
|
|
|
|
fileName = imageFileManager.getImageFileName();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return PageListTemplateDTO.builder()
|
|
|
|
|
|
.id(po.getId())
|
|
|
|
|
|
.page(po.getPage())
|
|
|
|
|
|
.name(po.getName())
|
|
|
|
|
|
.sharedType(po.getSharedType())
|
|
|
|
|
|
.systemType(po.getSystemType())
|
|
|
|
|
|
.sharedTypeName(SharedTypeEnum.parseByValue(po.getSharedType()).getDefaultLabel())
|
|
|
|
|
|
.systemTypeName(po.getSystemType() == 1 ? "系统模板" : "自定义")
|
|
|
|
|
|
.limits(CollUtil.isEmpty(po.getLimitIds()) ? "所有" : Optional.ofNullable(po.getLimitIds()).orElse(new ArrayList<>()).stream().map(id -> idNameMap.getOrDefault(id, "")).collect(Collectors.joining(",")))
|
|
|
|
|
|
.limitIds(CollUtil.isEmpty(po.getLimitIds()) ? new ArrayList<>() : po.getLimitIds())
|
|
|
|
|
|
.setting(po.getSetting())
|
|
|
|
|
|
.canEdit(chief || (Objects.equals((long) user.getUID(), po.getCreator()) && po.getSystemType() == 0))
|
|
|
|
|
|
.fileId(fileId)
|
|
|
|
|
|
.fileName(fileName)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
})
|
2024-12-04 09:13:41 +08:00
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), templateDTOS, PageListTemplateDTO.class);
|
|
|
|
|
|
}
|
2024-12-04 10:14:39 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deletePageListTemplate(PageListTemplateDeleteParam param) {
|
|
|
|
|
|
List<Long> ids = param.getIds();
|
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(ids)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("未选择模板!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ids.forEach(id -> {
|
|
|
|
|
|
PageListTemplatePO pageListTemplatePO = getPageListTemplateMapper().getById(id);
|
|
|
|
|
|
if (pageListTemplatePO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("模板不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (pageListTemplatePO.getSystemType() == 1) {
|
|
|
|
|
|
throw new SalaryRunTimeException("系统模板不允许删除!");
|
|
|
|
|
|
}
|
2024-12-04 17:45:56 +08:00
|
|
|
|
if (!Objects.equals((long) user.getUID(), pageListTemplatePO.getCreator())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(pageListTemplatePO.getName() + "模板无权限删除!");
|
|
|
|
|
|
}
|
2024-12-04 10:14:39 +08:00
|
|
|
|
List<PageLinkPO> pageLinkPOS = getPageLinkMapper().listSome(PageLinkPO.builder().templateId(id).build());
|
|
|
|
|
|
if (CollUtil.isNotEmpty(pageLinkPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(pageListTemplatePO.getName() + "模板正被使用!不允许删除");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
getPageListTemplateMapper().deleteByIds(ids);
|
|
|
|
|
|
}
|
2024-10-11 15:34:17 +08:00
|
|
|
|
}
|