From 1a49dd331dd2ac7e229131b8155d7dea07414217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 15 Mar 2022 14:18:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/biz/AttendQuoteDataValueBiz.java | 38 + src/com/engine/salary/init.sql | 1 + .../datacollection/AttendQuoteDataMapper.xml | 6 - .../AttendQuoteDataValueMapper.java | 9 +- .../AttendQuoteDataValueMapper.xml | 18 +- .../datacollection/AttendQuoteFieldMapper.xml | 9 +- .../service/AttendQuoteDataService.java | 60 ++ .../salary/service/AttendQuoteService.java | 2 +- .../impl/AttendQuoteDataServiceImpl.java | 878 ++++++++++++++++++ .../AttendQuoteFieldSettingServiceImpl.java | 3 + .../service/impl/AttendQuoteServiceImpl.java | 10 +- .../salary/web/AttendQuoteController.java | 67 +- 12 files changed, 1039 insertions(+), 62 deletions(-) create mode 100644 src/com/engine/salary/biz/AttendQuoteDataValueBiz.java create mode 100644 src/com/engine/salary/service/AttendQuoteDataService.java create mode 100644 src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java 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); + } // // /** // * 导出考勤数据 From 00bf811075f61247a09062199f9c29f0ff962055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 16 Mar 2022 14:29:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/salary/web/SalaryItemController.java | 7 + src/com/engine/salary/biz/AttendQuoteBiz.java | 32 + .../engine/salary/biz/AttendQuoteDataBiz.java | 11 + .../salary/biz/AttendQuoteDataValueBiz.java | 11 + .../salary/biz/AttendQuoteFieldBiz.java | 22 + .../biz/AttendQuoteFieldSettingBiz.java | 2 + .../engine/salary/common/LocalDateRange.java | 33 + .../datacollection/bo/AttendQuoteFieldBO.java | 156 ++++ .../param/AttendQuoteDataQueryParam.java | 1 + .../param/AttendQuoteDataSyncParam.java | 23 +- .../param/AttendQuoteFieldQueryParam.java | 5 + .../po/AttendQuoteDataValuePO.java | 4 + .../datacollection/po/AttendQuotePO.java | 4 + .../salarysob/dto/SalarySobCycleDTO.java | 47 ++ .../param/SalarySobBasicSaveParam.java | 83 ++ .../param/SalarySobDisableParam.java | 25 + .../param/SalarySobDuplicateParam.java | 26 + .../datacollection/AttendQuoteDataMapper.xml | 16 +- .../AttendQuoteDataValueMapper.xml | 6 + .../AttendQuoteFieldMapper.java | 102 +-- .../datacollection/AttendQuoteFieldMapper.xml | 16 +- .../datacollection/AttendQuoteMapper.java | 61 +- .../datacollection/AttendQuoteMapper.xml | 21 +- .../service/AttendQuoteDataService.java | 75 +- .../salary/service/AttendQuoteService.java | 12 +- .../salary/service/SalarySobService.java | 139 ++++ .../impl/AttendQuoteDataServiceImpl.java | 749 +++++++++--------- .../impl/AttendQuoteFieldServiceImpl.java | 69 +- .../AttendQuoteFieldSettingServiceImpl.java | 30 - .../service/impl/AttendQuoteServiceImpl.java | 6 +- .../engine/salary/util/SalaryDateUtil.java | 13 +- .../engine/salary/util/SalaryI18nUtil.java | 22 +- .../engine/salary/util/excel/ExcelUtil.java | 65 +- .../salary/web/AttendQuoteController.java | 172 ++-- .../salary/web/SalaryItemController.java | 133 ++++ 35 files changed, 1509 insertions(+), 690 deletions(-) create mode 100644 src/com/api/salary/web/SalaryItemController.java create mode 100644 src/com/engine/salary/common/LocalDateRange.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java create mode 100644 src/com/engine/salary/service/SalarySobService.java create mode 100644 src/com/engine/salary/web/SalaryItemController.java diff --git a/src/com/api/salary/web/SalaryItemController.java b/src/com/api/salary/web/SalaryItemController.java new file mode 100644 index 000000000..04bb234d6 --- /dev/null +++ b/src/com/api/salary/web/SalaryItemController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryitem") +public class SalaryItemController extends com.engine.salary.web.SalaryItemController{ +} diff --git a/src/com/engine/salary/biz/AttendQuoteBiz.java b/src/com/engine/salary/biz/AttendQuoteBiz.java index e17fdf424..f4a2dc2bb 100644 --- a/src/com/engine/salary/biz/AttendQuoteBiz.java +++ b/src/com/engine/salary/biz/AttendQuoteBiz.java @@ -2,6 +2,7 @@ package com.engine.salary.biz; import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; import com.engine.salary.mapper.datacollection.AttendQuoteMapper; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; @@ -29,6 +30,37 @@ public class AttendQuoteBiz { } finally { sqlSession.close(); } + } + public List listSome(AttendQuotePO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + + public void updateById(AttendQuotePO attendQuote) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + mapper.updateIgnoreNull(attendQuote); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(AttendQuotePO attendQuote) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + mapper.insertIgnoreNull(attendQuote); + sqlSession.commit(); + } finally { + sqlSession.close(); + } } } diff --git a/src/com/engine/salary/biz/AttendQuoteDataBiz.java b/src/com/engine/salary/biz/AttendQuoteDataBiz.java index 7fa111479..9bacae4f7 100644 --- a/src/com/engine/salary/biz/AttendQuoteDataBiz.java +++ b/src/com/engine/salary/biz/AttendQuoteDataBiz.java @@ -44,4 +44,15 @@ public class AttendQuoteDataBiz { } } + + public void insertData(List pos) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class); + mapper.insertData(pos); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java index aef9939b4..b8ae9cac6 100644 --- a/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java +++ b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java @@ -11,6 +11,7 @@ public class AttendQuoteDataValueBiz { /** * 根据考勤引用字段表的主键id删除 + * * @param attendQuoteDataIds */ public void deleteByAttendQuoteDataIds(List attendQuoteDataIds) { @@ -35,4 +36,14 @@ public class AttendQuoteDataValueBiz { } } + public void insertData(List values) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + mapper.insertData(values); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/AttendQuoteFieldBiz.java b/src/com/engine/salary/biz/AttendQuoteFieldBiz.java index 926558fd8..5858ff790 100644 --- a/src/com/engine/salary/biz/AttendQuoteFieldBiz.java +++ b/src/com/engine/salary/biz/AttendQuoteFieldBiz.java @@ -77,4 +77,26 @@ public class AttendQuoteFieldBiz { sqlSession.close(); } } + + public void saveBatch(List saves) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.saveBatch(saves); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteAttendByCode(AttendQuoteFieldQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.deleteAttendByCode(param); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java b/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java index 814b1d828..28266a88b 100644 --- a/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java +++ b/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java @@ -41,4 +41,6 @@ public class AttendQuoteFieldSettingBiz { sqlSession.close(); } } + + } diff --git a/src/com/engine/salary/common/LocalDateRange.java b/src/com/engine/salary/common/LocalDateRange.java new file mode 100644 index 000000000..e4b3d459f --- /dev/null +++ b/src/com/engine/salary/common/LocalDateRange.java @@ -0,0 +1,33 @@ +package com.engine.salary.common; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.time.LocalDate; + +/** + * 日期范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class LocalDateRange { + + //"开始日期 + private LocalDate fromDate; + + //结束日期 + private LocalDate endDate; + + +} diff --git a/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java new file mode 100644 index 000000000..354db1160 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java @@ -0,0 +1,156 @@ +package com.engine.salary.entity.datacollection.bo; + +import com.google.common.collect.Maps; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * 考勤引用-字段管理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteFieldBO { + + +// public static List buildRecordTableColumns(Long employeeId, String tenantKey) { +// List result = Lists.newArrayListWithExpectedSize(5); +// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87628, "字段名称"), "fieldName", "20%", WeaAlignEnum.LEFT.getStringVal(), "fieldName")); +// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87617, "来源"), "sourceType", "20%", WeaAlignEnum.LEFT.getStringVal(), "sourceType")); +// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84758, "类型"), "fieldType", "20%", WeaAlignEnum.LEFT.getStringVal(), "fieldType")); +// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87629, "是否启用"), "enableStatus", "20%", WeaAlignEnum.LEFT.getStringVal(), "enableStatus")); +// result.add(new WeaTableColumnWapper(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84961, "备注"), "description", "20%", WeaAlignEnum.LEFT.getStringVal(), "description")); +// return result; +// } +// +// public static Map buildEditableTableItemMap() { +// Map resultMap = Maps.newHashMapWithExpectedSize(9); +// resultMap.put("fieldName", new EditableTableItem(EditableTableItemType.INPUT, "",true)); +// resultMap.put("sourceType", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// resultMap.put("fieldType", new EditableTableItem(EditableTableItemType.INPUT, "",true)); +// resultMap.put("enableStatus", new EditableTableItem(EditableTableItemType.SWITCH, "",false)); +// resultMap.put("description", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// return resultMap; +// } + + /** + * 考勤模块固定字段编码 + * 注意:目前固定,后期考勤模块会管理维护 + * + * @return + */ + public static List> buildAttendFixedFields() { + List> attendFixedFields = new LinkedList<>(); + /* ====== 按小时 ============================================================================================================ */ + // 应出勤工时 + attendFixedFields.add(attendFixedField("working_hour", 92040, "应出勤工时")); + // 出勤工时 + attendFixedFields.add(attendFixedField("actual_hour", 92041, "出勤工时")); + // 实际出勤工时 + attendFixedFields.add(attendFixedField("actualWork_hour", 92042, "实际出勤工时")); + + /* ====== 异常缺勤 ==================================== */ + // 迟到工时 + attendFixedFields.add(attendFixedField("lateLength_hour", 92043, "迟到工时")); + // 早退工时 + attendFixedFields.add(attendFixedField("earlyOutLength_hour", 92044, "早退工时")); + // 未出勤工时 + attendFixedFields.add(attendFixedField("lostLength_hour", 92045, "未出勤工时")); + // 旷工工时 + attendFixedFields.add(attendFixedField("absenteeismLength_hour", 92046, "旷工工时")); + + // 外勤次数 + attendFixedFields.add(attendFixedField("oAttendNum_hour", 92047, "外勤次数(按小时)")); + // 外勤时长 + attendFixedFields.add(attendFixedField("oAttendLength_hour", 92048, "外勤时长(按小时)")); + + /* ====== 出差工时 ==================================== */ + // 工作日出差 + attendFixedFields.add(attendFixedField("bTnormal_hour", 92049, "工作日出差工时")); + // 周末出差 + attendFixedFields.add(attendFixedField("bTweekend_hour", 92050, "周末出差工时")); + // 节假日出差 + attendFixedFields.add(attendFixedField("bTholiday_hour", 92051, "节假日出差工时")); + + /* ====== 加班工时 ==================================== */ + // 工作日加班 + attendFixedFields.add(attendFixedField("normal_hour", 92052, "工作日加班工时")); + // 周末加班 + attendFixedFields.add(attendFixedField("weekend_hour", 92053, "周末加班工时")); + // 节假日加班 + attendFixedFields.add(attendFixedField("holiday_hour", 92054, "节假日加班工时")); + + /* ====== 异常考勤 ==================================== */ + // 未签到次数 + attendFixedFields.add(attendFixedField("absenseNumOfMonth_hour", 92055, "未签到次数(按小时)")); + // 未签退次数 + attendFixedFields.add(attendFixedField("unSignOutNumOfMonth_hour", 92056, "未签退次数(按小时)")); + // 未打卡次数 + attendFixedFields.add(attendFixedField("unSignNum_hour", 92057, "未打卡次数(按小时)")); + + // 申诉次数 + attendFixedFields.add(attendFixedField("appealNum_hour", 92058, "申诉次数(按小时)")); + + /* ====== 按天 ============================================================================================================ */ + // 应出勤天数 + attendFixedFields.add(attendFixedField("working_day", 92059, "应出勤天数")); + // 出勤天数 + attendFixedFields.add(attendFixedField("actual_day", 92060, "出勤天数")); + // 实际出勤天数 + attendFixedFields.add(attendFixedField("actualWork_day", 92061, "实际出勤天数")); + + /* ====== 异常缺勤 ==================================== */ + // 迟到天数 + attendFixedFields.add(attendFixedField("lateLength_day", 92062, "迟到天数")); + // 早退天数 + attendFixedFields.add(attendFixedField("earlyOutLength_day", 92063, "早退天数")); + // 未出勤天数 + attendFixedFields.add(attendFixedField("lostLength_day", 92064, "未出勤天数")); + // 旷工天数 + attendFixedFields.add(attendFixedField("absenteeismLength_day", 92065, "旷工天数")); + + // 外勤时长 + attendFixedFields.add(attendFixedField("oAttendNum_day", 92066, "外勤时长天数")); + // 外勤时长 + attendFixedFields.add(attendFixedField("oAttendLength_day", 92048, "外勤时长(按天)")); + + /* ====== 出差天数 ==================================== */ + // 工作日出差 + attendFixedFields.add(attendFixedField("bTnormal_day", 92067, "工作日出差天数")); + // 周末出差 + attendFixedFields.add(attendFixedField("bTweekend_day", 92068, "周末出差天数")); + // 节假日出差 + attendFixedFields.add(attendFixedField("bTholiday_day", 92069, "节假日出差天数")); + + /* ====== 加班天数 ==================================== */ + // 工作日加班 + attendFixedFields.add(attendFixedField("normal_day", 92070, "工作日加班天数")); + // 周末加班 + attendFixedFields.add(attendFixedField("weekend_day", 92071, "周末加班天数")); + // 节假日加班 + attendFixedFields.add(attendFixedField("holiday_day", 92072, "节假日加班天数")); + + /* ====== 异常考勤 ==================================== */ + // 未签到次数 + attendFixedFields.add(attendFixedField("absenseNumOfMonth_day", 92055, "未签到次数(按天)")); + // 未签退次数 + attendFixedFields.add(attendFixedField("unSignOutNumOfMonth_day", 92056, "未签退次数(按天)")); + // 未打卡次数 + attendFixedFields.add(attendFixedField("unSignNum_day", 94604, "未打卡次数(按天)")); + + // 申诉次数 + attendFixedFields.add(attendFixedField("appealNum_day", 94603, "申诉次数(按天)")); + return attendFixedFields; + } + + private static Map attendFixedField(String code, int labelId, String name) { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", code); + map.put("name", name); + return map; + } +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java index 60e8747dc..9872231b5 100644 --- a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java @@ -37,6 +37,7 @@ public class AttendQuoteDataQueryParam { private Collection unAccountingIds; + // // //人员信息表的主键id") // private Long employeeId; diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java index 019b0a8ea..1b004157b 100644 --- a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java @@ -1,9 +1,12 @@ package com.engine.salary.entity.datacollection.param; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; import java.util.Collection; @@ -31,13 +34,15 @@ public class AttendQuoteDataSyncParam { //备注") private String description; -// public static WeaResult checkParam(AttendQuoteDataSyncParam saveParam, Long employeeId, String tenantKey) { -// if (StringUtils.isEmpty(saveParam.getSalaryYearMonth())) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100294, "薪资所属月必传")); -// } -// if (saveParam.getSalarySobId() == null) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100295, "薪资账套必传")); -// } -// return WeaResult.success(StringUtils.EMPTY); -// } + public static void checkParam(AttendQuoteDataSyncParam saveParam) { + if (saveParam == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "参数异常")); + } + if (StringUtils.isEmpty(saveParam.getSalaryYearMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "薪资所属月必传")); + } + if (saveParam.getSalarySobId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100295, "薪资账套必传")); + } + } } diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java index 66fb2b3d5..8d695b192 100644 --- a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java @@ -29,6 +29,11 @@ public class AttendQuoteFieldQueryParam { //字段名称 private String fieldName; + //根据编码删除 + private Collection codes; + //来源。1:自定义、2:考勤模块 + private Integer sourceType; + /** * 查询where语句 * @param queryParam diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java index 057dab2d4..147bb3745 100644 --- a/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Collection; import java.util.Date; /** @@ -60,4 +61,7 @@ public class AttendQuoteDataValuePO { */ private String tenantKey; + //查询参数 + private Collection employeeIds; + } \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java index a2c5fe267..c3bb6836e 100644 --- a/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Collection; import java.util.Date; /** @@ -76,4 +77,7 @@ public class AttendQuotePO { */ private String tenantKey; + //主键id + private Collection ids; + } \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java new file mode 100644 index 000000000..65a482e20 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.common.LocalDateRange; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * 薪资账套的周期 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobCycleDTO { + + //薪资账套id + private Long salarySobId; + + //薪资所属月 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth salaryMonth; + + //税款所属期 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth taxCycle; + + //社保福利所属期 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth socialSecurityCycle; + + //薪资周期") + private LocalDateRange salaryCycle; + + //考勤周期") + private LocalDateRange attendCycle; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java new file mode 100644 index 000000000..e6289eea3 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java @@ -0,0 +1,83 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + + +/** + * 薪资账套保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobBasicSaveParam { + + //主键id + private Long id; + + /** + * 名称不允许为空 + * 名称不能超过40个字符长度 + */ + //薪资账套的名称 + private String name; + + /** + * 薪资类型不允许为空 + */ + //薪资类型 + private IncomeCategoryEnum taxableItems; + + /** + * 薪资周期不允许为空 + */ + //薪资周期 + private SalaryCycleTypeEnum salaryCycleType; + + /** + * 薪资周期的起始日期不允许为空 + */ + //薪资周期的起始日期 + private Integer salaryCycleFromDay; + + /** + * 税款所属期不允许为空 + */ + //税款所属期 + private SalaryCycleTypeEnum taxCycleType; + + /** + * 考勤周期不允许为空 + */ + //考勤周期 + private SalaryCycleTypeEnum attendCycleType; + + /** + * 考勤周期起始日期不允许为空 + */ + //考勤周期起始日期 + private Integer attendCycleFromDay; + + /** + * 福利台账月份不允许为空 + */ + //福利台账月份 + private SalaryCycleTypeEnum socialSecurityCycleType; + + /** + * 备注不能超过80个字符 + */ + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java new file mode 100644 index 000000000..91e13d7dc --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salarysob.param; + +import lombok.Data; + +/** + * 薪资账套禁用或启用保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalarySobDisableParam { + + /** + * 薪资账套的ID不允许为空 + */ + private Long id; + + /** + * 参数错误,只能选择启用或者禁用 + */ + private Integer disable; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java new file mode 100644 index 000000000..bc4760bc5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salarysob.param; + +import lombok.Data; + +/** + * 薪资账套复制参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalarySobDuplicateParam { + + /** + * 薪资账套的ID不允许为空 + */ + private Long id; + + /** + * 名称不允许为空 + * 名称不能超过40个字符长度 + */ + private String name; +} diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml index b94390a7d..1efa142a8 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml @@ -162,9 +162,9 @@ t1.employee_id, t1.attend_quote_id, e.lastname as username, - d.name AS departmentName, + d.departmentname AS departmentName, e.mobile, - e.job_num + e.workcode as job_num @@ -179,8 +179,8 @@ AND ( e.lastname like CONCAT('%',#{param.keyword},'%') - OR d.name like CONCAT('%',#{param.keyword},'%') - OR e.job_num like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') OR e.mobile like CONCAT('%',#{param.keyword},'%') ) @@ -207,8 +207,8 @@ AND ( e.lastname like '%'||#{param.keyword}||'%' - OR d.name like '%'||#{param.keyword}||'%' - OR e.job_num like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' OR e.mobile like '%'||#{param.keyword}||'%' ) @@ -234,8 +234,8 @@ AND ( e.lastname like '%'+#{param.keyword}+'%' - OR d.name like '%'+#{param.keyword}+'%' - OR e.job_num like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' OR e.mobile like '%'+#{param.keyword}+'%' ) diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml index 0e7851689..ac1673f9d 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml @@ -291,6 +291,12 @@ AND attend_quote_id = #{param.attendQuoteId} + + AND employee_id IN + + #{employeeId} + + diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java index c9dea3e32..9392a59f0 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java @@ -10,88 +10,98 @@ import java.util.List; public interface AttendQuoteFieldMapper { - /** + /** * 查询所有记录 * * @return 返回集合,没有返回空List */ - List listAll(); + List listAll(); - /** + /** * 根据主键查询 * * @param id 主键 * @return 返回记录,没有返回null */ - AttendQuoteFieldPO getById(Long id); - - /** + AttendQuoteFieldPO getById(Long id); + + /** * 新增,忽略null字段 * * @param AttendQuoteFieldPO 新增的记录 * @return 返回影响行数 */ - int insertIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); - - /** + int insertIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** * 修改,修改所有字段 * * @param AttendQuoteFieldPO 修改的记录 * @return 返回影响行数 */ - int update(AttendQuoteFieldPO AttendQuoteFieldPO); - - /** + int update(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** * 修改,忽略null字段 * * @param AttendQuoteFieldPO 修改的记录 * @return 返回影响行数 */ - int updateIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); - - /** + int updateIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** * 删除记录 * * @param AttendQuoteFieldPO 待删除的记录 * @return 返回影响行数 */ - int delete(AttendQuoteFieldPO AttendQuoteFieldPO); + int delete(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** + * 删除考勤的字段 + * + * @param param + * @return + */ + int deleteAttendByCode(@Param("param") AttendQuoteFieldQueryParam param); + /** + * 查询数据采集-考勤引用字段列表 + * + * @param param + * @return + */ + List list(@Param("param") AttendQuoteFieldQueryParam param); + /** + * 批量删除数据采集-考勤引用字段 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); - /** - * 查询数据采集-考勤引用字段列表 - * @param param - * @return - */ - List list(@Param("param") AttendQuoteFieldQueryParam param); + /** + * 插入 + * + * @param saves + */ + void saveBatch(@Param("saves") List saves); + /** + * 更新字段名 + * + * @param updates + */ + void updateNameByCode(@Param("updates") List updates); - /** - * 批量删除数据采集-考勤引用字段 - * @param ids - */ - void deleteByIds(@Param("ids") Collection ids); - - /** - * 插入 - * @param saves - */ - void saveBatch(@Param("saves") List saves); - - /** - * 更新字段名 - * @param updates - */ - void updateNameByCode(@Param("updates") List updates); - - /** - * 条件查询 - * @param param - * @return - */ - List listSome(@Param("param")AttendQuoteFieldPO param); + /** + * 条件查询 + * + * @param param + * @return + */ + List listSome(@Param("param") AttendQuoteFieldPO param); } \ 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 66be00b4d..776a48c89 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml @@ -204,6 +204,19 @@ AND delete_type = 0 + + UPDATE hrsa_attend_quote_field + SET delete_type=1 + WHERE delete_type = 0 + AND source_type= 2 + AND code IN + + #{code} + + + + t1 @@ -360,9 +373,8 @@ #{id} - AND delete_type = 0 + AND delete_type = 0 - \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java index 20c89eb5e..449a3fb58 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java @@ -12,71 +12,72 @@ import java.util.List; @Mapper public interface AttendQuoteMapper { - /** + /** * 查询所有记录 * * @return 返回集合,没有返回空List */ - List listAll(); + List listAll(); - /** + /** * 根据主键查询 * * @param id 主键 * @return 返回记录,没有返回null */ - AttendQuotePO getById(Long id); - - /** + AttendQuotePO getById(Long id); + + /** * 新增,忽略null字段 * * @param AttendQuotePO 新增的记录 * @return 返回影响行数 */ - int insertIgnoreNull(AttendQuotePO AttendQuotePO); - - /** + int insertIgnoreNull(AttendQuotePO AttendQuotePO); + + /** * 修改,修改所有字段 * * @param AttendQuotePO 修改的记录 * @return 返回影响行数 */ - int update(AttendQuotePO AttendQuotePO); - - /** + int update(AttendQuotePO AttendQuotePO); + + /** * 修改,忽略null字段 * * @param AttendQuotePO 修改的记录 * @return 返回影响行数 */ - int updateIgnoreNull(AttendQuotePO AttendQuotePO); - - /** + int updateIgnoreNull(AttendQuotePO AttendQuotePO); + + /** * 删除记录 * * @param AttendQuotePO 待删除的记录 * @return 返回影响行数 */ - int delete(AttendQuotePO AttendQuotePO); + int delete(AttendQuotePO AttendQuotePO); - - /** - * 查询数据采集-考勤引用列表 - * @param param - * @return - */ - List list(@Param("param") AttendQuoteQueryParam param); + /** + * 查询数据采集-考勤引用列表 + * + * @param param + * @return + */ + List list(@Param("param") AttendQuoteQueryParam param); - /** - * 批量删除数据采集-考勤引用 - * @param ids - */ - void deleteByIds(@Param("ids") Collection ids); + /** + * 批量删除数据采集-考勤引用 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + List listSome(@Param("param") AttendQuotePO param); - - } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml index 98c07b45b..968001ccd 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml @@ -241,9 +241,11 @@ - - t1.id, + t1 + . + id + , t1.salary_year_month, t1.salary_sob_id, t2.name AS salary_sob_name, @@ -281,7 +283,7 @@ LEFT JOIN hrsa_salary_sob t2 ON t1.salary_sob_id = t2.id LEFT JOIN hrmresource e ON e.id = t1.creator WHERE - t1.delete_type = 0 AND t2.delete_type = 0 + t1.delete_type = 0 AND t2.delete_type = 0 ORDER BY t1.id DESC @@ -296,5 +298,18 @@ + + \ No newline at end of file diff --git a/src/com/engine/salary/service/AttendQuoteDataService.java b/src/com/engine/salary/service/AttendQuoteDataService.java index 4893779fa..fe65f3a36 100644 --- a/src/com/engine/salary/service/AttendQuoteDataService.java +++ b/src/com/engine/salary/service/AttendQuoteDataService.java @@ -1,7 +1,13 @@ package com.engine.salary.service; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataExportTemplateParam; import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataSyncParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import java.time.YearMonth; +import java.util.List; import java.util.Map; /** @@ -20,41 +26,36 @@ public interface AttendQuoteDataService { * @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); + + + /** + * 导出考勤数据 + * @param queryParam + * @return + */ + XSSFWorkbook export(AttendQuoteDataQueryParam queryParam); + + /** + * 同步引用考勤数据 + * @param syncParam + * @return + */ + String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam); + + /** + * 获取考勤引用数据 + * @param salaryYearMonth + * @param salarySobId + * @param employeeIds + * @return + */ + List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds); + + /** + * 导出考勤数据作为模板 + * @param exportParam + * @return + */ + XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam); + } diff --git a/src/com/engine/salary/service/AttendQuoteService.java b/src/com/engine/salary/service/AttendQuoteService.java index 6d49646da..65366def7 100644 --- a/src/com/engine/salary/service/AttendQuoteService.java +++ b/src/com/engine/salary/service/AttendQuoteService.java @@ -15,29 +15,27 @@ public interface AttendQuoteService { * @return */ String delete(Collection ids); -// + // /** // * 获取引用考勤表单 // * @param currentEmployeeId -// * @param currentTenantKey // * @return // */ -// WeaForm getSyncForm(Long currentEmployeeId, String currentTenantKey); +// Map getSyncForm(Long currentEmployeeId); +// // // /** // * 获取薪资周期和考勤周期 // * @param salaryYearMonth // * @param salarySobId -// * @param currentTenantKey // * @return // */ -// Map getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId, Long currentEmployeeId, String currentTenantKey); +// Map getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId); // // /** // * 获取薪资账套下拉列表 // * @param currentEmployeeId -// * @param currentTenantKey // * @return // */ -// List> selectSalarySobList(Long currentEmployeeId, String currentTenantKey); +// List> selectSalarySobList(Long currentEmployeeId); } diff --git a/src/com/engine/salary/service/SalarySobService.java b/src/com/engine/salary/service/SalarySobService.java new file mode 100644 index 000000000..5287ff76f --- /dev/null +++ b/src/com/engine/salary/service/SalarySobService.java @@ -0,0 +1,139 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.param.SalarySobDisableParam; +import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; + +/** + * @description: 薪资账套 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 11/9/21 4:06 PM + * @version:v1.0 + */ +public interface SalarySobService { + + /** + * 根据主键id获取单个薪资账套 + * + * @param id 主键id + * @param tenantKey 租户key + * @return + */ + SalarySobPO getById(Long id, String tenantKey); + + /** + * 根据主键id查询薪资账套 + * + * @param ids 主键id + * @param tenantKey 租户key + * @return + */ + List listByIds(Collection ids, String tenantKey); + + /** + * 根据名称精确匹配查询薪资账套 + * + * @param name 薪资账套名称 + * @param tenantKey 租户key + * @return + */ + List listByName(String name, String tenantKey); + + /** + * 根据名称(模糊匹配)查询薪资账套 + * + * @param nameLike 薪资账套名称 + * @param tenantKey 租户key + * @return + */ + List listByNameLike(String nameLike, String tenantKey); + + /** + * 查询启用/禁用的薪资账套 + * + * @param disable 启用/禁用 + * @param tenantKey 租户key + * @return + */ + List listByDisable(Integer disable, String tenantKey); + + /** + * 根据薪资类型查询薪资账套 + * + * @param incomeCategory 薪资类型 + * @param tenantKey 租户key + * @return + */ + List listByIncomeCategory(IncomeCategoryEnum incomeCategory, String tenantKey); + + /** + * 根据列表查询参数查询薪资账套(分页) + * + * @param queryParam 列表查询参数 + * @param tenantKey 租户key + * @return + */ +// Page listPageByParam(SalarySobListQueryParam queryParam, String tenantKey); + + /** + * 保存 + * + * @param saveParam 保存参数 + * @param employeeId 人员id + * @param tenantKey 租户key + * @return + */ + Long save(SalarySobBasicSaveParam saveParam, Long employeeId, String tenantKey); + + /** + * 编辑 + * + * @param saveParam 更新参数 + * @param employeeId 人员id + * @param tenantKey 租户key + * @return + */ + Long update(SalarySobBasicSaveParam saveParam, Long employeeId, String tenantKey); + + /** + * 更新薪资账套的是否启用 + * + * @param disableParam 更新参数 + * @param tenantKey 租户key + */ + void updateDisable(SalarySobDisableParam disableParam, String tenantKey); + + /** + * 根据主键id删除 + * + * @param ids 薪资账套的主键id + * @param tenantKey 租户key + */ + void deleteByIds(Collection ids, String tenantKey); + + /** + * 复制 + * + * @param duplicateParam 复制参数 + * @param employeeId 人员id + * @param tenantKey 租户key + */ + void duplicate(SalarySobDuplicateParam duplicateParam, Long employeeId, String tenantKey); + + /** + * 根据薪资所属月计算出薪资账套的薪资周期、考勤周期的具体日期范围以及税款所属期、福利台账月份的具体月份 + * + * @param id 薪资账套的id + * @param salaryMonth 薪资所属月 + * @return + */ + SalarySobCycleDTO getSalarySobCycle(Long id, YearMonth salaryMonth); +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java index 44e7f62cb..ecf8d19fe 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java @@ -1,19 +1,34 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.*; -import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.dto.*; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataExportTemplateParam; import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataSyncParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO; import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.service.AttendQuoteDataService; +import com.engine.salary.service.AttendQuoteFieldSettingService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ExcelUtil; import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.time.YearMonth; +import java.util.*; import java.util.stream.Collectors; /** @@ -23,14 +38,21 @@ import java.util.stream.Collectors; */ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDataService { - private AttendQuoteBiz attendQuoteBiz = new AttendQuoteBiz(); - private AttendQuoteDataBiz biz = new AttendQuoteDataBiz(); + private AttendQuoteBiz quoteBiz = new AttendQuoteBiz(); + private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz(); private AttendQuoteFieldBiz fieldBiz = new AttendQuoteFieldBiz(); private EmployBiz employeeBiz = new EmployBiz(); -// AttendQuoteFieldSettingBiz a= new AttendQuoteFieldSettingBiz(); + // AttendQuoteFieldSettingBiz a= new AttendQuoteFieldSettingBiz(); + private AttendQuoteFieldSettingService getFieldSettingService(User user) { + return (AttendQuoteFieldSettingService) ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return (SalarySobService) ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user); + } // @Resource // private SalarySobMapper salarySobMapper; @@ -62,7 +84,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa throw new SalaryRunTimeException("考勤引用id不能为空"); } // 考勤数据分页主数据 - List attendQuoteDataBases = biz.list(queryParam); + List attendQuoteDataBases = dataBiz.list(queryParam); // 所有考勤字段 List attendQuoteFields = getAllAttendQuoteFields(); // 获取最终结果 @@ -132,187 +154,144 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa 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, "请先设置同步字段")); -// } -// // 获取薪资账套 + + + @Override + public List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds) { + if (salaryYearMonth == null || salarySobId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100358, "参数有误:薪资所属月、薪资账套id")); + } + List list = new ArrayList<>(); + Date salaryYearMonthDay = SalaryDateUtil.localDateToDate(salaryYearMonth.atDay(1)); + //查询引用主表 + List attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salaryYearMonth(salaryYearMonthDay).salarySobId(salarySobId).build()); + + if (CollectionUtils.isEmpty(attendQuotes)) { + return Collections.emptyList(); + } + AttendQuotePO attendQuote = attendQuotes.get(0); + + //查询考勤数据值 + List 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 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不能为空")); + } + + // 考勤数据分页主数据 + List attendQuoteDataBases = dataBiz.list(queryParam); + // 所有考勤字段 + List attendQuoteFields = getAllAttendQuoteFields(); + // 获取最终结果 + List> listMaps = getListMaps(attendQuoteDataBases); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(93931, "考勤数据"); + List 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)) { + Map mapColumn = listMaps.get(0); + for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + if (mapColumn.containsKey(attendQuoteField.getId() + "_attendQuoteData")) { + header.add(attendQuoteField.getFieldName()); + } + } + } + + List> rows = new ArrayList<>(); + // 2.表头 + rows.add(header); + // 3.表数据 + 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); + } + return ExcelUtil.genWorkbookV2(rows, sheetName); + + } + + + /** + * 获取表头设置字段 + * + * @param sourceType + * @return + */ + private List getAttendQuoteSetFields(AttendQuoteSourceTypeEnum sourceType) { + List allAttendQuoteFields = getAllAttendQuoteFields(); + AttendQuoteFieldSettingService attendQuoteFieldSettingService = getFieldSettingService(user); + List attendQuoteFieldSettingList = attendQuoteFieldSettingService.listNoSync(AttendQuoteFieldSettingQueryParam.builder().sourceType(sourceType).isViewChecked(Boolean.TRUE).build()); + List attendQuoteFields = new ArrayList<>(); + attendQuoteFieldSettingList.forEach(s -> { + List items = s.getItems(); + if (CollectionUtils.isNotEmpty(items)) { + items.forEach(i -> { + Optional 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 attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.QUOTE); + if (CollectionUtils.isEmpty(attendQuoteFields)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100366, "请先设置同步字段")); + } + // 获取薪资账套 todo // SalarySobCycleDTO salarySobCycle = salarySobService.getSalarySobCycle(syncParam.getSalarySobId(), YearMonth.of(year, month), currentTenantKey); -// // 2.薪资账套人员 -// List employeeIds = new ArrayList<>(); -// // 获取薪资账套人员 + // 2.薪资账套人员 + List employeeIds = new ArrayList<>(); + // 获取薪资账套人员 // List salarySobRanges = new LambdaQueryChainWrapper<>(salarySobRangeMapper) // .eq(SalarySobRangePO::getTenantKey, currentTenantKey) // .eq(SalarySobRangePO::getDeleteType, 0) @@ -320,119 +299,117 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa // .eq(SalarySobRangePO::getSalarySobId, salarySobCycle.getSalarySobId()) // .list(); // List salarySobRangeEmpQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(salarySobRanges); -// List employeeSalarySobIds = salarySobRangeMapper.listEmployeeIds(salarySobRangeEmpQueryParams, currentTenantKey); +// List employeeSalarySobIds = salarySobRangeMapper.listEmployeeIds(salarySobRangeEmpQueryParams); // if (CollectionUtils.isEmpty(employeeSalarySobIds) || CollectionUtils.isEmpty(salarySobRangeEmpQueryParams)) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100367, "薪资账套还没有人员")); +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100367, "薪资账套还没有人员")); // } -// // 账套外人员 -// List employeeOtherIds = (List) syncParam.getEmployeeIds(); + // 账套外人员 + 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(); + employeeIds.addAll(CollectionUtils.emptyIfNull(employeeOtherIds)); + // 3.考勤引用 + AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.QUOTE, syncParam.getSalarySobId(), year, month, syncParam.getDescription()); + + // 4.获取考勤模块数据 + //todo 日期范围需要账套后实现 List> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(salarySobCycle.getAttendCycle(), employeeIds, attendQuoteFields); + List> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(LocalDateRange.builder().build(), employeeIds, attendQuoteFields); + List pos = new ArrayList<>(); + List values = new ArrayList<>(); + // 5.考勤引用数据处理 + Date now = new Date(); + 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() + 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 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); -// // 记录日志 + .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())) + .dataValue(attendQuoteData.get("dataValue") == null ? "" : attendQuoteData.get("dataValue").toString()) + .build()); + } + } + } + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100368, "暂无考勤数据可以同步")); + } + // 6.数据落库处理 + handleDataToDB(attendQuote.getId(), pos, values); + // todo 记录日志 // 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 { + 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 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(); + // 考勤周期 + attendQuote.setAttendCycle(attendCycleRange.getFromDate() + " ~ " + attendCycleRange.getEndDate()); + // 薪资周期 + attendQuote.setSalaryCycle(salaryCycleRange.getFromDate() + " ~ " + salaryCycleRange.getEndDate()); + 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 { // 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<>(); + quoteBiz.insert(attendQuote); + } + return attendQuote; + } + + /** + * 获取考勤模块数据 todo + * + * @param attendCycleRange + * @param employeeIds + * @param attendQuoteFields + * @return + */ + private List> getAttendQuoteDataFromRemoteAttend(LocalDateRange attendCycleRange, List employeeIds, List attendQuoteFields) { + List> attendQuoteSyncData = new ArrayList<>(); // Attend4Salary attend4Salary = new Attend4Salary(); // try { // int partSize = 500; @@ -456,109 +433,89 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa // 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()); -// } + return attendQuoteSyncData; + } + + /** + * 引用同步或导入落库处理 + * + * @param attendQuoteId + * @param pos + * @param values + */ + private void handleDataToDB(Long attendQuoteId, List pos, List 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 quoteIds = new ArrayList<>(); + quoteIds.add(attendQuoteId); + dataBiz.deleteByAttendQuoteIds(quoteIds); + // 新增考勤数据 + dataBiz.insertData(pos); + // 删除考勤值数据 + dataValueBiz.deleteByAttendQuoteDataIds(pos.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList())); + // 新增考勤值数据 + if (CollectionUtils.isNotEmpty(values)) { + dataValueBiz.insertData(values); + } + } + + @Override + public XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam) { + // 考勤主数据 + Date salaryYearMonth = SalaryDateUtil.localDateToDate(exportParam.getSalaryYearMonth().atDay(1)); + List 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 attendQuoteDataBases = dataBiz.list(queryParam); + + // 获取已设置的可同步的字段 + List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT); + // 获取最终结果 + List> listMaps = getListMaps(attendQuoteDataBases); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(101606, "考勤引用导入模板"); + List header = new ArrayList<>(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(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> rows = new ArrayList<>(); + rows.add(header); + 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") : ""); + } + // 2.表头 + rows.add(row); + } + + return ExcelUtil.genWorkbookV2(rows, sheetName); + + } // // /** // * 导入考核数据 diff --git a/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java index 9994bc6ac..bad5ff43a 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java @@ -4,6 +4,7 @@ import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.salary.biz.AttendQuoteFieldBiz; import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.bo.AttendQuoteFieldBO; import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSaveParam; @@ -12,6 +13,8 @@ import com.engine.salary.enums.datacollection.AttendQuoteFieldSourceTypeEnum; import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.service.AttendQuoteFieldService; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.BeanUtils; @@ -211,22 +214,22 @@ public class AttendQuoteFieldServiceImpl extends Service implements AttendQuoteF // List attendLeaveFieldCodes = Lists.newArrayList(); // attendLeaveFieldCodes.addAll(attendLeaveHourFieldCodes); // attendLeaveFieldCodes.addAll(attendLeaveDayFieldCodes); -// // 所有考勤模块字段编码 -// List attendFieldCodes = Lists.newArrayList(); + // 所有考勤模块字段编码 + List attendFieldCodes = Lists.newArrayList(); // attendFieldCodes.addAll(attendLeaveFieldCodes); -// // 考勤模块固定字段 -// List> attendFixedFieldCodes = AttendQuoteFieldBO.buildAttendFixedFields(); -// attendFieldCodes.addAll(attendFixedFieldCodes.stream().map(m -> m.get("code")).collect(Collectors.toList())); -// -// // 本地已存在则更新【交集】 -// List updateCodes = localFieldCodes.stream().filter(item -> attendFieldCodes.contains(item)).collect(Collectors.toList()); -// // 本地比attend多,则删除【差集(local - attend)】 -// List deleteCodes = localFieldCodes.stream().filter(item -> !attendFieldCodes.contains(item)).collect(Collectors.toList()); -// // attend比本地多,则新增【差集(attend - local)】 -// List saveCodes = attendFieldCodes.stream().filter(item -> !localFieldCodes.contains(item)).collect(Collectors.toList()); -// String hourI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100743, "小时"); -// String dayI18n = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100744, "天"); -// // 1.更新 == 目前除了请假类型其余都是固定,故只需更新请假类型部分 + // 考勤模块固定字段 + List> attendFixedFieldCodes = AttendQuoteFieldBO.buildAttendFixedFields(); + attendFieldCodes.addAll(attendFixedFieldCodes.stream().map(m -> m.get("code")).collect(Collectors.toList())); + + // 本地已存在则更新【交集】 + List updateCodes = localFieldCodes.stream().filter(item -> attendFieldCodes.contains(item)).collect(Collectors.toList()); + // 本地比attend多,则删除【差集(local - attend)】 + List deleteCodes = localFieldCodes.stream().filter(item -> !attendFieldCodes.contains(item)).collect(Collectors.toList()); + // attend比本地多,则新增【差集(attend - local)】 + List saveCodes = attendFieldCodes.stream().filter(item -> !localFieldCodes.contains(item)).collect(Collectors.toList()); + String hourI18n = SalaryI18nUtil.getI18nLabel(100743, "小时"); + String dayI18n = SalaryI18nUtil.getI18nLabel(100744, "天"); + // 1.更新 == 目前除了请假类型其余都是固定,故只需更新请假类型部分 // List updates = Lists.newArrayList(); // CollectionUtils.emptyIfNull(updateCodes).forEach(e -> { // Optional optionalHour = CollectionUtils.emptyIfNull(attendVacationTypes).stream().filter(m -> (m.getId() + "_leave_hour").equals(e)).findFirst(); @@ -251,21 +254,17 @@ public class AttendQuoteFieldServiceImpl extends Service implements AttendQuoteF // if (CollectionUtils.isNotEmpty(updates)) { // mapper.updateNameByCode(updates); // } -// // 2.删除 -// if (CollectionUtils.isNotEmpty(deleteCodes)) { -// new LambdaUpdateChainWrapper<>(mapper) -// .eq(AttendQuoteFieldPO::getDeleteType, 0) -// .eq(AttendQuoteFieldPO::getTenantKey, currentTenantKey) -// .eq(AttendQuoteFieldPO::getSourceType, AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()) -// .in(AttendQuoteFieldPO::getCode, deleteCodes) -// .set(AttendQuoteFieldPO::getDeleteType, 1).update(); -// } -// // 3.新增 -// List saves = new ArrayList<>(); -// saves.addAll(CollectionUtils.emptyIfNull(attendFixedFieldCodes).stream().filter(e -> saveCodes.contains(e.get("code"))).map(m -> -// buildAttendQuoteField(m.get("code"), m.get("name"), currentEmployeeId, currentTenantKey) -// ).collect(Collectors.toList())); -// CollectionUtils.emptyIfNull(saveCodes).forEach(e -> { + // 2.删除 + if (CollectionUtils.isNotEmpty(deleteCodes)) { + //根据考勤字段编码删除考勤模块字段 + biz.deleteAttendByCode(AttendQuoteFieldQueryParam.builder().codes(deleteCodes).sourceType(AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()).build()); + } + // 3.新增 + List saves = new ArrayList<>(); + saves.addAll(attendFixedFieldCodes.stream().filter(e -> saveCodes.contains(e.get("code"))).map(m -> + buildAttendQuoteField(m.get("code"), m.get("name"), currentEmployeeId) + ).collect(Collectors.toList())); +// saveCodes.forEach(e -> { // Optional optionalHour = CollectionUtils.emptyIfNull(attendVacationTypes).stream().filter(m -> (m.getId() + "_leave_hour").equals(e)).findFirst(); // if (optionalHour.isPresent()) { // AttendVacationType hour = optionalHour.get(); @@ -277,12 +276,10 @@ public class AttendQuoteFieldServiceImpl extends Service implements AttendQuoteF // saves.add(buildAttendQuoteField(e, day.getName() + "(" + dayI18n + ")", currentEmployeeId, currentTenantKey)); // } // }); -// -// if (CollectionUtils.isNotEmpty(saves)) { -// mapper.saveBatch(saves); -// } -// -// return WeaResult.success(StringUtils.EMPTY); + + if (CollectionUtils.isNotEmpty(saves)) { + biz.saveBatch(saves); + } return null; } diff --git a/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java index 3a8046523..ba94690c3 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java @@ -75,36 +75,6 @@ public class AttendQuoteFieldSettingServiceImpl extends Service implements Atten return fieldBiz.listSome(AttendQuoteFieldPO.builder().build()); } - // /** -// * 获取字段设置 -// * @return -// */ -// private List getAttendQuoteFieldSetting(AttendQuoteSourceTypeEnum sourceType, String tenantKey) { -// LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); -// lambdaQueryWrapper.eq(AttendQuoteFieldSettingPO::getTenantKey, tenantKey) -// .eq(AttendQuoteFieldSettingPO::getDeleteType, 0) -// .eq(AttendQuoteFieldSettingPO::getSourceType, sourceType.getValue()); -// return mapper.selectList(lambdaQueryWrapper); -// } -// -// @Override -// public List list(AttendQuoteFieldSettingQueryParam queryParam, Long employeeId, String tenantKey) { -// // 同步字段 -// attendQuoteFieldService.syncAttendFields(employeeId, tenantKey); -// // 获取字段设置 -// List list = getAttendQuoteFieldSetting(queryParam.getSourceType(), tenantKey); -// -// List resultList = new ArrayList<>(); -// // 考勤模块分组字段 -// resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list)?null:list.get(0), AttendQuoteFieldSourceTypeEnum.ATTEND, "", queryParam.getKeyword(), queryParam.getIsViewChecked(), employeeId, tenantKey)); -// // 如果是导入还包含自定义分组 -// if (queryParam.getSourceType().equals(AttendQuoteSourceTypeEnum.IMPORT)) { -// resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list)?null:list.get(0), AttendQuoteFieldSourceTypeEnum.DEFAULT, "", queryParam.getKeyword(), queryParam.getIsViewChecked(), employeeId, tenantKey)); -// } -// -// return resultList; -// } -// @Override public List listNoSync(AttendQuoteFieldSettingQueryParam queryParam) { // 获取字段设置 diff --git a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java index 7cda6493f..2f9667e21 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java @@ -71,7 +71,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic } // @Override -// public WeaForm getSyncForm(Long employeeId, String tenantKey) { +// public Map getSyncForm(Long employeeId) { // // List salarySobOptions = Lists.newArrayList(); // List salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper) @@ -102,7 +102,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic // } // // @Override -// public Map getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId, Long currentEmployeeId, String currentTenantKey) { +// public Map getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId) { // // SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salarySobId, salaryYearMonth, currentTenantKey); // @@ -117,7 +117,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic // } // // @Override -// public List> selectSalarySobList(Long currentEmployeeId, String currentTenantKey) { +// public List> selectSalarySobList(Long currentEmployeeId) { // List salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper) // .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey()) // .eq(SalarySobPO::getDeleteType, 0) diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 043525049..d652449d9 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -8,7 +8,6 @@ import org.apache.commons.lang3.time.FastDateFormat; import java.text.SimpleDateFormat; import java.time.*; import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAdjusters; import java.util.Calendar; import java.util.Date; import java.util.regex.Matcher; @@ -72,6 +71,18 @@ public class SalaryDateUtil { } } + public static String getFormatLocalDate(LocalDate localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + return localDate.format(DATE_FORMATTER); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + public static String getFormatLocalDate(LocalDateTime localDateTime) { if (localDateTime == null) { return StringUtils.EMPTY; diff --git a/src/com/engine/salary/util/SalaryI18nUtil.java b/src/com/engine/salary/util/SalaryI18nUtil.java index e80c871fa..3b5d0e4a0 100644 --- a/src/com/engine/salary/util/SalaryI18nUtil.java +++ b/src/com/engine/salary/util/SalaryI18nUtil.java @@ -1,7 +1,5 @@ package com.engine.salary.util; -import weaver.systeminfo.SystemEnv; - /** * @description: 多语言工具类 * @author: xiajun @@ -11,16 +9,16 @@ import weaver.systeminfo.SystemEnv; */ public class SalaryI18nUtil { -// /** -// * 获取多语言信息 -// * -// * @param labelId 多语言对应的labelId -// * @param defaultLabel 默认中文 -// * @return -// */ -// public static String getI18nLabel(int labelId, String defaultLabel) { -// return SystemEnv.getHtmlLabelName(labelId, defaultLabel); -// } + /** + * 获取多语言信息 + * + * @param labelId 多语言对应的labelId + * @param defaultLabel 默认中文 + * @return + */ + public static String getI18nLabel(int labelId, String defaultLabel) { + return defaultLabel; + } // // /** // * 获取多语言信息 diff --git a/src/com/engine/salary/util/excel/ExcelUtil.java b/src/com/engine/salary/util/excel/ExcelUtil.java index 816553305..38c4d760b 100644 --- a/src/com/engine/salary/util/excel/ExcelUtil.java +++ b/src/com/engine/salary/util/excel/ExcelUtil.java @@ -1,20 +1,23 @@ package com.engine.salary.util.excel; +import com.engine.salary.util.SalaryDateUtil; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.xssf.usermodel.*; +import java.util.Date; import java.util.List; public class ExcelUtil { /** * 生成excel + * * @param rowList * @return */ - public static XSSFWorkbook genWorkbook(List> rowList,String sheetName) { + public static XSSFWorkbook genWorkbook(List> rowList, String sheetName) { XSSFWorkbook workbook = new XSSFWorkbook(); // 设置title样式 @@ -61,4 +64,64 @@ public class ExcelUtil { } return workbook; } + + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + }else if(o instanceof Date){ + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date)o)); + }else{ + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } + } + } + return workbook; + } } diff --git a/src/com/engine/salary/web/AttendQuoteController.java b/src/com/engine/salary/web/AttendQuoteController.java index e9c3c19bc..dd361dc41 100644 --- a/src/com/engine/salary/web/AttendQuoteController.java +++ b/src/com/engine/salary/web/AttendQuoteController.java @@ -5,6 +5,7 @@ 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.exception.SalaryRunTimeException; import com.engine.salary.service.AttendQuoteDataService; import com.engine.salary.service.AttendQuoteFieldService; import com.engine.salary.service.AttendQuoteFieldSettingService; @@ -14,8 +15,10 @@ import com.engine.salary.service.impl.AttendQuoteFieldServiceImpl; import com.engine.salary.service.impl.AttendQuoteFieldSettingServiceImpl; import com.engine.salary.service.impl.AttendQuoteServiceImpl; import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryI18nUtil; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -27,6 +30,11 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.YearMonth; import java.util.Collection; import java.util.List; import java.util.Map; @@ -63,17 +71,19 @@ public class AttendQuoteController { } -// /** -// * 获取引用考勤表单 -// * @return -// */ -// @GetMapping("/getSyncForm") -// @ApiOperation("获取引用考勤表单") -// @WeaPermission -// public WeaResult getSyncForm() { -// return WeaResult.success(service.getSyncForm(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); + /** + * 获取引用考勤表单 + * @return + */ +// @GET +// @Path("/getSyncForm") +// @Produces(MediaType.APPLICATION_JSON) +// public String getSyncForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>().run(getService(user)::getSyncForm, (long)user.getUID()); // } -// + + // /** // * 获取薪资周期和考勤周期 // * @param salaryYearMonth 薪资所属月 @@ -87,16 +97,20 @@ public class AttendQuoteController { // return WeaResult.success(service.getSalaryCycleAndAttendCycle(salaryYearMonth, salarySobId, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); // } // -// /** -// * 同步引用考勤数据 -// * @return -// */ -// @PostMapping("/syncAttendQuoteData") -// @ApiOperation("同步引用考勤数据") -// @WeaPermission -// public WeaResult syncAttendQuoteData(@RequestBody AttendQuoteDataSyncParam syncParam) { -// return attendQuoteDataService.syncAttendQuoteData(syncParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// } + + /** + * 同步引用考勤数据 + * + * @return + */ + @POST + @Path("/syncAttendQuoteData") + @Produces(MediaType.APPLICATION_JSON) + public String syncAttendQuoteData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataSyncParam syncParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getDataService(user)::syncAttendQuoteData, syncParam); + } + // // /** // * 获取薪资账套下拉列表 @@ -109,37 +123,43 @@ public class AttendQuoteController { // return WeaResult.success(service.selectSalarySobList(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); // } // -// /** -// * 下载导入模板 -// * @return -// */ -// @PostMapping("/downloadTemplate") -// @ApiOperation("下载导入模板") -// @WeaPermission -// public WeaResult> downloadTemplate(@RequestBody AttendQuoteDataExportTemplateParam exportParam) { -// String currentTenantKey = TenantContext.getCurrentTenantKey(); -// Long currentEmployeeId = UserContext.getCurrentEmployeeId(); -// if (exportParam.getSalaryYearMonth()==null || exportParam.getSalarySobId()==null) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100250, "薪资所属月和薪资账套id不能为空")); -// } -// return WeaResult.success(attendQuoteDataService.downloadTemplate(exportParam, currentEmployeeId, currentTenantKey)); -// } -// -// /** -// * 获取导入参数 -// * @return -// */ -// @GetMapping("/getImportParams") -// @ApiOperation("获取导入参数") -// @WeaPermission -// public WeaResult getImportParams() { -// return WeaResult.success(salaryBatchService.buildImportParam("importAttendQuoteData", -// "importAttendQuoteData", -// SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 85367, "考勤引用"), -// null, -// null)); -// } -// + + /** + * 下载导入模板 + */ + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String salaryYearMonth = request.getParameter("salaryYearMonth"); + String salarySobId = request.getParameter("salarySobId"); + AttendQuoteDataExportTemplateParam param = AttendQuoteDataExportTemplateParam.builder() + .salarySobId(Long.valueOf(salarySobId)) + .salaryYearMonth(YearMonth.parse(salaryYearMonth)) + .build(); + if (param.getSalaryYearMonth() == null || param.getSalarySobId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100250, "薪资所属月和薪资账套id不能为空")); + } + XSSFWorkbook workbook = getDataService(user).downloadTemplate(param); + String fileName = null; + try { + fileName = URLEncoder.encode("考勤引用导入模板.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + /** * 查看考勤数据 @@ -168,24 +188,38 @@ public class AttendQuoteController { User user = HrmUserVarify.getUser(request, response); return new ResponseResult, String>().run(getService(user)::delete, ids); } -// -// /** -// * 导出考勤数据 -// * @param queryParam -// * @return -// */ -// @PostMapping("/export") -// @ApiOperation("导出考勤数据") -// @WeaPermission -// public WeaResult> export(@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.export(queryParam, currentEmployeeId, currentTenantKey)); -// } -// + + /** + * 导出考勤数据 + * + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String attendQuoteId = request.getParameter("attendQuoteId"); + AttendQuoteDataQueryParam param = AttendQuoteDataQueryParam.builder().attendQuoteId(Long.valueOf(attendQuoteId)).build(); + XSSFWorkbook workbook = getDataService(user).export(param); + String fileName = null; + try { + fileName = URLEncoder.encode("考勤导出.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + /** * 考勤字段管理列表 diff --git a/src/com/engine/salary/web/SalaryItemController.java b/src/com/engine/salary/web/SalaryItemController.java new file mode 100644 index 000000000..b2151ad9a --- /dev/null +++ b/src/com/engine/salary/web/SalaryItemController.java @@ -0,0 +1,133 @@ +package com.engine.salary.web; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryItemController { + +// @Autowired +// private SalaryItemWrapper salaryItemWrapper; +// @Autowired +// private SysSalaryItemWrapper sysSalaryItemWrapper; +// +// /**********************************自定义薪资项目 start*********************************/ +// +// @PostMapping("/list") +// @ApiOperation("薪资项目列表") +// @WeaPermission +// public WeaResult> listSalaryItem(@RequestBody SalaryItemSearchParam searchParam) { +// return WeaResult.success(salaryItemWrapper.listPage(searchParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); +// } +// +// @PostMapping("/listCanDelete") +// @ApiOperation("可删除的薪资项目列表") +// @WeaPermission +// public WeaResult> listCanDeleteSalaryItem(@RequestBody SalaryItemSearchParam searchParam) { +// return WeaResult.success(salaryItemWrapper.listPage4CanDelete(searchParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); +// } +// +// @PostMapping("/listSalaryItemDetail") +// @ApiOperation("获取多个薪资项目的详情") +// @WeaPermission +// public WeaResult> listSalaryItemDetail(@RequestBody Collection ids) { +// if (CollectionUtils.isEmpty(ids)) { +// return WeaResult.success(Collections.emptyList()); +// } +// List salaryItemListDTOS = salaryItemWrapper.listByIds(ids, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(salaryItemListDTOS); +// } +// +// @GetMapping("/getSearchCondition") +// @ApiOperation("薪资项目列表的高级搜索") +// @WeaPermission +// public WeaResult getSearchCondition() { +// return WeaResult.success(salaryItemWrapper.getSearchCondition()); +// } +// +// @PostMapping("/getSalaryForm") +// @ApiOperation("薪资项目的详情") +// @WeaPermission +// public WeaResult getSalaryItemForm(@RequestParam(value = "id", required = false) Long id) { +// return WeaResult.success(salaryItemWrapper.getForm(id, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); +// } +// +// @GetMapping("/listSalaryItemTypeOption") +// @ApiOperation("获取薪资项目可选的类型(与属性有联动)") +// @WeaPermission +// public WeaResult>> listSalaryItemTypeOption() { +// Map> resultMap = salaryItemWrapper.listSalaryItemTypeOption(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// return WeaResult.success(resultMap); +// } +// +// @PostMapping("/delete") +// @ApiOperation("批量删除薪资项目") +// @WeaPermission +// public WeaResult deleteSalaryItem(@RequestBody Collection ids) { +// Long employeeId = UserContext.getCurrentEmployeeId(); +// String tenantKey = TenantContext.getCurrentTenantKey(); +// if (CollectionUtils.isEmpty(ids)) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84026, "参数错误")); +// } +// salaryItemWrapper.delete(ids, tenantKey); +// return WeaResult.success(null); +// } +// +// @PostMapping("/save") +// @ApiOperation("保存薪资项目") +// @WeaPermission +// public WeaResult saveSalaryItem(@RequestBody @Validated SalaryItemSaveParam saveParam) { +// if (saveParam.getId() == null || saveParam.getId() <= 0) { +// salaryItemWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// } else { +// salaryItemWrapper.update(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// } +// return WeaResult.success(null); +// } +// +// @PostMapping("/update") +// @ApiOperation("更新薪资项目") +// @WeaPermission +// public WeaResult updateSalaryItem(@RequestBody @Validated SalaryItemSaveParam saveParam) { +// salaryItemWrapper.update(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// return WeaResult.success(null); +// } +// +// /**********************************自定义薪资项目 end*********************************/ +// +// +// /**********************************系统薪资项目 start*********************************/ +// +// @PostMapping("/sysList") +// @ApiOperation("系统薪资项目列表") +// @WeaPermission +// public WeaResult> listSysSalaryItem(@RequestBody SysSalaryItemSearchParam searchParam) { +// return WeaResult.success(sysSalaryItemWrapper.listPage(searchParam, TenantContext.getCurrentTenantKey())); +// } +// +// @GetMapping("/getSysSearchCondition") +// @ApiOperation("系统薪资项目的高级搜索") +// @WeaPermission +// public WeaResult getSysSearchCondition() { +// return WeaResult.success(sysSalaryItemWrapper.getSearchCondition()); +// } +// +// @PostMapping("/saveSys") +// @ApiOperation("添加系统薪资项目") +// @WeaPermission +// public WeaResult saveSysSalaryItem(@RequestBody Collection sysSalaryItemIds) { +// Long employeeId = UserContext.getCurrentEmployeeId(); +// String tenantKey = TenantContext.getCurrentTenantKey(); +// if (CollectionUtils.isEmpty(sysSalaryItemIds)) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84026, "参数错误")); +// } +// sysSalaryItemWrapper.add2SalaryItem(sysSalaryItemIds, employeeId, tenantKey); +// return WeaResult.success(null); +// } +// +// /**********************************系统薪资项目 end*********************************/ +}