From 865852e7190254180f5a7e0811d6fcfe3c002d50 Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Fri, 29 Mar 2024 17:03:19 +0800 Subject: [PATCH] =?UTF-8?q?#E10-16#=20=E8=87=AA=E5=8A=A9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F=E3=80=81=E7=BB=A9=E6=95=88?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jcldoor/cmd/PortalPerformanceInfoCmd.java | 209 ++++++++++++++---- .../jcldoor/cmd/SelfServiceInfoCmd.java | 15 +- 2 files changed, 171 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/weaver/seconddev/jcldoor/cmd/PortalPerformanceInfoCmd.java b/src/main/java/com/weaver/seconddev/jcldoor/cmd/PortalPerformanceInfoCmd.java index 018465a..3ed04f2 100644 --- a/src/main/java/com/weaver/seconddev/jcldoor/cmd/PortalPerformanceInfoCmd.java +++ b/src/main/java/com/weaver/seconddev/jcldoor/cmd/PortalPerformanceInfoCmd.java @@ -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> indicatorList = new ArrayList>(); 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 strlist = new ArrayList<>(100); - strlist.add(employeeId); - strlist.add(tenant_key); - - - List sqlparam = databaseUtils.getSqlParamEntity(strlist); - Map result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam); - - List> recordList = databaseUtils.getDataSourceList(result); - if (CollectionUtils.isNotEmpty(recordList)) { - Map 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 strlist = new ArrayList<>(100); +// strlist.add(employeeId); +// strlist.add(tenant_key); +// +// +// List sqlparam = databaseUtils.getSqlParamEntity(strlist); +// Map result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam); +// +// List> recordList = databaseUtils.getDataSourceList(result); +// if (CollectionUtils.isNotEmpty(recordList)) { +// Map 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 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 strlist = new ArrayList<>(100); + strlist.add(employeeId); + strlist.add(startDay); + strlist.add(endDay); + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if (CollectionUtils.isNotEmpty(recordList)) { + Map 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 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 getLastScore(String nowDay) { + + Map dataMap = new HashMap(); + 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 userList = new ArrayList(); + Long employeeId = UserContext.getCurrentEmployeeId(); + userList.add(employeeId); + flowDataListReq.setUserList(userList); + FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq); + log.error("getWholeYearKpi2-flowData:" + flowData); + List 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; diff --git a/src/main/java/com/weaver/seconddev/jcldoor/cmd/SelfServiceInfoCmd.java b/src/main/java/com/weaver/seconddev/jcldoor/cmd/SelfServiceInfoCmd.java index 1d1dd07..5d1a17c 100644 --- a/src/main/java/com/weaver/seconddev/jcldoor/cmd/SelfServiceInfoCmd.java +++ b/src/main/java/com/weaver/seconddev/jcldoor/cmd/SelfServiceInfoCmd.java @@ -117,7 +117,7 @@ public class SelfServiceInfoCmd { } public List> 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 strlist = new ArrayList<>(100); @@ -178,11 +178,12 @@ public class SelfServiceInfoCmd { * @return */ public List> 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 getCustomServiceTypeName(String groupId,String sourceType,String employeeId){ Map optionMap = new HashMap(); - 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 strlist = new ArrayList<>(100);