604 lines
27 KiB
Java
604 lines
27 KiB
Java
package com.engine.salary.wrapper;
|
||
|
||
import com.api.browser.bean.SearchConditionGroup;
|
||
import com.api.browser.bean.SearchConditionItem;
|
||
import com.api.browser.bean.SearchConditionOption;
|
||
import com.api.browser.util.ConditionFactory;
|
||
import com.api.browser.util.ConditionType;
|
||
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
||
import com.cloudstore.eccom.pc.table.WeaTable;
|
||
import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom;
|
||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||
import com.engine.common.util.ServiceUtil;
|
||
import com.engine.core.impl.Service;
|
||
import com.engine.salary.constant.SalaryItemConstant;
|
||
import com.engine.salary.entity.salaryBill.dto.*;
|
||
import com.engine.salary.entity.salaryBill.param.*;
|
||
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
|
||
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
|
||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||
import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO;
|
||
import com.engine.salary.enums.UserStatusEnum;
|
||
import com.engine.salary.enums.salarybill.SalarySendStatusEnum;
|
||
import com.engine.salary.exception.SalaryRunTimeException;
|
||
import com.engine.salary.mapper.salarybill.SalarySendMapper;
|
||
import com.engine.salary.service.SalarySendService;
|
||
import com.engine.salary.service.SalarySobService;
|
||
import com.engine.salary.service.SalaryTemplateService;
|
||
import com.engine.salary.service.TaxAgentService;
|
||
import com.engine.salary.service.impl.SalarySendServiceImpl;
|
||
import com.engine.salary.service.impl.SalarySobServiceImpl;
|
||
import com.engine.salary.service.impl.SalaryTemplateServiceImpl;
|
||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||
import com.engine.salary.util.SalaryDateUtil;
|
||
import com.engine.salary.util.SalaryEntityUtil;
|
||
import com.engine.salary.util.SalaryI18nUtil;
|
||
import com.engine.salary.util.page.PageInfo;
|
||
import com.engine.salary.util.page.SalaryPageUtil;
|
||
import org.apache.commons.collections.CollectionUtils;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
import org.apache.commons.lang3.math.NumberUtils;
|
||
import org.apache.ibatis.session.SqlSession;
|
||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||
import weaver.conn.mybatis.MyBatisFactory;
|
||
import weaver.hrm.User;
|
||
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
import java.util.stream.Collectors;
|
||
|
||
/**
|
||
* @Description: 工资单发放
|
||
* @Author: wangxiangzhong
|
||
* @Date: 2022/3/16 13:57
|
||
*/
|
||
public class SalarySendWrapper extends Service {
|
||
private TaxAgentService getTaxAgentService(User user) {
|
||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||
}
|
||
|
||
private SalarySendService getSalarySendService(User user) {
|
||
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
|
||
}
|
||
|
||
private SalaryTemplateService getSalaryTemplateService(User user) {
|
||
return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user);
|
||
}
|
||
|
||
private SalarySobService getSalarySobService(User user) {
|
||
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
||
}
|
||
|
||
/**
|
||
* 工资单发放列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public Map<String, Object> list(SalarySendQueryParam queryParam) {
|
||
long currentEmployeeId = user.getUID();
|
||
|
||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||
Map<String, Object> datas = new HashMap<>(16);
|
||
try {
|
||
queryParam.setSalaryMonth(queryParam.getSalaryYearMonth().stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
||
queryParam.setSalaryMonthDate(queryParam.getSalaryYearMonth().stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
||
//分权,获取当前人员管理的账套
|
||
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
|
||
List<SalarySendListDTO> list = new ArrayList<>();
|
||
if (needAuth) {
|
||
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO);
|
||
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
||
if (CollectionUtils.isNotEmpty(salarySobIds)) {
|
||
queryParam.setSalarySobIds(salarySobIds);
|
||
SalarySendMapper salarySendMapper = sqlSession.getMapper(SalarySendMapper.class);
|
||
list = salarySendMapper.list(queryParam);
|
||
}
|
||
} else {
|
||
SalarySendMapper salarySendMapper = sqlSession.getMapper(SalarySendMapper.class);
|
||
list = salarySendMapper.list(queryParam);
|
||
}
|
||
|
||
PageInfo<SalarySendListDTO> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
|
||
list, SalarySendListDTO.class);
|
||
List<SalarySendListDTO> pageList = pageInfo.getList();
|
||
List<Long> salarySobIds = pageList.stream().map(SalarySendListDTO::getSalarySobId).distinct().collect(Collectors.toList());
|
||
// 获取默认模板
|
||
if (salarySobIds.size() > 0) {
|
||
List<SalaryTemplatePO> salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(salarySobIds);
|
||
pageList.forEach(e -> {
|
||
// 已发放
|
||
e.setSendSituation(e.getSendNum() + "/" + e.getSendTotal());
|
||
// 工资单模板
|
||
Optional<SalaryTemplatePO> optional = salaryTemplates.stream().filter(s -> s.getSalarySobId().equals(e.getSalarySobId())).findFirst();
|
||
if (optional.isPresent()) {
|
||
e.setTemplate(optional.get().getName());
|
||
e.setTemplateId(optional.get().getId());
|
||
}
|
||
});
|
||
}
|
||
|
||
List<WeaTableColumn> columns = buildWeaTableColumns();
|
||
WeaTable table = new WeaTable();
|
||
table.setColumns(columns);
|
||
//设置check是否可用
|
||
List<WeaTableCheckboxpopedom> checkboxpopedomList = new ArrayList<>();
|
||
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
|
||
checkboxpopedom.setPopedompara("column:system_type");
|
||
checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom");
|
||
checkboxpopedomList.add(checkboxpopedom);
|
||
table.setCheckboxList(checkboxpopedomList);
|
||
table.setCheckboxpopedom(null);
|
||
|
||
WeaResultMsg result = new WeaResultMsg(false);
|
||
result.putAll(table.makeDataResult());
|
||
result.success();
|
||
|
||
datas.put("pageInfo", pageInfo);
|
||
datas.put("datas", pageList);
|
||
datas.put("columns", columns);
|
||
datas.put("dataKey", result.getResultMap());
|
||
return datas;
|
||
} catch (Exception e) {
|
||
throw new SalaryRunTimeException(e.getMessage());
|
||
} finally {
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 创建表展示字段
|
||
*
|
||
* @return
|
||
*/
|
||
private List<WeaTableColumn> buildWeaTableColumns() {
|
||
List<WeaTableColumn> list = new ArrayList<>();
|
||
WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id");
|
||
idColumn.setDisplay(WeaBoolAttr.FALSE);
|
||
list.add(new WeaTableColumn("10%", "薪资所属月", "salaryYearMonth"));
|
||
list.add(new WeaTableColumn("35%", "薪资账套", "salarySob"));
|
||
list.add(new WeaTableColumn("25%", "工资单模板", "template"));
|
||
list.add(new WeaTableColumn("15%", "已发放", "sendSituation"));
|
||
list.add(new WeaTableColumn("15%", "最后发送时间", "lastSendTime"));
|
||
return list;
|
||
}
|
||
|
||
/**
|
||
* 工资单发放基本信息
|
||
*
|
||
* @param id
|
||
* @return
|
||
*/
|
||
public SalarySendBaseInfoDTO getBaseInfo(Long id) {
|
||
return getSalarySendService(user).getBaseInfo(id);
|
||
}
|
||
|
||
/**
|
||
* 工资单发放信息列表的高级搜索
|
||
*
|
||
* @return
|
||
*/
|
||
public Map<String, Object> getInfoSearchCondition() {
|
||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||
ConditionFactory conditionFactory = new ConditionFactory(user);
|
||
|
||
//条件组
|
||
List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
|
||
List<SearchConditionItem> conditionItems = new ArrayList<SearchConditionItem>();
|
||
|
||
//文本输入框
|
||
SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");
|
||
username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
username.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
username.setLabelcol(8);
|
||
username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值
|
||
username.setInputType("");
|
||
conditionItems.add(username);
|
||
|
||
// 个税扣缴义务人
|
||
SearchConditionItem taxAgent = conditionFactory.createCondition(ConditionType.SELECT, 25034, "taxAgentId");
|
||
taxAgent.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
taxAgent.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
taxAgent.setLabelcol(8);
|
||
List<SearchConditionOption> searchConditionOptions = new ArrayList<>();
|
||
Collection<TaxAgentListDTO> taxAgentLists = getTaxAgentService(user).findAll();
|
||
taxAgentLists.forEach(e -> searchConditionOptions.add(new SearchConditionOption(e.getId().toString(), e.getName())));
|
||
taxAgent.setOptions(searchConditionOptions);
|
||
taxAgent.setInputType("");
|
||
taxAgent.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
taxAgent.setLabel("个税扣缴义务人"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(taxAgent);
|
||
|
||
// 部门
|
||
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "4");
|
||
departmentName.setColSpan(2);
|
||
departmentName.setFieldcol(16);
|
||
departmentName.setLabelcol(8);
|
||
departmentName.setViewAttr(2);
|
||
departmentName.setIsQuickSearch(false);
|
||
departmentName.setLabel("部门");
|
||
departmentName.setInputType("");
|
||
conditionItems.add(departmentName);
|
||
|
||
// 岗位
|
||
SearchConditionItem position = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "positionIds", "24");
|
||
position.setColSpan(2);
|
||
position.setFieldcol(16);
|
||
position.setLabelcol(8);
|
||
position.setViewAttr(2);
|
||
position.setIsQuickSearch(false);
|
||
position.setLabel("岗位");
|
||
position.setInputType("");
|
||
conditionItems.add(position);
|
||
|
||
//状态
|
||
SearchConditionItem status = conditionFactory.createCondition(ConditionType.SELECT, 25034, "userstatus");
|
||
status.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
status.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
status.setLabelcol(8);
|
||
List<SearchConditionOption> userStatusOptions = new ArrayList<>();
|
||
UserStatusEnum.getList().forEach(e -> userStatusOptions.add(new SearchConditionOption(e.get("id"), e.get("content"))));
|
||
status.setOptions(userStatusOptions);
|
||
status.setInputType("");
|
||
status.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
status.setLabel("状态"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(status);
|
||
|
||
//发送状态
|
||
SearchConditionItem sendStatus = conditionFactory.createCondition(ConditionType.SELECT, 25034, "sendStatusVal");
|
||
sendStatus.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
sendStatus.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
sendStatus.setLabelcol(8);
|
||
List<SearchConditionOption> sendStatusOptions = new ArrayList<>();
|
||
Arrays.asList(SalarySendStatusEnum.values())
|
||
.forEach(e -> sendStatusOptions.add(new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel())));
|
||
sendStatus.setOptions(sendStatusOptions);
|
||
sendStatus.setInputType("");
|
||
sendStatus.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
sendStatus.setLabel("发送状态"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(sendStatus);
|
||
|
||
addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems));
|
||
|
||
apidatas.put("condition", addGroups);
|
||
return apidatas;
|
||
}
|
||
|
||
/**
|
||
* 工资单发放信息列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public PageInfo<SalarySendInfoListDTO> infoList(SalarySendInfoQueryParam queryParam) {
|
||
|
||
SalarySendInfoQueryParam.checkParam(queryParam);
|
||
// 发送状态
|
||
if (queryParam.getSendStatus() != null) {
|
||
queryParam.setSendStatusVal(queryParam.getSendStatus().getValue());
|
||
}
|
||
|
||
PageInfo<SalarySendInfoListDTO> pageInfo = getSalarySendService(user).salarySendInfoListPage(queryParam);
|
||
List<SalarySendInfoListDTO> list = pageInfo.getList();
|
||
list.forEach(e -> {
|
||
// 发放状态
|
||
int sendStatus = Integer.parseInt(e.getSendStatus());
|
||
e.setSendStatus(SalarySendStatusEnum.getDefaultLabelByValue(sendStatus));
|
||
// e.setOperation(SalarySendStatusEnum.getNameByValue(sendStatus));
|
||
});
|
||
|
||
return pageInfo;
|
||
}
|
||
|
||
/**
|
||
* 工资单信息列表
|
||
*
|
||
* @return
|
||
*/
|
||
private List<WeaTableColumn> buildInfoListWeaTableColumns() {
|
||
List<WeaTableColumn> list = new ArrayList<>();
|
||
WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id");
|
||
idColumn.setDisplay(WeaBoolAttr.TRUE);
|
||
list.add(new WeaTableColumn("20%", "姓名", "username"));
|
||
list.add(new WeaTableColumn("20%", "个税扣缴义务人", "taxAgent"));
|
||
list.add(new WeaTableColumn("20%", "部门", "department"));
|
||
list.add(new WeaTableColumn("20%", "手机号", "mobile"));
|
||
list.add(new WeaTableColumn("20%", "工号", "jobNum"));
|
||
list.add(new WeaTableColumn("20%", "发送状态", "sendStatus"));
|
||
list.add(new WeaTableColumn("20%", "操作", "operation"));
|
||
return list;
|
||
}
|
||
|
||
|
||
/**
|
||
* 导出-工资单发放信息列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam) {
|
||
return getSalarySendService(user).exportInfoList(queryParam);
|
||
}
|
||
|
||
/**
|
||
* 工资单发放
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public Map<String, Object> grant(SalarySendGrantParam queryParam) {
|
||
return getSalarySendService(user).grant(queryParam);
|
||
}
|
||
|
||
/**
|
||
* 工资单撤回
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public Map<String, Object> withdraw(SalarySendWithdrawParam queryParam) {
|
||
return getSalarySendService(user).withdraw(queryParam);
|
||
}
|
||
|
||
/**
|
||
* 工资单发放详情列表的高级搜索
|
||
*
|
||
* @return
|
||
*/
|
||
public Map<String, Object> getDetailSearchCondition() {
|
||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||
ConditionFactory conditionFactory = new ConditionFactory(user);
|
||
|
||
//条件组
|
||
List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
|
||
List<SearchConditionItem> conditionItems = new ArrayList<SearchConditionItem>();
|
||
|
||
//文本输入框
|
||
SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");
|
||
username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
username.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
username.setLabelcol(8);
|
||
username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值
|
||
username.setInputType("");
|
||
conditionItems.add(username);
|
||
|
||
// 个税扣缴义务人
|
||
SearchConditionItem taxAgent = conditionFactory.createCondition(ConditionType.SELECT, 25034, "taxAgent");
|
||
taxAgent.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
taxAgent.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
taxAgent.setLabelcol(8);
|
||
List<SearchConditionOption> searchConditionOptions = new ArrayList<>();
|
||
Collection<TaxAgentListDTO> taxAgentLists = getTaxAgentService(user).findAll();
|
||
taxAgentLists.forEach(e -> searchConditionOptions.add(new SearchConditionOption(e.getId().toString(), e.getName())));
|
||
taxAgent.setOptions(searchConditionOptions);
|
||
taxAgent.setInputType("");
|
||
taxAgent.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
taxAgent.setLabel("个税扣缴义务人"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(taxAgent);
|
||
|
||
// 部门
|
||
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "department", "4");
|
||
departmentName.setColSpan(2);
|
||
departmentName.setFieldcol(16);
|
||
departmentName.setLabelcol(8);
|
||
departmentName.setViewAttr(2);
|
||
departmentName.setInputType("");
|
||
departmentName.setIsQuickSearch(false);
|
||
departmentName.setLabel("部门");
|
||
conditionItems.add(departmentName);
|
||
|
||
// 岗位
|
||
SearchConditionItem position = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "position", "24");
|
||
position.setColSpan(2);
|
||
position.setFieldcol(16);
|
||
position.setInputType("");
|
||
position.setLabelcol(8);
|
||
position.setViewAttr(2);
|
||
position.setIsQuickSearch(false);
|
||
position.setLabel("岗位");
|
||
conditionItems.add(position);
|
||
|
||
//状态
|
||
SearchConditionItem status = conditionFactory.createCondition(ConditionType.SELECT, 25034, "userstatus");
|
||
status.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
status.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
status.setLabelcol(8);
|
||
List<SearchConditionOption> userStatusOptions = new ArrayList<>();
|
||
UserStatusEnum.getList().forEach(e -> userStatusOptions.add(new SearchConditionOption(e.get("id"), e.get("content"))));
|
||
status.setOptions(userStatusOptions);
|
||
status.setInputType("");
|
||
status.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
status.setLabel("状态"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(status);
|
||
|
||
// //入职日期
|
||
// SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 25034, "hiredate");
|
||
// hiredate.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
// hiredate.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
// hiredate.setLabelcol(8);
|
||
// hiredate.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
// Map<String, Object> otherParams1 = new HashMap<String, Object>();
|
||
// otherParams1.put("format", "yyyy-MM-dd");
|
||
// hiredate.setOtherParams(otherParams1);
|
||
// hiredate.setInputType("day");
|
||
// hiredate.setMode("day");
|
||
// hiredate.setLabel("入职日期"); //设置文本值 这个将覆盖多语言标签的值
|
||
// conditionItems.add(hiredate);
|
||
|
||
//合并计税
|
||
SearchConditionItem mergeCountTax = conditionFactory.createCondition(ConditionType.CHECKBOX, 25034, "mergeCountTax");
|
||
mergeCountTax.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
||
mergeCountTax.setFieldcol(16); //条件输入框所占宽度,默认值18
|
||
mergeCountTax.setLabelcol(8);
|
||
mergeCountTax.setInputType("switch");
|
||
mergeCountTax.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
||
mergeCountTax.setLabel("合并计税"); //设置文本值 这个将覆盖多语言标签的值
|
||
conditionItems.add(mergeCountTax);
|
||
|
||
addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems));
|
||
|
||
apidatas.put("condition", addGroups);
|
||
return apidatas;
|
||
}
|
||
|
||
/**
|
||
* 工资单发放详情列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public Map<String, Object> detailList(SalarySendDetailQueryParam queryParam) {
|
||
Map<String, Object> datas = new HashMap<>();
|
||
SalarySendDetailQueryParam.checkParam(queryParam);
|
||
SalarySendPO salarySend = getSalarySendService(user).getById(queryParam.getSalarySendId());
|
||
|
||
if (salarySend == null) {
|
||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100510, "工资发放不存在"));
|
||
}
|
||
|
||
// 1.根据模板获取薪资项目设置
|
||
List<SalaryTemplatePO> salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySend.getSalarySobId()));
|
||
List<SalaryTemplateSalaryItemListDTO> salaryItems = getSalarySendService(user).getSalaryItemsSetting(CollectionUtils.isNotEmpty(salaryTemplates) ? salaryTemplates.get(0) : null);
|
||
|
||
// 2.获取基本数据
|
||
PageInfo<SalarySendDetailListDTO> pageInfo = getSalarySendService(user).salarySendInfoDetailListPage(queryParam);
|
||
|
||
List<SalarySendDetailListDTO> records = pageInfo.getList();
|
||
// 3.组装详情数据
|
||
List<Map<String, Object>> listMaps = getSalarySendService(user).buildDetailList(salaryItems, records, salarySend.getSalaryAccountingId());
|
||
|
||
List<WeaTableColumn> columns = buildDetailListWeaTableColumns();
|
||
|
||
for (SalaryTemplateSalaryItemListDTO salaryItem : salaryItems) {
|
||
columns.add(new WeaTableColumn("100px", salaryItem.getName(), salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX));
|
||
}
|
||
|
||
|
||
WeaTable table = new WeaTable();
|
||
table.setColumns(columns);
|
||
//设置check是否可用
|
||
List<WeaTableCheckboxpopedom> checkboxpopedomList = new ArrayList<>();
|
||
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
|
||
checkboxpopedom.setPopedompara("column:system_type");
|
||
checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom");
|
||
checkboxpopedomList.add(checkboxpopedom);
|
||
table.setCheckboxList(checkboxpopedomList);
|
||
table.setCheckboxpopedom(null);
|
||
|
||
WeaResultMsg result = new WeaResultMsg(false);
|
||
result.putAll(table.makeDataResult());
|
||
result.success();
|
||
|
||
datas.put("pageInfo", pageInfo);
|
||
datas.put("datas", listMaps);
|
||
datas.put("columns", columns);
|
||
datas.put("dataKey", result.getResultMap());
|
||
|
||
return datas;
|
||
}
|
||
|
||
private List<WeaTableColumn> buildDetailListWeaTableColumns() {
|
||
List<WeaTableColumn> list = new ArrayList<>();
|
||
WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id");
|
||
idColumn.setDisplay(WeaBoolAttr.TRUE);
|
||
list.add(new WeaTableColumn("100px", "姓名", "username"));
|
||
list.add(new WeaTableColumn("100px", "个税扣缴义务人", "taxAgent"));
|
||
list.add(new WeaTableColumn("100px", "部门", "department"));
|
||
list.add(new WeaTableColumn("100px", "手机号", "mobile"));
|
||
list.add(new WeaTableColumn("100px", "工号", "jobNum"));
|
||
return list;
|
||
}
|
||
|
||
/**
|
||
* 导出-工资单发放详情列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public XSSFWorkbook exportDetailList(SalarySendDetailQueryParam queryParam) {
|
||
// 获取发放详情
|
||
SalarySendDetailQueryParam.checkParam(queryParam);
|
||
|
||
SalarySendPO salarySend = getSalarySendService(user).getById(queryParam.getSalarySendId());
|
||
if (salarySend == null) {
|
||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在"));
|
||
}
|
||
|
||
return getSalarySendService(user).exportDetailList(salarySend, queryParam);
|
||
}
|
||
|
||
/**
|
||
* 我的工资单列表
|
||
*
|
||
* @param queryParam
|
||
* @return
|
||
*/
|
||
public Map<String, Object> mySalaryBillList(SalaryBillQueryParam queryParam) {
|
||
Map<String, Object> datas = new HashMap<>();
|
||
queryParam.setEmployeeId((long) user.getUID());
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||
queryParam.setSalaryMonth(
|
||
queryParam.getSalaryYearMonth().stream().map(e -> {
|
||
try {
|
||
return simpleDateFormat.parse(e + "-01");
|
||
} catch (ParseException parseException) {
|
||
throw new SalaryRunTimeException("日期转换错误");
|
||
}
|
||
}).collect(Collectors.toList()));
|
||
PageInfo<SalaryMySalaryBillListDTO> pageInfo = getSalarySendService(user).mySalaryBillListPage(queryParam);
|
||
List<SalaryMySalaryBillListDTO> records = pageInfo.getList();
|
||
|
||
records.forEach(e -> {
|
||
e.setTaxAgent(StringUtils.isEmpty(e.getTaxAgent()) ? "" : e.getTaxAgent());
|
||
e.setAcctTimes(e.getAcctTimes());
|
||
});
|
||
List<WeaTableColumn> columns = buildMySalaryBillListColumns();
|
||
WeaTable table = new WeaTable();
|
||
table.setColumns(columns);
|
||
//设置check是否可用
|
||
List<WeaTableCheckboxpopedom> checkboxpopedomList = new ArrayList<>();
|
||
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
|
||
checkboxpopedom.setPopedompara("column:system_type");
|
||
checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom");
|
||
checkboxpopedomList.add(checkboxpopedom);
|
||
table.setCheckboxList(checkboxpopedomList);
|
||
table.setCheckboxpopedom(null);
|
||
|
||
WeaResultMsg result = new WeaResultMsg(false);
|
||
result.putAll(table.makeDataResult());
|
||
result.success();
|
||
|
||
datas.put("pageInfo", pageInfo);
|
||
datas.put("datas", records);
|
||
datas.put("columns", columns);
|
||
datas.put("dataKey", result.getResultMap());
|
||
|
||
return datas;
|
||
}
|
||
|
||
private List<WeaTableColumn> buildMySalaryBillListColumns() {
|
||
List<WeaTableColumn> list = new ArrayList<>();
|
||
WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id");
|
||
idColumn.setDisplay(WeaBoolAttr.TRUE);
|
||
list.add(new WeaTableColumn("20%", "薪资所属月", "salaryYearMonth"));
|
||
list.add(new WeaTableColumn("40%", "个税扣缴义务人", "taxAgent"));
|
||
list.add(new WeaTableColumn("40%", "发放时间", "sendTime"));
|
||
return list;
|
||
}
|
||
|
||
|
||
/**
|
||
* 我的工资单
|
||
*
|
||
* @param salaryInfoId
|
||
* @return
|
||
*/
|
||
public Map<String, Object> mySalaryBill(Long salaryInfoId) {
|
||
return getSalarySendService(user).mySalaryBill(salaryInfoId, (long) user.getUID());
|
||
}
|
||
}
|