Merge branch 'feature/qt' into develop

This commit is contained in:
钱涛 2022-03-16 14:30:54 +08:00
commit 59fc1ded4e
37 changed files with 2115 additions and 319 deletions

View File

@ -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{
}

View File

@ -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<AttendQuotePO> 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();
}
}
}

View File

@ -44,4 +44,15 @@ public class AttendQuoteDataBiz {
}
}
public void insertData(List<AttendQuoteDataPO> pos) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class);
mapper.insertData(pos);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -0,0 +1,49 @@
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<Long> attendQuoteDataIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class);
mapper.deleteByAttendQuoteDataIds(attendQuoteDataIds);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
public List<AttendQuoteDataValuePO> listSome(AttendQuoteDataValuePO param) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class);
return mapper.listSome(param);
} finally {
sqlSession.close();
}
}
public void insertData(List<AttendQuoteDataValuePO> values) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class);
mapper.insertData(values);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -77,4 +77,26 @@ public class AttendQuoteFieldBiz {
sqlSession.close();
}
}
public void saveBatch(List<AttendQuoteFieldPO> 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();
}
}
}

View File

@ -41,4 +41,6 @@ public class AttendQuoteFieldSettingBiz {
sqlSession.close();
}
}
}

View File

@ -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;
/**
* 日期范围
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class LocalDateRange {
//"开始日期
private LocalDate fromDate;
//结束日期
private LocalDate endDate;
}

View File

@ -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;
/**
* 考勤引用-字段管理
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class AttendQuoteFieldBO {
// public static List<WeaTableColumn> buildRecordTableColumns(Long employeeId, String tenantKey) {
// List<WeaTableColumn> 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<String, EditableTableItem> buildEditableTableItemMap() {
// Map<String, EditableTableItem> 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<Map<String, String>> buildAttendFixedFields() {
List<Map<String, String>> 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<String, String> attendFixedField(String code, int labelId, String name) {
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
map.put("code", code);
map.put("name", name);
return map;
}
}

View File

@ -37,6 +37,7 @@ public class AttendQuoteDataQueryParam {
private Collection<Long> unAccountingIds;
//
// //人员信息表的主键id")
// private Long employeeId;

View File

@ -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<String> 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, "薪资账套必传"));
}
}
}

View File

@ -29,6 +29,11 @@ public class AttendQuoteFieldQueryParam {
//字段名称
private String fieldName;
//根据编码删除
private Collection<String> codes;
//来源1自定义2考勤模块
private Integer sourceType;
/**
* 查询where语句
* @param queryParam

View File

@ -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<Long> employeeIds;
}

View File

@ -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<Long> ids;
}

View File

@ -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;
/**
* 薪资账套的周期
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @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;
}

View File

@ -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;
/**
* 薪资账套保存参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @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;
}

View File

@ -0,0 +1,25 @@
package com.engine.salary.entity.salarysob.param;
import lombok.Data;
/**
* 薪资账套禁用或启用保存参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
public class SalarySobDisableParam {
/**
* 薪资账套的ID不允许为空
*/
private Long id;
/**
* 参数错误只能选择启用或者禁用
*/
private Integer disable;
}

View File

@ -0,0 +1,26 @@
package com.engine.salary.entity.salarysob.param;
import lombok.Data;
/**
* 薪资账套复制参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
public class SalarySobDuplicateParam {
/**
* 薪资账套的ID不允许为空
*/
private Long id;
/**
* 名称不允许为空
* 名称不能超过40个字符长度
*/
private String name;
}

View File

@ -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;

View File

@ -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
</sql>
<sql id="paramSql">
@ -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},'%')
)
</if>
@ -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}||'%'
)
</if>
@ -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}+'%'
)
</if>
@ -303,7 +303,6 @@
<insert id="insertData">
INSERT INTO hrsa_attend_quote_data(
id,
employee_id,
attend_quote_id,
create_time,
@ -313,7 +312,6 @@
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.createTime},
@ -325,7 +323,6 @@
</insert>
<insert id="insertData" databaseId="oracle">
INSERT INTO hrsa_attend_quote_data(
id,
employee_id,
attend_quote_id,
create_time,
@ -335,7 +332,6 @@
<foreach collection="collection" item="item" separator="union all">
select
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.createTime},
@ -347,7 +343,6 @@
</insert>
<insert id="insertData" databaseId="sqlserver">
INSERT INTO hrsa_attend_quote_data(
id,
employee_id,
attend_quote_id,
create_time,
@ -357,7 +352,6 @@
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.createTime},

View File

@ -61,15 +61,14 @@ public interface AttendQuoteDataValueMapper {
/**
* 批量删除数据采集-考勤引用数据
* @param attendQuoteDataIds
* @param tenantKey
*/
void deleteByAttendQuoteDataIds(@Param("attendQuoteDataIds") Collection<Long> attendQuoteDataIds, @Param("tenantKey") String tenantKey);
void deleteByAttendQuoteDataIds(@Param("attendQuoteDataIds") Collection<Long> attendQuoteDataIds);
/**
* 批量插入数据采集-考勤引用数据
* @param values
* @param currentTenantKey
*/
void insertData(@Param("collection") List<AttendQuoteDataValuePO> values, String currentTenantKey);
void insertData(@Param("collection") List<AttendQuoteDataValuePO> values);
List<AttendQuoteDataValuePO> listSome(AttendQuoteDataValuePO param);
}

View File

