聚才林产品功能

聚才林产品功能
Chengliang 7 months ago
parent c243ea65e2
commit c050bdb59e

@ -0,0 +1,24 @@
package com.engine.jclproduct.entity.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/10/31 10:38 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TransferParam {
private Integer changeOldDept;
private Integer changeNewDept;
}

@ -0,0 +1,46 @@
package com.engine.jclproduct.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2024/10/30 2:24 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CaluResourceVo {
private Integer key;
private Integer superKey;
private String departmentName;
private Integer startNumber;
private Integer entryNumber;
private Integer transferNumber;
private Integer leaveNumber;
private Integer onNumber;
private Integer outNumber;
private Integer endNumber;
private List<CaluResourceVo> children;
}

@ -118,8 +118,8 @@ public class LeaveResourceVo {
/** /**
* *
*/ */
@WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") // @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear")
private Integer workyear; // private Integer workyear;
/** /**
* *
*/ */

@ -117,8 +117,8 @@ public class TimeResourceVo {
/** /**
* *
*/ */
@WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") // @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear")
private Integer workyear; // private Integer workyear;
/** /**
* *
*/ */

@ -125,8 +125,8 @@ public class TransferResourceVo {
/** /**
* *
*/ */
@WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") // @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear")
private Integer workyear; // private Integer workyear;
/** /**
* *
*/ */

@ -51,4 +51,15 @@ public interface EmployeeRecordReportService {
*/ */
Map<String, Object> transferResourece(Map<String, Object> params); Map<String, Object> transferResourece(Map<String, Object> params);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/10/25 2:21 PM
* @param: []
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String, Object> caluResourece(Map<String, Object> params);
} }

