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;
|
|
|
|
|
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-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;
|
2024-11-04 19:49:46 +08:00
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪资核算
|
|
|
|
|
* <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) {
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
PageListSettingPO pageListSettingPO = getPageListSettingMapper().getByPage(pageListSettingSaveParam.getPage());
|
2024-11-19 09:48:13 +08:00
|
|
|
List<Long> 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 {
|
|
|
|
|
pageListSettingPO = PageListSettingPO.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.page(pageListSettingSaveParam.getPage())
|
2024-11-19 09:48:13 +08:00
|
|
|
.setting(checked)
|
2024-10-11 15:34:17 +08:00
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
.createTime(now)
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
.build();
|
|
|
|
|
getPageListSettingMapper().insertIgnoreNull(pageListSettingPO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-10-11 17:04:13 +08:00
|
|
|
public Map getPageListSetting(PageListSettingQueryParam param) {
|
|
|
|
|
String page = param.getPage();
|
2024-10-11 15:34:17 +08:00
|
|
|
Map result = new HashMap();
|
|
|
|
|
PageListSettingPO pageListSettingPO = getPageListSettingMapper().getByPage(page);
|
2024-11-04 19:49:46 +08:00
|
|
|
if (SALARY_DETAILS_REPORT.getValue().equals(page)) {
|
2024-10-11 15:34:17 +08:00
|
|
|
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listAll();
|
|
|
|
|
salaryItemList = salaryItemList.stream()
|
2024-10-11 17:04:13 +08:00
|
|
|
.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);
|
2024-10-11 15:34:17 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
result.put("setting", salaryItemList);
|
2024-11-07 17:45:17 +08:00
|
|
|
if (pageListSettingPO != null && CollUtil.isNotEmpty(pageListSettingPO.getSetting())) {
|
|
|
|
|
result.put("checked", pageListSettingPO.getSetting());
|
2024-10-11 15:34:17 +08:00
|
|
|
} else {
|
|
|
|
|
List<Long> collect = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
|
|
|
|
result.put("checked", collect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2024-11-04 19:49:46 +08:00
|
|
|
|
|
|
|
|
@Override
|
2024-11-07 17:45:17 +08:00
|
|
|
public PageListTemplateDTO getPageListTemplate(PageListTemplateQueryParam param) {
|
|
|
|
|
String page = param.getPage();
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
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"));
|
|
|
|
|
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();
|
|
|
|
|
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-04 19:49:46 +08:00
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
columns.addAll(collect);
|
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);
|
|
|
|
|
List<WeaTableColumn> checkedList = new ArrayList<>();
|
|
|
|
|
if (id != null) {
|
|
|
|
|
PageListTemplatePO po = getPageListTemplateMapper().getById(id);
|
|
|
|
|
if (po != null) {
|
|
|
|
|
checkedList = Optional.ofNullable(po.getSetting()).orElse(new ArrayList<>())
|
|
|
|
|
.stream()
|
|
|
|
|
.map(s -> columnMap.getOrDefault(s, new WeaTableColumn()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return PageListTemplateDTO.builder().setting(columns).checked(checkedList).build();
|
2024-11-04 19:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-07 17:45:17 +08:00
|
|
|
return PageListTemplateDTO.builder().build();
|
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
|
|
String page = param.getPage();
|
|
|
|
|
|
|
|
|
|
PageListTemplatePO build = PageListTemplatePO.builder().page(page).build();
|
|
|
|
|
List<PageListTemplatePO> pos = getPageListTemplateMapper().listSome(build);
|
|
|
|
|
|
|
|
|
|
//获取当前选择的模板
|
|
|
|
|
PageLinkPO link = getPageLinkMapper().getLink((long) user.getUID(), SALARY_DETAILS_REPORT.getValue());
|
|
|
|
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService().listAllTaxAgents((long) user.getUID());
|
2024-11-11 16:58:16 +08:00
|
|
|
List<String> taxIds = SalaryEntityUtil.properties(taxAgentPOS, po -> po.getId().toString(), Collectors.toList());
|
2024-11-07 17:45:17 +08:00
|
|
|
pos = pos.stream()
|
2024-11-11 16:58:16 +08:00
|
|
|
.filter(po -> {
|
|
|
|
|
if (po.getSharedType() == 1) {
|
2024-11-11 18:03:31 +08:00
|
|
|
List limitIds = po.getLimitIds();
|
|
|
|
|
List<String> collect = new ArrayList<>();
|
2024-11-11 16:58:16 +08:00
|
|
|
for (int i = 0; i < limitIds.size(); i++) {
|
|
|
|
|
collect.add(limitIds.get(i).toString());
|
|
|
|
|
}
|
|
|
|
|
return CollectionUtil.isNotEmpty(limitIds) && CollectionUtil.intersection(collect, taxIds).size() != 0;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
})
|
2024-11-07 17:45:17 +08:00
|
|
|
.peek(po -> {
|
|
|
|
|
po.setChecked(link != null && po.getId().equals(link.getTemplateId()));
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
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-11-07 17:45:17 +08:00
|
|
|
po = PageListTemplatePO.builder()
|
2024-11-04 19:49:46 +08:00
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.page(param.getPage())
|
2024-11-07 17:45:17 +08:00
|
|
|
.name(param.getName())
|
|
|
|
|
.sharedType(param.getSharedType())
|
|
|
|
|
.limitIds(param.getLimitIds())
|
|
|
|
|
.setting(param.getSetting())
|
2024-11-04 19:49:46 +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());
|
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
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
getPageLinkMapper().insertIgnoreNull(pageLinkPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<WeaTableColumn> getPageListColumns(String page) {
|
|
|
|
|
PageLinkPO link = getPageLinkMapper().getLink((long) user.getUID(), page);
|
|
|
|
|
if (link != null) {
|
|
|
|
|
PageListTemplateDTO pageListTemplate = getPageListTemplate(PageListTemplateQueryParam.builder().page(page).id(link.getTemplateId()).build());
|
|
|
|
|
return pageListTemplate.getChecked();
|
2024-11-11 16:58:16 +08:00
|
|
|
} else {
|
2024-11-07 17:45:17 +08:00
|
|
|
PageListTemplateDTO pageListTemplate = getPageListTemplate(PageListTemplateQueryParam.builder().page(page).build());
|
|
|
|
|
return pageListTemplate.getSetting();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-11 15:34:17 +08:00
|
|
|
}
|