@ -196,7 +196,7 @@
<update id="deleteByAttendQuoteDataIds">
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
<foreach collection="attendQuoteDataIds" open="(" item="attendQuoteDataId" separator="," close=")">
#{attendQuoteDataId}
@ -205,7 +205,6 @@
<insert id="insertData">
INSERT INTO hrsa_attend_quote_data_value(
id,
employee_id,
attend_quote_id,
attend_quote_data_id,
@ -218,7 +217,6 @@
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.attendQuoteDataId},
@ -233,7 +231,6 @@
</insert>
<insert id="insertData" databaseId="oracle">
INSERT INTO hrsa_attend_quote_data_value(
id,
employee_id,
attend_quote_id,
attend_quote_data_id,
@ -246,7 +243,6 @@
<foreach collection="collection" item="item" separator="union all">
select
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.attendQuoteDataId},
@ -261,7 +257,6 @@
</insert>
<insert id="insertData" databaseId="sqlserver">
INSERT INTO hrsa_attend_quote_data_value(
id,
employee_id,
attend_quote_id,
attend_quote_data_id,
@ -274,7 +269,6 @@
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.employeeId},
#{item.attendQuoteId},
#{item.attendQuoteDataId},
@ -288,6 +282,22 @@
</foreach>
</insert>
<!-- 查询全部 -->
<select id="listSome" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_attend_quote_data_value t
WHERE delete_type = 0
<if test="param.attendQuoteId != null and param.attendQuoteId != ''">
AND attend_quote_id = #{param.attendQuoteId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size() > 0 ''">
AND employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</select>
</mapper>

View File

@ -10,88 +10,98 @@ import java.util.List;
public interface AttendQuoteFieldMapper {
/**
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<AttendQuoteFieldPO> listAll();
List<AttendQuoteFieldPO> 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<AttendQuoteFieldListDTO> list(@Param("param") AttendQuoteFieldQueryParam param);
/**
* 批量删除数据采集-考勤引用字段
*
* @param ids
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
/**
* 查询数据采集-考勤引用字段列表
* @param param
* @return
*/
List<AttendQuoteFieldListDTO> list(@Param("param") AttendQuoteFieldQueryParam param);
/**
* 插入
*
* @param saves
*/
void saveBatch(@Param("saves") List<AttendQuoteFieldPO> saves);
/**
* 更新字段名
*
* @param updates
*/
void updateNameByCode(@Param("updates") List<AttendQuoteFieldPO> updates);
/**
* 批量删除数据采集-考勤引用字段
* @param ids
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
/**
* 插入
* @param saves
*/
void saveBatch(@Param("saves") List<AttendQuoteFieldPO> saves);
/**
* 更新字段名
* @param updates
*/
void updateNameByCode(@Param("updates") List<AttendQuoteFieldPO> updates);
/**
* 条件查询
* @param param
* @return
*/
List<AttendQuoteFieldPO> listSome(@Param("param")AttendQuoteFieldPO param);
/**
* 条件查询
*
* @param param
* @return
*/
List<AttendQuoteFieldPO> listSome(@Param("param") AttendQuoteFieldPO param);
}

View File

