#E10-16# 自助服务增加排序、绩效接口优化

main
shilei 1 year ago
parent c782764503
commit 865852e719

@ -3,6 +3,7 @@ package com.weaver.seconddev.jcldoor.cmd;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.framework.rpc.annotation.RpcReference;
import com.weaver.seconddev.jcldoor.util.DatabaseUtils;
import com.weaver.seconddev.jcldoor.util.JucailinPortalUtils;
import com.weaver.teams.domain.hr.entity.FlowData;
import com.weaver.teams.domain.hr.entity.FlowDataListReq;
import com.weaver.teams.domain.hr.entity.FlowDataListRes;
@ -17,13 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
*
@ -42,6 +42,9 @@ public class PortalPerformanceInfoCmd {
public String tenant_key = "t7akvdnf84";
@Autowired
private JucailinPortalUtils jucailinPortalUtils;
@RpcReference
public RemotePerformanceService remotePerformanceService;
@ -86,42 +89,92 @@ public class PortalPerformanceInfoCmd {
List<Map<String, Object>> indicatorList = new ArrayList<Map<String, Object>>();
if (StringUtils.isNotBlank(employeeId)) {
String sql = " select left(k.real_period,10) as real_period,left(k.real_period,7) as period_month,k.kpi_scheme,k.score\n" +
" from (select real_period,kpi_scheme,score\n" +
" from hr_kpi_flow \n" +
" where kpi_user=? \n" +
" and module = 'kpiFlow' \n" +
" and date_type = 'month' \n" +
" and delete_type = '0' " +
" and tenant_key=?\n" +
" and FLOW_STATUS in('noApprove','approve','finished')\n" +
" order by real_period desc\n" +
") k limit 1 ";
log.error("sql20-1:" + sql);
List<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(tenant_key);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam);
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
if (CollectionUtils.isNotEmpty(recordList)) {
Map<String, Object> recordMap = recordList.get(0);
if (!recordMap.isEmpty()) {
String score = String.valueOf(recordMap.get("score"));
String kpi_scheme = String.valueOf(recordMap.get("kpi_scheme"));
String real_period = String.valueOf(recordMap.get("real_period"));
String period_month = String.valueOf(recordMap.get("period_month"));
dataMap.put("score", score);
dataMap.put("yearmonth", period_month);
dataMap.put("kpi_scheme", kpi_scheme);
dataMap.put("real_period", real_period);
// String sql =" select left(k.real_period,10) as real_period,left(k.real_period,7) as period_month,k.kpi_scheme,k.score\n" +
// " from (select real_period,kpi_scheme,score\n" +
// " from hr_kpi_flow \n" +
// " where kpi_user=? \n" +
// " and module = 'kpiFlow' \n" +
// " and date_type = 'month' \n" +
// " and delete_type = '0' " +
// " and tenant_key=?\n" +
// " order by real_period desc\n" +
// ") k limit 1 ";
//
// log.error("sql20-1:" + sql);
//
// List<String> strlist = new ArrayList<>(100);
// strlist.add(employeeId);
// strlist.add(tenant_key);
//
//
// List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
// Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam);
//
// List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
// if (CollectionUtils.isNotEmpty(recordList)) {
// Map<String, Object> recordMap = recordList.get(0);
// if (!recordMap.isEmpty()) {
// String score = String.valueOf(recordMap.get("score"));
// String kpi_scheme = String.valueOf(recordMap.get("kpi_scheme"));
// String real_period = String.valueOf(recordMap.get("real_period"));
// String period_month = String.valueOf(recordMap.get("period_month"));
//
//// dataMap.put("score", score);
//// dataMap.put("yearmonth", period_month);
// dataMap.put("kpi_scheme", kpi_scheme);
//// dataMap.put("real_period", real_period);
// }
// }
try{
String startDay = "" ;
String endDay = "" ;
String period_month = "" ;
String score = "0.0";
String kpi_scheme = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String nowDate = sdf.format(new Date())+"-01";
Map<String,String> scoreMap = getLastScore(nowDate);
if(!scoreMap.isEmpty()){
score = scoreMap.get("score");
period_month = scoreMap.get("period_month");
startDay = scoreMap.get("startDay");
endDay = scoreMap.get("endDay");
}
log.error("startDay:"+startDay);
log.error("endDay:"+endDay);
if(StringUtils.isNotBlank(startDay) && StringUtils.isNotBlank(endDay)){
String sql =" select scheme_id " +
" from hr_kpi_scheme_flow_log_detail " +
" where user_id=? \n" +
" and date_type='month' \n" +
" and real_period >= ? \n" +
" and real_period <=? " ;
List<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startDay);
strlist.add(endDay);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam);
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
if (CollectionUtils.isNotEmpty(recordList)) {
Map<String, Object> recordMap = recordList.get(0);
if (!recordMap.isEmpty()) {
kpi_scheme = String.valueOf(recordMap.get("kpi_scheme"));
}
}
}
log.error("kpi_scheme:"+kpi_scheme);
dataMap.put("score", score);
dataMap.put("yearmonth", period_month);
dataMap.put("real_period", period_month);
dataMap.put("kpi_scheme", kpi_scheme);
}catch (Exception e){
e.printStackTrace();
log.error("getLastScore-e:"+e);
}
}
@ -132,12 +185,12 @@ public class PortalPerformanceInfoCmd {
if (StringUtils.isNotBlank(kpi_scheme)) {
String sql = " select indicator_type,indicator_description,weight \n" +
" from hr_kpi_scheme_indicator " +
" where scheme_id=? " +
" and indicator_mode='quantify'\n" +
" and status='on' " +
" and delete_type = '0'" +
" and tenant_key = ?";
" from hr_kpi_scheme_indicator " +
" where scheme_id=? " +
" and indicator_mode='quantify'\n" +
" and status='on' " +
" and delete_type = '0'" +
" and tenant_key = ?";
log.error("sql2:" + sql);
@ -373,7 +426,6 @@ public class PortalPerformanceInfoCmd {
flowDataListReq.setUserList(userList);
FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq);
log.error("getWholeYearKpi2-flowData:" + flowData);
Long total = flowData.getTotal();
List<FlowDataListRes> flowDataList = flowData.getDataList();
if (flowDataList.size() > 0) {
for (int index = 0; index < flowDataList.size(); index++) {
@ -389,6 +441,71 @@ public class PortalPerformanceInfoCmd {
return score;
}
/**
*
* @return
*/
public Map<String, String> getLastScore(String nowDay) {
Map<String, String> dataMap = new HashMap<String, String>();
String DateType = "month";
String score = "0.0";
String period_month = "";
String startDay = "" ;
String endDay = "" ;
try {
LocalDate date = LocalDate.parse(nowDay);
for (int i = 1; i <= 12; i++) {
LocalDate localStartDay = date.minusMonths(i);
LocalDate localEndDay = localStartDay.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
startDay = localStartDay.toString();
endDay = localEndDay.toString() ;
log.error("getLastScore-startDay:"+startDay);
log.error("getLastScore-endDay:"+endDay);
FlowDataListReq flowDataListReq = new FlowDataListReq();
flowDataListReq.setCurrent(1);
flowDataListReq.setPageSize(20);
flowDataListReq.setStartTime(startDay);
flowDataListReq.setEndTime(endDay);
flowDataListReq.setDateType(DateType);
flowDataListReq.setTenantKey(tenant_key);
List<Long> userList = new ArrayList<Long>();
Long employeeId = UserContext.getCurrentEmployeeId();
userList.add(employeeId);
flowDataListReq.setUserList(userList);
FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq);
log.error("getWholeYearKpi2-flowData:" + flowData);
List<FlowDataListRes> flowDataList = flowData.getDataList();
if (flowDataList.size() > 0) {
FlowDataListRes flowDataListRes = flowDataList.get(0);
float Score = flowDataListRes.getScore();
if(Math.abs(Score) > 0){
score = String.valueOf(Score);
period_month = startDay.substring(0,7);
break;
}
}
}
} catch (Exception e) {
log.error("getWholeYearKpi2-getScore-Exception:" + e.getMessage());
score = "0.0";
}
dataMap.put("score", score);
dataMap.put("yearmonth", period_month);
dataMap.put("real_period", period_month);
dataMap.put("startDay", startDay);
dataMap.put("endDay", endDay);
return dataMap;
}
public static String null2String(String s, String def) {
return s == null ? (def == null ? "" : def) : s;

@ -117,7 +117,7 @@ public class SelfServiceInfoCmd {
}
public List<Map<String,Object>> getCustomeServiceDataByType(String groupId,String sourceType,String value,String employeeId){
String sql = " select id,fwmc,fwdz,fwtb,taby from uf_zzfwrkpz where ry=? and qy is not null and taby is not null and taby=? and delete_type=0 and tenant_key = ?";
String sql = " select id,fwmc,fwdz,fwtb,taby from uf_zzfwrkpz where ry=? and qy is not null and taby is not null and taby=? and delete_type=0 and tenant_key = ? order by ifnull(xssx,0) ";
log.info("getSelfServiceData--sql:"+sql);
List<String> strlist = new ArrayList<>(100);
@ -178,11 +178,12 @@ public class SelfServiceInfoCmd {
* @return
*/
public List<Map<String,Object>> getDefaultServiceDataByType(String groupId,String sourceType,String value){
String sql =" select t.taby,t.fwtb,t.fwmc,t.fwdz\n" +
" from uf_zzfwcsh t \n" +
" where t.delete_type=0 \n" +
" and t.taby= ?" +
" and t.tenant_key = ?";
String sql =" select t.taby,t.fwtb,t.fwmc,t.fwdz " +
" from uf_zzfwcsh t \n" +
" where t.delete_type=0 \n" +
" and t.taby= ?" +
" and t.tenant_key = ?" +
" order by ifnull(t.xssx,0) ";
log.error("getSelfServiceData--sql:"+sql);
@ -215,7 +216,7 @@ public class SelfServiceInfoCmd {
public Map<String,String> getCustomServiceTypeName(String groupId,String sourceType,String employeeId){
Map<String,String> optionMap = new HashMap<String,String>();
String sql = " select id,tabymmc from uf_zzfwrktaby where qy is not null and ry=? and delete_type=0 and tenant_key = ?";
String sql = " select id,tabymmc from uf_zzfwrktaby where qy is not null and ry=? and delete_type=0 and tenant_key = ? order by ifnull(xssx,0) ";
log.error("getCustomServiceTypeName-sql:"+sql);
List<String> strlist = new ArrayList<>(100);

Loading…
Cancel
Save