diff --git a/src/com/engine/jclproduct/entity/bo/EmploymentRecordBo.java b/src/com/engine/jclproduct/entity/bo/EmploymentRecordBo.java index 2aeedf8..a2c7bbb 100644 --- a/src/com/engine/jclproduct/entity/bo/EmploymentRecordBo.java +++ b/src/com/engine/jclproduct/entity/bo/EmploymentRecordBo.java @@ -4,8 +4,6 @@ import cn.hutool.core.collection.CollectionUtil; import com.engine.jclproduct.entity.po.EmploymentRecordPo; import com.engine.jclproduct.entity.po.HrmresourcePo; import com.engine.jclproduct.utils.EmploymentUtil; -import com.weaver.general.BaseBean; -import com.weaver.general.TimeUtil; import weaver.common.DateUtil; import java.util.ArrayList; @@ -27,6 +25,7 @@ public class EmploymentRecordBo { if (CollectionUtil.isEmpty(hrmresourcePos)) { return employmentRecordPos; } + String currentDate = DateUtil.getCurrentDate(); //失效日期默认最大值 return hrmresourcePos.stream().map(e-> { Map map = EmploymentUtil.dateSplitExample(e.getCompanyStartDate()); @@ -35,7 +34,7 @@ public class EmploymentRecordBo { .workcode(e.getWorkcode()) .employeeStatus(e.getStatus()) .changType(EmploymentUtil.getChangeType(e.getStatus())) - .startDate(DateUtil.getCurrentDate()) + .startDate("".equals(e.getCompanyStartDate())?currentDate:e.getCompanyStartDate()) .stopDate("9999-12-31") //失效日期默认最大值 .departmentId(e.getDepartmentId()) .subCompanyId(e.getSubcompanyId()) diff --git a/src/com/engine/jclproduct/entity/vo/LeaveResourceVo.java b/src/com/engine/jclproduct/entity/vo/LeaveResourceVo.java new file mode 100644 index 0000000..0d006c7 --- /dev/null +++ b/src/com/engine/jclproduct/entity/vo/LeaveResourceVo.java @@ -0,0 +1,134 @@ +package com.engine.jclproduct.entity.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.jclproduct.annotation.WeaverTable; +import com.engine.jclproduct.annotation.WeaverTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/10/25 2:22 PM + * @Description: + * @Version 1.0 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@WeaverTable(pageId = "3824ecae-fa94-4020-be40-b78eb2831f32", + fields = "t.id," + + "t.startDate," + + "t.stopDate," + + "t.userId," + + "t.workcode," + + "t.employeeStatus," + + "t.subCompanyId," + + "t.departmentId," + + "t.position," + + "t.superior," + + "t.companyStartDate," + + "t.expectedLastWorkDate," + + "t.lastWorkDate," + + "t.probationActualStopDate," + + "t.regularizationDate," + + "t.workyear," + + "t.sex," + + "t.birthday", + fromSql = "FROM uf_EmploymentRecord t ", + orderby = "userid", + sortway = "asc", + primarykey = "id", + tableType = WeaTableType.NONE +) +public class LeaveResourceVo { + + + /** + * 主键 + */ + @WeaverTableColumn(column = "id",text = "序号", display = false) + private Integer id; + + @WeaverTableColumn(column = "startDate",text = "生效日期", display = false) + private String startDate; + + @WeaverTableColumn(column = "stopDate",text = "失效日期", display = false) + private String stopDate; + + /** + * 姓名 + */ + @WeaverTableColumn( text = "姓名", width = "10%", column = "userId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") + private String userId; + /** + * 工号 + */ + @WeaverTableColumn( text = "工号", width = "10%", column = "workcode") + private String workcode; + /** + * 状态 + */ + @WeaverTableColumn( text = "状态", width = "10%", column = "employeeStatus",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.statusName") + private String employeeStatus; + + /** + * 分部 + */ + @WeaverTableColumn( text = "分部", width = "10%", column = "subCompanyId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.subCompanyName") + private String subCompanyId; + /** + * 部门 + */ + @WeaverTableColumn( text = "部门", width = "10%", column = "departmentId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.departmentName") + private String departmentId; + /** + * 岗位 + */ + @WeaverTableColumn( text = "岗位", width = "10%", column = "position",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.jobTitleName") + private String position; + /** + * 直接上级 + */ + @WeaverTableColumn( text = "直接上级", width = "10%", column = "superior",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") + private Integer superior; + /** + * 入职日期 + */ + @WeaverTableColumn( text = "入职日期", width = "10%", column = "companyStartDate") + private Integer companyStartDate; + /** + * 退休日期 + */ + @WeaverTableColumn( text = "退休日期", width = "10%", column = "expectedLastWorkDate") + private Integer expectedLastWorkDate; + /** + * 离职日期 + */ + @WeaverTableColumn( text = "离职日期", width = "10%", column = "lastWorkDate") + private Integer lastWorkDate; + /** + * 转正日期 + */ + @WeaverTableColumn( text = "转正日期", width = "10%", column = "regularizationDate") + private Integer regularizationDate; + /** + * 司龄 + */ + @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") + private Integer workyear; + /** + * 性别 + */ + @WeaverTableColumn( text = "性别", width = "10%", column = "sex",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.sexName") + private String sex; + /** + * 生日 + */ + @WeaverTableColumn( text = "生日", width = "10%", column = "birthday") + private String birthday; + +} diff --git a/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java b/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java index a4a2ad3..b993097 100644 --- a/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java +++ b/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java @@ -21,6 +21,8 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @WeaverTable(pageId = "6f201832-a940-4225-a4c9-3f4b96ff5b89", fields = "t.id," + + "t.startDate," + + "t.stopDate," + "t.userId," + "t.workcode," + "t.employeeStatus," + @@ -29,14 +31,18 @@ import lombok.NoArgsConstructor; "t.position," + "t.superior," + "t.companyStartDate," + + "t.expectedLastWorkDate," + + "t.lastWorkDate," + + "t.probationActualStopDate," + + "t.regularizationDate," + "t.workyear," + "t.sex," + "t.birthday", - fromSql = "FROM uf_EmploymentRecord t", + fromSql = "FROM uf_EmploymentRecord t ", orderby = "userid", sortway = "asc", primarykey = "id", - tableType = WeaTableType.CHECKBOX + tableType = WeaTableType.NONE ) public class TimeResourceVo { @@ -46,47 +52,68 @@ public class TimeResourceVo { @WeaverTableColumn(column = "id",text = "序号", display = false) private Integer id; + @WeaverTableColumn(column = "startDate",text = "生效日期", display = false) + private String startDate; + + @WeaverTableColumn(column = "stopDate",text = "失效日期", display = false) + private String stopDate; + /** * 姓名 */ - @WeaverTableColumn( text = "姓名", width = "10%", column = "userId", transmethod = "") + @WeaverTableColumn( text = "姓名", width = "10%", column = "userId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") private String userId; /** * 工号 */ - @WeaverTableColumn( text = "工号", width = "10%", column = "workcode", transmethod = "") + @WeaverTableColumn( text = "工号", width = "10%", column = "workcode") private String workcode; /** * 状态 */ - @WeaverTableColumn( text = "状态", width = "10%", column = "employeeStatus") + @WeaverTableColumn( text = "状态", width = "10%", column = "employeeStatus",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.statusName") private String employeeStatus; /** * 分部 */ - @WeaverTableColumn( text = "分部", width = "10%", column = "subCompanyId", transmethod = "") + @WeaverTableColumn( text = "分部", width = "10%", column = "subCompanyId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.subCompanyName") private String subCompanyId; /** * 部门 */ - @WeaverTableColumn( text = "部门", width = "10%", column = "departmentId", transmethod = "") + @WeaverTableColumn( text = "部门", width = "10%", column = "departmentId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.departmentName") private String departmentId; /** * 岗位 */ - @WeaverTableColumn( text = "岗位", width = "10%", column = "position", transmethod = "") + @WeaverTableColumn( text = "岗位", width = "10%", column = "position",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.jobTitleName") private String position; /** * 直接上级 */ - @WeaverTableColumn( text = "直接上级", width = "10%", column = "superior") + @WeaverTableColumn( text = "直接上级", width = "10%", column = "superior",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") private Integer superior; /** * 入职日期 */ @WeaverTableColumn( text = "入职日期", width = "10%", column = "companyStartDate") private Integer companyStartDate; + /** + * 退休日期 + */ + @WeaverTableColumn( text = "退休日期", width = "10%", column = "expectedLastWorkDate") + private Integer expectedLastWorkDate; + /** + * 离职日期 + */ + @WeaverTableColumn( text = "离职日期", width = "10%", column = "lastWorkDate") + private Integer lastWorkDate; + /** + * 转正日期 + */ + @WeaverTableColumn( text = "转正日期", width = "10%", column = "regularizationDate") + private Integer regularizationDate; /** * 司龄 */ @@ -95,7 +122,7 @@ public class TimeResourceVo { /** * 性别 */ - @WeaverTableColumn( text = "性别", width = "20%", column = "sex", transmethod = "") + @WeaverTableColumn( text = "性别", width = "10%", column = "sex",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.sexName") private String sex; /** * 生日 diff --git a/src/com/engine/jclproduct/entity/vo/TransferResourceVo.java b/src/com/engine/jclproduct/entity/vo/TransferResourceVo.java new file mode 100644 index 0000000..9141481 --- /dev/null +++ b/src/com/engine/jclproduct/entity/vo/TransferResourceVo.java @@ -0,0 +1,138 @@ +package com.engine.jclproduct.entity.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.jclproduct.annotation.WeaverTable; +import com.engine.jclproduct.annotation.WeaverTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/10/25 2:22 PM + * @Description: + * @Version 1.0 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@WeaverTable(pageId = "ba7d8752-a037-4b1a-b1dc-7361f78f0683", + fields = "t.id," + + "t.startDate," + + "t.stopDate," + + "t.userId," + + "t.workcode," + + "t.employeeStatus," + + "t.subCompanyId," + + "t.changeNewDept," + + "t.changeNewJob," + + "t.changeNewSuperior," + + "t.changeOldDept," + + "t.changeOldJob," + + "t.changeOldSuperior," + + "t.companyStartDate," + + "t.lastWorkDate," + + "t.workyear," + + "t.sex," + + "t.birthday", + fromSql = "FROM uf_EmploymentRecord t ", + orderby = "userid", + sortway = "asc", + primarykey = "id", + tableType = WeaTableType.NONE +) +public class TransferResourceVo { + + /** + * 主键 + */ + @WeaverTableColumn(column = "id",text = "序号", display = false) + private Integer id; + + + + @WeaverTableColumn(column = "startDate",width = "10%",text = "调动日期") + private String startDate; + + @WeaverTableColumn(column = "stopDate",width = "10%",text = "失效日期", display = false) + private String stopDate; + /** + * 姓名 + */ + @WeaverTableColumn( text = "姓名", width = "10%", column = "userId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") + private String userId; + /** + * 工号 + */ + @WeaverTableColumn( text = "工号", width = "10%", column = "workcode") + private String workcode; + /** + * 状态 + */ + @WeaverTableColumn( text = "状态", width = "10%", column = "employeeStatus",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.statusName") + private String employeeStatus; + + /** + * 分部 + */ + @WeaverTableColumn( text = "分部", width = "10%", column = "subCompanyId",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.subCompanyName") + private String subCompanyId; + /** + * 新部门 + */ + @WeaverTableColumn( text = "新部门", width = "10%", column = "changeNewDept",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.departmentName") + private String changeNewDept; + /** + * 新岗位 + */ + @WeaverTableColumn( text = "新岗位", width = "10%", column = "changeNewJob",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.jobTitleName") + private String changeNewJob; + /** + * 新直接上级 + */ + @WeaverTableColumn( text = "新直接上级", width = "10%", column = "changeNewSuperior",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") + private Integer changeNewSuperior; + /** + * 原部门 + */ + @WeaverTableColumn( text = "原部门", width = "10%", column = "changeOldDept",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.departmentName") + private String changeOldDept; + /** + * 原岗位 + */ + @WeaverTableColumn( text = "原岗位", width = "10%", column = "changeOldJob",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.jobTitleName") + private String changeOldJob; + /** + * 原直接上级 + */ + @WeaverTableColumn( text = "原直接上级", width = "10%", column = "changeOldSuperior",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.resourceName") + private Integer changeOldSuperior; + /** + * 入职日期 + */ + @WeaverTableColumn( text = "入职日期", width = "10%", column = "companyStartDate") + private Integer companyStartDate; + + /** + * 离职日期 + */ + @WeaverTableColumn( text = "离职日期", width = "10%", column = "lastWorkDate") + private Integer lastWorkDate; + + /** + * 司龄 + */ + @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") + private Integer workyear; + /** + * 性别 + */ + @WeaverTableColumn( text = "性别", width = "10%", column = "sex",transmethod = "com.engine.jclproduct.transmethod.EmReportTransMethod.sexName") + private String sex; + + + +} diff --git a/src/com/engine/jclproduct/service/EmployeeRecordReportService.java b/src/com/engine/jclproduct/service/EmployeeRecordReportService.java index 8849b35..aee5c0e 100644 --- a/src/com/engine/jclproduct/service/EmployeeRecordReportService.java +++ b/src/com/engine/jclproduct/service/EmployeeRecordReportService.java @@ -28,6 +28,27 @@ public interface EmployeeRecordReportService { * @param: [] * @return: java.util.Map */ - Map timeResourece(); + Map timeResourece(Map params); + + + /** + * @Description: 离职员工花名册 + * @Author: liang.cheng + * @Date: 2024/10/25 2:21 PM + * @param: [] + * @return: java.util.Map + */ + Map leaveResourece(Map params); + + + + /** + * @Description: 人员调动记录 + * @Author: liang.cheng + * @Date: 2024/10/25 2:21 PM + * @param: [] + * @return: java.util.Map + */ + Map transferResourece(Map params); } diff --git a/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java b/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java index 897cf06..b4a88af 100644 --- a/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java +++ b/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java @@ -3,8 +3,14 @@ package com.engine.jclproduct.service.impl; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.jclproduct.component.WeaverWeaTable; +import com.engine.jclproduct.entity.vo.LeaveResourceVo; import com.engine.jclproduct.entity.vo.TimeResourceVo; +import com.engine.jclproduct.entity.vo.TransferResourceVo; import com.engine.jclproduct.service.EmployeeRecordReportService; +import com.engine.jclproduct.utils.EmploymentUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.general.Util; import java.util.HashMap; import java.util.Map; @@ -19,20 +25,238 @@ public class EmployeeRecordReportServiceImpl extends Service implements Employee @Override public Map commonReport(Map params) { - return timeResourece(); + Map result = new HashMap<>(); + String selectedKey = Util.null2String(params.get("selectedKey")); + switch (selectedKey) { + case "0": + result = timeResourece(params); + break; + case "1": + result = leaveResourece(params); + break; + case "2": + result = transferResourece(params); + break; + default: + break; + } + + + return result; } @Override - public Map timeResourece() { + public Map timeResourece(Map params) { Map resultMap = new HashMap<>(8); WeaverWeaTable table = new WeaverWeaTable<>(user, TimeResourceVo.class); -// String sqlWhere = buildSqlWhere(params); -// table.setSqlwhere(sqlWhere); + String sqlWhere = buildtimeResoureceSql(params); + table.setSqlwhere(sqlWhere); + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + resultMap.putAll(result.getResultMap()); + return resultMap; + } + + @Override + public Map leaveResourece(Map params) { + Map resultMap = new HashMap<>(8); + + WeaverWeaTable table = new WeaverWeaTable<>(user, LeaveResourceVo.class); + String sqlWhere = buildLeaveResoureceSql(params); + sqlWhere += " and employeeStatus in (5)"; + table.setSqlwhere(sqlWhere); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); resultMap.putAll(result.getResultMap()); return resultMap; } + + @Override + public Map transferResourece(Map params) { + Map resultMap = new HashMap<>(8); + + WeaverWeaTable table = new WeaverWeaTable<>(user, TransferResourceVo.class); + String sqlWhere = buildtransferResoureceSql(params); + sqlWhere += " and changType in (2)"; + table.setSqlwhere(sqlWhere); + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + resultMap.putAll(result.getResultMap()); + return resultMap; + } + + private String buildtransferResoureceSql(Map params) { + String pointValue = Util.null2String(params.get("pointValue")); + String startDate = Util.null2String(params.get("startDate")); + String endDate = Util.null2String(params.get("endDate")); + String sql = getLeaveSql(pointValue,startDate,endDate); + String sqlWhere = " where 1=1 "+sql; + String resourceId = Util.null2String(params.get("resourceId")); + if (StringUtils.isNotBlank(resourceId)) { + sqlWhere += " and userId ="+resourceId; + } + + String departmentId = Util.null2String(params.get("departmentId")); + if (StringUtils.isNotBlank(departmentId)) { + sqlWhere += " and departmentId ="+departmentId; + } + + String statusValue = Util.null2String(params.get("statusValue")); + if (StringUtils.isNotBlank(statusValue)) { + sqlWhere += " and employeeStatus in ("+statusValue+")"; + } + + return sqlWhere; + } + + + private String buildLeaveResoureceSql(Map params) { + String pointValue = Util.null2String(params.get("pointValue")); + String startDate = Util.null2String(params.get("startDate")); + String endDate = Util.null2String(params.get("endDate")); + String sql = getLeaveSql(pointValue,startDate,endDate); + String sqlWhere = " where 1=1 "+sql; + String departmentId = Util.null2String(params.get("departmentId")); + if (StringUtils.isNotBlank(departmentId)) { + sqlWhere += " and departmentId ="+departmentId; + } + + return sqlWhere; + } + + private String getLeaveSql(String pointValue, String startDate, String endDate) { + String sql = ""; + switch (pointValue){ + case "0": + break; + case "1": + String today = DateUtil.getCurrentDate(); + sql += " and startDate = '"+today+"' and stopDate >= '"+today+"'"; + break; + case "2": + String firstDayOfWeek = DateUtil.getFirstDayOfWeek(); + String lastDayOfWeek = DateUtil.getLastDayOfWeek(); + sql += " and startDate >= '"+firstDayOfWeek+"' and startDate <= '"+lastDayOfWeek+"' and stopDate >= '"+lastDayOfWeek+"'"; + break; + case "3": + String firstDayOfMonth = DateUtil.getFirstDayOfMonthToString(); + String lastDayOfMonth = DateUtil.getLastDayOfMonthToString(); + sql += " and startDate >= '"+firstDayOfMonth+"' and startDate <= '"+lastDayOfMonth+"' and stopDate >= '"+lastDayOfMonth+"'"; + break; + case "5": + String firstDayOfYear = DateUtil.getFirstDayOfYear(); + String lastDayOfYear = DateUtil.getLastDayOfYear(); + sql += " and startDate >= '"+firstDayOfYear+"' and startDate <= '"+lastDayOfYear+"' and stopDate >= '"+lastDayOfYear+"'"; + break; + case "7": + String firstDayOfPreviousMonth = EmploymentUtil.firstDayOfPreviousMonth(); + String lastDayOfPreviousMonth = EmploymentUtil.lastDayOfPreviousMonth(); + sql += " and startDate >= '"+firstDayOfPreviousMonth+"' and startDate <= '"+lastDayOfPreviousMonth+"' and stopDate >= '"+lastDayOfPreviousMonth+"'"; + break; + case "8": + String firstDayOfPreviousYear = EmploymentUtil.firstDayOfPreviousYear(); + String lastDayOfPreviousYear = EmploymentUtil.lastDayOfPreviousYear(); + sql += " and startDate >= '"+firstDayOfPreviousYear+"' and startDate <= '"+lastDayOfPreviousYear+"' and stopDate >= '"+lastDayOfPreviousYear+"'"; + break; + case "6": + sql += " and startDate >= '"+startDate+"' and startDate <= '"+endDate+"' and stopDate >= '"+endDate+"'"; + break; + default: + break; + } + + return sql; + } + + private String buildtimeResoureceSql(Map params) { + String pointValue = Util.null2String(params.get("pointValue")); + String startDate = Util.null2String(params.get("startDate")); + + String sql = getPointSql(pointValue,startDate); + String sqlWhere = " where 1=1 and "+sql; + + String statusValue = Util.null2String(params.get("statusValue")); + if (StringUtils.isNotBlank(statusValue)) { + sqlWhere += " and employeeStatus in ("+statusValue+")"; + } + + String resourceId = Util.null2String(params.get("resourceId")); + if (StringUtils.isNotBlank(resourceId)) { + sqlWhere += " and userId ="+resourceId; + } + + String departmentId = Util.null2String(params.get("departmentId")); + if (StringUtils.isNotBlank(departmentId)) { + sqlWhere += " and departmentId ="+departmentId; + } + + return sqlWhere; + } + + private String getPointSql(String pointValue, String startDate) { + String sql = ""; + switch (pointValue){ + case "0": + String currentDate = DateUtil.getCurrentDate(); + sql += " startDate <= '"+currentDate+"' and stopDate >= '"+currentDate+"'"; + break; + case "1": + String yesterday = DateUtil.getYesterday(); + sql += " startDate <= '"+yesterday+"' and stopDate >= '"+yesterday+"'"; + break; + case "2": + String firstDayOfWeek = DateUtil.getFirstDayOfWeek(); + sql += " startDate <= '"+firstDayOfWeek+"' and stopDate >= '"+firstDayOfWeek+"'"; + break; + case "3": + String lastDayOfWeek = DateUtil.getLastDayOfWeek(); + sql += " startDate <= '"+lastDayOfWeek+"' and stopDate >= '"+lastDayOfWeek+"'"; + break; + case "4": + String firstDayOfMonth = DateUtil.getFirstDayOfMonthToString(); + sql += " startDate <= '"+firstDayOfMonth+"' and stopDate >= '"+firstDayOfMonth+"'"; + break; + case "5": + String lastDayOfMonth = DateUtil.getLastDayOfMonthToString(); + sql += " startDate <= '"+lastDayOfMonth+"' and stopDate >= '"+lastDayOfMonth+"'"; + break; + case "7": + String firstDayOfYear = DateUtil.getFirstDayOfYear(); + sql += " startDate <= '"+firstDayOfYear+"' and stopDate >= '"+firstDayOfYear+"'"; + break; + case "8": + String lastDayOfYear = DateUtil.getLastDayOfYear(); + sql += " startDate <= '"+lastDayOfYear+"' and stopDate >= '"+lastDayOfYear+"'"; + break; + case "9": + String firstDayOfPreviousMonth = EmploymentUtil.firstDayOfPreviousMonth(); + sql += " startDate <= '"+firstDayOfPreviousMonth+"' and stopDate >= '"+firstDayOfPreviousMonth+"'"; + break; + case "10": + String lastDayOfPreviousMonth = EmploymentUtil.lastDayOfPreviousMonth(); + sql += " startDate <= '"+lastDayOfPreviousMonth+"' and stopDate >= '"+lastDayOfPreviousMonth+"'"; + break; + case "11": + String firstDayOfPreviousYear = EmploymentUtil.firstDayOfPreviousYear(); + sql += " startDate <= '"+firstDayOfPreviousYear+"' and stopDate >= '"+firstDayOfPreviousYear+"'"; + break; + case "12": + String lastDayOfPreviousYear = EmploymentUtil.lastDayOfPreviousYear(); + sql += " startDate <= '"+lastDayOfPreviousYear+"' and stopDate >= '"+lastDayOfPreviousYear+"'"; + break; + case "6": + sql += " startDate <= '"+startDate+"' and stopDate >= '"+startDate+"'"; + break; + default: + break; + } + return sql; + + } + + } diff --git a/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java b/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java index a1280a1..f9ce998 100644 --- a/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java +++ b/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java @@ -1,7 +1,10 @@ package com.engine.jclproduct.transmethod; +import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; /** * @Author liang.cheng @@ -15,4 +18,67 @@ public class EmReportTransMethod { SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); return subCompanyComInfo.getSubCompanyname(id); } + + public static String departmentName(String id) { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + try { + return departmentComInfo.getDepartmentName(id); + } catch (Exception e) { + return ""; + } + } + + public static String jobTitleName(String id) { + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + return jobTitlesComInfo.getJobTitlesname(id); + } + + public static String resourceName(String id) { + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + return resourceComInfo.getLastname(id); + } catch (Exception e) { + return ""; + } + } + + public static String sexName(String id) { + return "1".equals(id) ? "女":"男"; + } + + public static String statusName(String id) { + String name = ""; + switch (id){ + case "0": + name = "试用"; + break; + case "1": + name = "正式"; + break; + case "2": + name = "临时"; + break; + case "3": + name = "试用延期"; + break; + case "4": + name = "解聘"; + break; + case "5": + name = "离职"; + break; + case "6": + name = "退休"; + break; + case "7": + name = "无效"; + break; + default: + break; + } + return name; + } + + + } diff --git a/src/com/engine/jclproduct/utils/EmploymentUtil.java b/src/com/engine/jclproduct/utils/EmploymentUtil.java index 789a85c..ce94e34 100644 --- a/src/com/engine/jclproduct/utils/EmploymentUtil.java +++ b/src/com/engine/jclproduct/utils/EmploymentUtil.java @@ -7,6 +7,8 @@ import weaver.common.DateUtil; import weaver.conn.RecordSet; import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.HashMap; @@ -144,4 +146,42 @@ public class EmploymentUtil { } + public static String firstDayOfPreviousMonth() { + LocalDate now = LocalDate.now(); + YearMonth previousMonth = YearMonth.from(now).minusMonths(1); + LocalDate firstDayOfPreviousMonth = previousMonth.atDay(1); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return firstDayOfPreviousMonth.format(formatter); + } + + + public static String lastDayOfPreviousMonth() { + LocalDate now = LocalDate.now(); + YearMonth previousMonth = YearMonth.from(now).minusMonths(1); + LocalDate lastDayOfPreviousMonth = previousMonth.atEndOfMonth(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return lastDayOfPreviousMonth.format(formatter); + } + + + public static String firstDayOfPreviousYear() { + LocalDate now = LocalDate.now(); + Year previousYear = Year.from(now).minusYears(1); + LocalDate firstDayOfPreviousYear = previousYear.atDay(1); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return firstDayOfPreviousYear.format(formatter); + } + + public static String lastDayOfPreviousYear() { + LocalDate now = LocalDate.now(); + Year previousYear = Year.from(now).minusYears(1); + LocalDate lastDayOfPreviousYear = previousYear.atMonth(12).atEndOfMonth(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return lastDayOfPreviousYear.format(formatter); + + } + + + + } diff --git a/src/test/MainTest.java b/src/test/MainTest.java index 801ca8e..e1c3dc3 100644 --- a/src/test/MainTest.java +++ b/src/test/MainTest.java @@ -4,6 +4,10 @@ import com.engine.jclproduct.utils.EmploymentUtil; import com.weaver.general.TimeUtil; import weaver.common.DateUtil; +import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; import java.util.Map; /** @@ -15,7 +19,27 @@ import java.util.Map; public class MainTest { public static void main(String[] args) { - String modeDataCreateDate = DateUtil.getCurrentDate(); - String modeDataCreateTime = TimeUtil.getOnlyCurrentTimeString(); + // 获取当前日期 + LocalDate now = LocalDate.now(); + + // 获取上一年的 Year 对象 + Year previousYear = Year.from(now).minusYears(1); + + // 获取上一年的第一天 + LocalDate firstDayOfPreviousYear = previousYear.atDay(1); + + // 获取上一年的最后一天 + LocalDate lastDayOfPreviousYear = previousYear.atMonth(12).atEndOfMonth(); + + // 创建日期格式化器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + // 格式化日期为字符串 + String firstDayOfPreviousYearStr = firstDayOfPreviousYear.format(formatter); + String lastDayOfPreviousYearStr = lastDayOfPreviousYear.format(formatter); + + // 打印结果 + System.out.println("上一年的第一天: " + firstDayOfPreviousYearStr); + System.out.println("上一年的最后一天: " + lastDayOfPreviousYearStr); } } diff --git a/src/weaver/interfaces/jclproduct/EmploymentRecordCrob.java b/src/weaver/interfaces/jclproduct/EmploymentRecordCrob.java index 71d3b30..82e2fe9 100644 --- a/src/weaver/interfaces/jclproduct/EmploymentRecordCrob.java +++ b/src/weaver/interfaces/jclproduct/EmploymentRecordCrob.java @@ -98,7 +98,7 @@ public class EmploymentRecordCrob extends BaseCronJob { if (CollectionUtil.isNotEmpty(list)) { String date = DateUtil.getCurrentDate(); EmploymentRecordPo latest = list.stream() - .max(Comparator.comparing(record -> LocalDate.parse(record.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")))) + .max(Comparator.comparing(EmploymentRecordPo::getId)) .orElse(null); assert latest != null; if (EmploymentUtil.compareDate(latest.getStartDate())) {