@ -204,6 +204,19 @@
AND delete_type = 0
</delete>
<delete id="deleteAttendByCode"
parameterType="com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam">
UPDATE hrsa_attend_quote_field
SET delete_type=1
WHERE delete_type = 0
AND source_type= 2
AND code IN
<foreach collection="param.codes" open="(" item="code" separator="," close=")">
#{code}
</foreach>
</delete>
<sql id="attendQuoteFieldColumn">
t1
@ -264,11 +277,10 @@
<insert id="saveBatch">
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
<foreach collection="saves" item="item" separator=",">
(
#{item.id},
#{item.fieldName},
#{item.sourceType},
#{item.fieldType},
@ -281,11 +293,10 @@
</insert>
<insert id="saveBatch" databaseId="oracle">
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)
<foreach collection="saves" item="item" separator="union all">
select
#{item.id},
#{item.fieldName},
#{item.sourceType},
#{item.fieldType},
@ -298,11 +309,10 @@
</insert>
<insert id="saveBatch" databaseId="sqlserver">
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
<foreach collection="saves" item="item" separator=",">
(
#{item.id},
#{item.fieldName},
#{item.sourceType},
#{item.fieldType},
@ -363,9 +373,8 @@
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
AND delete_type = 0
AND delete_type = 0
</delete>
</mapper>

View File

@ -12,71 +12,72 @@ import java.util.List;
@Mapper
public interface AttendQuoteMapper {
/**
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<AttendQuotePO> listAll();
List<AttendQuotePO> 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<AttendQuoteListDTO> list(@Param("param") AttendQuoteQueryParam param);
/**
* 查询数据采集-考勤引用列表
*
* @param param
* @return
*/
List<AttendQuoteListDTO> list(@Param("param") AttendQuoteQueryParam param);
/**
* 批量删除数据采集-考勤引用
* @param ids
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
/**
* 批量删除数据采集-考勤引用
*
* @param ids
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
List<AttendQuotePO> listSome(@Param("param") AttendQuotePO param);
}

View File

@ -241,9 +241,11 @@
</delete>
<sql id="attendQuoteColumn">
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
<include refid="paramSql"/>
ORDER BY t1.id DESC
</select>
@ -296,5 +298,18 @@
</foreach>
</update>
<select id="listSome" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_attend_quote t
WHERE delete_type = 0
<if test="param.salaryYearMonth != null">
AND t.salary_year_month = #{param.salaryYearMonth}
</if>
<if test="param.salarySobId != null">
AND t.salary_sob_id = #{param.salarySobId}
</if>
</select>
</mapper>

View File

@ -0,0 +1,61 @@
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;
/**
* 数据采集-考勤引用数据
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface AttendQuoteDataService {
/**
* 查看数据采集-考勤引用
* @param queryParam
* @return
*/
Map<String, Object> view(AttendQuoteDataQueryParam queryParam);
/**
* 导出考勤数据
* @param queryParam
* @return
*/
XSSFWorkbook export(AttendQuoteDataQueryParam queryParam);
/**
* 同步引用考勤数据
* @param syncParam
* @return
*/
String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam);
/**
* 获取考勤引用数据
* @param salaryYearMonth
* @param salarySobId
* @param employeeIds
* @return
*/
List<AttendQuoteDataDTO> getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List<Long> employeeIds);
/**
* 导出考勤数据作为模板
* @param exportParam
* @return
*/
XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam);
}

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.Map;
public interface AttendQuoteService {
/**
/**AttendQuoteDataService
* 数据采集-考勤引用列表
*/
Map<String, Object> list(Map<String, Object> params);
@ -15,29 +15,27 @@ public interface AttendQuoteService {
* @return
*/
String delete(Collection<Long> ids);
//
// /**
// * 获取引用考勤表单
// * @param currentEmployeeId
// * @param currentTenantKey
// * @return
// */
// WeaForm getSyncForm(Long currentEmployeeId, String currentTenantKey);
// Map<String, Object> getSyncForm(Long currentEmployeeId);
//
//
// /**
// * 获取薪资周期和考勤周期
// * @param salaryYearMonth
// * @param salarySobId
// * @param currentTenantKey
// * @return
// */
// Map<String, Object> getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId, Long currentEmployeeId, String currentTenantKey);
// Map<String, Object> getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId);
//
// /**
// * 获取薪资账套下拉列表
// * @param currentEmployeeId
// * @param currentTenantKey
// * @return
// */
// List<Map<String, Object>> selectSalarySobList(Long currentEmployeeId, String currentTenantKey);
// List<Map<String, Object>> selectSalarySobList(Long currentEmployeeId);
}

View File

@ -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<SalarySobPO> listByIds(Collection<Long> ids, String tenantKey);
/**
* 根据名称精确匹配查询薪资账套
*
* @param name 薪资账套名称
* @param tenantKey 租户key
* @return
*/
List<SalarySobPO> listByName(String name, String tenantKey);
/**
* 根据名称模糊匹配查询薪资账套
*
* @param nameLike 薪资账套名称
* @param tenantKey 租户key
* @return
*/
List<SalarySobPO> listByNameLike(String nameLike, String tenantKey);
/**
* 查询启用/禁用的薪资账套
*
* @param disable 启用/禁用
* @param tenantKey 租户key
* @return
*/
List<SalarySobPO> listByDisable(Integer disable, String tenantKey);
/**
* 根据薪资类型查询薪资账套
*
* @param incomeCategory 薪资类型
* @param tenantKey 租户key
* @return
*/
List<SalarySobPO> listByIncomeCategory(IncomeCategoryEnum incomeCategory, String tenantKey);
/**
* 根据列表查询参数查询薪资账套分页
*
* @param queryParam 列表查询参数
* @param tenantKey 租户key
* @return
*/
// Page<SalarySobPO> 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<Long> 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);
}

View File