@ -1,8 +1,11 @@
package com.engine.jclproduct.service.impl; package com.engine.jclproduct.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.cloudstore.eccom.result.WeaResultMsg; import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.jclproduct.component.WeaverWeaTable; import com.engine.jclproduct.component.WeaverWeaTable;
import com.engine.jclproduct.entity.param.TransferParam;
import com.engine.jclproduct.entity.vo.CaluResourceVo;
import com.engine.jclproduct.entity.vo.LeaveResourceVo; import com.engine.jclproduct.entity.vo.LeaveResourceVo;
import com.engine.jclproduct.entity.vo.TimeResourceVo; import com.engine.jclproduct.entity.vo.TimeResourceVo;
import com.engine.jclproduct.entity.vo.TransferResourceVo; import com.engine.jclproduct.entity.vo.TransferResourceVo;
@ -10,10 +13,16 @@ import com.engine.jclproduct.service.EmployeeRecordReportService;
import com.engine.jclproduct.utils.EmploymentUtil; import com.engine.jclproduct.utils.EmploymentUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil; import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* @Author liang.cheng * @Author liang.cheng
@ -37,6 +46,9 @@ public class EmployeeRecordReportServiceImpl extends Service implements Employee
case "2": case "2":
result = transferResourece(params); result = transferResourece(params);
break; break;
case "3":
result = caluResourece(params);
break;
default: default:
break; break;
} }
@ -51,6 +63,7 @@ public class EmployeeRecordReportServiceImpl extends Service implements Employee
WeaverWeaTable<TimeResourceVo> table = new WeaverWeaTable<>(user, TimeResourceVo.class); WeaverWeaTable<TimeResourceVo> table = new WeaverWeaTable<>(user, TimeResourceVo.class);
String sqlWhere = buildtimeResoureceSql(params); String sqlWhere = buildtimeResoureceSql(params);
//sqlWhere += " order by userid asc";
table.setSqlwhere(sqlWhere); table.setSqlwhere(sqlWhere);
WeaResultMsg result = new WeaResultMsg(false); WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult()); result.putAll(table.makeDataResult());
@ -89,6 +102,98 @@ public class EmployeeRecordReportServiceImpl extends Service implements Employee
return resultMap; return resultMap;
} }
@Override
public Map<String, Object> caluResourece(Map<String, Object> params) {
RecordSet rs = new RecordSet();
Map<String, Object> resultMap = new HashMap<>(4);
List<CaluResourceVo> caluResourceVos = new ArrayList<>();
String departmentId = Util.null2String(params.get("departmentId"));
String date = Util.null2String(params.get("date"));
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
String sql = "select id,supdepid,departmentname from hrmdepartment where (canceled is null or canceled != 1) ";
if(!"".equals(departmentId)){
ArrayList<String> lists = new ArrayList<>();
lists.add(departmentId);
departmentComInfo.getAllChildDeptByDepId(lists,departmentId);
String join = CollectionUtil.join(lists, ",");
sql += " and id in ("+join+")";
}
sql += " order by showorder,id asc";
//1.获取部门数据信息
rs.executeQuery(sql);
while (rs.next()) {
caluResourceVos.add(CaluResourceVo.builder()
.key(Util.getIntValue(rs.getString("id")))
.superKey(Util.getIntValue(rs.getString("supdepid"),0))
.departmentName(Util.null2String(rs.getString("departmentname")))
.build());
}
//2.人数统计计算
String firstDayOfMonth = EmploymentUtil.firstDayOfMonth(date);
String lastDayOfMonth = EmploymentUtil.lastDayOfMonth(date);
//期初人数
Map<Integer, Integer> startMap = EmploymentUtil.sumPerson(firstDayOfMonth, "0,1,2,3");
//期末人数
Map<Integer, Integer> endMap = EmploymentUtil.sumPerson(lastDayOfMonth, "0,1,2,3");
//入职人数
Map<Integer, Integer> entryMap = EmploymentUtil.rangePerson(firstDayOfMonth, lastDayOfMonth, "0");
//转正人数
Map<Integer, Integer> transferMap = EmploymentUtil.rangePerson(firstDayOfMonth, lastDayOfMonth, "1");
//离职人数
Map<Integer, Integer> leaveMap = EmploymentUtil.rangePerson(firstDayOfMonth, lastDayOfMonth, "4,5");
//调动信息
List<TransferParam> transferList = EmploymentUtil.transferPerson(firstDayOfMonth, lastDayOfMonth);
caluResourceVos.forEach(e-> {
e.setStartNumber(startMap.getOrDefault(e.getKey(), 0));
e.setEntryNumber(entryMap.getOrDefault(e.getKey(), 0));
e.setTransferNumber(transferMap.getOrDefault(e.getKey(), 0));
e.setLeaveNumber(leaveMap.getOrDefault(e.getKey(), 0));
int oldCount = (int) transferList.stream()
.filter(param -> param.getChangeOldDept() != null && param.getChangeOldDept().equals(e.getKey()))
.count();
int newCount = (int) transferList.stream()
.filter(param -> param.getChangeNewDept() != null && param.getChangeNewDept().equals(e.getKey()))
.count();
e.setOnNumber(newCount);
e.setOutNumber(oldCount);
e.setEndNumber(endMap.getOrDefault(e.getKey(), 0));
});
//3.构建上下级关系
List<CaluResourceVo> topLevelResources = new ArrayList<>();
Map<Integer, CaluResourceVo> resourceMap = caluResourceVos.stream()
.collect(Collectors.toMap(CaluResourceVo::getKey, Function.identity()));
caluResourceVos.forEach(resource -> {
if (resource.getSuperKey() == 0 || String.valueOf(resource.getKey()).equals(departmentId)) {
// 如果 superKey 为 0说明是顶级元素 或者departmentId出现
topLevelResources.add(resource);
} else {
CaluResourceVo parent = resourceMap.get(resource.getSuperKey());
if (parent != null) {
if (parent.getChildren() == null) {
parent.setChildren( new ArrayList<>());
}
parent.getChildren().add(resource);
}
}
});
resultMap.put("dataSource",topLevelResources);
return resultMap;
}
private String buildtransferResoureceSql(Map<String, Object> params) { private String buildtransferResoureceSql(Map<String, Object> params) {
String pointValue = Util.null2String(params.get("pointValue")); String pointValue = Util.null2String(params.get("pointValue"));
String startDate = Util.null2String(params.get("startDate")); String startDate = Util.null2String(params.get("startDate"));

@ -1,5 +1,6 @@
package com.engine.jclproduct.utils; package com.engine.jclproduct.utils;
import com.engine.jclproduct.entity.param.TransferParam;
import com.engine.jclproduct.entity.po.EmploymentRecordPo; import com.engine.jclproduct.entity.po.EmploymentRecordPo;
import com.engine.jclproduct.entity.po.HrmresourcePo; import com.engine.jclproduct.entity.po.HrmresourcePo;
import com.weaver.general.Util; import com.weaver.general.Util;
@ -76,7 +77,7 @@ public class EmploymentUtil {
public static List<HrmresourcePo> getHrmResources(){ public static List<HrmresourcePo> getHrmResources(){
List<HrmresourcePo> hrmresourcePoList = new ArrayList<>(); List<HrmresourcePo> hrmresourcePoList = new ArrayList<>();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
rs.executeQuery("select id,workcode,status,companystartdate,companyworkyear,sex,birthday,jobtitle,departmentid,subcompanyid1,managerid from hrmresource"); rs.executeQuery("select id,workcode,status,companystartdate,companyworkyear,sex,birthday,jobtitle,departmentid,subcompanyid1,managerid from hrmresource order by id asc");
while (rs.next()) { while (rs.next()) {
hrmresourcePoList.add(HrmresourcePo.builder() hrmresourcePoList.add(HrmresourcePo.builder()
.userId(Util.getIntValue(rs.getString("id"))) .userId(Util.getIntValue(rs.getString("id")))
@ -182,6 +183,72 @@ public class EmploymentUtil {
} }
public static String firstDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate firstDayOfMonth = yearMonth.atDay(1);
return firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
public static String lastDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
return lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
public static Map<Integer,Integer> sumPerson(String date,String employeeStatus) {
Map<Integer,Integer> map = new HashMap<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select count(1) as nums,departmentid" +
" from uf_EmploymentRecord where employeeStatus in ("+employeeStatus+") " +
" and startDate <= '"+date+"' and stopDate >= '"+date+"'" +
" group by departmentid");
while (rs.next()) {
int departmentid = Util.getIntValue(rs.getString("departmentid"));
int nums = Util.getIntValue(rs.getString("nums"));
map.put(departmentid,nums);
}
return map;
}
public static Map<Integer,Integer> rangePerson(String startDate,String endDate,String employeeStatus) {
Map<Integer,Integer> map = new HashMap<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select count(1) as nums,departmentid" +
" from uf_EmploymentRecord where employeeStatus in ("+employeeStatus+") and changtype != 2" +
" and startDate >= '"+startDate+"' and startDate <= '"+endDate+"' and stopDate >= '"+endDate+"'" +
" group by departmentid");
while (rs.next()) {
int departmentid = Util.getIntValue(rs.getString("departmentid"));
int nums = Util.getIntValue(rs.getString("nums"));
map.put(departmentid,nums);
}
return map;
}
public static List<TransferParam> transferPerson(String startDate,String endDate) {
List<TransferParam> paramList = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select changeOldDept,changeNewDept " +
" from uf_EmploymentRecord where changtype = 2 " +
" and startDate >= '"+startDate+"' and startDate <= '"+endDate+"' and stopDate >= '"+endDate+"'");
while (rs.next()) {
int changeOldDept = Util.getIntValue(rs.getString("changeOldDept"));
int changeNewDept = Util.getIntValue(rs.getString("changeNewDept"));
paramList.add(TransferParam.builder().changeNewDept(changeNewDept).changeOldDept(changeOldDept).build());
}
return paramList;
}
} }

@ -19,27 +19,22 @@ import java.util.Map;
public class MainTest { public class MainTest {
public static void main(String[] args) { public static void main(String[] args) {
// 获取当前日期 String yearMonthStr = "2023-02";
LocalDate now = LocalDate.now();
// 获取上一年的 Year 对象 // 定义日期格式
Year previousYear = Year.from(now).minusYears(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
// 获取上一年的第一天 // 解析字符串为 YearMonth 对象
LocalDate firstDayOfPreviousYear = previousYear.atDay(1); YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
// 获取上一年的最后一天 // 获取该月的第一天
LocalDate lastDayOfPreviousYear = previousYear.atMonth(12).atEndOfMonth(); LocalDate firstDayOfMonth = yearMonth.atDay(1);
// 创建日期格式化器 // 获取该月的最后一天
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
// 格式化日期为字符串 // 格式化输出
String firstDayOfPreviousYearStr = firstDayOfPreviousYear.format(formatter); System.out.println("First day of month: " + firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
String lastDayOfPreviousYearStr = lastDayOfPreviousYear.format(formatter); System.out.println("Last day of month: " + lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
// 打印结果
System.out.println("上一年的第一天: " + firstDayOfPreviousYearStr);
System.out.println("上一年的最后一天: " + lastDayOfPreviousYearStr);
} }
} }

Loading…
Cancel
Save