diff --git a/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java new file mode 100644 index 000000000..aef9939b4 --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java @@ -0,0 +1,38 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; +import com.engine.salary.mapper.datacollection.AttendQuoteDataValueMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class AttendQuoteDataValueBiz { + + /** + * 根据考勤引用字段表的主键id删除 + * @param attendQuoteDataIds + */ + public void deleteByAttendQuoteDataIds(List attendQuoteDataIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + mapper.deleteByAttendQuoteDataIds(attendQuoteDataIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public List listSome(AttendQuoteDataValuePO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + +} diff --git a/src/com/engine/salary/init.sql b/src/com/engine/salary/init.sql index c797ce514..f99793aed 100644 --- a/src/com/engine/salary/init.sql +++ b/src/com/engine/salary/init.sql @@ -6,6 +6,7 @@ alter table hrsa_add_up_deduction modify id bigint auto_increment; alter table hrsa_add_up_situation modify id bigint auto_increment; alter table hrsa_other_deduction modify id bigint auto_increment; alter table hrsa_attend_quote_field modify id bigint auto_increment; +alter table hrsa_attend_quote_sync_set modify id bigint auto_increment; --福利方案主键自增增加 alter table hrsa_social_security_scheme modify id bigint auto_increment; diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml index 1d6199b78..b94390a7d 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml @@ -303,7 +303,6 @@ INSERT INTO hrsa_attend_quote_data( - id, employee_id, attend_quote_id, create_time, @@ -313,7 +312,6 @@ VALUES ( - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.createTime}, @@ -325,7 +323,6 @@ INSERT INTO hrsa_attend_quote_data( - id, employee_id, attend_quote_id, create_time, @@ -335,7 +332,6 @@ select - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.createTime}, @@ -347,7 +343,6 @@ INSERT INTO hrsa_attend_quote_data( - id, employee_id, attend_quote_id, create_time, @@ -357,7 +352,6 @@ VALUES ( - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.createTime}, diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java index 9e41c3e3d..2d49b67be 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java @@ -61,15 +61,14 @@ public interface AttendQuoteDataValueMapper { /** * 批量删除数据采集-考勤引用数据 * @param attendQuoteDataIds - * @param tenantKey */ - void deleteByAttendQuoteDataIds(@Param("attendQuoteDataIds") Collection attendQuoteDataIds, @Param("tenantKey") String tenantKey); + void deleteByAttendQuoteDataIds(@Param("attendQuoteDataIds") Collection attendQuoteDataIds); /** * 批量插入数据采集-考勤引用数据 * @param values - * @param currentTenantKey */ - void insertData(@Param("collection") List values, String currentTenantKey); - + void insertData(@Param("collection") List values); + + List listSome(AttendQuoteDataValuePO param); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml index 5ebf4eae1..0e7851689 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml @@ -196,7 +196,7 @@ UPDATE hrsa_attend_quote_data_value SET delete_type = 1 - WHERE tenant_key = #{tenantKey} AND delete_type = 0 + WHERE delete_type = 0 AND attend_quote_data_id IN #{attendQuoteDataId} @@ -205,7 +205,6 @@ INSERT INTO hrsa_attend_quote_data_value( - id, employee_id, attend_quote_id, attend_quote_data_id, @@ -218,7 +217,6 @@ VALUES ( - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.attendQuoteDataId}, @@ -233,7 +231,6 @@ INSERT INTO hrsa_attend_quote_data_value( - id, employee_id, attend_quote_id, attend_quote_data_id, @@ -246,7 +243,6 @@ select - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.attendQuoteDataId}, @@ -261,7 +257,6 @@ INSERT INTO hrsa_attend_quote_data_value( - id, employee_id, attend_quote_id, attend_quote_data_id, @@ -274,7 +269,6 @@ VALUES ( - #{item.id}, #{item.employeeId}, #{item.attendQuoteId}, #{item.attendQuoteDataId}, @@ -288,6 +282,16 @@ + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml index 1a122072e..66be00b4d 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml @@ -264,11 +264,10 @@ INSERT INTO hrsa_attend_quote_field - (id,field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) VALUES ( - #{item.id}, #{item.fieldName}, #{item.sourceType}, #{item.fieldType}, @@ -281,11 +280,10 @@ INSERT INTO hrsa_attend_quote_field - (id,field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) select - #{item.id}, #{item.fieldName}, #{item.sourceType}, #{item.fieldType}, @@ -298,11 +296,10 @@ INSERT INTO hrsa_attend_quote_field - (id,field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) VALUES ( - #{item.id}, #{item.fieldName}, #{item.sourceType}, #{item.fieldType}, diff --git a/src/com/engine/salary/service/AttendQuoteDataService.java b/src/com/engine/salary/service/AttendQuoteDataService.java new file mode 100644 index 000000000..4893779fa --- /dev/null +++ b/src/com/engine/salary/service/AttendQuoteDataService.java @@ -0,0 +1,60 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; + +import java.util.Map; + +/** + * 数据采集-考勤引用数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AttendQuoteDataService { + + /** + * 查看数据采集-考勤引用 + * @param queryParam + * @return + */ + Map view(AttendQuoteDataQueryParam queryParam); +// +// /** +// * 导出考勤数据 +// * @param queryParam +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// Map export(AttendQuoteDataQueryParam queryParam, Long currentEmployeeId, String currentTenantKey); +// +// /** +// * 同步引用考勤数据 +// * @param syncParam +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam, Long currentEmployeeId, String currentTenantKey); +// +// /** +// * 获取考勤引用数据 +// * @param salaryYearMonth +// * @param salarySobId +// * @param employeeIds +// * @param tenantKey +// * @return +// */ +// List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds, String tenantKey); +// +// /** +// * 导出考勤数据作为模板 +// * @param exportParam +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// Map downloadTemplate(AttendQuoteDataExportTemplateParam exportParam, Long currentEmployeeId, String currentTenantKey); +} diff --git a/src/com/engine/salary/service/AttendQuoteService.java b/src/com/engine/salary/service/AttendQuoteService.java index 13636fdc5..6d49646da 100644 --- a/src/com/engine/salary/service/AttendQuoteService.java +++ b/src/com/engine/salary/service/AttendQuoteService.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.Map; public interface AttendQuoteService { - /** + /**AttendQuoteDataService * 数据采集-考勤引用列表 */ Map list(Map params); diff --git a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java new file mode 100644 index 000000000..44e7f62cb --- /dev/null +++ b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java @@ -0,0 +1,878 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.*; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AttendQuoteDataService; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Description: 数据采集-考勤引用数据 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDataService { + + private AttendQuoteBiz attendQuoteBiz = new AttendQuoteBiz(); + private AttendQuoteDataBiz biz = new AttendQuoteDataBiz(); + private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz(); + + private AttendQuoteFieldBiz fieldBiz = new AttendQuoteFieldBiz(); + private EmployBiz employeeBiz = new EmployBiz(); +// AttendQuoteFieldSettingBiz a= new AttendQuoteFieldSettingBiz(); + + + // @Resource +// private SalarySobMapper salarySobMapper; +// @Resource +// private SalarySobRangeMapper salarySobRangeMapper; +// @Resource +// private SalarySobService salarySobService; + // @Resource +// private HrmCommonEmployeeService employeeService; +// @Resource +// private SalaryBatchService salaryBatchService; +// @Resource +// private AttendQuoteFieldSettingService attendQuoteFieldSettingService; +// @RpcReference +// private RemoteAttend4SalaryService remoteAttend4SalaryService; +// @Autowired +// private ExecutorService taskExecutor; +// @Autowired +// private LoggerTemplate attendQuoteLoggerTemplate; +// + @Override + public Map view(AttendQuoteDataQueryParam queryParam) { + if (queryParam == null) { + throw new SalaryRunTimeException("参数不能为空"); + } + + Long id = queryParam.getAttendQuoteId(); + if (id == null) { + throw new SalaryRunTimeException("考勤引用id不能为空"); + } + // 考勤数据分页主数据 + List attendQuoteDataBases = biz.list(queryParam); + // 所有考勤字段 + List attendQuoteFields = getAllAttendQuoteFields(); + // 获取最终结果 + List> listMaps = getListMaps(attendQuoteDataBases); + +// Page> listPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount()); +// listPage.setRecords(listMaps); +// +// WeaTable weaTable = FormatManager.getInstance() +// .genTable(LinkedHashMap.class, listPage); +// // 表格表头 +// List columns = new ArrayList<>(); +// columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85429, "姓名"), "username", "150")); +// columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"), "departmentName", "150")); +// columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86186, "手机号"), "mobile", "150")); +// columns.add(new WeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86317, "工号"), "jobNum", "150")); +// // 动态列 +// if (CollectionUtils.isNotEmpty(listMaps)) { +// Map map = listMaps.get(0); +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// if (map.containsKey(attendQuoteField.getId() + "_attendQuoteData")) { +// columns.add(new WeaTableColumn(attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData", "150")); +// } +// } +// } +// weaTable.setColumns(columns); +// weaTable.setModule("hrmsalary"); +// +// return weaTable; + return null; + } + + /** + * 获取所有考勤字段 + * + * @return + */ + private List getAllAttendQuoteFields() { + return fieldBiz.listSome(AttendQuoteFieldPO.builder().build()); + } + + /** + * 获取考勤数据结果 + * + * @param attendQuoteDataBases + * @return + */ + private List> getListMaps(List attendQuoteDataBases) { + if (CollectionUtils.isEmpty(attendQuoteDataBases)) { + return new ArrayList<>(); + } + + // 考核数据值 + List attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuoteDataBases.get(0).getAttendQuoteId()).build()); + + return attendQuoteDataBases.stream().map(m -> { + Map 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()); + } +// +// @Override +// public List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds, String tenantKey) { +// if (salaryYearMonth == null || salarySobId == null || com.weaver.teams.util.StringUtils.isEmpty(tenantKey)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, UserContext.getCurrentEmployeeId(), 100358, "参数有误:薪资所属月、薪资账套id、租户key必传")); +// } +// List list = new ArrayList<>(); +// List attendQuotes = new LambdaQueryChainWrapper<>(attendQuoteMapper) +// .eq(AttendQuotePO::getDeleteType, 0) +// .eq(AttendQuotePO::getTenantKey, tenantKey) +// .eq(AttendQuotePO::getSalaryYearMonth, salaryYearMonth.atDay(1)) +// .eq(AttendQuotePO::getSalarySobId, salarySobId).list(); +// +// if (CollectionUtils.isEmpty(attendQuotes)) { +// return Collections.emptyList(); +// } +// AttendQuotePO attendQuote = attendQuotes.get(0); +// +// List attendQuoteDataValues = new LambdaQueryChainWrapper<>(attendQuoteDataValueMapper) +// .eq(AttendQuoteDataValuePO::getDeleteType, 0) +// .eq(AttendQuoteDataValuePO::getTenantKey, tenantKey) +// .eq(AttendQuoteDataValuePO::getAttendQuoteId, attendQuote.getId()) +// .in(CollectionUtils.isNotEmpty(employeeIds), AttendQuoteDataValuePO::getEmployeeId, employeeIds).list(); +// +// if (CollectionUtils.isEmpty(employeeIds)) { +// employeeIds = CollectionUtils.emptyIfNull(attendQuoteDataValues).stream().map(AttendQuoteDataValuePO::getEmployeeId) +// .distinct().collect(Collectors.toList()); +// } +// +// employeeIds.forEach(e->{ +// AttendQuoteDataDTO attendQuoteData = new AttendQuoteDataDTO(); +// attendQuoteData.setEmployeeId(e); +// List 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 Map export(AttendQuoteDataQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) { +// if (queryParam.getAttendQuoteId() == null) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100253, "考勤引用id不能为空")); +// } +// // 构建异步导出参数 +// Map map = salaryBatchService.buildeExportParam("exportAttendQuoteData"); +// +// String username = UserContext.getCurrentUser().getUsername(); +// String eteamsId = TenantRpcContext.getEteamsId(); +// taskExecutor.execute(() -> { +// try { +// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); +// +// List sheetList = new ArrayList<>(); +// +// ExcelSheetData excelSheetData = new ExcelSheetData(); +// +// // 考勤数据分页主数据 +// List attendQuoteDataBases = mapper.list(queryParam, currentTenantKey);; +// // 所有考勤字段 +// List attendQuoteFields = getAllAttendQuoteFields(currentTenantKey); +// // 获取最终结果 +// List> listMaps = getListMaps(attendQuoteDataBases, currentTenantKey); +// +// // 1.工作簿名称 +// String nameI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 93931, "考勤数据"); +// excelSheetData.setSheetName(nameI18n); +// List header = new ArrayList<>(); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 85429, "姓名")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86185, "部门")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86186, "手机号")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86317, "工号")); +// // 动态列 +// if (CollectionUtils.isNotEmpty(listMaps)) { +// Map mapColumn = listMaps.get(0); +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// if (mapColumn.containsKey(attendQuoteField.getId()+"_attendQuoteData")) { +// header.add(attendQuoteField.getFieldName()); +// } +// } +// } +// +// // 2.表头 +// excelSheetData.setHeaders(Collections.singletonList(header.toArray(new String[]{}))); +// +// List> rows = new ArrayList<>(); +// for (Map dto : listMaps) { +// List row = new ArrayList<>(); +// row.add(dto.get("username")); +// row.add(dto.get("departmentName")); +// row.add(dto.get("mobile")); +// row.add(dto.get("jobNum")); +// +// // 动态列 +// Map mapColumn = listMaps.get(0); +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// if (mapColumn.containsKey(attendQuoteField.getId()+"_attendQuoteData")) { +// row.add(dto.get(attendQuoteField.getId().toString()+"_attendQuoteData")); +// } +// } +// +// rows.add(row); +// } +// // 3.表数据 +// excelSheetData.setRows(rows); +// +// sheetList.add(excelSheetData); +// +// salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() +// .bizId(map.get("biz").toString()) +// .flag(true) +// .userId(currentEmployeeId) +// .eteamsId(eteamsId) +// .tenantKey(currentTenantKey) +// .operator(username) +// .module(map.get("module").toString()) +// .fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())) +// .handlerName(map.get("function").toString()) +// .dataType(nameI18n) +// .function(map.get("function").toString()).build(), sheetList); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// }); +// return map; +// } +// +// @BatchExportHandler("exportAttendQuoteData") +// public void exportAttendQuoteDataHandler() { +// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); +// log.info("接受到考勤数据导出的结果:{}", JSONObject.toJSONString(message)); +// } +// +// /** +// * 获取表头设置字段 +// * @param sourceType +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// private List getAttendQuoteSetFields(AttendQuoteSourceTypeEnum sourceType, Long currentEmployeeId, String currentTenantKey) { +// List allAttendQuoteFields = getAllAttendQuoteFields(currentTenantKey); +// List attendQuoteFieldSettingList = attendQuoteFieldSettingService.listNoSync(AttendQuoteFieldSettingQueryParam.builder().sourceType(sourceType).isViewChecked(Boolean.TRUE).build(), currentEmployeeId, currentTenantKey); +// List attendQuoteFields = new ArrayList<>(); +// attendQuoteFieldSettingList.forEach(s->{ +// List items = s.getItems(); +// CollectionUtils.emptyIfNull(items).forEach(i->{ +// Optional optional = allAttendQuoteFields.stream().filter(f->f.getId().equals(i.getId())).findFirst(); +// optional.ifPresent(attendQuoteFields::add); +// }); +// }); +// return attendQuoteFields; +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public WeaResult syncAttendQuoteData(AttendQuoteDataSyncParam syncParam, Long currentEmployeeId, String currentTenantKey) { +// WeaResult checkResult = AttendQuoteDataSyncParam.checkParam(syncParam, currentEmployeeId, currentTenantKey); +// if (checkResult.getCode() == WeaResultCodeEnum.ERROR.getCode()) { +// return checkResult; +// } +// String salaryYearMonth = syncParam.getSalaryYearMonth(); +// int year = Integer.parseInt(salaryYearMonth.split("-")[0]); +// int month = Integer.parseInt(salaryYearMonth.split("-")[1]); +// if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100365, "薪资所属月格式有误,正确格式示例为'2021-01'")); +// } +// // 1.获取已设置的可同步的考勤字段 +// List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.QUOTE, currentEmployeeId, currentTenantKey); +// if (CollectionUtils.isEmpty(attendQuoteFields)) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100366, "请先设置同步字段")); +// } +// // 获取薪资账套 +// SalarySobCycleDTO salarySobCycle = salarySobService.getSalarySobCycle(syncParam.getSalarySobId(), YearMonth.of(year, month), currentTenantKey); +// // 2.薪资账套人员 +// List employeeIds = new ArrayList<>(); +// // 获取薪资账套人员 +// List salarySobRanges = new LambdaQueryChainWrapper<>(salarySobRangeMapper) +// .eq(SalarySobRangePO::getTenantKey, currentTenantKey) +// .eq(SalarySobRangePO::getDeleteType, 0) +// .eq(SalarySobRangePO::getIncludeType, 1) +// .eq(SalarySobRangePO::getSalarySobId, salarySobCycle.getSalarySobId()) +// .list(); +// List salarySobRangeEmpQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(salarySobRanges); +// List employeeSalarySobIds = salarySobRangeMapper.listEmployeeIds(salarySobRangeEmpQueryParams, currentTenantKey); +// if (CollectionUtils.isEmpty(employeeSalarySobIds) || CollectionUtils.isEmpty(salarySobRangeEmpQueryParams)) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100367, "薪资账套还没有人员")); +// } +// // 账套外人员 +// List employeeOtherIds = (List) syncParam.getEmployeeIds(); +// employeeIds.addAll(employeeSalarySobIds); +// employeeIds.addAll(CollectionUtils.emptyIfNull(employeeOtherIds)); +// // 3.考勤引用 +// AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.QUOTE, syncParam.getSalarySobId(), year, month, syncParam.getDescription(), currentEmployeeId, currentTenantKey); +// +// // 4.获取考勤模块数据 +// List> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(salarySobCycle.getAttendCycle(), employeeIds, attendQuoteFields, currentTenantKey); +// List pos = new ArrayList<>(); +// List values = new ArrayList<>(); +// // 5.考勤引用数据处理 +// if (CollectionUtils.isNotEmpty(attendQuoteSyncData)) { +// for (Long employeeId : employeeIds) { +// AttendQuoteDataPO po = new AttendQuoteDataPO(); +// po.setId(IdGenerator.generate()); +// po.setCreateTime(LocalDateTime.now()); +// po.setUpdateTime(LocalDateTime.now()); +// po.setCreator(currentEmployeeId); +// po.setTenantKey(currentTenantKey); +// // 考勤引用表的主键id +// po.setAttendQuoteId(attendQuote.getId()); +// po.setEmployeeId(employeeId); +// pos.add(po); +// for (Map attendQuoteData : attendQuoteSyncData) { +// if (attendQuoteData.get("employeeId").toString().equals(employeeId.toString())) { +// values.add(AttendQuoteDataValuePO.builder() +// .id(IdGenerator.generate()) +// .createTime(LocalDateTime.now()) +// .updateTime(LocalDateTime.now()) +// .creator(currentEmployeeId) +// .tenantKey(currentTenantKey) +// .employeeId(employeeId) +// .attendQuoteId(attendQuote.getId()) +// .attendQuoteDataId(po.getId()) +// .attendQuoteFieldId(Long.valueOf(attendQuoteData.get("attendQuoteFieldId").toString())) +// .dataValue(attendQuoteData.get("dataValue") == null ? "" : attendQuoteData.get("dataValue").toString()) +// .build()); +// } +// } +// } +// } else { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100368, "暂无考勤数据可以同步")); +// } +// // 6.数据落库处理 +// handleDataToDB(attendQuote.getId(), pos, values, currentTenantKey); +// // 记录日志 +// recordLog(attendQuote, currentEmployeeId, currentTenantKey, null); +// return WeaResult.success(StringUtils.EMPTY); +// } +// +// /** +// * 获取考勤引用 +// * @param salarySobId +// * @param year +// * @param month +// * @param employeeId +// * @param tenantKey +// * @return +// */ +// private AttendQuotePO getAttendQuote(AttendQuoteSourceTypeEnum sourceType, Long salarySobId, int year, int month, String description, Long employeeId, String tenantKey) { +// SalarySobCycleDTO salarySobCycle = salarySobService.getSalarySobCycle(salarySobId, YearMonth.of(year, month), tenantKey); +// +// List attendQuotes = new LambdaQueryChainWrapper<>(attendQuoteMapper) +// .eq(AttendQuotePO::getTenantKey, tenantKey) +// .eq(AttendQuotePO::getDeleteType, 0) +// .eq(AttendQuotePO::getSalarySobId, salarySobId) +// .eq(AttendQuotePO::getSalaryYearMonth, LocalDate.of(year, month, 1)) +// .list(); +// // 考勤引用 +// AttendQuotePO attendQuote = new AttendQuotePO(); +// if (CollectionUtils.isNotEmpty(attendQuotes)) { +// attendQuote = attendQuotes.get(0); +// } +// attendQuote.setSalarySobId(salarySobCycle.getSalarySobId()); +// LocalDateRange salaryCycleRange = salarySobCycle.getSalaryCycle(); +// LocalDateRange attendCycleRange = salarySobCycle.getAttendCycle(); +// // 考勤周期 +// attendQuote.setAttendCycle(attendCycleRange.getFromDate()+" ~ "+attendCycleRange.getEndDate()); +// // 薪资周期 +// attendQuote.setSalaryCycle(salaryCycleRange.getFromDate()+" ~ "+salaryCycleRange.getEndDate()); +// attendQuote.setSalaryYearMonth(LocalDate.of(year, month, 1)); +// // 来源:导入 +// attendQuote.setSourceType(sourceType.getValue()); +// attendQuote.setDescription(description); +// attendQuote.setCreateTime(LocalDateTime.now()); +// attendQuote.setUpdateTime(LocalDateTime.now()); +// attendQuote.setCreator(employeeId); +// attendQuote.setTenantKey(tenantKey); +// // 新增或修改考勤引用 +// if (attendQuote.getId()!=null) { +// attendQuoteMapper.updateById(attendQuote); +// } else { +// attendQuote.setId(IdGenerator.generate()); +// attendQuoteMapper.insert(attendQuote); +// } +// return attendQuote; +// } +// +// /** +// * 获取考勤模块数据 +// * @param attendCycleRange +// * @param employeeIds +// * @param attendQuoteFields +// * @param currentTenantKey +// * @return +// */ +// private List> getAttendQuoteDataFromRemoteAttend(LocalDateRange attendCycleRange, List employeeIds, List attendQuoteFields, String currentTenantKey) { +// List> attendQuoteSyncData = new ArrayList<>(); +// Attend4Salary attend4Salary = new Attend4Salary(); +// try { +// int partSize = 500; +// List> partition = Lists.partition(employeeIds, partSize); +// for (List part : partition) { +// attend4Salary.setBeginDate(SalaryDateUtil.localDateToDate(attendCycleRange.getFromDate())); +// attend4Salary.setEndDate(SalaryDateUtil.localDateToDate(attendCycleRange.getEndDate())); +// attend4Salary.setTenantKey(currentTenantKey); +// attend4Salary.setOnlyEmpIds(part); +// attend4Salary.setPageSize(partSize); +// attend4Salary.setUnit("hour"); +// WeaResult> attendResult = remoteAttend4SalaryService.getWorkTimeSummary(attend4Salary, AttendQuoteDataBO.getCurrentUser4Remote()); +// log.info("考勤数据[按小时]:{}", JSONUtils.toJSONString(attendResult.getData())); +// AttendQuoteDataBO.buildAttendDataFromRemote("hour", attendResult.getData(), attendQuoteFields, attendQuoteSyncData); +// attend4Salary.setUnit("day"); +// attendResult = remoteAttend4SalaryService.getWorkTimeSummary(attend4Salary, AttendQuoteDataBO.getCurrentUser4Remote()); +// log.info("考勤数据[按天]:{}", JSONUtils.toJSONString(attendResult.getData())); +// AttendQuoteDataBO.buildAttendDataFromRemote("day", attendResult.getData(), attendQuoteFields, attendQuoteSyncData); +// } +// } catch (Exception e) { +// log.error("获取考勤数据错误失败:{}", String.format("参数:%s,错误信息:%s", JSONObject.toJSONString(attend4Salary), e.getMessage())); +// return attendQuoteSyncData; +// } +// return attendQuoteSyncData; +// } +// +// /** +// * 引用同步或导入落库处理 +// * @param attendQuoteId +// * @param pos +// * @param values +// * @param currentTenantKey +// */ +// private void handleDataToDB(Long attendQuoteId, List pos, List values, String currentTenantKey) { +// // 数据落库处理 +// 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)); +// // 删除考勤数据 +// new LambdaUpdateChainWrapper<>(mapper) +// .eq(AttendQuoteDataPO::getAttendQuoteId, attendQuoteId) +// .eq(AttendQuoteDataPO::getDeleteType, 0) +// .eq(AttendQuoteDataPO::getTenantKey, currentTenantKey) +// .set(AttendQuoteDataPO::getDeleteType, 1) +// .update(); +// // 新增考勤数据 +// mapper.insertData(pos, currentTenantKey); +// // 删除考勤值数据 +// attendQuoteDataValueMapper.deleteByAttendQuoteDataIds(pos.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList()), currentTenantKey); +// // 新增考勤值数据 +// if (CollectionUtils.isNotEmpty(values)) { +// attendQuoteDataValueMapper.insertData(values, currentTenantKey); +// } +// } +// +// @Override +// public Map downloadTemplate(AttendQuoteDataExportTemplateParam exportParam, Long currentEmployeeId, String currentTenantKey) { +// List sheetList = new ArrayList<>(); +// ExcelSheetData excelSheetData = new ExcelSheetData(); +// // 考勤主数据 +// AttendQuotePO po = new LambdaQueryChainWrapper<>(attendQuoteMapper) +// .eq(AttendQuotePO::getDeleteType, 0) +// .eq(AttendQuotePO::getTenantKey, currentTenantKey) +// .in(CollectionUtils.isNotEmpty(exportParam.getIds()), AttendQuotePO::getId, exportParam.getIds()) +// .eq(AttendQuotePO::getSalaryYearMonth, exportParam.getSalaryYearMonth().atDay(1)) +// .eq(AttendQuotePO::getSalarySobId, exportParam.getSalarySobId()).one(); +// AttendQuoteDataQueryParam queryParam = AttendQuoteDataQueryParam.builder().attendQuoteId(po==null?0L:po.getId()).build(); +// List attendQuoteDataBases = mapper.list(queryParam, currentTenantKey);; +// // 获取已设置的可同步的字段 +// List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT, currentEmployeeId, currentTenantKey); +// // 获取最终结果 +// List> listMaps = getListMaps(attendQuoteDataBases, currentTenantKey); +// +// // 1.工作簿名称 +// String nameI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 101606, "考勤引用导入模板"); +// excelSheetData.setSheetName(nameI18n); +// List header = new ArrayList<>(); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 85429, "姓名")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86185, "部门")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86186, "手机号")); +// header.add(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 86317, "工号")); +// // 动态列 +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// header.add(attendQuoteField.getFieldName()); +// } +// // 2.表头 +// excelSheetData.setHeaders(Collections.singletonList(header.toArray(new String[]{}))); +// +// List> rows = new ArrayList<>(); +// for (Map dto : listMaps) { +// List row = new ArrayList<>(); +// row.add(dto.get("username")); +// row.add(dto.get("departmentName")); +// row.add(dto.get("mobile")); +// row.add(dto.get("jobNum")); +// +// // 动态列 +// Map map = listMaps.get(0); +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// row.add(map.containsKey(attendQuoteField.getId()+"_attendQuoteData")?dto.get(attendQuoteField.getId()+"_attendQuoteData"):""); +// } +// +// rows.add(row); +// } +// // 3.表数据 +// excelSheetData.setRows(rows); +// // 4.注释 +// List excelComments = Lists.newArrayList(); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100344, "必填"), 0, 0, 0, 0); +// if (CollectionUtils.isNotEmpty(attendQuoteFields)) { +// for (int i=4; i excelSheets = message.getBatchFile().getExcelSheets(); +// +// // 租户key +// String tenantKey = message.getTenantKey().toLowerCase(); +// Long currentEmployeeId = message.getUserId(); +// // 加密用 +// DSTenantKeyThreadVar.tenantKey.set(tenantKey); +// String paramsData = message.getUploadSet().getCustomData(); +// Map params = JSONObject.parseObject(paramsData, Map.class); +// +// // 参数校验 +// boolean isValid = checkParams(message, params); +// if (!isValid) { +// return; +// } +// +// String salaryYearMonth = params.get("salaryYearMonth").toString(); +// int year = Integer.parseInt(salaryYearMonth.split("-")[0]); +// int month = Integer.parseInt(salaryYearMonth.split("-")[1]); +// +// // 获取租户下所有的人员 +// List employees = attendQuoteMapper.listEmployee(tenantKey); +// // 获取已设置的可同步的考勤字段 +// List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT, currentEmployeeId, tenantKey); +// // 获取考勤引用 +// AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.IMPORT, Long.valueOf(params.get("salarySobId").toString()), year, month, StringUtils.EMPTY, message.getUserId(), tenantKey); +// +// int total = 0; +// for (ExcelSheet excelSheet : excelSheets) { +// List> data = excelSheet.getData(); +// if (data != null) { +// total += data.size(); +// } +// } +// int index = 0; +// int successCount = 0; +// int errorCount = 0; +// // 错误excel内容 +// List errorExcelSheets = new ArrayList<>(); +// // 待导入数据 +// List pos = new ArrayList<>(); +// List values = new ArrayList<>(); +// String valI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100581, "请输入数字"); +// for (ExcelSheet excelSheet : excelSheets) { +// if (excelSheet.getHeader().size() == 0) { +// continue; +// } +// List headers = excelSheet.getHeader(); +// boolean isValidHeader = checkHeaders(message, headers, attendQuoteFields); +// if (!isValidHeader) { +// return; +// } +// // 错误sheet数据 +// List> errorData = new ArrayList<>(); +// // 错误提示 +// List excelComments = new ArrayList<>(); +// +// List> data = excelSheet.getData(); +// Map map; +// if (data == null) { +// continue; +// } +// AttendQuoteDataPO po; +// for (int i = 0; i < data.size(); i++) { +// index += 1; +// map = data.get(i); +// +// po = new AttendQuoteDataPO(); +// po.setId(IdGenerator.generate()); +// po.setCreateTime(LocalDateTime.now()); +// po.setUpdateTime(LocalDateTime.now()); +// po.setCreator(message.getUserId()); +// po.setTenantKey(tenantKey); +// // 考勤引用表的主键id +// po.setAttendQuoteId(attendQuote.getId()); +// +// int errorSum = 0; +// +// String userName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名"))).orElse("").toString(); +// String deparmentName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 86185, "部门"))).orElse("").toString(); +// List employeeSameIds = employees.stream().filter(e -> (com.weaver.teams.util.StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) +// && (com.weaver.teams.util.StringUtils.isBlank(deparmentName) || Objects.equals(e.getDeparmentName(), deparmentName))).map(DataCollectionEmployeePO::getEmployeeId) +// .collect(Collectors.toList()); +// +// for (int j = 0; j < headers.size(); j++) { +// Map header = headers.get(j); +// Object key = header.get("key"); +// if (key == null) { +// continue; +// } +// String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString(); +// if (SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名").equals(key.toString())) { +// if (com.weaver.teams.util.StringUtils.isEmpty(cellVal)) { +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100577, "不能为空"), errorCount+1, errorCount+1, j, j); +// errorSum += 1; +// } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100578, "员工信息不能为空且不可重复(姓名与部门同时确认唯一)"), errorCount+1, errorCount+1, j, j); +// errorSum += 1; +// } else { +// Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1?employeeSameIds.get(0):null; +// if (employeeId!=null && employeeId>0) { +// po.setEmployeeId(employeeId); +// } else { +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100579, "姓名错误,系统内不存在该姓名"), errorCount+1, errorCount+1, j, j); +// errorSum += 1; +// } +// } +// } +// String bigDecimalValue; +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// if (attendQuoteField.getFieldName().equals(key.toString())) { +// bigDecimalValue = bigDecimalVal(cellVal, excelComments, valI18n, errorCount+1, j); +// errorSum += StringUtils.isEmpty(bigDecimalValue)?1:0; +// if (StringUtils.isNotEmpty(bigDecimalValue)) { +// values.add(AttendQuoteDataValuePO.builder() +// .id(IdGenerator.generate()) +// .createTime(LocalDateTime.now()) +// .updateTime(LocalDateTime.now()) +// .creator(message.getUserId()) +// .tenantKey(tenantKey) +// .employeeId(po.getEmployeeId()) +// .attendQuoteId(attendQuote.getId()) +// .attendQuoteDataId(po.getId()) +// .attendQuoteFieldId(attendQuoteField.getId()) +// .dataValue(cellVal) +// .build()); +// } +// break; +// } +// } +// } +// +// if (errorSum>0) { +// errorCount += 1; +// // 添加错误数据 +// errorData.add(map); +// } else { +// successCount += 1; +// // 成功一条就添加一条记录 +// pos.add(po); +// } +// // 导入进度 +// salaryBatchService.sendImportRate(message.getBizId(), total, index); +// } +// +// // 如果sheet包含错误数据 +// if (CollectionUtils.isNotEmpty(errorData)) { +// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets); +// } +// } +// // 数据入库处理 +// log.info("【考勤引用数据】导入记录:{}", JsonUtil.toJsonString(pos)); +// handleDataToDB(attendQuote.getId(), pos, values, tenantKey); +// // 记录日志 +// recordLog(attendQuote, message.getUserId(), message.getTenantKey(), message.getClientIp()); +// // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets); +// } +// +// /** +// * 获取金额数字值 +// * @param bigDecimalValStr +// * @param excelComments +// * @param i +// * @param j +// * @return +// */ +// private String bigDecimalVal(String bigDecimalValStr, List excelComments, String valI18n, int i, int j) { +// BigDecimal bigDecimalVal = null; +// try { +// bigDecimalVal = new BigDecimal(bigDecimalValStr); +// } catch (Exception e) { +// salaryBatchService.createExcelComment(excelComments, valI18n, i, i, j, j); +// } +// return bigDecimalVal == null? "" : bigDecimalVal.toString(); +// } +// +// /** +// * 记录日志 +// * @param attendQuote +// * @param currentEmployeeId +// * @param currentTenantKey +// * @param clientIp +// */ +// private void recordLog(AttendQuotePO attendQuote, Long currentEmployeeId, String currentTenantKey, String clientIp) { +// List salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper) +// .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()); +// loggerContext.setOperateTypeName(sourceType+SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 93931, "考勤数据")); +// loggerContext.setOperatedesc(sourceType+SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 93931, "考勤数据")); +// loggerContext.setNewValues(attendQuote); +// loggerContext.setTenant_key(currentTenantKey); +// loggerContext.setOperator(currentEmployeeId.toString()); +// if (StringUtils.isNotEmpty(clientIp)) { +// loggerContext.setClientIp(clientIp); +// } +// attendQuoteLoggerTemplate.write(loggerContext); +// } +// +// /** +// * 检查参数 +// * @param message +// * @param params +// * @return +// */ +// private boolean checkParams(BatchDocumentMessage message, Map 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 { +// List salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper) +// .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; +// } +// +// /** +// * 检查列头 +// * @param message +// * @param headers +// * @param attendQuoteFields +// * @return +// */ +// private boolean checkHeaders(BatchDocumentMessage message, List headers, List attendQuoteFields) { +// boolean isValid = true; +// +// String tenantKey = message.getTenantKey(); +// Long currentEmployeeId = message.getUserId(); +// String userNameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名"); +// +// List headerList = headers.stream().map(m->m.getOrDefault("key", "").toString()).collect(Collectors.toList()); +// +// List mustHeaders = CollectionUtils.emptyIfNull(attendQuoteFields).stream().map(AttendQuoteFieldPO::getFieldName).collect(Collectors.toList()); +// mustHeaders.add(userNameI18n); +// +// // 缺少的必须列 +// List lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList()); +// +// String errorMsg = ""; +// String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101850, "缺少如下列,请检查:"); +// if (CollectionUtils.isEmpty(attendQuoteFields)) { +// errorMsg = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101849, "考勤字段列缺失,请补充"); +// } else if (CollectionUtils.isNotEmpty(lackHeaders)) { +// errorMsg = checkHeaderI18n + Joiner.on(",").join(lackHeaders); +// } +// // 有错误信息发送 +// if (com.weaver.teams.util.StringUtils.isNotEmpty(errorMsg)) { +// // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, errorMsg); +// isValid = false; +// } +// return isValid; +// } +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java index 89d4aca7f..3a8046523 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java @@ -207,6 +207,9 @@ public class AttendQuoteFieldSettingServiceImpl extends Service implements Atten @Override public String save(AttendQuoteFieldSettingSaveParam saveParam) { + if (saveParam == null) { + throw new SalaryRunTimeException("参数异常"); + } if (CollectionUtils.isEmpty(saveParam.getCurrentSettingFields())) { throw new SalaryRunTimeException("字段不能为空"); } diff --git a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java index 1ab87fd2e..7cda6493f 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java @@ -3,6 +3,7 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; import com.engine.salary.biz.AttendQuoteBiz; import com.engine.salary.biz.AttendQuoteDataBiz; +import com.engine.salary.biz.AttendQuoteDataValueBiz; import com.engine.salary.cmd.datacollection.AttendQuoteListCmd; import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; @@ -19,8 +20,9 @@ import java.util.stream.Collectors; public class AttendQuoteServiceImpl extends Service implements AttendQuoteService { - AttendQuoteBiz biz = new AttendQuoteBiz(); - AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); + private AttendQuoteBiz biz = new AttendQuoteBiz(); + private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); + private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz(); @Override public Map list(Map params) { @@ -50,8 +52,8 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic dataBiz.deleteByAttendQuoteIds(unAccountingIds); // 3.删除考核数据对应的考核值 -// List attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList()); -// attendQuoteDataValueMapper.deleteByAttendQuoteDataIds(CollectionUtils.isEmpty(attendQuoteDataIds) ? Collections.singletonList(0L) : attendQuoteDataIds, tenantKey); + List attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList()); + dataValueBiz.deleteByAttendQuoteDataIds(attendQuoteDataIds); //todo 日志 // attendQuotes.forEach(e -> { diff --git a/src/com/engine/salary/web/AttendQuoteController.java b/src/com/engine/salary/web/AttendQuoteController.java index 2c4ba0d94..e9c3c19bc 100644 --- a/src/com/engine/salary/web/AttendQuoteController.java +++ b/src/com/engine/salary/web/AttendQuoteController.java @@ -5,9 +5,11 @@ import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO; import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.service.AttendQuoteDataService; import com.engine.salary.service.AttendQuoteFieldService; import com.engine.salary.service.AttendQuoteFieldSettingService; import com.engine.salary.service.AttendQuoteService; +import com.engine.salary.service.impl.AttendQuoteDataServiceImpl; import com.engine.salary.service.impl.AttendQuoteFieldServiceImpl; import com.engine.salary.service.impl.AttendQuoteFieldSettingServiceImpl; import com.engine.salary.service.impl.AttendQuoteServiceImpl; @@ -35,6 +37,10 @@ public class AttendQuoteController { return (AttendQuoteService) ServiceUtil.getService(AttendQuoteServiceImpl.class, user); } + private AttendQuoteDataService getDataService(User user) { + return (AttendQuoteDataService) ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user); + } + private AttendQuoteFieldService getFieldService(User user) { return (AttendQuoteFieldService) ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); } @@ -134,39 +140,34 @@ public class AttendQuoteController { // null)); // } // -// /** -// * 查看考勤数据 -// * @param queryParam -// * @return -// */ -// @PostMapping("/view") -// @ApiOperation("查看") -// @WeaPermission -// public WeaResult> view(@RequestBody AttendQuoteDataQueryParam queryParam) { -// String currentTenantKey = TenantContext.getCurrentTenantKey(); -// Long currentEmployeeId = UserContext.getCurrentEmployeeId(); -// if (queryParam.getAttendQuoteId() == null) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 100253, "考勤引用id不能为空")); -// } -// return WeaResult.success(attendQuoteDataService.view(queryParam, currentEmployeeId, currentTenantKey)); -// } -// -// /** -// * 删除考勤数据 -// * @param ids -// * @return -// */ -// @PostMapping("/delete") -// @ApiOperation("删除") -// @WeaPermission -// public WeaResult delete(@RequestBody Collection ids) { -// String currentTenantKey = TenantContext.getCurrentTenantKey(); -// Long currentEmployeeId = UserContext.getCurrentEmployeeId(); -// if (CollectionUtils.isEmpty(ids)) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 84026, "参数错误")); -// } -// return service.delete(ids, currentEmployeeId, currentTenantKey); -// } + + /** + * 查看考勤数据 + * + * @param queryParam + * @return + */ + @POST + @Path("/view") + @Produces(MediaType.APPLICATION_JSON) + public String view(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>().run(getDataService(user)::view, queryParam); + } + + /** + * 删除考勤数据 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>().run(getService(user)::delete, ids); + } // // /** // * 导出考勤数据