@ -0,0 +1,835 @@
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.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.time.YearMonth;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 数据采集-考勤引用数据
* @Author: wangxiangzhong
* @Date: 2021-11-17 14:37
*/
public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDataService {
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();
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;
// @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<AttendQuoteDataBaseDTO> attendQuoteDataBases = dataBiz.list(queryParam);
// 所有考勤字段
List<AttendQuoteFieldPO> attendQuoteFields = getAllAttendQuoteFields();
// 获取最终结果
List<Map<String, Object>> listMaps = getListMaps(attendQuoteDataBases);
// Page<Map<String, Object>> listPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
// listPage.setRecords(listMaps);
//
// WeaTable<LinkedHashMap> weaTable = FormatManager.<LinkedHashMap>getInstance()
// .genTable(LinkedHashMap.class, listPage);
// // 表格表头
// List<WeaTableColumn> 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<String, Object> 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<AttendQuoteFieldPO> getAllAttendQuoteFields() {
return fieldBiz.listSome(AttendQuoteFieldPO.builder().build());
}
/**
* 获取考勤数据结果
*
* @param attendQuoteDataBases
* @return
*/
private List<Map<String, Object>> getListMaps(List<AttendQuoteDataBaseDTO> attendQuoteDataBases) {
if (CollectionUtils.isEmpty(attendQuoteDataBases)) {
return new ArrayList<>();
}
// 考核数据值
List<AttendQuoteDataValuePO> attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuoteDataBases.get(0).getAttendQuoteId()).build());
return attendQuoteDataBases.stream().map(m -> {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", m.getId());
map.put("username", m.getUsername());
map.put("departmentName", m.getDepartmentName());
map.put("mobile", m.getMobile());
map.put("jobNum", m.getJobNum());
// 考勤数据
attendQuoteDataValues.stream().filter(a -> a.getAttendQuoteDataId().equals(m.getId())).collect(Collectors.toList()).forEach(e -> {
map.put(e.getAttendQuoteFieldId() + "_attendQuoteData", e.getDataValue());
});
return map;
}).collect(Collectors.toList());
}
@Override
public List<AttendQuoteDataDTO> getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List<Long> employeeIds) {
if (salaryYearMonth == null || salarySobId == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100358, "参数有误薪资所属月、薪资账套id"));
}
List<AttendQuoteDataDTO> list = new ArrayList<>();
Date salaryYearMonthDay = SalaryDateUtil.localDateToDate(salaryYearMonth.atDay(1));
//查询引用主表
List<AttendQuotePO> attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salaryYearMonth(salaryYearMonthDay).salarySobId(salarySobId).build());
if (CollectionUtils.isEmpty(attendQuotes)) {
return Collections.emptyList();
}
AttendQuotePO attendQuote = attendQuotes.get(0);
//查询考勤数据值
List<AttendQuoteDataValuePO> attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuote.getId()).employeeIds(employeeIds).build());
if (CollectionUtils.isEmpty(employeeIds)) {
employeeIds = attendQuoteDataValues.stream().map(AttendQuoteDataValuePO::getEmployeeId)
.distinct().collect(Collectors.toList());
}
employeeIds.forEach(e -> {
AttendQuoteDataDTO attendQuoteData = new AttendQuoteDataDTO();
attendQuoteData.setEmployeeId(e);
List<AttendQuoteDataValueDTO> dataValues = attendQuoteDataValues.stream().filter(v -> v.getEmployeeId().equals(e)).map(m ->
AttendQuoteDataValueDTO.builder()
.attendQuoteFieldId(m.getAttendQuoteFieldId())
.dataValue(m.getDataValue())
.build()).collect(Collectors.toList());
attendQuoteData.setDataValues(dataValues);
list.add(attendQuoteData);
});
return list;
}
@Override
public XSSFWorkbook export(AttendQuoteDataQueryParam queryParam) {
if (queryParam.getAttendQuoteId() == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100253, "考勤引用id不能为空"));
}
// 考勤数据分页主数据
List<AttendQuoteDataBaseDTO> attendQuoteDataBases = dataBiz.list(queryParam);
// 所有考勤字段
List<AttendQuoteFieldPO> attendQuoteFields = getAllAttendQuoteFields();
// 获取最终结果
List<Map<String, Object>> listMaps = getListMaps(attendQuoteDataBases);
// 1.工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(93931, "考勤数据");
List<Object> header = new ArrayList<>();
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
// 动态列
if (CollectionUtils.isNotEmpty(listMaps)) {
Map<String, Object> mapColumn = listMaps.get(0);
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
if (mapColumn.containsKey(attendQuoteField.getId() + "_attendQuoteData")) {
header.add(attendQuoteField.getFieldName());
}
}
}
List<List<Object>> rows = new ArrayList<>();
// 2.表头
rows.add(header);
// 3.表数据
for (Map<String, Object> dto : listMaps) {
List<Object> row = new ArrayList<>();
row.add(dto.get("username"));
row.add(dto.get("departmentName"));
row.add(dto.get("mobile"));
row.add(dto.get("jobNum"));
// 动态列
Map<String, Object> 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<AttendQuoteFieldPO> getAttendQuoteSetFields(AttendQuoteSourceTypeEnum sourceType) {
List<AttendQuoteFieldPO> allAttendQuoteFields = getAllAttendQuoteFields();
AttendQuoteFieldSettingService attendQuoteFieldSettingService = getFieldSettingService(user);
List<AttendQuoteFieldSettingListDTO> attendQuoteFieldSettingList = attendQuoteFieldSettingService.listNoSync(AttendQuoteFieldSettingQueryParam.builder().sourceType(sourceType).isViewChecked(Boolean.TRUE).build());
List<AttendQuoteFieldPO> attendQuoteFields = new ArrayList<>();
attendQuoteFieldSettingList.forEach(s -> {
List<AttendQuoteFieldSettingFieldListDTO> items = s.getItems();
if (CollectionUtils.isNotEmpty(items)) {
items.forEach(i -> {
Optional<AttendQuoteFieldPO> optional = allAttendQuoteFields.stream().filter(f -> f.getId().equals(i.getId())).findFirst();
optional.ifPresent(attendQuoteFields::add);
});
}
});
return attendQuoteFields;
}
@Override
public String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam) {
AttendQuoteDataSyncParam.checkParam(syncParam);
String salaryYearMonth = syncParam.getSalaryYearMonth();
int year = Integer.parseInt(salaryYearMonth.split("-")[0]);
int month = Integer.parseInt(salaryYearMonth.split("-")[1]);
if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'"));
}
// 1.获取已设置的可同步的考勤字段
List<AttendQuoteFieldPO> attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.QUOTE);
if (CollectionUtils.isEmpty(attendQuoteFields)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100366, "请先设置同步字段"));
}
// 获取薪资账套 todo
// SalarySobCycleDTO salarySobCycle = salarySobService.getSalarySobCycle(syncParam.getSalarySobId(), YearMonth.of(year, month), currentTenantKey);
// 2.薪资账套人员
List<Long> employeeIds = new ArrayList<>();
// 获取薪资账套人员
// List<SalarySobRangePO> salarySobRanges = new LambdaQueryChainWrapper<>(salarySobRangeMapper)
// .eq(SalarySobRangePO::getTenantKey, currentTenantKey)
// .eq(SalarySobRangePO::getDeleteType, 0)
// .eq(SalarySobRangePO::getIncludeType, 1)
// .eq(SalarySobRangePO::getSalarySobId, salarySobCycle.getSalarySobId())
// .list();
// List<SalarySobRangeEmpQueryParam> salarySobRangeEmpQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(salarySobRanges);
// List<Long> employeeSalarySobIds = salarySobRangeMapper.listEmployeeIds(salarySobRangeEmpQueryParams);
// if (CollectionUtils.isEmpty(employeeSalarySobIds) || CollectionUtils.isEmpty(salarySobRangeEmpQueryParams)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100367, "薪资账套还没有人员"));
// }
// 账套外人员
List<Long> employeeOtherIds = (List<Long>) syncParam.getEmployeeIds();
// employeeIds.addAll(employeeSalarySobIds);
employeeIds.addAll(CollectionUtils.emptyIfNull(employeeOtherIds));
// 3.考勤引用
AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.QUOTE, syncParam.getSalarySobId(), year, month, syncParam.getDescription());
// 4.获取考勤模块数据
//todo 日期范围需要账套后实现 List<Map<String, Object>> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(salarySobCycle.getAttendCycle(), employeeIds, attendQuoteFields);
List<Map<String, Object>> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(LocalDateRange.builder().build(), employeeIds, attendQuoteFields);
List<AttendQuoteDataPO> pos = new ArrayList<>();
List<AttendQuoteDataValuePO> 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(now);
po.setUpdateTime(now);
po.setCreator((long) user.getUID());
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
// 考勤引用表的主键id
po.setAttendQuoteId(attendQuote.getId());
po.setEmployeeId(employeeId);
pos.add(po);
for (Map<String, Object> attendQuoteData : attendQuoteSyncData) {
if (attendQuoteData.get("employeeId").toString().equals(employeeId.toString())) {
values.add(AttendQuoteDataValuePO.builder()
// .id(IdGenerator.generate())
.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 null;
}
/**
* 获取考勤引用
*
* @param salarySobId
* @param year
* @param month
* @return
*/
private AttendQuotePO getAttendQuote(AttendQuoteSourceTypeEnum sourceType, Long salarySobId, int year, int month, String description) {
SalarySobCycleDTO salarySobCycle = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month));
Date salaryYearMonthDayDate = SalaryDateUtil.localDateToDate(YearMonth.of(year, month).atDay(1));
List<AttendQuotePO> attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salarySobId(salarySobId).salaryYearMonth(salaryYearMonthDayDate).build());
// 考勤引用
AttendQuotePO attendQuote = new AttendQuotePO();
if (CollectionUtils.isNotEmpty(attendQuotes)) {
attendQuote = attendQuotes.get(0);
}
attendQuote.setSalarySobId(salarySobCycle.getSalarySobId());
LocalDateRange salaryCycleRange = salarySobCycle.getSalaryCycle();
LocalDateRange attendCycleRange = salarySobCycle.getAttendCycle();
// 考勤周期
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());
quoteBiz.insert(attendQuote);
}
return attendQuote;
}
/**
* 获取考勤模块数据 todo
*
* @param attendCycleRange
* @param employeeIds
* @param attendQuoteFields
* @return
*/
private List<Map<String, Object>> getAttendQuoteDataFromRemoteAttend(LocalDateRange attendCycleRange, List<Long> employeeIds, List<AttendQuoteFieldPO> attendQuoteFields) {
List<Map<String, Object>> attendQuoteSyncData = new ArrayList<>();
// Attend4Salary attend4Salary = new Attend4Salary();
// try {
// int partSize = 500;
// List<List<Long>> partition = Lists.partition(employeeIds, partSize);
// for (List<Long> 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<Map<String, Object>> 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
*/
private void handleDataToDB(Long attendQuoteId, List<AttendQuoteDataPO> pos, List<AttendQuoteDataValuePO> values) {
// 数据落库处理
if (CollectionUtils.isEmpty(pos)) {
return;
}
// 多条相同人的则以第一条为准如果逆序排列用于重复的则以最后一条为准Collections.reverse(pos);
pos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId()))), ArrayList::new));
// 删除考勤数据
ArrayList<Long> quoteIds = new ArrayList<>();
quoteIds.add(attendQuoteId);
dataBiz.deleteByAttendQuoteIds(quoteIds);
// 新增考勤数据
dataBiz.insertData(pos);
// 删除考勤值数据
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<AttendQuotePO> attendQuotePOS = quoteBiz.listSome(AttendQuotePO.builder()
.salarySobId(exportParam.getSalarySobId())
.salaryYearMonth(salaryYearMonth)
.ids(exportParam.getIds()).build());
AttendQuotePO po = CollectionUtils.isNotEmpty(attendQuotePOS) ? attendQuotePOS.get(0) : null;
AttendQuoteDataQueryParam queryParam = AttendQuoteDataQueryParam.builder().attendQuoteId(po == null ? 0L : po.getId()).build();
List<AttendQuoteDataBaseDTO> attendQuoteDataBases = dataBiz.list(queryParam);
// 获取已设置的可同步的字段
List<AttendQuoteFieldPO> attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT);
// 获取最终结果
List<Map<String, Object>> listMaps = getListMaps(attendQuoteDataBases);
// 1.工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(101606, "考勤引用导入模板");
List<Object> header = new ArrayList<>();
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
// 动态列
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
header.add(attendQuoteField.getFieldName());
}
// // 2.表头
// excelSheetData.setHeaders(Collections.singletonList(header.toArray(new String[]{})));
List<List<Object>> rows = new ArrayList<>();
rows.add(header);
for (Map<String, Object> dto : listMaps) {
List<Object> row = new ArrayList<>();
row.add(dto.get("username"));
row.add(dto.get("departmentName"));
row.add(dto.get("mobile"));
row.add(dto.get("jobNum"));
// 动态列
Map<String, Object> 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);
}
//
// /**
// * 导入考核数据
// */
// @BatchImportHandler("importAttendQuoteData")
// public void importAttendQuoteData() {
// BatchDocumentMessage message = BatchImportContext.getBatchDocumentMessage();
// log.info("【考勤引用数据】接收到上传的数据:{}", JSONObject.toJSONString(message));
// // 租户key
// String tenantKey = message.getTenantKey().toLowerCase();
// try {
// // 加密用
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// // 接收到解析的数据
// batchImportEbatch(message);
// } catch (Exception e) {
// log.error("【考勤引用数据】导入失败:{}", String.format("BatchTaskId=%s,错误信息=%s", message.getBatchTaskId(), e.getMessage()));
// } finally {
// // 加密用
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
//
// /**
// * 导入的数据插入到数据库中
// * @param message
// * @throws ParseException
// */
// @Transactional(rollbackFor = Exception.class)
// public void batchImportEbatch(BatchDocumentMessage message) {
// List<ExcelSheet> excelSheets = message.getBatchFile().getExcelSheets();
//
// // 租户key
// String tenantKey = message.getTenantKey().toLowerCase();
// Long currentEmployeeId = message.getUserId();
// // 加密用
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// String paramsData = message.getUploadSet().getCustomData();
// Map<String, Object> 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<DataCollectionEmployeePO> employees = attendQuoteMapper.listEmployee(tenantKey);
// // 获取已设置的可同步的考勤字段
// List<AttendQuoteFieldPO> 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<Map<String, Object>> data = excelSheet.getData();
// if (data != null) {
// total += data.size();
// }
// }
// int index = 0;
// int successCount = 0;
// int errorCount = 0;
// // 错误excel内容
// List<ExcelSheet> errorExcelSheets = new ArrayList<>();
// // 待导入数据
// List<AttendQuoteDataPO> pos = new ArrayList<>();
// List<AttendQuoteDataValuePO> values = new ArrayList<>();
// String valI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100581, "请输入数字");
// for (ExcelSheet excelSheet : excelSheets) {
// if (excelSheet.getHeader().size() == 0) {
// continue;
// }
// List<Map> headers = excelSheet.getHeader();
// boolean isValidHeader = checkHeaders(message, headers, attendQuoteFields);
// if (!isValidHeader) {
// return;
// }
// // 错误sheet数据
// List<Map<String,Object>> errorData = new ArrayList<>();
// // 错误提示
// List<ExcelComment> excelComments = new ArrayList<>();
//
// List<Map<String, Object>> data = excelSheet.getData();
// Map<String, Object> 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<Long> 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<ExcelComment> 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<SalarySobPO> 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<String, Object> params) {
// boolean isValid = true;
// String errorMsg = "";
// if (params == null) {
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100582, "参数必传");
// } else {
// if (!params.containsKey("salaryYearMonth")
// || !params.containsKey("salarySobId")
// || params.get("salaryYearMonth") == null
// || params.get("salarySobId") == null) {
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100588, "薪资所属月和薪资账套必传");
// } else {
// String salaryYearMonth = params.get("salaryYearMonth").toString();
// if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) {
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100365, "薪资所属月格式有误,正确格式示例为'2021-01'");
// } else {
// List<SalarySobPO> 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<Map> headers, List<AttendQuoteFieldPO> attendQuoteFields) {
// boolean isValid = true;
//
// String tenantKey = message.getTenantKey();
// Long currentEmployeeId = message.getUserId();
// String userNameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名");
//
// List<String> headerList = headers.stream().map(m->m.getOrDefault("key", "").toString()).collect(Collectors.toList());
//
// List<String> mustHeaders = CollectionUtils.emptyIfNull(attendQuoteFields).stream().map(AttendQuoteFieldPO::getFieldName).collect(Collectors.toList());
// mustHeaders.add(userNameI18n);
//
// // 缺少的必须列
// List<String> lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList());
//
// String errorMsg = "";
// String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(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;
// }
}

