中航富士达绩效需求
This commit is contained in:
parent
ec8421a610
commit
ce9a9954a4
|
|
@ -8,6 +8,6 @@ import javax.ws.rs.Path;
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
@Path("/for/cube")
|
@Path("/forstar/second/cube")
|
||||||
public class ExamineRankingAction extends com.engine.forstarsecond.web.ExamineRankingAction {
|
public class ExamineRankingAction extends com.engine.forstarsecond.web.ExamineRankingAction {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.engine.forstarsecond.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2025/4/29 10:05
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ExamineRanking {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private double df;
|
||||||
|
|
||||||
|
private Integer ssks;
|
||||||
|
|
||||||
|
private Integer bmmc;
|
||||||
|
|
||||||
|
private String bmpm;
|
||||||
|
|
||||||
|
private String kspm;
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package com.engine.forstarsecond.service;
|
package com.engine.forstarsecond.service;
|
||||||
|
|
||||||
|
import com.engine.forstarsecond.entity.ExamineRanking;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -10,5 +13,33 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface ExamineRankingService {
|
public interface ExamineRankingService {
|
||||||
|
|
||||||
Map<String, Object> examineRanking(Map<String, Object> params);
|
/**
|
||||||
|
* @Description: 计算排名
|
||||||
|
* @Author: liang.cheng
|
||||||
|
* @Date: 2025/4/29 09:54
|
||||||
|
* @param: [params]
|
||||||
|
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||||
|
*/
|
||||||
|
int examineRanking(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 员工月/季绩效评价
|
||||||
|
* @Author: liang.cheng
|
||||||
|
* @Date: 2025/4/29 09:58
|
||||||
|
* @param: [khqj]
|
||||||
|
* @return: List<ExamineRanking>
|
||||||
|
*/
|
||||||
|
List<ExamineRanking> calculateWorkers(String khqj);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 年度综合评价
|
||||||
|
* @Author: liang.cheng
|
||||||
|
* @Date: 2025/4/29 09:58
|
||||||
|
* @param: [khqj]
|
||||||
|
* @return: List<ExamineRanking>
|
||||||
|
*/
|
||||||
|
List<ExamineRanking> calculateWorkersByYear(String khqj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
package com.engine.forstarsecond.service.impl;
|
package com.engine.forstarsecond.service.impl;
|
||||||
|
|
||||||
import com.engine.core.impl.Service;
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.forstarsecond.entity.ExamineRanking;
|
||||||
import com.engine.forstarsecond.service.ExamineRankingService;
|
import com.engine.forstarsecond.service.ExamineRankingService;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author liang.cheng
|
* @Author liang.cheng
|
||||||
|
|
@ -14,9 +22,105 @@ import java.util.Map;
|
||||||
public class ExamineRankingServiceImpl extends Service implements ExamineRankingService {
|
public class ExamineRankingServiceImpl extends Service implements ExamineRankingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> examineRanking(Map<String, Object> params) {
|
public int examineRanking(Map<String, Object> params) {
|
||||||
|
|
||||||
|
String type = Util.null2String(params.get("type"));
|
||||||
|
String khqj = Util.null2String(params.get("khqj"));
|
||||||
|
String khnd = Util.null2String(params.get("khnd"));
|
||||||
|
|
||||||
return null;
|
List<ExamineRanking> examineRankings;
|
||||||
|
|
||||||
|
if ("1".equals(type)) {
|
||||||
|
examineRankings = calculateWorkers(khqj);
|
||||||
|
}else {
|
||||||
|
examineRankings = calculateWorkersByYear(khnd);
|
||||||
|
}
|
||||||
|
return examineRankings.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExamineRanking> calculateWorkers(String khqj) {
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
List<ExamineRanking> examineRankings = new ArrayList<>();
|
||||||
|
rs.executeQuery("select id,ydzhdf,ssks,bmmc from uf_hr_ydjxkhpj_data where khqj = ?",khqj);
|
||||||
|
while (rs.next()) {
|
||||||
|
examineRankings.add(ExamineRanking.builder()
|
||||||
|
.id(Util.getIntValue(rs.getString("id")))
|
||||||
|
.df(Util.getDoubleValue(rs.getString("ydzhdf")))
|
||||||
|
.ssks(Util.getIntValue(rs.getString("ssks")))
|
||||||
|
.bmmc(Util.getIntValue(rs.getString("bmmc")))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
// 分别处理 ssks → kspm 和 bmmc → bmpm 的排名
|
||||||
|
calculateRank(examineRankings, ExamineRanking::getSsks, ExamineRanking::setKspm);
|
||||||
|
calculateRank(examineRankings, ExamineRanking::getBmmc, ExamineRanking::setBmpm);
|
||||||
|
|
||||||
|
examineRankings.forEach(examine -> rs.executeUpdate("update uf_hr_ydjxkhpj_data set bmpm = ?,kspm = ? where id = ?",examine.getBmpm(),examine.getKspm(),examine.getId()));
|
||||||
|
|
||||||
|
return examineRankings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExamineRanking> calculateWorkersByYear(String year) {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
List<ExamineRanking> examineRankings = new ArrayList<>();
|
||||||
|
rs.executeQuery("select id,ndzhdf,ssks,bmmc from uf_hr_jxkhndpjb where khnd = ?",year);
|
||||||
|
while (rs.next()) {
|
||||||
|
examineRankings.add(ExamineRanking.builder()
|
||||||
|
.id(Util.getIntValue(rs.getString("id")))
|
||||||
|
.df(Util.getDoubleValue(rs.getString("ndzhdf")))
|
||||||
|
.ssks(Util.getIntValue(rs.getString("ssks")))
|
||||||
|
.bmmc(Util.getIntValue(rs.getString("bmmc")))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
// 分别处理 ssks → kspm 和 bmmc → bmpm 的排名
|
||||||
|
calculateRank(examineRankings, ExamineRanking::getSsks, ExamineRanking::setKspm);
|
||||||
|
calculateRank(examineRankings, ExamineRanking::getBmmc, ExamineRanking::setBmpm);
|
||||||
|
|
||||||
|
examineRankings.forEach(examine -> rs.executeUpdate("update uf_hr_jxkhndpjb set bmpm = ?,kspm = ? where id = ?",examine.getBmpm(),examine.getKspm(),examine.getId()));
|
||||||
|
|
||||||
|
return examineRankings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用排名计算方法
|
||||||
|
* @param dataList
|
||||||
|
* @param groupKeyGetter
|
||||||
|
* @param rankFieldSetter
|
||||||
|
*/
|
||||||
|
private void calculateRank(
|
||||||
|
List<ExamineRanking> dataList,
|
||||||
|
Function<ExamineRanking, Integer> groupKeyGetter, // 分组字段的 Getter
|
||||||
|
BiConsumer<ExamineRanking, String> rankFieldSetter // 排名结果的 Setter(直接使用 BiConsumer)
|
||||||
|
) {
|
||||||
|
// 1. 按分组字段(如 ssks 或 bmmc)分组
|
||||||
|
Map<Integer, List<ExamineRanking>> groupedData = dataList.stream()
|
||||||
|
.collect(Collectors.groupingBy(groupKeyGetter));
|
||||||
|
|
||||||
|
// 2. 处理每个分组
|
||||||
|
groupedData.forEach((groupKey, groupList) -> {
|
||||||
|
// 按 ydzhdf 降序排序
|
||||||
|
groupList.sort((a, b) -> Double.compare(b.getDf(), a.getDf()));
|
||||||
|
|
||||||
|
int groupSize = groupList.size();
|
||||||
|
if (groupSize == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 动态计算排名
|
||||||
|
double previousScore = groupList.get(0).getDf();
|
||||||
|
int currentRank = 1;
|
||||||
|
rankFieldSetter.accept(groupList.get(0), currentRank + "/" + groupSize);
|
||||||
|
|
||||||
|
for (int i = 1; i < groupSize; i++) {
|
||||||
|
ExamineRanking current = groupList.get(i);
|
||||||
|
if (Math.abs(current.getDf() - previousScore) > 1e-6) {
|
||||||
|
currentRank = i + 1;
|
||||||
|
previousScore = current.getDf();
|
||||||
|
}
|
||||||
|
rankFieldSetter.accept(current, currentRank + "/" + groupSize);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import weaver.hrm.User;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
|
|
@ -31,14 +31,14 @@ public class ExamineRankingAction {
|
||||||
return ServiceUtil.getService(ExamineRankingServiceImpl.class, user);
|
return ServiceUtil.getService(ExamineRankingServiceImpl.class, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@POST
|
||||||
@Path("/workflowDetail")
|
@Path("/examineRanking")
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
public String examineRanking(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
public String examineRanking(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
Map<String, Object> data = new HashMap<>(8);
|
Map<String, Object> data = new HashMap<>(8);
|
||||||
try {
|
try {
|
||||||
User user = HrmUserVarify.getUser(request, response);
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
data.put("datas", getService(user).examineRanking(ParamUtil.request2Map(request)));
|
data.put("size", getService(user).examineRanking(ParamUtil.request2Map(request)));
|
||||||
data.put("code", 200);
|
data.put("code", 200);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
data.put("code", 500);
|
data.put("code", 500);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue