2022-03-15 14:18:04 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-04-24 17:42:32 +08:00
|
|
|
|
import com.alibaba.druid.support.json.JSONUtils;
|
2022-04-25 15:51:35 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2022-09-21 14:47:26 +08:00
|
|
|
|
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
2022-10-31 14:50:54 +08:00
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTable;
|
|
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.biz.*;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
|
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.bo.AttendQuoteDataBO;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.*;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.*;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuotePO;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
|
2022-05-30 18:03:20 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.AttendQuoteDataMapper;
|
|
|
|
|
|
import com.engine.salary.mapper.salarysob.SalarySobMapper;
|
|
|
|
|
|
import com.engine.salary.mapper.salarysob.SalarySobRangeMapper;
|
2022-09-21 14:47:26 +08:00
|
|
|
|
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
import com.engine.salary.remote.attend.entity.Attend4Salary;
|
|
|
|
|
|
import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService;
|
|
|
|
|
|
import com.engine.salary.remote.attend.service.impl.RemoteAttend4SalaryServiceImpl;
|
2022-10-28 16:15:51 +08:00
|
|
|
|
import com.engine.salary.service.AttendQuoteDataService;
|
|
|
|
|
|
import com.engine.salary.service.AttendQuoteFieldSettingService;
|
|
|
|
|
|
import com.engine.salary.service.SalaryEmployeeService;
|
|
|
|
|
|
import com.engine.salary.service.SalarySobService;
|
2022-09-21 14:47:26 +08:00
|
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
2022-09-26 18:51:17 +08:00
|
|
|
|
import com.engine.salary.sys.entity.vo.OrderRuleVO;
|
|
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
|
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
2022-10-28 16:15:51 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelParseHelper;
|
|
|
|
|
|
import com.engine.salary.util.excel.ExcelSupport;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelUtil;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
|
|
|
|
|
import com.google.common.base.Joiner;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2024-01-25 11:38:38 +08:00
|
|
|
|
import com.engine.salary.util.db.IdGenerator;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
|
import org.apache.poi.util.IOUtils;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import weaver.file.ImageFileManager;
|
2023-01-05 16:24:40 +08:00
|
|
|
|
import weaver.general.BaseBean;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-08-16 14:42:31 +08:00
|
|
|
|
import weaver.wechat.util.Utils;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
import java.math.BigDecimal;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
import java.time.YearMonth;
|
|
|
|
|
|
import java.util.*;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
|
|
|
|
|
|
|
2022-03-15 14:18:04 +08:00
|
|
|
|
/**
|
2022-03-30 11:29:48 +08:00
|
|
|
|
* 数据采集-考勤引用数据
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
2022-04-24 17:42:32 +08:00
|
|
|
|
@Slf4j
|
2022-03-15 14:18:04 +08:00
|
|
|
|
public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDataService {
|
2023-01-05 16:24:40 +08:00
|
|
|
|
private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log"));
|
2022-03-15 14:18:04 +08:00
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
private AttendQuoteBiz quoteBiz = new AttendQuoteBiz();
|
|
|
|
|
|
private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz();
|
2022-03-15 14:18:04 +08:00
|
|
|
|
private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz();
|
|
|
|
|
|
private AttendQuoteFieldBiz fieldBiz = new AttendQuoteFieldBiz();
|
|
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
private AttendQuoteFieldSettingService getFieldSettingService(User user) {
|
2022-09-26 18:51:17 +08:00
|
|
|
|
return ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySysConfService getSalarySysConfService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
private SalarySobService getSalarySobService(User user) {
|
2022-09-26 18:51:17 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
2022-03-15 14:18:04 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
private AttendQuoteDataMapper getAttendQuoteDataMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(AttendQuoteDataMapper.class);
|
|
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
private SalarySobMapper getSalarySobMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalarySobMapper.class);
|
|
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
private SalarySobRangeMapper getSalarySobRangeMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalarySobRangeMapper.class);
|
|
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-05-06 16:01:33 +08:00
|
|
|
|
private RemoteAttend4SalaryService getRemoteAttend4SalaryService(User user) {
|
2022-09-26 18:51:17 +08:00
|
|
|
|
return ServiceUtil.getService(RemoteAttend4SalaryServiceImpl.class, user);
|
2022-04-24 17:42:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 15:49:55 +08:00
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
2022-09-26 18:51:17 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
2022-09-21 14:47:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySysConfMapper getSalarySysConfMapper() {
|
|
|
|
|
|
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
|
|
|
|
|
}
|
2022-04-24 17:42:32 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<AttendQuoteDataBaseDTO> listPage(AttendQuoteDataQueryParam queryParam) {
|
2022-09-26 18:51:17 +08:00
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
queryParam.setOrderRule(orderRule);
|
|
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
List<AttendQuoteDataBaseDTO> list = getAttendQuoteDataMapper().list(queryParam);
|
2022-12-09 15:28:29 +08:00
|
|
|
|
PageInfo<AttendQuoteDataBaseDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AttendQuoteDataBaseDTO.class);
|
2022-04-21 14:15:56 +08:00
|
|
|
|
return page;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取所有考勤字段
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<AttendQuoteFieldPO> getAllAttendQuoteFields() {
|
|
|
|
|
|
return fieldBiz.listSome(AttendQuoteFieldPO.builder().build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取考勤数据结果
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param attendQuoteDataBases
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-04-21 14:15:56 +08:00
|
|
|
|
public List<Map<String, Object>> getListMaps(List<AttendQuoteDataBaseDTO> attendQuoteDataBases) {
|
2022-03-15 14:18:04 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(attendQuoteDataBases)) {
|
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 考核数据值
|
|
|
|
|
|
List<AttendQuoteDataValuePO> attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuoteDataBases.get(0).getAttendQuoteId()).build());
|
|
|
|
|
|
|
|
|
|
|
|
return attendQuoteDataBases.stream().map(m -> {
|
|
|
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
|
|
map.put("id", m.getId());
|
|
|
|
|
|
map.put("username", m.getUsername());
|
|
|
|
|
|
map.put("departmentName", m.getDepartmentName());
|
|
|
|
|
|
map.put("mobile", m.getMobile());
|
|
|
|
|
|
map.put("jobNum", m.getJobNum());
|
|
|
|
|
|
// 考勤数据
|
|
|
|
|
|
attendQuoteDataValues.stream().filter(a -> a.getAttendQuoteDataId().equals(m.getId())).collect(Collectors.toList()).forEach(e -> {
|
|
|
|
|
|
map.put(e.getAttendQuoteFieldId() + "_attendQuoteData", e.getDataValue());
|
|
|
|
|
|
});
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<AttendQuoteDataDTO> getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List<Long> employeeIds) {
|
|
|
|
|
|
if (salaryYearMonth == null || salarySobId == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100358, "参数有误:薪资所属月、薪资账套id"));
|
|
|
|
|
|
}
|
|
|
|
|
|
List<AttendQuoteDataDTO> list = new ArrayList<>();
|
|
|
|
|
|
Date salaryYearMonthDay = SalaryDateUtil.localDateToDate(salaryYearMonth.atDay(1));
|
|
|
|
|
|
//查询引用主表
|
|
|
|
|
|
List<AttendQuotePO> attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salaryYearMonth(salaryYearMonthDay).salarySobId(salarySobId).build());
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(attendQuotes)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
AttendQuotePO attendQuote = attendQuotes.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
//查询考勤数据值
|
|
|
|
|
|
List<AttendQuoteDataValuePO> attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuote.getId()).employeeIds(employeeIds).build());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeIds)) {
|
|
|
|
|
|
employeeIds = attendQuoteDataValues.stream().map(AttendQuoteDataValuePO::getEmployeeId)
|
|
|
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
employeeIds.forEach(e -> {
|
|
|
|
|
|
AttendQuoteDataDTO attendQuoteData = new AttendQuoteDataDTO();
|
|
|
|
|
|
attendQuoteData.setEmployeeId(e);
|
|
|
|
|
|
List<AttendQuoteDataValueDTO> dataValues = attendQuoteDataValues.stream().filter(v -> v.getEmployeeId().equals(e)).map(m ->
|
|
|
|
|
|
AttendQuoteDataValueDTO.builder()
|
|
|
|
|
|
.attendQuoteFieldId(m.getAttendQuoteFieldId())
|
|
|
|
|
|
.dataValue(m.getDataValue())
|
|
|
|
|
|
.build()).collect(Collectors.toList());
|
|
|
|
|
|
attendQuoteData.setDataValues(dataValues);
|
|
|
|
|
|
list.add(attendQuoteData);
|
|
|
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook export(AttendQuoteDataQueryParam queryParam) {
|
|
|
|
|
|
if (queryParam.getAttendQuoteId() == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100253, "考勤引用id不能为空"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
queryParam.setOrderRule(orderRule);
|
|
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 考勤数据分页主数据
|
|
|
|
|
|
List<AttendQuoteDataBaseDTO> attendQuoteDataBases = dataBiz.list(queryParam);
|
|
|
|
|
|
// 所有考勤字段
|
|
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = getAllAttendQuoteFields();
|
|
|
|
|
|
// 获取最终结果
|
|
|
|
|
|
List<Map<String, Object>> listMaps = getListMaps(attendQuoteDataBases);
|
|
|
|
|
|
|
|
|
|
|
|
// 1.工作簿名称
|
|
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(93931, "考勤数据");
|
|
|
|
|
|
List<Object> header = new ArrayList<>();
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
|
|
|
|
|
// 动态列
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(listMaps)) {
|
|
|
|
|
|
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
2023-02-06 16:28:56 +08:00
|
|
|
|
header.add(attendQuoteField.getFieldName());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
// 2.表头
|
|
|
|
|
|
rows.add(header);
|
|
|
|
|
|
// 3.表数据
|
|
|
|
|
|
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("mobile"));
|
|
|
|
|
|
row.add(dto.get("jobNum"));
|
|
|
|
|
|
|
|
|
|
|
|
// 动态列
|
|
|
|
|
|
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
2023-02-06 16:28:56 +08:00
|
|
|
|
row.add(dto.get(attendQuoteField.getId().toString() + "_attendQuoteData"));
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取表头设置字段
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param sourceType
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<AttendQuoteFieldPO> getAttendQuoteSetFields(AttendQuoteSourceTypeEnum sourceType) {
|
|
|
|
|
|
List<AttendQuoteFieldPO> allAttendQuoteFields = getAllAttendQuoteFields();
|
2022-04-21 20:29:11 +08:00
|
|
|
|
List<AttendQuoteFieldSettingListDTO> attendQuoteFieldSettingList = getFieldSettingService(user).listNoSync(AttendQuoteFieldSettingQueryParam.builder().sourceType(sourceType).isViewChecked(Boolean.TRUE).build());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = new ArrayList<>();
|
|
|
|
|
|
attendQuoteFieldSettingList.forEach(s -> {
|
|
|
|
|
|
List<AttendQuoteFieldSettingFieldListDTO> items = s.getItems();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
|
|
items.forEach(i -> {
|
|
|
|
|
|
Optional<AttendQuoteFieldPO> optional = allAttendQuoteFields.stream().filter(f -> f.getId().equals(i.getId())).findFirst();
|
|
|
|
|
|
optional.ifPresent(attendQuoteFields::add);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return attendQuoteFields;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam) {
|
|
|
|
|
|
AttendQuoteDataSyncParam.checkParam(syncParam);
|
|
|
|
|
|
|
|
|
|
|
|
String salaryYearMonth = syncParam.getSalaryYearMonth();
|
|
|
|
|
|
int year = Integer.parseInt(salaryYearMonth.split("-")[0]);
|
|
|
|
|
|
int month = Integer.parseInt(salaryYearMonth.split("-")[1]);
|
|
|
|
|
|
if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 1.获取已设置的可同步的考勤字段
|
|
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.QUOTE);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(attendQuoteFields)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100366, "请先设置同步字段"));
|
|
|
|
|
|
}
|
2022-04-21 14:15:56 +08:00
|
|
|
|
// 获取薪资账套
|
|
|
|
|
|
SalarySobCycleDTO salarySobCycle = getSalarySobService(user).getSalarySobCycle(syncParam.getSalarySobId(), YearMonth.of(year, month));
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 2.薪资账套人员
|
|
|
|
|
|
List<Long> employeeIds = new ArrayList<>();
|
|
|
|
|
|
// 获取薪资账套人员
|
2022-04-21 14:15:56 +08:00
|
|
|
|
List<SalarySobRangePO> salarySobRanges = getSalarySobRangeMapper().listSome(SalarySobRangePO.builder().includeType(1).salarySobId(salarySobCycle.getSalarySobId()).build());
|
|
|
|
|
|
List<SalarySobRangeEmpQueryParam> salarySobRangeEmpQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(salarySobRanges);
|
2023-01-03 10:22:42 +08:00
|
|
|
|
List<List<SalarySobRangeEmpQueryParam>> partition = Lists.partition(salarySobRangeEmpQueryParams, 100);
|
|
|
|
|
|
List<Long> employeeSalarySobIds = new ArrayList<>();
|
2023-01-05 16:24:40 +08:00
|
|
|
|
partition.forEach(l -> employeeSalarySobIds.addAll(getSalarySobRangeMapper().listEmployeeIds(l)));
|
2023-01-03 10:22:42 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(employeeSalarySobIds) || CollectionUtils.isEmpty(salarySobRangeEmpQueryParams)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100367, "薪资账套还没有人员"));
|
|
|
|
|
|
}
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 账套外人员
|
|
|
|
|
|
List<Long> employeeOtherIds = (List<Long>) syncParam.getEmployeeIds();
|
2022-04-21 14:15:56 +08:00
|
|
|
|
employeeIds.addAll(employeeSalarySobIds);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
employeeIds.addAll(CollectionUtils.emptyIfNull(employeeOtherIds));
|
|
|
|
|
|
|
|
|
|
|
|
// 4.获取考勤模块数据
|
2022-04-21 14:15:56 +08:00
|
|
|
|
List<Map<String, Object>> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(salarySobCycle.getAttendCycle(), employeeIds, attendQuoteFields);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
List<AttendQuoteDataPO> pos = new ArrayList<>();
|
|
|
|
|
|
List<AttendQuoteDataValuePO> values = new ArrayList<>();
|
|
|
|
|
|
// 5.考勤引用数据处理
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(attendQuoteSyncData)) {
|
2022-06-30 16:15:19 +08:00
|
|
|
|
|
|
|
|
|
|
// 3.生成考勤引用
|
|
|
|
|
|
AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.QUOTE, syncParam.getSalarySobId(), year, month, syncParam.getDescription());
|
|
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
for (Long employeeId : employeeIds) {
|
|
|
|
|
|
AttendQuoteDataPO po = new AttendQuoteDataPO();
|
2022-04-21 14:15:56 +08:00
|
|
|
|
po.setId(IdGenerator.generate());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
po.setCreateTime(now);
|
|
|
|
|
|
po.setUpdateTime(now);
|
|
|
|
|
|
po.setCreator((long) user.getUID());
|
|
|
|
|
|
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
// 考勤引用表的主键id
|
|
|
|
|
|
po.setAttendQuoteId(attendQuote.getId());
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
pos.add(po);
|
|
|
|
|
|
for (Map<String, Object> attendQuoteData : attendQuoteSyncData) {
|
2022-06-02 17:10:54 +08:00
|
|
|
|
if (!Objects.isNull(attendQuoteData.get("employeeId")) &&
|
|
|
|
|
|
!Objects.isNull(employeeId) &&
|
|
|
|
|
|
!Objects.isNull(attendQuoteData.get("attendQuoteFieldId")) &&
|
|
|
|
|
|
attendQuoteData.get("employeeId").toString().equals(employeeId.toString())) {
|
2022-03-16 14:29:02 +08:00
|
|
|
|
values.add(AttendQuoteDataValuePO.builder()
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.employeeId(employeeId)
|
|
|
|
|
|
.attendQuoteId(attendQuote.getId())
|
|
|
|
|
|
.attendQuoteDataId(po.getId())
|
|
|
|
|
|
.attendQuoteFieldId(Long.valueOf(attendQuoteData.get("attendQuoteFieldId").toString()))
|
2022-08-16 14:42:31 +08:00
|
|
|
|
.dataValue(Utils.null2String(attendQuoteData.get("dataValue")))
|
2022-03-16 14:29:02 +08:00
|
|
|
|
.build());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-06-30 16:15:19 +08:00
|
|
|
|
|
|
|
|
|
|
// 6.数据落库处理
|
|
|
|
|
|
handleDataToDB(attendQuote.getId(), pos, values);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100368, "暂无考勤数据可以同步"));
|
|
|
|
|
|
}
|
2022-06-30 16:15:19 +08:00
|
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// todo 记录日志
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// recordLog(attendQuote, currentEmployeeId, currentTenantKey, null);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取考勤引用
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salarySobId
|
|
|
|
|
|
* @param year
|
|
|
|
|
|
* @param month
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private AttendQuotePO getAttendQuote(AttendQuoteSourceTypeEnum sourceType, Long salarySobId, int year, int month, String description) {
|
|
|
|
|
|
SalarySobCycleDTO salarySobCycle = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month));
|
|
|
|
|
|
|
|
|
|
|
|
Date salaryYearMonthDayDate = SalaryDateUtil.localDateToDate(YearMonth.of(year, month).atDay(1));
|
|
|
|
|
|
List<AttendQuotePO> attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salarySobId(salarySobId).salaryYearMonth(salaryYearMonthDayDate).build());
|
|
|
|
|
|
// 考勤引用
|
|
|
|
|
|
AttendQuotePO attendQuote = new AttendQuotePO();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(attendQuotes)) {
|
|
|
|
|
|
attendQuote = attendQuotes.get(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
attendQuote.setSalarySobId(salarySobCycle.getSalarySobId());
|
|
|
|
|
|
LocalDateRange salaryCycleRange = salarySobCycle.getSalaryCycle();
|
|
|
|
|
|
LocalDateRange attendCycleRange = salarySobCycle.getAttendCycle();
|
|
|
|
|
|
// 考勤周期
|
2022-04-22 17:26:17 +08:00
|
|
|
|
attendQuote.setAttendCycle(SalaryDateUtil.getFormatLocalDate(attendCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(attendCycleRange.getEndDate()));
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 薪资周期
|
2022-04-22 17:26:17 +08:00
|
|
|
|
attendQuote.setSalaryCycle(SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getEndDate()));
|
2022-03-16 14:29:02 +08:00
|
|
|
|
attendQuote.setSalaryYearMonth(salaryYearMonthDayDate);
|
|
|
|
|
|
// 来源:导入
|
|
|
|
|
|
attendQuote.setSourceType(sourceType.getValue());
|
|
|
|
|
|
attendQuote.setDescription(description);
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
attendQuote.setCreateTime(now);
|
|
|
|
|
|
attendQuote.setUpdateTime(now);
|
|
|
|
|
|
attendQuote.setCreator((long) user.getUID());
|
|
|
|
|
|
attendQuote.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
// 新增或修改考勤引用
|
|
|
|
|
|
if (attendQuote.getId() != null) {
|
|
|
|
|
|
quoteBiz.updateById(attendQuote);
|
|
|
|
|
|
} else {
|
2022-04-21 14:15:56 +08:00
|
|
|
|
attendQuote.setId(IdGenerator.generate());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
quoteBiz.insert(attendQuote);
|
|
|
|
|
|
}
|
|
|
|
|
|
return attendQuote;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-25 16:20:57 +08:00
|
|
|
|
* 获取考勤模块数据
|
2022-03-16 14:29:02 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param attendCycleRange
|
|
|
|
|
|
* @param employeeIds
|
|
|
|
|
|
* @param attendQuoteFields
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<Map<String, Object>> getAttendQuoteDataFromRemoteAttend(LocalDateRange attendCycleRange, List<Long> employeeIds, List<AttendQuoteFieldPO> attendQuoteFields) {
|
|
|
|
|
|
List<Map<String, Object>> attendQuoteSyncData = new ArrayList<>();
|
2022-04-24 17:42:32 +08:00
|
|
|
|
Attend4Salary attend4Salary = new Attend4Salary();
|
|
|
|
|
|
try {
|
|
|
|
|
|
int partSize = 500;
|
|
|
|
|
|
List<List<Long>> partition = Lists.partition(employeeIds, partSize);
|
|
|
|
|
|
for (List<Long> part : partition) {
|
|
|
|
|
|
attend4Salary.setBeginDate(attendCycleRange.getFromDate());
|
|
|
|
|
|
attend4Salary.setEndDate(attendCycleRange.getEndDate());
|
|
|
|
|
|
attend4Salary.setOnlyEmpIds(part);
|
2022-05-06 16:01:33 +08:00
|
|
|
|
List<Map<String, String>> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary);
|
2023-01-05 16:24:40 +08:00
|
|
|
|
|
2022-04-24 17:42:32 +08:00
|
|
|
|
AttendQuoteDataBO.buildAttendDataFromRemote(attendResult, attendQuoteFields, attendQuoteSyncData);
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// attend4Salary.setUnit("day");
|
2022-04-24 17:42:32 +08:00
|
|
|
|
// attendResult = remoteAttend4SalaryService.getWorkTimeSummary(attend4Salary);
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// log.info("考勤数据[按天]:{}", JSONUtils.toJSONString(attendResult.getData()));
|
|
|
|
|
|
// AttendQuoteDataBO.buildAttendDataFromRemote("day", attendResult.getData(), attendQuoteFields, attendQuoteSyncData);
|
2022-04-24 17:42:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
2023-11-13 11:15:49 +08:00
|
|
|
|
log.error("salaryAttend获取考勤数据错误失败:{}", String.format("参数:%s,错误信息:%s", JSONObject.toJSONString(attend4Salary), e.getMessage()), e);
|
2022-04-24 17:42:32 +08:00
|
|
|
|
return attendQuoteSyncData;
|
|
|
|
|
|
}
|
2023-01-05 16:24:40 +08:00
|
|
|
|
if (isLog) {
|
2023-11-13 11:15:49 +08:00
|
|
|
|
log.info("salaryAttend同步的考勤数据:{}", JSONUtils.toJSONString(attendQuoteSyncData));
|
2023-01-05 16:24:40 +08:00
|
|
|
|
}
|
2022-03-16 14:29:02 +08:00
|
|
|
|
return attendQuoteSyncData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 引用同步或导入落库处理
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param attendQuoteId
|
|
|
|
|
|
* @param pos
|
|
|
|
|
|
* @param values
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void handleDataToDB(Long attendQuoteId, List<AttendQuoteDataPO> pos, List<AttendQuoteDataValuePO> values) {
|
|
|
|
|
|
// 数据落库处理
|
|
|
|
|
|
if (CollectionUtils.isEmpty(pos)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos);
|
|
|
|
|
|
pos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId()))), ArrayList::new));
|
|
|
|
|
|
// 删除考勤数据
|
|
|
|
|
|
ArrayList<Long> quoteIds = new ArrayList<>();
|
|
|
|
|
|
quoteIds.add(attendQuoteId);
|
|
|
|
|
|
dataBiz.deleteByAttendQuoteIds(quoteIds);
|
|
|
|
|
|
// 新增考勤数据
|
|
|
|
|
|
dataBiz.insertData(pos);
|
|
|
|
|
|
// 删除考勤值数据
|
2022-04-24 17:42:32 +08:00
|
|
|
|
// dataValueBiz.deleteByAttendQuoteDataIds(pos.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList()));
|
|
|
|
|
|
dataValueBiz.deleteByAttendQuoteIds(quoteIds);
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 新增考勤值数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(values)) {
|
2022-10-10 17:07:51 +08:00
|
|
|
|
//去除空值
|
2022-12-09 15:28:29 +08:00
|
|
|
|
values = values.stream().filter(po -> StringUtils.isNotBlank(po.getDataValue())).collect(Collectors.toList());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
dataValueBiz.insertData(values);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam) {
|
2022-05-06 16:01:33 +08:00
|
|
|
|
try {
|
|
|
|
|
|
// 考勤主数据
|
|
|
|
|
|
Date salaryYearMonth = SalaryDateUtil.localDateToDate(exportParam.getSalaryYearMonth().atDay(1));
|
|
|
|
|
|
List<AttendQuotePO> attendQuotePOS = quoteBiz.listSome(AttendQuotePO.builder()
|
|
|
|
|
|
.salarySobId(exportParam.getSalarySobId())
|
|
|
|
|
|
.salaryYearMonth(salaryYearMonth)
|
|
|
|
|
|
.ids(exportParam.getIds()).build());
|
|
|
|
|
|
AttendQuotePO po = CollectionUtils.isNotEmpty(attendQuotePOS) ? attendQuotePOS.get(0) : null;
|
|
|
|
|
|
AttendQuoteDataQueryParam queryParam = AttendQuoteDataQueryParam.builder().attendQuoteId(po == null ? 0L : po.getId()).build();
|
|
|
|
|
|
List<AttendQuoteDataBaseDTO> attendQuoteDataBases = dataBiz.list(queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取已设置的可同步的字段
|
|
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT);
|
|
|
|
|
|
// 获取最终结果
|
|
|
|
|
|
List<Map<String, Object>> listMaps = getListMaps(attendQuoteDataBases);
|
|
|
|
|
|
|
|
|
|
|
|
// 1.工作簿名称
|
|
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(101606, "考勤引用导入模板");
|
|
|
|
|
|
List<Object> header = new ArrayList<>();
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
2022-03-16 14:29:02 +08:00
|
|
|
|
// 动态列
|
|
|
|
|
|
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
2022-05-06 16:01:33 +08:00
|
|
|
|
header.add(attendQuoteField.getFieldName());
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
2022-05-06 16:01:33 +08:00
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
rows.add(header);
|
2022-09-26 13:46:43 +08:00
|
|
|
|
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("mobile"));
|
|
|
|
|
|
row.add(dto.get("jobNum"));
|
|
|
|
|
|
|
2022-05-31 16:41:11 +08:00
|
|
|
|
// // 动态列
|
|
|
|
|
|
// Map<String, Object> map = listMaps.get(0);
|
|
|
|
|
|
// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
|
|
|
|
|
// row.add(map.containsKey(attendQuoteField.getId() + "_attendQuoteData") ? dto.get(attendQuoteField.getId() + "_attendQuoteData") : "");
|
|
|
|
|
|
// }
|
2022-09-26 13:46:43 +08:00
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
2022-05-06 16:01:33 +08:00
|
|
|
|
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
|
|
|
|
|
} catch (Exception e) {
|
2023-11-13 11:15:49 +08:00
|
|
|
|
log.error("salaryAttend下载模板失败", e);
|
2022-05-06 16:01:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
2022-03-16 14:29:02 +08:00
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导入的数据插入到数据库中
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> preview(AttendQuoteDataImportParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
Long salarySobId = param.getSalarySobId();
|
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId);
|
|
|
|
|
|
if (salarySobPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100537, "薪资账套不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
String salaryYearMonth = param.getSalaryYearMonth();
|
|
|
|
|
|
if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
|
|
|
|
|
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0));
|
|
|
|
|
|
apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1));
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导入的数据插入到数据库中
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> importAttendQuoteData(AttendQuoteDataImportParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
Long salarySobId = param.getSalarySobId();
|
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId);
|
|
|
|
|
|
if (salarySobPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100537, "薪资账套不存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
String salaryYearMonth = param.getSalaryYearMonth();
|
|
|
|
|
|
if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'"));
|
|
|
|
|
|
}
|
|
|
|
|
|
int year = Integer.parseInt(salaryYearMonth.split("-")[0]);
|
|
|
|
|
|
int month = Integer.parseInt(salaryYearMonth.split("-")[1]);
|
|
|
|
|
|
|
2022-09-21 14:47:26 +08:00
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
|
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
// 获取租户下所有的人员
|
2023-04-12 15:27:35 +08:00
|
|
|
|
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
2022-04-22 15:46:03 +08:00
|
|
|
|
// 获取已设置的可同步的考勤字段
|
|
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT);
|
2022-04-22 17:26:17 +08:00
|
|
|
|
// 生成获取考勤引用
|
2022-04-22 15:46:03 +08:00
|
|
|
|
AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.IMPORT, salarySobId, year, month, StringUtils.EMPTY);
|
|
|
|
|
|
|
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 待导入数据
|
|
|
|
|
|
List<AttendQuoteDataPO> pos = new ArrayList<>();
|
|
|
|
|
|
List<AttendQuoteDataValuePO> values = new ArrayList<>();
|
|
|
|
|
|
String valI18n = SalaryI18nUtil.getI18nLabel(100581, "请输入数字");
|
|
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
|
|
|
|
|
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
|
|
|
|
|
// 表头
|
|
|
|
|
|
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
|
|
|
|
|
|
|
|
|
|
|
// 错误sheet数据
|
|
|
|
|
|
List<Map<String, Object>> errorData = new ArrayList<>();
|
|
|
|
|
|
// 错误提示
|
|
|
|
|
|
List<Map<String, String>> excelComments = new ArrayList<>();
|
|
|
|
|
|
|
2022-06-23 14:08:55 +08:00
|
|
|
|
//验证字段是否缺失
|
|
|
|
|
|
String isValidHeader = checkHeaders(headers, attendQuoteFields);
|
|
|
|
|
|
if (StringUtils.isNotBlank(isValidHeader)) {
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
apidatas.put("successCount", successCount);
|
|
|
|
|
|
apidatas.put("errorCount", errorCount);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", isValidHeader);
|
|
|
|
|
|
excelComments.add(errorMessageMap);
|
|
|
|
|
|
apidatas.put("errorData", excelComments);
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
// 处理数值
|
|
|
|
|
|
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
|
|
|
|
|
|
total = data.size();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
AttendQuoteDataPO po;
|
|
|
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
|
|
|
index += 1;
|
2023-01-18 10:02:23 +08:00
|
|
|
|
String rowIndex = "第" + index + "行";
|
2022-04-22 15:46:03 +08:00
|
|
|
|
map = data.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
po = new AttendQuoteDataPO();
|
|
|
|
|
|
po.setId(IdGenerator.generate());
|
|
|
|
|
|
po.setCreateTime(now);
|
|
|
|
|
|
po.setUpdateTime(now);
|
|
|
|
|
|
po.setCreator((long) user.getUID());
|
|
|
|
|
|
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
// 考勤引用表的主键id
|
|
|
|
|
|
po.setAttendQuoteId(attendQuote.getId());
|
|
|
|
|
|
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
String userName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(85429, "姓名"))).orElse("").toString();
|
|
|
|
|
|
String deparmentName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86185, "部门"))).orElse("").toString();
|
2022-08-25 11:43:52 +08:00
|
|
|
|
String mobile = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86186, "手机号"))).orElse("").toString();
|
2022-09-21 14:47:26 +08:00
|
|
|
|
String workcode = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86317, "工号"))).orElse("").toString();
|
2022-05-30 18:03:20 +08:00
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
2022-09-21 14:47:26 +08:00
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
2022-09-21 15:49:55 +08:00
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null);
|
2022-05-30 18:03:20 +08:00
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
for (int j = 0; j < headers.size(); j++) {
|
|
|
|
|
|
String key = headers.get(j);
|
|
|
|
|
|
if (key == null) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString();
|
|
|
|
|
|
if (SalaryI18nUtil.getI18nLabel(85429, "姓名").equals(key.toString())) {
|
2022-09-21 14:47:26 +08:00
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isEmpty(cellVal) && "0".equals(confValue)) {
|
2022-04-22 15:46:03 +08:00
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2023-01-18 10:02:23 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "姓名不能为空"));
|
2022-04-22 15:46:03 +08:00
|
|
|
|
excelComments.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2023-01-18 10:02:23 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "员工信息不存在或者存在多个员工"));
|
2022-04-22 15:46:03 +08:00
|
|
|
|
excelComments.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2023-01-18 10:02:23 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"));
|
2022-04-22 15:46:03 +08:00
|
|
|
|
excelComments.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-18 10:02:23 +08:00
|
|
|
|
if (po.getEmployeeId() != null) {
|
|
|
|
|
|
String bigDecimalValue;
|
|
|
|
|
|
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
|
|
|
|
|
if (attendQuoteField.getFieldName().equals(key)) {
|
|
|
|
|
|
if (1 == attendQuoteField.getFieldType()) {
|
|
|
|
|
|
bigDecimalValue = bigDecimalVal(cellVal, excelComments, valI18n, errorCount + 1, j);
|
|
|
|
|
|
errorSum += StringUtils.isEmpty(bigDecimalValue) ? 1 : 0;
|
|
|
|
|
|
if (StringUtils.isNotEmpty(bigDecimalValue)) {
|
|
|
|
|
|
values.add(AttendQuoteDataValuePO.builder()
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.employeeId(po.getEmployeeId())
|
|
|
|
|
|
.attendQuoteId(attendQuote.getId())
|
|
|
|
|
|
.attendQuoteDataId(po.getId())
|
|
|
|
|
|
.attendQuoteFieldId(attendQuoteField.getId())
|
|
|
|
|
|
.dataValue(Utils.null2String(bigDecimalValue))
|
|
|
|
|
|
.build());
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2022-06-27 16:01:33 +08:00
|
|
|
|
values.add(AttendQuoteDataValuePO.builder()
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.employeeId(po.getEmployeeId())
|
|
|
|
|
|
.attendQuoteId(attendQuote.getId())
|
|
|
|
|
|
.attendQuoteDataId(po.getId())
|
|
|
|
|
|
.attendQuoteFieldId(attendQuoteField.getId())
|
2023-01-18 10:02:23 +08:00
|
|
|
|
.dataValue(Utils.null2String(cellVal))
|
2022-06-27 16:01:33 +08:00
|
|
|
|
.build());
|
|
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum > 0) {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
errorData.add(map);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
// 成功一条就添加一条记录
|
|
|
|
|
|
pos.add(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 导入进度
|
|
|
|
|
|
// salaryBatchService.sendImportRate(message.getBizId(), total, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 数据入库处理
|
|
|
|
|
|
handleDataToDB(attendQuote.getId(), pos, values);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// todo 记录日志
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// recordLog(attendQuote, message.getUserId(), message.getTenantKey(), message.getClientIp());
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
apidatas.put("successCount", successCount);
|
|
|
|
|
|
apidatas.put("errorCount", errorCount);
|
|
|
|
|
|
apidatas.put("errorData", excelComments);
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-28 16:15:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @return null
|
2022-12-09 15:28:29 +08:00
|
|
|
|
* @description 编辑数据
|
2022-10-28 16:15:51 +08:00
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/28 14:40
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void editData(AttendQuoteDataEditParam attendQuoteDataEditParam) {
|
|
|
|
|
|
Map<String, String> attendQuoteData = attendQuoteDataEditParam.getAttendQuoteData();
|
|
|
|
|
|
AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz();
|
|
|
|
|
|
AttendQuoteDataValueBiz attendQuoteDataValueBiz = new AttendQuoteDataValueBiz();
|
|
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
|
|
ids.add(attendQuoteDataEditParam.getId());
|
|
|
|
|
|
AttendQuoteDataQueryParam build = AttendQuoteDataQueryParam.builder().ids(ids).build();
|
|
|
|
|
|
List<AttendQuoteDataBaseDTO> list = dataBiz.list(build);
|
2022-12-09 15:28:29 +08:00
|
|
|
|
if (list == null || list.size() == 0) {
|
2022-10-28 16:15:51 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, String> attendQuoteFieldData = new HashMap<>();
|
2022-12-09 15:28:29 +08:00
|
|
|
|
for (Map.Entry<String, String> entrySet : attendQuoteData.entrySet()) {
|
2022-10-28 16:15:51 +08:00
|
|
|
|
String[] s = entrySet.getKey().split("_");
|
2022-12-09 15:28:29 +08:00
|
|
|
|
attendQuoteFieldData.put(s[0], entrySet.getValue());
|
2022-10-28 16:15:51 +08:00
|
|
|
|
}
|
2022-12-09 15:28:29 +08:00
|
|
|
|
for (Map.Entry<String, String> entrySet : attendQuoteFieldData.entrySet()) {
|
2022-10-28 16:15:51 +08:00
|
|
|
|
AttendQuoteDataValuePO updatePO = AttendQuoteDataValuePO.builder().employeeId(list.get(0).getEmployeeId()).attendQuoteFieldId(SalaryEntityUtil.string2Long(entrySet.getKey())).dataValue(entrySet.getValue()).build();
|
|
|
|
|
|
attendQuoteDataValueBiz.updateDataValue(updatePO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-31 14:50:54 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @return void
|
2022-12-09 15:28:29 +08:00
|
|
|
|
* @description 获取数据
|
2022-10-31 14:50:54 +08:00
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/31 14:12
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-12-09 15:28:29 +08:00
|
|
|
|
public Map<String, Object> getData(AttendQuoteDataEditParam attendQuoteDataEditParam) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
|
|
ids.add(attendQuoteDataEditParam.getId());
|
|
|
|
|
|
AttendQuoteDataQueryParam build = AttendQuoteDataQueryParam.builder().ids(ids).build();
|
|
|
|
|
|
List<AttendQuoteDataBaseDTO> list = dataBiz.list(build);
|
2022-12-09 15:28:29 +08:00
|
|
|
|
if (list == null || list.size() == 0) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
// 所有考勤字段
|
|
|
|
|
|
List<AttendQuoteFieldPO> attendQuoteFields = getAllAttendQuoteFields();
|
|
|
|
|
|
// 获取最终结果
|
|
|
|
|
|
List<Map<String, Object>> listMaps = getListMaps(list);
|
|
|
|
|
|
List<WeaTableColumn> columns = new ArrayList<>();
|
|
|
|
|
|
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile"));
|
|
|
|
|
|
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86317, "工号"), "jobNum"));
|
|
|
|
|
|
|
|
|
|
|
|
// 动态列
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(listMaps)) {
|
|
|
|
|
|
Map<String, Object> map = listMaps.stream().max(Comparator.comparingInt(m -> m.keySet().size())).get();
|
|
|
|
|
|
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
|
|
|
|
|
|
if (map.containsKey(attendQuoteField.getId() + "_attendQuoteData")) {
|
|
|
|
|
|
columns.add(new WeaTableColumn("150", attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
WeaTable weaTable = new WeaTable();
|
|
|
|
|
|
weaTable.setColumns(columns);
|
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
|
result.putAll(weaTable.makeDataResult());
|
|
|
|
|
|
result.success();
|
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
2022-12-09 15:28:29 +08:00
|
|
|
|
datas.put("data", listMaps.get(0));
|
2022-10-31 14:50:54 +08:00
|
|
|
|
datas.put("dataKey", result.getResultMap());
|
|
|
|
|
|
return datas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-22 15:46:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取金额数字值
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param bigDecimalValStr
|
|
|
|
|
|
* @param excelComments
|
|
|
|
|
|
* @param i
|
|
|
|
|
|
* @param j
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private String bigDecimalVal(String bigDecimalValStr, List<Map<String, String>> excelComments, String valI18n, int i, int j) {
|
2022-06-27 16:01:33 +08:00
|
|
|
|
if (StringUtils.isBlank(bigDecimalValStr)) {
|
|
|
|
|
|
return BigDecimal.ZERO.toString();
|
|
|
|
|
|
}
|
2022-04-22 15:46:03 +08:00
|
|
|
|
BigDecimal bigDecimalVal = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
bigDecimalVal = new BigDecimal(bigDecimalValStr);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", valI18n);
|
|
|
|
|
|
excelComments.add(errorMessageMap);
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, valI18n, i, i, j, j);
|
2022-04-22 15:46:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
return bigDecimalVal == null ? "" : bigDecimalVal.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// /**
|
|
|
|
|
|
// * 记录日志
|
|
|
|
|
|
// * @param attendQuote
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @param currentTenantKey
|
|
|
|
|
|
// * @param clientIp
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private void recordLog(AttendQuotePO attendQuote, Long currentEmployeeId, String currentTenantKey, String clientIp) {
|
2022-04-21 14:15:56 +08:00
|
|
|
|
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(getSalarySobMapper())
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey())
|
|
|
|
|
|
// .eq(SalarySobPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalarySobPO::getId, attendQuote.getSalarySobId())
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// String sourceType = AttendQuoteSourceTypeEnum.getDefaultLabelByValue(attendQuote.getSourceType(), currentEmployeeId, currentTenantKey);
|
|
|
|
|
|
//
|
|
|
|
|
|
// LoggerContext loggerContext = new LoggerContext();
|
|
|
|
|
|
// loggerContext.setTargetId(String.valueOf(attendQuote.getId()));
|
|
|
|
|
|
// loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(attendQuote.getSalaryYearMonth())+" "+(CollectionUtils.isNotEmpty(salarySobs)?salarySobs.get(0).getName():""));
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
2022-04-22 15:46:03 +08:00
|
|
|
|
// loggerContext.setOperateTypeName(sourceType+SalaryI18nUtil.getI18nLabel(93931, "考勤数据"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(sourceType+SalaryI18nUtil.getI18nLabel( 93931, "考勤数据"));
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// loggerContext.setNewValues(attendQuote);
|
|
|
|
|
|
// loggerContext.setTenant_key(currentTenantKey);
|
|
|
|
|
|
// loggerContext.setOperator(currentEmployeeId.toString());
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(clientIp)) {
|
|
|
|
|
|
// loggerContext.setClientIp(clientIp);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// attendQuoteLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
// }
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 检查参数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
* @param params
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// private boolean checkParams(BatchDocumentMessage message, Map<String, Object> params) {
|
|
|
|
|
|
// boolean isValid = true;
|
|
|
|
|
|
// String errorMsg = "";
|
|
|
|
|
|
// if (params == null) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100582, "参数必传");
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// if (!params.containsKey("salaryYearMonth")
|
|
|
|
|
|
// || !params.containsKey("salarySobId")
|
|
|
|
|
|
// || params.get("salaryYearMonth") == null
|
|
|
|
|
|
// || params.get("salarySobId") == null) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100588, "薪资所属月和薪资账套必传");
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// String salaryYearMonth = params.get("salaryYearMonth").toString();
|
|
|
|
|
|
// if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100365, "薪资所属月格式有误,正确格式示例为'2021-01'");
|
|
|
|
|
|
// } else {
|
2022-04-21 14:15:56 +08:00
|
|
|
|
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(getSalarySobMapper())
|
2022-03-15 14:18:04 +08:00
|
|
|
|
// .eq(SalarySobPO::getTenantKey, message.getTenantKey())
|
|
|
|
|
|
// .eq(SalarySobPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalarySobPO::getId, Long.valueOf(params.get("salarySobId").toString()))
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// if (CollectionUtils.isEmpty(salarySobs)) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100537, "薪资账套不存在");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 有错误信息发送
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(errorMsg)) {
|
|
|
|
|
|
// // 发送导入回调信息
|
|
|
|
|
|
// salaryBatchService.sendImportCallBackInfo(message, errorMsg);
|
|
|
|
|
|
// isValid = false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isValid;
|
|
|
|
|
|
// }
|
2022-04-22 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 检查列头
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-06-23 14:08:55 +08:00
|
|
|
|
private String checkHeaders(List<String> headerList, List<AttendQuoteFieldPO> attendQuoteFields) {
|
2022-04-22 15:46:03 +08:00
|
|
|
|
boolean isValid = true;
|
|
|
|
|
|
String userNameI18n = SalaryI18nUtil.getI18nLabel(85429, "姓名");
|
|
|
|
|
|
|
|
|
|
|
|
List<String> mustHeaders = attendQuoteFields.stream().map(AttendQuoteFieldPO::getFieldName).collect(Collectors.toList());
|
|
|
|
|
|
mustHeaders.add(userNameI18n);
|
|
|
|
|
|
|
|
|
|
|
|
// 缺少的必须列
|
|
|
|
|
|
List<String> lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
String errorMsg = "";
|
|
|
|
|
|
String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(101850, "缺少如下列,请检查:");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(attendQuoteFields)) {
|
|
|
|
|
|
errorMsg = SalaryI18nUtil.getI18nLabel(101849, "考勤字段列缺失,请补充");
|
|
|
|
|
|
} else if (CollectionUtils.isNotEmpty(lackHeaders)) {
|
|
|
|
|
|
errorMsg = checkHeaderI18n + Joiner.on(",").join((Iterable<?>) lackHeaders);
|
|
|
|
|
|
}
|
2022-06-23 14:08:55 +08:00
|
|
|
|
|
|
|
|
|
|
return errorMsg;
|
2022-04-22 15:46:03 +08:00
|
|
|
|
}
|
2022-03-15 14:18:04 +08:00
|
|
|
|
}
|