View File

@ -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<String> attendLeaveFieldCodes = Lists.newArrayList();
// attendLeaveFieldCodes.addAll(attendLeaveHourFieldCodes);
// attendLeaveFieldCodes.addAll(attendLeaveDayFieldCodes);
// // 所有考勤模块字段编码
// List<String> attendFieldCodes = Lists.newArrayList();
// 所有考勤模块字段编码
List<String> attendFieldCodes = Lists.newArrayList();
// attendFieldCodes.addAll(attendLeaveFieldCodes);
// // 考勤模块固定字段
// List<Map<String, String>> attendFixedFieldCodes = AttendQuoteFieldBO.buildAttendFixedFields();
// attendFieldCodes.addAll(attendFixedFieldCodes.stream().map(m -> m.get("code")).collect(Collectors.toList()));
//
// // 本地已存在则更新交集
// List<String> updateCodes = localFieldCodes.stream().filter(item -> attendFieldCodes.contains(item)).collect(Collectors.toList());
// // 本地比attend多则删除差集(local - attend)
// List<String> deleteCodes = localFieldCodes.stream().filter(item -> !attendFieldCodes.contains(item)).collect(Collectors.toList());
// // attend比本地多则新增差集(attend - local)
// List<String> 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<Map<String, String>> attendFixedFieldCodes = AttendQuoteFieldBO.buildAttendFixedFields();
attendFieldCodes.addAll(attendFixedFieldCodes.stream().map(m -> m.get("code")).collect(Collectors.toList()));
// 本地已存在则更新交集
List<String> updateCodes = localFieldCodes.stream().filter(item -> attendFieldCodes.contains(item)).collect(Collectors.toList());
// 本地比attend多则删除差集(local - attend)
List<String> deleteCodes = localFieldCodes.stream().filter(item -> !attendFieldCodes.contains(item)).collect(Collectors.toList());
// attend比本地多则新增差集(attend - local)
List<String> saveCodes = attendFieldCodes.stream().filter(item -> !localFieldCodes.contains(item)).collect(Collectors.toList());
String hourI18n = SalaryI18nUtil.getI18nLabel(100743, "小时");
String dayI18n = SalaryI18nUtil.getI18nLabel(100744, "");
// 1.更新 == 目前除了请假类型其余都是固定故只需更新请假类型部分
// List<AttendQuoteFieldPO> updates = Lists.newArrayList();
// CollectionUtils.emptyIfNull(updateCodes).forEach(e -> {
// Optional<AttendVacationType> 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<AttendQuoteFieldPO> 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<AttendQuoteFieldPO> 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<AttendVacationType> 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;
}

