Merge branch 'release/2.7.3.2304.01' into feature/外部人员

# Conflicts:
#	src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java
This commit is contained in:
钱涛 2023-04-11 11:41:30 +08:00
commit e8ae952f18
35 changed files with 1154 additions and 196 deletions

View File

@ -1002,7 +1002,7 @@ public class SIArchivesBiz {
log.info("buildWeaTableColumns方法处理福利档案列表数据开始");
sw.start("buildWeaTableColumns方法处理福利档案列表数据");
List<WeaTableColumn> columns = buildWeaTableColumns(page, operateId);
List<WeaTableColumn> columns = buildWeaTableColumns(pageInfo.getList(), operateId);
sw.stop();
log.info("buildWeaTableColumns方法处理福利档案列表数据完成");
WeaTable table = new WeaTable();

View File

@ -140,4 +140,18 @@ public class SalarySobItemBiz {
}
public void batchInsertItemShow(List<SalarySobItemHidePO> list) {
if (CollectionUtils.isEmpty(list)) {
return;
}
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class);
List<List<SalarySobItemHidePO>> partition = Lists.partition( list, 100);
partition.forEach(mapper::batchInsertItemShow);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -90,7 +90,7 @@ public class SpecialAddDeductionBiz extends BaseBean {
try {
SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class);
encryptUtil.encryptList(param, SpecialAddDeductionPO.class);
List<List<SpecialAddDeductionPO>> partition = Lists.partition(param, 100);
List<List<SpecialAddDeductionPO>> partition = Lists.partition(param, 50);
partition.forEach(mapper::updateBatchSelective);
sqlSession.commit();
} finally {

View File

@ -14,4 +14,11 @@ public class SalaryItemConstant {
* 列表中薪资项目动态列后缀标识
*/
public static final String DYNAMIC_SUFFIX = "_salaryItem";
/**
* 薪资核算导入缓存表头字段key
*/
public static final String RESULT_IMPORT_FIELD_SIGN="_salaryAcctResultImportFieldSign";
}

View File

@ -4,10 +4,14 @@ import com.engine.salary.sys.constant.SalarySysConstant;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.enums.OpenEnum;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.wbi.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.general.AES;
import weaver.general.BaseBean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 此AES加密工具类仅用于关联应用设置中是否开启加密的应用使用
* 如另有需要请重写工具类
@ -77,12 +81,58 @@ public class AESEncryptUtil {
*/
public static String closeEncryptSetting(String encryptStr) {
SalarySysConfPO sysConfPo = salarySysConfService.getOneByCode(SalarySysConstant.OPEN_APPLICATION_ENCRYPT);
if (StringUtils.isNotBlank(encryptStr) && encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
encryptStr = encryptStr.substring(4, encryptStr.length());
return AES.decrypt(encryptStr, aesEncryptScrect);
} else if (sysConfPo == null && StringUtils.isNotBlank(encryptStr)) {
return AES.decrypt(encryptStr, aesEncryptScrect);
// if (StringUtils.isNotBlank(encryptStr) && encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
// encryptStr = encryptStr.substring(4, encryptStr.length());
// return AES.decrypt(encryptStr, aesEncryptScrect);
// } else if (sysConfPo == null && StringUtils.isNotBlank(encryptStr)) {
// return AES.decrypt(encryptStr, aesEncryptScrect);
// }
// return encryptStr;
if (encryptStr == null) {
return null;
} else {
//AES_前缀的密文
if (encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
encryptStr = encryptStr.substring(4, encryptStr.length());
return AES.decrypt(encryptStr, aesEncryptScrect);
} else if (isNumeric(encryptStr) || checkHaveChinese(encryptStr) || encryptStr.startsWith("{") || encryptStr.contains("-") || encryptStr.contains(".")) {
return encryptStr;
} else if ("null".equals(encryptStr) || StringUtils.isBlank(encryptStr)) {
return encryptStr;
} else if (sysConfPo == null || sysConfPo.getConfValue().equals(OpenEnum.OFF.getValue())) {
return AES.decrypt(encryptStr, aesEncryptScrect);
} else {
return encryptStr;
}
}
return encryptStr;
}
/**
* 判断字符串是否为整数或者小数或者负数
*/
public static boolean isNumeric(String str) {
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
}
/**
* 判断字符串是否包含中文字符
*/
public static boolean checkHaveChinese(String countname) {
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(countname);
if (m.find()) {
return true;
}
return false;
}
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.List;
/**
* 薪资核算导入时生成导入模板的薪资项目
@ -30,6 +31,9 @@ public class SalaryAcctImportFieldDTO {
//输入项
private Collection<ImportFieldDTO> inputItems;
// 缓存勾选项目
private List<Long> checkItems;
@Data
@Builder
@NoArgsConstructor

View File

@ -6,6 +6,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* <p>Copyright: Copyright (c) 2022</p>
@ -28,4 +30,7 @@ public class SalaryAcctImportParam {
@DataCheck(require = true,message = "薪资核算记录id为空")
Long salaryAcctRecordId;
// 导入表单字段缓存项目
List<Long> salaryItems;
}

View File

@ -715,6 +715,7 @@ public class TaxDeclarationBO {
private static String findStringValue(String fieldCode, Map<Long, List<SalaryAcctResultPO>> resultMap, Map<String, Long> salaryItemMap) {
return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream()
.filter(f -> StringUtils.isNotBlank(f.getResultValue()))
.map(SalaryAcctResultPO::getResultValue)
.findFirst().orElse("");
}

View File

@ -709,7 +709,8 @@
<update id="deleteSuspendTodo" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
UPDATE hrsa_salary_archive
<set>
run_status='FIXED'
run_status='FIXED',
pay_end_date= null
</set>
WHERE run_status = 'SUSPEND'
and id IN

View File

@ -724,6 +724,9 @@
<if test="param.taxYearMonth != null">
and tax_year_month = #{param.taxYearMonth}
</if>
<if test="param.taxAgentId != null">
and tax_agent_id = #{param.taxAgentId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size()>0">
AND employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">

View File

@ -310,7 +310,7 @@
insert into hrsa_salary_send_range_obj
(salary_send_id, salary_send_range_id, range_type, target_type, target_id, creator,
create_time, update_time, delete_type, tenant_key)
<foreach collection="list" item="item" separator=",">
<foreach collection="list" item="item" separator="union all">
select
#{item.salarySendId,jdbcType=BIGINT}, #{item.salarySendRangeId,jdbcType=BIGINT},
#{item.rangeType,jdbcType=INTEGER}, #{item.targetType,jdbcType=INTEGER}, #{item.targetId,jdbcType=BIGINT},

View File

@ -367,6 +367,9 @@
<if test="salaryItemNullStatus != null">
salary_item_null_status=#{salaryItemNullStatus},
</if>
<if test="salaryItemZeroStatus != null">
salary_item_zero_status=#{salaryItemZeroStatus},
</if>
<if test="salaryItemSetting != null">
salary_item_setting=#{salaryItemSetting},
</if>

View File

@ -112,5 +112,9 @@ public interface SalarySobItemMapper {
void deleteByGroupIds(@Param("groupIds") List<Long> needDeleteGroupIds);
/**
* 批量插入薪资项目分组是否显示
* @param list
*/
void batchInsertItemShow(@Param("collection")List<SalarySobItemHidePO> list);
}

View File

@ -434,6 +434,63 @@
#{tenantKey},#{createTime},#{updateTime},0)
</insert>
<insert id="batchInsertItemShow">
insert into hrsa_salary_item_hide (id,salary_sob_id,salary_item_id,is_group,item_hide,
creator,tenant_key,create_time,update_time,delete_type)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.salarySobId},
#{item.salaryItemId},
#{item.isGroup},
#{item.itemHide},
#{item.creator},
#{item.tenantKey},
#{item.createTime},
#{item.updateTime},
0
)
</foreach>
</insert>
<insert id="batchInsertItemShow" databaseId="oracle">
insert into hrsa_salary_item_hide (id,salary_sob_id,salary_item_id,is_group,item_hide,
creator,tenant_key,create_time,update_time,delete_type)
<foreach collection="collection" item="item" separator="union all">
select
#{item.id,jdbcType=DOUBLE},
#{item.salarySobId,jdbcType=DOUBLE},
#{item.salaryItemId,jdbcType=DOUBLE},
#{item.isGroup,jdbcType=INTEGER},
#{item.itemHide,jdbcType=INTEGER},
#{item.creator,jdbcType=DOUBLE},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
0
from dual
</foreach>
</insert>
<insert id="batchInsertItemShow" databaseId="sqlserver">
<foreach collection="collection" item="item" separator=";">
insert into hrsa_salary_item_hide (id,salary_sob_id,salary_item_id,is_group,item_hide,
creator,tenant_key,create_time,update_time,delete_type)
VALUES
(
#{item.id},
#{item.salarySobId},
#{item.salaryItemId},
#{item.isGroup},
#{item.itemHide},
#{item.creator},
#{item.tenantKey},
#{item.createTime},
#{item.updateTime},
0
)
</foreach>
</insert>
<update id="deleteByGroupIds">
UPDATE hrsa_salary_sob_item

View File

@ -275,5 +275,14 @@ public interface SIAccountService {
* 将福利台账-补差模板导入的数据更新到数据库
*/
Map<String, Object> importBalanceInsuranceDetail(InsuranceAcctImportParam importParam);
/**
* 合计行
*
* @param queryParam
* @return
*/
Map<String, Object> listCommonSum(InsuranceAccountDetailParam queryParam);
}

View File

@ -105,6 +105,11 @@ public interface SalaryAcctExcelService {
Map<String, Object> preview(SalaryAcctImportParam param);
Map<String, Object> previewImportSalaryAcctResult(SalaryAcctImportParam param);
void cacheImportField(List<Long> salaryItems);
//
// /**
// * 薪资核算结果校验异常导出

View File

@ -149,4 +149,12 @@ public interface SalarySendService {
* @date 2022/11/25 10:45
*/
void handleHistory();
/**
* 合计行
*
* @param queryParam
* @return
*/
Map<String, Object> sumRow(SalarySendInfoQueryParam queryParam);
}

View File

@ -604,8 +604,14 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// 获取租户下所有的人员
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
// 已经核算过的不可操作
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(taxYearMonthStr);
// 获取已经核算的数据(获取税款所属期下一个月的数据)
YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr);
String nextTaxYearMonthStr = taxYearMonthStr;
if( !Objects.equals(nextTaxYearMonth.getMonthValue(),12) ){
nextTaxYearMonth = nextTaxYearMonth.plusMonths(1);
nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER);
}
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr);
//税款所属期
Date taxYearMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(taxYearMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER));
@ -736,7 +742,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// }
// 判断是否有核算过
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12") ) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())).findFirst();
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId()));
if (optionalAcctEmp.isPresent() && isExist) {
@ -861,11 +867,17 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
}
// 已经核算过的不可操作
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(taxYearMonthStr);
// 获取已经核算的数据(获取税款所属期下一个月的数据)
YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr);
String nextTaxYearMonthStr = taxYearMonthStr;
if( !Objects.equals(nextTaxYearMonth.getMonthValue(),12) ){
nextTaxYearMonth = nextTaxYearMonth.plusMonths(1);
nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER);
}
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr);
// 判断是否有核算过
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpSituationParam.getEmployeeId()) && f.getTaxAgentId().equals(addUpSituationParam.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!");

View File

@ -78,7 +78,6 @@ import weaver.hrm.User;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -2830,7 +2829,46 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
}
return apidatas;
}
@Override
public Map<String, Object> listCommonSum(InsuranceAccountDetailParam queryParam) {
Long employeeId = (long) user.getUID();
Map<String, Object> datas = new HashMap<>();
// 正常缴纳列表
queryParam.setPageSize(10000000);
PageInfo<InsuranceAccountDetailPO> pageInfo = getSiAccountBiz(user).listCommonPage(queryParam);
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = pageInfo.getList();
// 数据组装
List<Map<String, Object>> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId);
Map<String, Object> maxSizeRecord = records.stream().reduce(new HashMap<>(), (a, b) -> a.size() > b.size() ? a : b);
// 获取需要统计的列
String[] keys = {"Base", "Com", "Sum", "Per", "total"};
List<String> numKeys = new ArrayList<>();
for(String key : maxSizeRecord.keySet()){
if(StringUtils.containsAny(key,keys)){
numKeys.add(key);
}
}
Map<String, Object> sumRow = new HashMap<>();
for(String numKey : numKeys){
BigDecimal value = new BigDecimal(0);
for(Map<String, Object> record : records){
BigDecimal addValue = null;
if(record.get(numKey) == null || StringUtils.isBlank(record.get(numKey).toString())){
addValue = new BigDecimal(0);
}else{
addValue = new BigDecimal(record.get(numKey).toString());
}
value = value.add(addValue);
}
sumRow.put(numKey,value);
}
datas.put("sumRow", sumRow);
return datas;
}
/**
* 检查补差数据中的福利缴纳费用相关福利类别是否在正常缴纳中有设置缴纳
* @param po

View File

@ -1,11 +1,12 @@
package com.engine.salary.service.impl;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.constant.SalaryItemConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
@ -34,11 +35,12 @@ import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.enums.OpenEnum;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.excel.ExcelParseHelper;
import com.engine.salary.util.excel.ExcelSupport;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.excel.ExcelUtilPlus;
import com.engine.salary.util.page.Column;
import com.engine.salary.util.valid.ValidUtil;
import com.google.common.collect.Lists;
@ -162,8 +164,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
// 3.表数据
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
rows.addAll(lists);
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
@ -195,8 +197,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
// 3.表数据
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
rows.addAll(lists);
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
@Override
@ -227,7 +229,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
// 3.表数据
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
rows.addAll(lists);
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
private List<List<Object>> convert2ExcelRow(List<SalaryAcctEmployeePO> salaryAcctEmployees) {
@ -276,11 +279,12 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
// 查询列表的表头
List<WeaTableColumnGroup> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO);
parseHeader(headerColumnGroup, weaTableColumns);
// excel导出的表头
String[] headers = headerColumnGroup.stream()
.map(WeaTableColumn::getText)
.toArray(String[]::new);
List<Object> headerList = new ArrayList<>(Arrays.asList(headers));
// // excel导出的表头
// String[] headers = headerColumnGroup.stream()
// .map(WeaTableColumn::getText)
// .toArray(String[]::new);
// List<Object> headerList = new ArrayList<>(Arrays.asList(headers));
List<Object> headerList = new ArrayList<>(weaTableColumns);
// 查询薪资核算结果
List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(queryParam);
@ -291,8 +295,10 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (openSum != null && StringUtils.isNotBlank(openSum.getConfValue()) && OpenEnum.parseByValue(openSum.getConfValue()) == OpenEnum.OPEN) {
total = true;
Map<String, Object> sumRow = getSalaryAcctResultService(user).sumRow(queryParam);
sumRow.put("taxAgentName", "总计");
resultMapList.add(sumRow);
if(sumRow !=null){
sumRow.put("taxAgentName", "总计");
resultMapList.add(sumRow);
}
}
// excel导出的数据
@ -307,9 +313,11 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
}
String sheetName = "薪资核算结果";
return ExcelUtil.genWorkbookV2(rows, sheetName, total);
// return ExcelUtil.genWorkbookV2(rows, sheetName, total);
return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, total);
}
/**
* 构建薪资核算结果列表的表头
*
@ -391,8 +399,12 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
.salaryItemName(salaryItemPO.getName())
.build())
.collect(Collectors.toList());
// 缓存勾选
String cacheKey = user.getUID() + SalaryItemConstant.RESULT_IMPORT_FIELD_SIGN;
String cacheValue = (String)Util_DataCache.getObjVal(cacheKey);
List<Long> checkItems = JsonUtil.parseList(cacheValue, Long.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, Long.class);
// 转换成dto
return SalaryAcctImportFieldDTO.builder().formulaItems(formulaItems).sqlItems(sqlItems).inputItems(inputItems).build();
return SalaryAcctImportFieldDTO.builder().formulaItems(formulaItems).sqlItems(sqlItems).inputItems(inputItems).checkItems(checkItems).build();
}
@Override
@ -408,38 +420,86 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 模板表头(默认必带"个税扣缴义务人""姓名")
List<Object> headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"),
"部门",
SalaryI18nUtil.getI18nLabel(86186, "手机号"),
SalaryI18nUtil.getI18nLabel(86317, "工号"),
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName");
// // 模板表头(默认必带"个税扣缴义务人""姓名")
// List<Object> headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"),
// "部门",
// SalaryI18nUtil.getI18nLabel(86186, "手机号"),
// SalaryI18nUtil.getI18nLabel(86317, "工号"),
// SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
// List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName");
// // 查询薪资项目
// List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
// for (SalaryItemPO salaryItemPO : salaryItemPOS) {
// headerList.add(salaryItemPO.getName());
// dataIndexList.add("" + salaryItemPO.getId());
// }
//
// // 查询薪资核算结果
// List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(param);
// // excel导出的数据
// List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
// rows.add(headerList);
// for (Map<String, Object> map : resultMapList) {
// List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
// for (String dataIndex : dataIndexList) {
// row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
// }
// rows.add(row);
// }
// return ExcelUtil.genWorkbookV2(rows, sheetName);
// 查询薪资项目
List<Object> headerRangeList = new ArrayList<>();
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
for (SalaryItemPO salaryItemPO : salaryItemPOS) {
headerList.add(salaryItemPO.getName());
dataIndexList.add("" + salaryItemPO.getId());
headerRangeList.add(salaryItemPO.getId().toString());
}
headerRangeList.add("username");
headerRangeList.add("mobile");
headerRangeList.add("workcode");
headerRangeList.add("taxAgentName");
headerRangeList.add("departmentName");
// 查询列表的表头
List<WeaTableColumnGroup> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO);
List<WeaTableColumnGroup> finalWeaTableColumns = new ArrayList<>();
for (WeaTableColumnGroup tableColumn : weaTableColumns) {
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) tableColumn;
if (columnGroupItem.getChildren() != null) {
List<WeaTableColumnGroup> childrenColumns = columnGroupItem.getChildren().stream().filter(f -> headerRangeList.contains(f.getColumn())).collect(Collectors.toList());
if (childrenColumns.size() > 0) {
columnGroupItem.setChildren(childrenColumns);
finalWeaTableColumns.add(columnGroupItem);
}
} else if (headerRangeList.contains(columnGroupItem.getColumn())) {
finalWeaTableColumns.add(columnGroupItem);
}
}
// excel导出的表头
List<WeaTableColumnGroup> headerColumnGroup = Lists.newArrayList();
// 查询列表的表头
parseHeader(headerColumnGroup, finalWeaTableColumns);
List<Object> headerList = new ArrayList<>(finalWeaTableColumns);
// 查询薪资核算结果
List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(param);
// excel导出的数据
List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
List<List<Object>> rows = new ArrayList<>();
rows.add(headerList);
for (Map<String, Object> map : resultMapList) {
List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
for (String dataIndex : dataIndexList) {
row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
List<Object> row = Lists.newArrayListWithExpectedSize(headerColumnGroup.size());
for (WeaTableColumnGroup weaTableColumn : headerColumnGroup) {
row.add(map.getOrDefault(weaTableColumn.getColumn(), StringUtils.EMPTY));
}
rows.add(row);
}
String sheetName = "薪资核算导入模板";
return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, false);
}
@Override
public XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
@ -494,7 +554,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
String sheetName = "线下对比结果";
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
@ -542,7 +603,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
rows.add(headerList);
String sheetName = "线下对比结果导入模板";
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
public Map<String, Object> importSalaryAcctResult(SalaryAcctImportParam param) {
@ -575,6 +637,33 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
}
}
@Override
public void cacheImportField(List<Long> salaryItems) {
String cacheKey = user.getUID() + SalaryItemConstant.RESULT_IMPORT_FIELD_SIGN;
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryItems));
}
@Override
public Map<String, Object> previewImportSalaryAcctResult(SalaryAcctImportParam param) {
//1参数校验
ValidUtil.doValidator(param);
Map<String, Object> map = new HashMap<>();
InputStream fileInputStream = null;
try {
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
map.put("headers", ExcelSupport.getSheetHeader(sheet, 1));
map.put("list", ExcelParseHelper.parse2List(sheet, 2, 1));
return map;
} finally {
IOUtils.closeQuietly(fileInputStream);
}
}
private Map<String, Object> batchImport(SalaryAcctImportParam param, String importType) {
Map<String, Object> apidatas = new HashMap<String, Object>();
ValidUtil.doValidator(param);
@ -648,10 +737,23 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
// 存在错误的那行数据
List<Map<String, Object>> errorDatas = Lists.newArrayList();
// 表头
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
// List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
List<String> headers;
if (StringUtils.equals("importSalaryAcctResult", importType)) {
headers = ExcelSupport.getSheetHeader(sheet, 1);
} else {
headers = ExcelSupport.getSheetHeader(sheet, 0);
}
// 处理数值
// List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
List<Map<String, Object>> data;
if (StringUtils.equals("importSalaryAcctResult", importType)) {
data = ExcelParseHelper.parse2Map(sheet, 2, 1);
} else {
data = ExcelParseHelper.parse2Map(sheet, 1);
}
// 处理数值
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
if (CollectionUtils.isEmpty(headers)) {
throw new RuntimeException("表头为空");
}

View File

@ -23,13 +23,13 @@ import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
import com.engine.salary.mapper.archive.SalaryArchiveMapper;
import com.engine.salary.service.*;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelComment;
import com.engine.salary.util.excel.ExcelParseHelper;
import com.engine.salary.util.excel.ExcelSupport;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.excel.*;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -83,6 +83,10 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user);
}
public SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz();
private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz();
private SalaryArchiveTaxAgentBiz salaryArchiveTaxAgentMapper = new SalaryArchiveTaxAgentBiz();
@ -338,7 +342,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// row.add(e.get("hiredate"));
row.add(Util.null2String(e.get("departmentName")));
row.add(e.get("mobile") == null ? "" : e.get("mobile").toString());
row.add(Optional.ofNullable(e.get("jobNum")).orElse("").toString());
row.add(Optional.ofNullable(e.get("workcode")).orElse("").toString());
// if (enableHr) {
// row.add(Optional.ofNullable(e.get("idNo")).orElse("").toString());
// }
@ -398,7 +402,8 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// SalaryArchiveExcelBO.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(109736, "格式样例为'2022-01-01'、'2022/1/1'"), 0, 0, i + 1, i + 1);
}
return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments);
// return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments);
return ExcelUtilPlus.genWorkbookV2(rows, finalNameI18n, excelComments);
}
// /**
@ -482,6 +487,9 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
}
// 错误sheet数据
List<Map<String, Object>> errorData = new ArrayList<>();
// 获取匹配规则
SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode");
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
Map<String, Object> map;
for (int i = 0; i < data.size(); i++) {
@ -489,7 +497,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
map = data.get(i);
map.put("index", i + 2);
// 3.校验行内容
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam);
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, confValue);
if (isError) {
errorCount += 1;
// 添加错误数据
@ -500,7 +508,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// 初始化导入对重复记录校验
if (importHandleParam.isInit()) {
Map<String, Object> validMap = SalaryArchiveExcelBO
.validInitImportData(isError, i, map, excelComments, errorCount, successCount, errorData, initImportData, importHandleParam);
.validInitImportData(isError, i+1, map, excelComments, errorCount, successCount, errorData, initImportData, importHandleParam);
errorCount = Integer.parseInt(validMap.getOrDefault("errorCount", errorCount).toString());
successCount = Integer.parseInt(validMap.getOrDefault("successCount", successCount).toString());
}
@ -570,6 +578,10 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// 错误sheet数据
List<Map<String, Object>> errorData = new ArrayList<>();
// 获取匹配规则
SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode");
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
for (int i = 0; i < data.size(); i++) {
Map<String, Object> map = data.get(i);
@ -597,7 +609,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
map = data.get(i);
map.put("index", i + 2);
// 3.校验行内容
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam);
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, confValue);
if (isError) {
errorCount += 1;
// 添加错误数据

View File

@ -38,6 +38,7 @@ import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelParseHelper;
import com.engine.salary.util.excel.ExcelSupport;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.excel.ExcelUtilPlus;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.util.valid.ValidUtil;
@ -528,7 +529,8 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
});
// 3.表数据
return ExcelUtil.genWorkbookV2(rows, sheetName);
// return ExcelUtil.genWorkbookV2(rows, sheetName);
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
}
@ -1126,17 +1128,49 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
List<SalaryArchivePO> oldList = listSome(SalaryArchivePO.builder()
.ids(ids)
.runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
.build());
List<SalaryArchivePO> unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(unableList)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天"));
}
// List<SalaryArchivePO> oldList = listSome(SalaryArchivePO.builder()
// .ids(ids)
// .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue())
// .build());
// List<SalaryArchivePO> unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList());
// if (CollectionUtils.isNotEmpty(unableList)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天"));
// }
//
// // 从待停薪到定薪
// getSalaryArchiveMapper().deleteSuspendTodo(ids);
// return StringUtils.EMPTY;
// 从待停薪到定薪
getSalaryArchiveMapper().deleteSuspendTodo(ids);
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(Long.valueOf(user.getUID()));
// 获取删除待停薪信息
List<SalaryArchiveListDTO> list = getSalaryArchiveMapper().list(SalaryArchiveQueryParam.builder().ids(ids).build());
if(list.size() != ids.size()){
throw new SalaryRunTimeException("薪资档案不存在,删除失败!");
}
Set<String> employeeStatus = list.stream().map(SalaryArchiveListDTO::getEmployeeStatus).collect(Collectors.toSet());
if(employeeStatus.contains("5")){
throw new SalaryRunTimeException("离职人员无法删除待办");
}
Map<Long, TaxAgentManageRangeEmployeeDTO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentManageRangeEmployeeDTO::getTaxAgentId);
// 判断删除待停薪代办的人是否在个税扣缴义务人的人员范围中
for(SalaryArchiveListDTO dto : list){
TaxAgentManageRangeEmployeeDTO taxAgentManageRangeEmployeeDTO = taxAgentMap.get(dto.getTaxAgentId());
if(Objects.nonNull(taxAgentManageRangeEmployeeDTO)){
boolean canDelete = taxAgentManageRangeEmployeeDTO.getEmployeeList().stream()
.map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId)
.anyMatch(id -> Objects.equals(id, dto.getEmployeeId()));
if(!canDelete){
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!");
}
}else{
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!");
}
}
// 删除最后发薪日期设置状态为发薪
if(CollectionUtils.isNotEmpty(list)){
getSalaryArchiveMapper().deleteSuspendTodo(list.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()));
}
return StringUtils.EMPTY;
}

View File

@ -1,11 +1,9 @@
package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.cloudstore.dev.api.bean.MessageBean;
import com.cloudstore.dev.api.service.ServiceMessageCustom;
import com.cloudstore.dev.api.service.ServiceMessageCustomImpl;
import com.cloudstore.dev.api.bean.MessageType;
import com.cloudstore.dev.api.util.Util_Message;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
@ -21,6 +19,7 @@ import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO;
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
@ -64,6 +63,7 @@ import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
@ -935,42 +935,30 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
*/
private void sendPayRollEMMessage(SalarySendInfoPO po, SalaryTemplatePO template, Long employeeId) {
Long id = po.getId();
String billTitle = getBillTitle(template.getTheme(), po.getSalaryMonth(), employeeId);
String background = template.getBackground();
String billTitle = getBillTitle(template.getTheme(), po.getSalaryMonth(), employeeId);
MessageType messageType = MessageType.newInstance(499); // 消息来源见文档第四点补充 必填
Set<String> userIdList = new HashSet<>(); // 接收人id 必填
userIdList.add(employeeId.toString());
String title = billTitle; // 标题
String context = "点击查看详情"; // 内容
String linkUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?id=" + id; // PC端链接
String linkMobileUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?type=phone&id=" + id; // 移动端链接
Map<String, Object> map = new HashMap();
map.put("code", "499");
map.put("title", title);
map.put("context", context);
map.put("linkUrl", linkUrl);
map.put("linkMobileUrl", linkMobileUrl);
map.put("bizState", "0"); //在消息需要修改状态时传入表示消息初始的状态是待处理
map.put("targetId", "499|" + id);// 消息来源code +|+业务id 消息需要打上已处理标记
map.put("userIdList", userIdList); //接收人OA系统id 第一种形式 参数是userIdList
map.put("creater", user.getUID()); //创建人OA系统id 第一种形式 参数是creater
try {
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(user.getUID());// 创建人id
messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理
messageBean.setTargetId("499|" + id); //消息来源code +|+业务id需要修改消息为已处理等状态时传入
Map extraMap = new HashMap<>();
extraMap.put("linkurl", linkUrl);
if (StringUtils.isNotBlank(background)) {
extraMap.put("showimage", background);//图片地址
} else {
extraMap.put("showimage", "/hrm/hrm_e9/images/payroll.jpg?pictype=jpg");//图片地址
if (StringUtils.isNotBlank(background)) {
messageBean.setPictureUrl(background);
} else {
messageBean.setPictureUrl("/hrm/hrm_e9/images/payroll.jpg?pictype=jpg");
}
Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
}
Map shareMap = new HashMap<>();
shareMap.put("extra", extraMap);
Map emParams = new HashMap<>();
emParams.put("share", shareMap);
map.put("emParams", emParams);
ServiceMessageCustom factory = new ServiceMessageCustomImpl();
factory.sendCustomMessageSingle(JSON.toJSONString(map));
}
/**
@ -1273,7 +1261,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
for (Map<String, Object> dto : listMaps) {
List<Object> row = new ArrayList<>();
row.add(dto.get("username"));
row.add(dto.get("departmentName"));
row.add(dto.get("department"));
row.add(dto.get("mobile"));
row.add(dto.get("jobNum"));
@ -1324,4 +1312,16 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage();
// System.out.println("接受到导出的结果" + JSONObject.toJSONString(message));
// }
@Override
public Map<String, Object> sumRow(SalarySendInfoQueryParam queryParam) {
Long salarySendId = queryParam.getSalarySendId();
// 获取薪资核算ID
SalarySendPO salarySendPO = getById(salarySendId);
if(Objects.isNull(salarySendPO)){
throw new SalaryRunTimeException("工资发放记录不存在或已被删除");
}
return getSalaryAcctResultService(user).sumRow(SalaryAcctResultQueryParam.builder().salaryAcctRecordId(salarySendPO.getSalaryAccountingId()).build());
}
}

View File

@ -153,6 +153,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
List<SalarySobItemGroupPO> salarySobItemGroupPOS = getSalarySobItemGroupService(user).listBySalarySobIdWithItemHide(salarySobId);
// 查询薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = listBySalarySobIdWithHideItem(salarySobId);
// 薪资项目副本去重
salarySobItemPOS = salarySobItemPOS.stream().filter(SalaryEntityUtil.distinctByKey(PO -> PO.getSalarySobId() + "-" + PO.getSalaryItemId())).collect(Collectors.toList());
// 回算薪资项目
List<SalarySobBackItemPO> salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salarySobId);
// 薪资账套的薪资项目副本所用的公式id
@ -346,6 +348,9 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
List<SalarySobItemSaveParam.SalarySobItemGroupParam> needUpdateGroup = itemGroups.stream().filter(f -> f.getId() != null && oldGroupIds.contains(f.getId())).collect(Collectors.toList());
List<Long> needDeleteGroupIds = oldGroupIds.stream().filter(f -> !newGroupIds.contains(f)).collect(Collectors.toList());
// 需要保存的隐藏项目
List<SalarySobItemHidePO> needInsertItemShow = new ArrayList<>();
//先保存项目分类获取分类id
Collection<SalarySobItemPO> salarySobItems = new ArrayList<>();
for (SalarySobItemSaveParam.SalarySobItemGroupParam itemGroupParam : needAddGroup) {
@ -383,7 +388,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
if (itemGroupParam.getItemHide() == null) {
salarySobGroupItemHidePO.setItemHide(Long.valueOf(0));
}
salarySobItemMapper.InsertItemShow(salarySobGroupItemHidePO);
needInsertItemShow.add(salarySobGroupItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobGroupItemHidePO);
for (SalarySobItemSaveParam.SalarySobItemParam itemParam : itemGroupParam.getItems()) {
@ -417,7 +423,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
needInsertItemShow.add(salarySobItemHidePO);
}
}
@ -451,7 +458,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
if (itemGroupParam.getItemHide() == null) {
salarySobGroupItemHidePO.setItemHide(Long.valueOf(0));
}
salarySobItemMapper.InsertItemShow(salarySobGroupItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobGroupItemHidePO);
needInsertItemShow.add(salarySobGroupItemHidePO);
List<SalarySobItemSaveParam.SalarySobItemParam> items = itemGroupParam.getItems();
@ -494,7 +502,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
needInsertItemShow.add(salarySobItemHidePO);
}
//更新
for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needUpdateItems) {
@ -523,7 +532,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
needInsertItemShow.add(salarySobItemHidePO);
}
@ -578,7 +588,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
needInsertItemShow.add(salarySobItemHidePO);
}
for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needUpdateItems) {
@ -606,7 +617,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
// salarySobItemMapper.InsertItemShow(salarySobItemHidePO);
needInsertItemShow.add(salarySobItemHidePO);
}
if (CollectionUtils.isNotEmpty(needDeleteItemIds)) {
@ -615,8 +627,13 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
// 保存薪资账套的薪资项目副本
batchSave(salarySobItems);
// 保存薪资账套的薪资项目隐藏信息
batchSaveShow(needInsertItemShow);
}
private void handleEmpField(SalarySobItemSaveParam saveParam) {
long employeeId = (long) user.getUID();
Date now = new Date();
@ -670,6 +687,17 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
salarySobItemMapper.batchInsert(list);
}
private void batchSaveShow(List<SalarySobItemHidePO> needInsertItemShow) {
if (CollectionUtils.isEmpty(needInsertItemShow)) {
return;
}
//前端可能传重复数据去重
List<SalarySobItemHidePO> list = new ArrayList<>(needInsertItemShow.stream()
.collect(Collectors.toMap(SalarySobItemHidePO::getSalaryItemId, Function.identity(), (oldValue, newValue) -> oldValue))
.values());
salarySobItemMapper.batchInsertItemShow(list);
}
@Override
public void deleteBySalarySobIds(Collection<Long> salarySobIds) {
salarySobItemMapper.deleteBySalarySobIds(salarySobIds);

View File

@ -23,7 +23,6 @@ import com.engine.salary.enums.SalarySystemTypeEnum;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobDefaultItemMapper;
import com.engine.salary.mapper.salarysob.SalarySobMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
@ -603,6 +602,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listSome(SalarySobEmpFieldPO.builder().salarySobId(duplicateParam.getId()).build());
// 查询薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobIdWithHideItem(SalarySobItemPO.builder().salarySobId(duplicateParam.getId()).build());
// 薪资项目副本去重
salarySobItemPOS = salarySobItemPOS.stream().filter(SalaryEntityUtil.distinctByKey(PO -> PO.getSalarySobId() + "-" + PO.getSalaryItemId())).collect(Collectors.toList());
// 查询薪资账套的薪资项目分类
List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listSomeWithItemHide(SalarySobItemGroupPO.builder().salarySobId(duplicateParam.getId()).build());
// 查询薪资账套的调薪计薪规则

View File

@ -1,76 +0,0 @@
package com.engine.salary.sys.service.impl;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.weaverboot.frame.ioc.anno.classAnno.WeaSysInitComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaSysInit;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.lang3.StringUtils;
import weaver.general.BaseBean;
import java.util.Date;
@WeaSysInitComponent("initSalary")
public class InitServiceImpl {
private SalarySysConfMapper getSalarySysConfMapper() {
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
}
BaseBean baseBean = new BaseBean();
@WeaSysInit(order = 1, description = "升级薪酬非标版本")
public void init() {
String version = baseBean.getPropValue("hrmSalary", "version");
Date date = new Date();
//升级版本号
//当前版本
SalarySysConfPO currentVersion = getSalarySysConfMapper().getOneByCode("currentVersion");
//前一个版本
int orderWeight = getSalarySysConfMapper().countByCode("previousVersion");
if (currentVersion == null) {
//初始化版本
SalarySysConfPO current = SalarySysConfPO.builder()
.id(IdGenerator.generate())
.confKey("currentVersion")
.confValue(version)
.title("当前版本")
.module("basic")
.orderWeight(0)
.createTime(date)
.updateTime(date)
.deleteType(0).build();
getSalarySysConfMapper().insertIgnoreNull(current);
} else {
//版本不一样
if (!StringUtils.equals(version, currentVersion.getConfValue())) {
//生成历史版本记录
SalarySysConfPO previous = SalarySysConfPO.builder()
.id(IdGenerator.generate())
.confKey("previousVersion")
.confValue(currentVersion.getConfValue())
.title("上一个版本")
.module("basic")
.orderWeight(orderWeight)
.createTime(date)
.updateTime(date)
.deleteType(0)
.build();
getSalarySysConfMapper().insertIgnoreNull(previous);
//更新当前版本
currentVersion.setConfValue(version);
currentVersion.setUpdateTime(date);
getSalarySysConfMapper().updateIgnoreNull(currentVersion);
}
}
}
@WeaSysInit(order = 2, description = "处理薪资档案历史数据")
public void handleSalaryArchiveHistoryData() {
// new SalaryArchiveServiceImpl().handleHistory(1L);
}
}

View File

@ -770,7 +770,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setTotal(AESEncryptUtil.encrypt(po.getTotal()));
}
});
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 50);
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 20);
InsuranceAccountDetailMapper mapper = sqlSession.getMapper(InsuranceAccountDetailMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();

View File

@ -174,6 +174,31 @@ public class ExcelParseHelper {
return result;
}
/**
* 将sheet数据转为map
*
* @param rowIndex 从哪行开始解析
* @param headerRowIndex 抽取列数的参考行
* @return
*/
public static List<Map<String, Object>> parse2Map(Sheet sheet, int rowIndex, int headerRowIndex) {
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数
List<String> sheetHeader = ExcelSupport.getSheetHeader(sheet, headerRowIndex);
List<Map<String, Object>> result = new ArrayList<>();
for (; rowIndex < rowCount; rowIndex++) {
Map<String, Object> cellResult = new HashMap<>();
for (int j = 0; j < cellCount; j++) {
String key = sheetHeader.get(j);
cellResult.put(key, ExcelSupport.getCellValue(sheet, rowIndex, j));
}
result.add(cellResult);
}
return result;
}
/**
* 将sheet数据转为List
*
@ -195,6 +220,27 @@ public class ExcelParseHelper {
return result;
}
/**
* 将sheet数据转为List
* @param rowIndex 从哪行开始解析
* @param headerRowIndex 抽取列数的参考行
* @return
*/
public static List<List<String>> parse2List(Sheet sheet, int rowIndex, int headerRowIndex) {
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数
List<List<String>> result = new ArrayList<List<String>>();
for (; rowIndex < rowCount; rowIndex++) {
List<String> cellResult = new ArrayList<String>();
for (int j = 0; j < cellCount; j++) {
cellResult.add(ExcelSupport.getCellValue(sheet, rowIndex, j));
}
result.add(cellResult);
}
return result;
}
/**
* 为对象的每一个属性赋值

View File

@ -0,0 +1,532 @@
package com.engine.salary.util.excel;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.util.SalaryDateUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import java.awt.Color;
import java.util.Date;
import java.util.List;
public class ExcelUtilPlus {
/**
* 生成excel
*
* @param rowList
* @return
*/
public static XSSFWorkbook genWorkbook(List<List<String>> rowList, String sheetName) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<String> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
cell.setCellType(CellType.STRING);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
cell.setCellValue(infoList.get(cellIndex));
// sheet.setColumnWidth(cellIndex, 35 * 256);
}
}
return workbook;
}
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
titleCellStyle.setBorderLeft(BorderStyle.THIN);
titleCellStyle.setBorderRight(BorderStyle.THIN);
titleCellStyle.setBorderTop(BorderStyle.THIN);
titleCellStyle.setBorderBottom(BorderStyle.THIN);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
//遍历设置列宽
List<Object> header = rowList.get(0);
for (int i = 0; i < header.size(); i++) {
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
}
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
float height = 18;
float finalHeight = 18;
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(o == null ? "" : o.toString());
}
//判断是否要调整高度
int width = sheet.getColumnWidth(cellIndex) / 256;
finalHeight = getFinalHeight(o, width, finalHeight, height);
}
row.setHeightInPoints(finalHeight);
}
return workbook;
}
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName, List<ExcelComment> comments) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
titleCellStyle.setBorderLeft(BorderStyle.THIN);
titleCellStyle.setBorderRight(BorderStyle.THIN);
titleCellStyle.setBorderTop(BorderStyle.THIN);
titleCellStyle.setBorderBottom(BorderStyle.THIN);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
//遍历设置列宽
List<Object> header = rowList.get(0);
for (int i = 0; i < header.size(); i++) {
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
}
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
float height = 18;
float finalHeight = 18;
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
}
//判断是否要调整高度
int width = sheet.getColumnWidth(cellIndex) / 256;
finalHeight = getFinalHeight(o, width, finalHeight, height);
}
row.setHeightInPoints(finalHeight);
}
if (CollectionUtils.isNotEmpty(comments)) {
for (ExcelComment c : comments) {
XSSFDrawing patr = sheet.createDrawingPatriarch();
XSSFComment cellComment = patr.createCellComment(new XSSFClientAnchor(c.dx1, c.dy1, c.dx2, c.dy2, c.col1, c.row1, c.col2, c.row2));
cellComment.setString(c.content);
}
}
return workbook;
}
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName, boolean lastRowRed) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
titleCellStyle.setBorderLeft(BorderStyle.THIN);
titleCellStyle.setBorderRight(BorderStyle.THIN);
titleCellStyle.setBorderTop(BorderStyle.THIN);
titleCellStyle.setBorderBottom(BorderStyle.THIN);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
XSSFCellStyle redCellStyle = workbook.createCellStyle();
XSSFFont redFont = workbook.createFont();
redFont.setFontName("宋体");
redFont.setFontHeightInPoints((short) 10);// 设置字体大小
redFont.setColor(new XSSFColor(new Color(0xFF3333), null));
redFont.setBold(true);
redCellStyle.setWrapText(true);
redCellStyle.setFont(redFont);// 选择需要用到的字体格式
redCellStyle.setBorderLeft(BorderStyle.THIN);
redCellStyle.setBorderRight(BorderStyle.THIN);
redCellStyle.setBorderTop(BorderStyle.THIN);
redCellStyle.setBorderBottom(BorderStyle.THIN);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
//遍历设置列宽
List<Object> header = rowList.get(0);
for (int i = 0; i < header.size(); i++) {
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
}
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
float height = 18;
float finalHeight = 18;
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
if (lastRowRed && rowIndex == rowList.size() - 1) {
cell.setCellStyle(redCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(o == null ? "" : o.toString());
}
//判断是否要调整高度
int width = sheet.getColumnWidth(cellIndex) / 256;
finalHeight = getFinalHeight(o, width, finalHeight, height);
}
row.setHeightInPoints(finalHeight);
}
return workbook;
}
public static XSSFWorkbook genWorkbookWithChildTitleColumn(List<List<Object>> rowList, String sheetName, boolean lastRowRed) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
titleCellStyle.setBorderLeft(BorderStyle.THIN);
titleCellStyle.setBorderRight(BorderStyle.THIN);
titleCellStyle.setBorderTop(BorderStyle.THIN);
titleCellStyle.setBorderBottom(BorderStyle.THIN);
XSSFCellStyle childTitleCellStyle = workbook.createCellStyle();
childTitleCellStyle.setFont(titleFont);
childTitleCellStyle.setAlignment(HorizontalAlignment.LEFT);
childTitleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
childTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
childTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
childTitleCellStyle.setBorderLeft(BorderStyle.THIN);
childTitleCellStyle.setBorderRight(BorderStyle.THIN);
childTitleCellStyle.setBorderTop(BorderStyle.THIN);
childTitleCellStyle.setBorderBottom(BorderStyle.THIN);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
XSSFCellStyle redCellStyle = workbook.createCellStyle();
XSSFFont redFont = workbook.createFont();
redFont.setFontName("宋体");
redFont.setFontHeightInPoints((short) 10);// 设置字体大小
redFont.setColor(new XSSFColor(new Color(0xFF3333), null));
redFont.setBold(true);
redCellStyle.setWrapText(true);
redCellStyle.setFont(redFont);// 选择需要用到的字体格式
redCellStyle.setBorderLeft(BorderStyle.THIN);
redCellStyle.setBorderRight(BorderStyle.THIN);
redCellStyle.setBorderTop(BorderStyle.THIN);
redCellStyle.setBorderBottom(BorderStyle.THIN);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
//处理合并单元格
XSSFRow row0 = sheet.createRow(0);
XSSFRow row1 = sheet.createRow(1);
List<Object> header = rowList.get(0);
int startIndex = 0;
for (int i = 0; i < header.size(); i++) {
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i);
if (columnGroupItem.getChildren() == null) {
sheet.addMergedRegion(new CellRangeAddress(0, 1, startIndex, startIndex));
XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING);
rowZeroCell.setCellValue(columnGroupItem.getText().toString());
rowZeroCell.setCellStyle(titleCellStyle);
XSSFCell rowOneCell = row1.createCell(startIndex, CellType.STRING);
rowOneCell.setCellValue(columnGroupItem.getText().toString());
rowOneCell.setCellStyle(titleCellStyle);
//设置列宽
sheet.setColumnWidth(startIndex,Math.max(12, columnGroupItem.getText().length()*4)*256);
startIndex++;
} else {
List<WeaTableColumnGroup> childrenList = columnGroupItem.getChildren();
int endIndex = startIndex + childrenList.size() - 1;
if (endIndex > startIndex) {
sheet.addMergedRegion(new CellRangeAddress(0, 0, startIndex, endIndex));
}
XSSFCell cell = row0.createCell(startIndex, CellType.STRING);
cell.setCellValue(columnGroupItem.getText().toString());
cell.setCellStyle(childTitleCellStyle);
for (int j = 0; j < childrenList.size(); j++) {
WeaTableColumnGroup childrenItem = (WeaTableColumnGroup) childrenList.get(j);
XSSFCell subHeader = row1.createCell(startIndex + j, CellType.STRING);
subHeader.setCellValue(childrenItem.getText().toString());
subHeader.setCellStyle(titleCellStyle);
//设置列宽
sheet.setColumnWidth(startIndex + j,Math.max(12, childrenItem.getText().length()*4)*256);
}
startIndex += childrenList.size();
}
}
for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex + 1);
float height = 18;
float finalHeight = 18;
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
if (lastRowRed && rowIndex == rowList.size() - 1) {
cell.setCellStyle(redCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(o == null ? "" : o.toString());
}
//判断是否要调整高度
int width = sheet.getColumnWidth(cellIndex) / 256;
finalHeight = getFinalHeight(o, width, finalHeight, height);
}
row.setHeightInPoints(finalHeight);
}
return workbook;
}
public static float getFinalHeight(Object o, int width, float finalHeight, float height) {
if (o != null && getStrlength(o.toString()) > width) {
float remainder = getStrlength(o.toString()) % width;
int multiple = getStrlength(o.toString()) / width;
int finalMultiple = remainder > 0 ? (multiple + 1) : multiple;
float compareHeight = height * finalMultiple;
finalHeight = Math.max(finalHeight, compareHeight);
}
return finalHeight;
}
public static int getStrlength(String str) {
int strLength = 0;
String chinese = "[\u0391-\uFFE5]";
/* 获取字段值的长度如果含中文字符则每个中文字符长度为2否则为1 */
for (int i = 0; i < str.length(); i++) {
/* 从字符串中获取一个字符 */
String temp = str.substring(i, i + 1);
/* 判断是否为中文字符 */
if (temp.matches(chinese)) {
/* 中文字符长度为2 */
strLength += 2;
} else {
/* 其他字符长度为1 */
strLength += 1;
}
}
return strLength;
}
}