View File

@ -75,36 +75,6 @@ public class AttendQuoteFieldSettingServiceImpl extends Service implements Atten
return fieldBiz.listSome(AttendQuoteFieldPO.builder().build());
}
// /**
// * 获取字段设置
// * @return
// */
// private List<AttendQuoteFieldSettingPO> getAttendQuoteFieldSetting(AttendQuoteSourceTypeEnum sourceType, String tenantKey) {
// LambdaQueryWrapper<AttendQuoteFieldSettingPO> lambdaQueryWrapper = Wrappers.lambdaQuery();
// lambdaQueryWrapper.eq(AttendQuoteFieldSettingPO::getTenantKey, tenantKey)
// .eq(AttendQuoteFieldSettingPO::getDeleteType, 0)
// .eq(AttendQuoteFieldSettingPO::getSourceType, sourceType.getValue());
// return mapper.selectList(lambdaQueryWrapper);
// }
//
// @Override
// public List<AttendQuoteFieldSettingListDTO> list(AttendQuoteFieldSettingQueryParam queryParam, Long employeeId, String tenantKey) {
// // 同步字段
// attendQuoteFieldService.syncAttendFields(employeeId, tenantKey);
// // 获取字段设置
// List<AttendQuoteFieldSettingPO> list = getAttendQuoteFieldSetting(queryParam.getSourceType(), tenantKey);
//
// List<AttendQuoteFieldSettingListDTO> 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<AttendQuoteFieldSettingListDTO> listNoSync(AttendQuoteFieldSettingQueryParam queryParam) {
// 获取字段设置
@ -207,6 +177,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("字段不能为空");
}

View File

@ -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<String, Object> list(Map<String, Object> params) {
@ -50,8 +52,8 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic
dataBiz.deleteByAttendQuoteIds(unAccountingIds);
// 3.删除考核数据对应的考核值
// List<Long> attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList());
// attendQuoteDataValueMapper.deleteByAttendQuoteDataIds(CollectionUtils.isEmpty(attendQuoteDataIds) ? Collections.singletonList(0L) : attendQuoteDataIds, tenantKey);
List<Long> attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList());
dataValueBiz.deleteByAttendQuoteDataIds(attendQuoteDataIds);
//todo 日志
// attendQuotes.forEach(e -> {
@ -69,7 +71,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic
}
// @Override
// public WeaForm getSyncForm(Long employeeId, String tenantKey) {
// public Map<String, Object> getSyncForm(Long employeeId) {
//
// List<WeaFormOption> salarySobOptions = Lists.newArrayList();
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper)
@ -100,7 +102,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic
// }
//
// @Override
// public Map<String, Object> getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId, Long currentEmployeeId, String currentTenantKey) {
// public Map<String, Object> getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId) {
//
// SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salarySobId, salaryYearMonth, currentTenantKey);
//
@ -115,7 +117,7 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic
// }
//
// @Override
// public List<Map<String, Object>> selectSalarySobList(Long currentEmployeeId, String currentTenantKey) {
// public List<Map<String, Object>> selectSalarySobList(Long currentEmployeeId) {
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper)
// .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey())
// .eq(SalarySobPO::getDeleteType, 0)

View File

@ -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;

View File

@ -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;
}
//
// /**
// * 获取多语言信息

View File

@ -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<List<String>> rowList,String sheetName) {
public static XSSFWorkbook genWorkbook(List<List<String>> rowList, String sheetName) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
@ -61,4 +64,64 @@ public class ExcelUtil {
}
return workbook;
}
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.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<Object> 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;
}
}

View File