View File

@ -9,6 +9,7 @@ import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.*;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.AddUpDeductionWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
@ -198,9 +199,11 @@ public class AddUpDeductionController {
if (StringUtils.isNotBlank(id)) {
param.setId(Long.valueOf(id));
}
String declareMonth = request.getParameter("declareMonth");
if (StringUtils.isNotBlank(declareMonth)) {
param.setDeclareMonth(Arrays.asList(declareMonth.split(",")));
param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
}
String username = request.getParameter("username");

View File

@ -97,6 +97,25 @@ public class SIAccountController {
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>(user).run(getService(user)::listCommonPage, insuranceAccountDetailParam);
}
/**
* 获取正常缴纳列表合计行
*
* @param request
* @param response
* @param insuranceAccountDetailParam
* @return
*/
@POST
@Path("/detail/common/list/sum")
@Produces(MediaType.APPLICATION_JSON)
public String commonListSum(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>(user).run(getService(user)::listCommonSum, insuranceAccountDetailParam);
}
/**
* 根据姓名获取正常缴纳列表
*

View File

@ -31,6 +31,7 @@ import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -483,6 +484,15 @@ public class SalaryAcctController {
return new ResponseResult<Long, SalaryAcctImportFieldDTO>(user).run(getSalaryAcctExcelService(user)::getImportField, salaryAcctRecordId);
}
// 薪资核算导入字段缓存
@POST
@Path("/acctresult/cacheImportField")
@Produces(MediaType.APPLICATION_JSON)
public String cacheImportField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<List<Long>, String>(user).run(getSalaryAcctExcelService(user)::cacheImportField, param.getSalaryItems());
}
//导出导入模板
@GET
@Path("/acctresult/importtemplate/export")
@ -537,7 +547,7 @@ public class SalaryAcctController {
@Produces(MediaType.APPLICATION_JSON)
public String importSalaryAcctResultPreview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryAcctImportParam, Map<String, Object>>(user).run(getSalaryAcctExcelService(user)::preview, param);
return new ResponseResult<SalaryAcctImportParam, Map<String, Object>>(user).run(getSalaryAcctExcelService(user)::previewImportSalaryAcctResult, param);
}
// **********************************薪资核算结果 end*********************************/

View File

@ -312,6 +312,20 @@ public class SalaryBillController {
return new ResponseResult<SalarySendInfoQueryParam, PageInfo<SalarySendInfoListDTO>>(user).run(getSalarySendWrapper(user)::infoList, queryParam);
}
/**
* 工资单发放信息合计行
*
* @param queryParam
* @return
*/
@POST
@Path("/send/sum")
@Produces(MediaType.APPLICATION_JSON)
public String sumSendResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalarySendInfoQueryParam, Map<String, Object>>(user).run(getSalarySendWrapper(user)::sumSendResult, queryParam);
}
/**
* 导出-工资单发放信息列表
*

View File

@ -17,7 +17,6 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
@ -32,8 +31,6 @@ import weaver.hrm.User;
import java.math.BigDecimal;
import java.util.*;
import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_ACCT_RESULT_SUM;
/**
* 薪资核算结果
* <p>Copyright: Copyright (c) 2022</p>
@ -125,7 +122,7 @@ public class SalaryAcctResultWrapper extends Service {
Map<String, Object> datas = new HashMap<>();
//合计
SalarySysConfPO openSum = getSalarySysConfService(user).getOneByCode(OPEN_ACCT_RESULT_SUM);
// SalarySysConfPO openSum = getSalarySysConfService(user).getOneByCode(OPEN_ACCT_RESULT_SUM);
Map<String, Object> sumRow = getSalaryAcctResultService(user).sumRow(queryParam);
datas.put("sumRow", sumRow);
return datas;

View File

@ -647,4 +647,19 @@ public class SalarySendWrapper extends Service {
public Map<String, Object> mySalaryBill(Long salaryInfoId) {
return getSalarySendService(user).mySalaryBill(salaryInfoId, (long) user.getUID());
}
/**
* 工资单发放信息合计行
*
* @param queryParam
* @return
*/
public Map<String, Object> sumSendResult(SalarySendInfoQueryParam queryParam) {
Map<String, Object> datas = new HashMap<>();
//合计
Map<String, Object> sumRow = getSalarySendService(user).sumRow(queryParam);
datas.put("sumRow", sumRow);
return datas;
}
}