@ -5,15 +5,20 @@ 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;
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;
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;
@ -25,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;
@ -35,6 +45,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);
}
@ -57,17 +71,19 @@ public class AttendQuoteController {
}
// /**
// * 获取引用考勤表单
// * @return
// */
// @GetMapping("/getSyncForm")
// @ApiOperation("获取引用考勤表单")
// @WeaPermission
// public WeaResult<WeaForm> 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<Long, Map<String, Object>>().run(getService(user)::getSyncForm, (long)user.getUID());
// }
//
// /**
// * 获取薪资周期和考勤周期
// * @param salaryYearMonth 薪资所属月
@ -81,16 +97,20 @@ public class AttendQuoteController {
// return WeaResult.success(service.getSalaryCycleAndAttendCycle(salaryYearMonth, salarySobId, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
//
// /**
// * 同步引用考勤数据
// * @return
// */
// @PostMapping("/syncAttendQuoteData")
// @ApiOperation("同步引用考勤数据")
// @WeaPermission
// public WeaResult<String> 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<AttendQuoteDataSyncParam, String>().run(getDataService(user)::syncAttendQuoteData, syncParam);
}
//
// /**
// * 获取薪资账套下拉列表
@ -103,88 +123,103 @@ public class AttendQuoteController {
// return WeaResult.success(service.selectSalarySobList(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
//
// /**
// * 下载导入模板
// * @return
// */
// @PostMapping("/downloadTemplate")
// @ApiOperation("下载导入模板")
// @WeaPermission
// public WeaResult<Map<String, Object>> 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<ExcelImportParam> getImportParams() {
// return WeaResult.success(salaryBatchService.buildImportParam("importAttendQuoteData",
// "importAttendQuoteData",
// SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 85367, "考勤引用"),
// null,
// null));
// }
//
// /**
// * 查看考勤数据
// * @param queryParam
// * @return
// */
// @PostMapping("/view")
// @ApiOperation("查看")
// @WeaPermission
// public WeaResult<WeaTable<LinkedHashMap>> 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<String> delete(@RequestBody Collection<Long> 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
// */
// @PostMapping("/export")
// @ApiOperation("导出考勤数据")
// @WeaPermission
// public WeaResult<Map<String, Object>> 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));
// }
//
/**
* 下载导入模板
*/
@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();
}
/**
* 查看考勤数据
*
* @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<AttendQuoteDataQueryParam, Map<String, Object>>().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<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, String>().run(getService(user)::delete, ids);
}
/**
* 导出考勤数据
*
* @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();
}
/**
* 考勤字段管理列表

View File

@ -0,0 +1,133 @@
package com.engine.salary.web;
/**
* 薪资项目
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryItemController {
// @Autowired
// private SalaryItemWrapper salaryItemWrapper;
// @Autowired
// private SysSalaryItemWrapper sysSalaryItemWrapper;
//
// /**********************************自定义薪资项目 start*********************************/
//
// @PostMapping("/list")
// @ApiOperation("薪资项目列表")
// @WeaPermission
// public WeaResult<WeaTable<SalaryItemListDTO>> listSalaryItem(@RequestBody SalaryItemSearchParam searchParam) {
// return WeaResult.success(salaryItemWrapper.listPage(searchParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
//
// @PostMapping("/listCanDelete")
// @ApiOperation("可删除的薪资项目列表")
// @WeaPermission
// public WeaResult<WeaTable<SalaryItemListDTO>> listCanDeleteSalaryItem(@RequestBody SalaryItemSearchParam searchParam) {
// return WeaResult.success(salaryItemWrapper.listPage4CanDelete(searchParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
//
// @PostMapping("/listSalaryItemDetail")
// @ApiOperation("获取多个薪资项目的详情")
// @WeaPermission
// public WeaResult<List<SalaryItemListDTO>> listSalaryItemDetail(@RequestBody Collection<Long> ids) {
// if (CollectionUtils.isEmpty(ids)) {
// return WeaResult.success(Collections.emptyList());
// }
// List<SalaryItemListDTO> salaryItemListDTOS = salaryItemWrapper.listByIds(ids, TenantContext.getCurrentTenantKey());
// return WeaResult.success(salaryItemListDTOS);
// }
//
// @GetMapping("/getSearchCondition")
// @ApiOperation("薪资项目列表的高级搜索")
// @WeaPermission
// public WeaResult<WeaSearchCondition> getSearchCondition() {
// return WeaResult.success(salaryItemWrapper.getSearchCondition());
// }
//
// @PostMapping("/getSalaryForm")
// @ApiOperation("薪资项目的详情")
// @WeaPermission
// public WeaResult<WeaForm> getSalaryItemForm(@RequestParam(value = "id", required = false) Long id) {
// return WeaResult.success(salaryItemWrapper.getForm(id, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
//
// @GetMapping("/listSalaryItemTypeOption")
// @ApiOperation("获取薪资项目可选的类型(与属性有联动)")
// @WeaPermission
// public WeaResult<Map<String, List<WeaFormOption>>> listSalaryItemTypeOption() {
// Map<String, List<WeaFormOption>> resultMap = salaryItemWrapper.listSalaryItemTypeOption(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey());
// return WeaResult.success(resultMap);
// }
//
// @PostMapping("/delete")
// @ApiOperation("批量删除薪资项目")
// @WeaPermission
// public WeaResult<Object> deleteSalaryItem(@RequestBody Collection<Long> 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<Object> 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<Object> updateSalaryItem(@RequestBody @Validated SalaryItemSaveParam saveParam) {
// salaryItemWrapper.update(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey());
// return WeaResult.success(null);
// }
//
// /**********************************自定义薪资项目 end*********************************/
//
//
// /**********************************系统薪资项目 start*********************************/
//
// @PostMapping("/sysList")
// @ApiOperation("系统薪资项目列表")
// @WeaPermission
// public WeaResult<WeaTable<SysSalaryItemListDTO>> listSysSalaryItem(@RequestBody SysSalaryItemSearchParam searchParam) {
// return WeaResult.success(sysSalaryItemWrapper.listPage(searchParam, TenantContext.getCurrentTenantKey()));
// }
//
// @GetMapping("/getSysSearchCondition")
// @ApiOperation("系统薪资项目的高级搜索")
// @WeaPermission
// public WeaResult<WeaSearchCondition> getSysSearchCondition() {
// return WeaResult.success(sysSalaryItemWrapper.getSearchCondition());
// }
//
// @PostMapping("/saveSys")
// @ApiOperation("添加系统薪资项目")
// @WeaPermission
// public WeaResult<Object> saveSysSalaryItem(@RequestBody Collection<Long> 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*********************************/
}