From 9d647996e737563e691dd58a020121f7815fdd5a Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Fri, 24 May 2024 11:44:44 +0800 Subject: [PATCH] =?UTF-8?q?#E10-37#=20=E8=81=9A=E6=89=8D=E6=9E=97=E9=A9=BE?= =?UTF-8?q?=E9=A9=B6=E8=88=B1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cockpit/cmd/CockpitBlogDataCmd.java | 129 +++ .../cmd/CockpitDocumentAnalysisCmd.java | 271 ++++++ .../cmd/CockpitMonthPerformanceInfoCmd.java | 105 +++ .../cmd/CockpitWorkAchievementsCmd.java | 816 ++++++++++++++++++ .../cockpit/cmd/CockpitWorkDate4TypeCmd.java | 570 ++++++++++++ .../cmd/CockpitWorkflowAnalysisCmd.java | 204 +++++ .../controller/JucailinCockpitController.java | 755 ++++++++++++++++ .../service/JucailinCockpitService.java | 19 + .../impl/JucailinCockpitServiceimpl.java | 56 ++ .../seconddev/cockpit/util/CommonUtils.java | 395 +++++++++ .../seconddev/cockpit/util/DatabaseUtils.java | 293 +++++++ .../cockpit/util/JucailinCockpitUtils.java | 160 ++++ 12 files changed, 3773 insertions(+) create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitBlogDataCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitDocumentAnalysisCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitMonthPerformanceInfoCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkAchievementsCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkDate4TypeCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkflowAnalysisCmd.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/controller/JucailinCockpitController.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/service/JucailinCockpitService.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/service/impl/JucailinCockpitServiceimpl.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/util/CommonUtils.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/util/DatabaseUtils.java create mode 100644 src/main/java/com/weaver/seconddev/cockpit/util/JucailinCockpitUtils.java diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitBlogDataCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitBlogDataCmd.java new file mode 100644 index 0000000..e5712c7 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitBlogDataCmd.java @@ -0,0 +1,129 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.calendar.service.RemoteAgendaService; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.seconddev.cockpit.util.DatabaseUtils; +import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils; +import com.weaver.teams.client.doc.remote.DocClientService; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum; +import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import com.weaver.workrelate.performance.api.rest.RemotePerformanceService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; + +/** + * 流程、日程、协助、文档 4个类型数据 + * + * @author shil + * @version 1.00版本 + * @Date 2024/5/22 + */ +@Component +public class CockpitBlogDataCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitWorkDate4TypeCmd.class); + + @RpcReference + public RemotePerformanceService remotePerformanceService; + + @Autowired + private JucailinCockpitUtils jucailinCockpitUtils; + + @Autowired + private DatabaseUtils databaseUtils; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + @RpcReference + DocClientService docClientService; + + @RpcReference + RemoteAgendaService remoteAgendaService; + + public Map getDataInfo(SimpleEmployee simpleEmployee, Map paramMap,String tenantKey) { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Map recordMap = new HashMap(); + + try { + String employeeId = String.valueOf(simpleEmployee.getEmployeeId()); + + String groupId = "weaver-elog-service"; + String sourceType = "LOGIC"; + + String sql =" select w.id,w.blog_time,w.content \n" + + " from (\n" + + " select id,blog_time,content \n" + + " from blog where creator = ?\n" + + " and delete_type = 0\n" + + " and tenant_key = ? \n" + + " order by blog_time desc\n" + + " ) w limit 5 " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + List> blogList = new ArrayList>(); + Map blogMap = null; + + if(recordList.size()>0){ + for(int i=0;i dataMap = recordList.get(i) ; + String blogid = String.valueOf(dataMap.get("id")); + String blog_time = String.valueOf(dataMap.get("blog_time")); + String content = String.valueOf(dataMap.get("content")); + String blogDate = ""; + if(StringUtils.isNotBlank(blog_time)){ + try{ + Long blogTime = Long.parseLong(blog_time); + Date date = new Date(blogTime); + blogDate = sdf.format(date); + }catch (Exception e){ + + } + } + + if(StringUtils.isNotBlank(blogDate)){ + blogMap = new HashMap(); + blogMap.put("blogid",blogid); + blogMap.put("blog_time",blogDate); + blogMap.put("content",content); + blogList.add(blogMap); + } + } + } + recordMap.put("datas",blogList); + } catch (Exception e) { + e.printStackTrace(); + log.error("PortalPerformanceInfoCmd :" + e); + } + return recordMap; + } +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitDocumentAnalysisCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitDocumentAnalysisCmd.java new file mode 100644 index 0000000..7868974 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitDocumentAnalysisCmd.java @@ -0,0 +1,271 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.calendar.service.RemoteAgendaService; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.seconddev.cockpit.util.DatabaseUtils; +import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils; +import com.weaver.teams.client.doc.remote.DocClientService; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum; +import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import com.weaver.workrelate.performance.api.rest.RemotePerformanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; + +/** + * 文档分析 + * + * @author shil + * @version 1.00版本 + * @Date 2024/5/22 + */ +@Component +public class CockpitDocumentAnalysisCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitWorkDate4TypeCmd.class); + + @RpcReference + public RemotePerformanceService remotePerformanceService; + + @Autowired + private JucailinCockpitUtils jucailinCockpitUtils; + + @Autowired + private DatabaseUtils databaseUtils; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + @RpcReference + DocClientService docClientService; + + @RpcReference + RemoteAgendaService remoteAgendaService; + + public Map getDataInfo(SimpleEmployee employee, Map paramMap,String tenantKey) { + + Map recordMap = new HashMap(); + try { + List> dataList = getDocumentDate(employee,tenantKey); + recordMap.put("leftdata",dataList); + Map chartMap = new HashMap(); + chartMap.put("项目管理","16.6"); + chartMap.put("客户服务","16.6"); + chartMap.put("产品中心","40.8"); + chartMap.put("市场管理","10.0"); + chartMap.put("其他","8.6"); + recordMap.put("rightdata",chartMap); + } catch (Exception e) { + e.printStackTrace(); + log.error("CockpitDocumentAnalysisCmd-e:" + e); + } + return recordMap; + } + + /*** + * + * @param employee + * @param tenantKey + * @return + */ + public List> getDocumentDate(SimpleEmployee employee,String tenantKey) { + + List> doclist = new ArrayList<>(100); + try { + long employeeId = employee.getEmployeeId(); + + Map docMap = new HashMap(); + + + String doc_count4 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name4 = "待查看文档数量"; + String doc_pkey4 = "document.create.amount"; + String doc_url4 = jucailinCockpitUtils.getUfPropData(doc_pkey4,tenantKey); + docMap.put("count",doc_count4); + docMap.put("name",doc_name4); + docMap.put("url",doc_url4); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count5 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name5 = "我的积分"; + String doc_pkey5 = "document.create.amount"; + String doc_url5 = jucailinCockpitUtils.getUfPropData(doc_pkey5,tenantKey); + docMap.put("count",doc_count5); + docMap.put("name",doc_name5); + docMap.put("url",doc_url5); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count6 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name6 = "我的分享"; + String doc_pkey6 = "document.create.amount"; + String doc_url6 = jucailinCockpitUtils.getUfPropData(doc_pkey6,tenantKey); + docMap.put("count",doc_count6); + docMap.put("name",doc_name6); + docMap.put("url",doc_url6); + doclist.add(docMap); + + + docMap = new HashMap(); + String doc_count7 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name7 = "下属知识"; + String doc_pkey7 = "document.create.amount"; + String doc_url7 = jucailinCockpitUtils.getUfPropData(doc_pkey7,tenantKey); + docMap.put("count",doc_count7); + docMap.put("name",doc_name7); + docMap.put("url",doc_url7); + doclist.add(docMap); + + + docMap = new HashMap(); + String doc_count1 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name1 = "我创建的文档"; + String doc_pkey1 = "document.create.amount"; + String doc_url1 = jucailinCockpitUtils.getUfPropData(doc_pkey1,tenantKey); + docMap.put("count",doc_count1); + docMap.put("name",doc_name1); + docMap.put("url",doc_url1); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count2 = getDocumentDateAmount(employeeId,"2",tenantKey); + String doc_name2 = "共享给我的文档"; + String doc_pkey2 = "document.read.amount"; + String doc_url2 = jucailinCockpitUtils.getUfPropData(doc_pkey2,tenantKey); + docMap.put("count",doc_count2); + docMap.put("name",doc_name2); + docMap.put("url",doc_url2); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count3 = getDocumentDateAmount(employeeId,"3",tenantKey); + String doc_name3 = "我订阅的文档"; + String doc_pkey3 = "document.number.amount"; + String doc_url3 = jucailinCockpitUtils.getUfPropData(doc_pkey3,tenantKey); + docMap.put("count",doc_count3); + docMap.put("name",doc_name3); + docMap.put("url",doc_url3); + doclist.add(docMap); + + + docMap = new HashMap(); + String doc_count8 = getDocumentDateAmount(employeeId,"3",tenantKey); + String doc_name8 = "我关注的文档"; + String doc_pkey8 = "document.number.amount"; + String doc_url8 = jucailinCockpitUtils.getUfPropData(doc_pkey8,tenantKey); + docMap.put("count",doc_count8); + docMap.put("name",doc_name8); + docMap.put("url",doc_url8); + doclist.add(docMap); + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return doclist; + } + + + public String getDocumentDateAmount(Long employeeId,String type,String tenantKey) { + String count = "0"; + String groupId = "weaver-doc-service"; + String sourceType = "LOGIC"; + + try { + if("1".equals(type)){ + + int doccreatecount = docClientService.countByCreator(employeeId); + count = doccreatecount + ""; + + }else if("2".equals(type)){ + + String sql =" select count(1) as cou " + + " from document " + + " where id in( select targetid from doc_documentlogs where log_operator <> ? and operatetype = 'read' and delete_type = 0 and tenant_key=? and doc_status = 2 ) \n" + + " and creator = ?\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + }else if("3".equals(type)){ + String sql =" select count(1) as cou \n" + + " from doc_documentlogs \n" + + " where targetid in( select id from document where creator = ? and delete_type = 0 and tenant_key=? and doc_status = 2) \n" + + " and log_operator <> ? \n" + + " and OPERATETYPE = 'read' \n" + + " and delete_type = 0 \n" + + " and tenant_key=? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("getDocCreateNum:" + e); + } + + return count; + } + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitMonthPerformanceInfoCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitMonthPerformanceInfoCmd.java new file mode 100644 index 0000000..7a9f65a --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitMonthPerformanceInfoCmd.java @@ -0,0 +1,105 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.teams.domain.hr.entity.FlowData; +import com.weaver.teams.domain.hr.entity.FlowDataListReq; +import com.weaver.teams.domain.hr.entity.FlowDataListRes; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.workrelate.performance.api.rest.RemotePerformanceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.*; + +/** + * 月绩效信息 + * + * @author wangj + * @version 1.00版本 + * @Date 2024/3/8 + */ +@Component +public class CockpitMonthPerformanceInfoCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitMonthPerformanceInfoCmd.class); + + @RpcReference + public RemotePerformanceService remotePerformanceService; + + public Map getDataInfo(SimpleEmployee simpleEmployee, Map paramMap,String tenantKey) { + Map dataMap = new HashMap(100); + String dateType = "month"; + try { + long employeeId = simpleEmployee.getEmployeeId(); + List userList = new ArrayList(); + userList.add(employeeId); + + LocalDate currentDate = LocalDate.now(); + Map scoreMap = new HashMap(); + for (int i = 0; i < 6; i++) { + LocalDate lastLocalDate = currentDate.minus(i, ChronoUnit.MONTHS); // 当前日期减去6个月 + LocalDate startDay = lastLocalDate.with(TemporalAdjusters.firstDayOfMonth()); // 计算当前月份的首日 + LocalDate endDay = lastLocalDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + + log.error("startDay:"+startDay.toString()); + log.error("endDay:"+endDay.toString()); + + String score = getScore(userList,startDay.toString(), endDay.toString(),dateType,tenantKey); + log.error("score:"+score); + + int month = lastLocalDate.getMonth().getValue(); + int year = lastLocalDate.getYear(); + + String currentMonth = "" ; + if(month < 10){ + currentMonth = year+"-0"+month; + }else{ + currentMonth = year+"-"+month; + } + log.error("currentMonth:"+currentMonth); + + scoreMap.put(currentMonth,score); + } + dataMap.put("score",dataMap); + } catch (Exception e) { + e.printStackTrace(); + log.error("PortalPerformanceInfoCmd :" + e); + } + + return dataMap; + } + + + public String getScore( List userList,String startDay, String endDay,String dateType,String tenantKey) { + String scoreData = "0.00" ; + try { + FlowDataListReq flowDataListReq = new FlowDataListReq(); + flowDataListReq.setCurrent(1); + flowDataListReq.setPageSize(20); + flowDataListReq.setStartTime(startDay + ""); + flowDataListReq.setEndTime(endDay + ""); + flowDataListReq.setDateType(dateType); + flowDataListReq.setTenantKey(tenantKey); + + flowDataListReq.setUserList(userList); + FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq); + log.error("getWholeYearKpi2-flowData:" + flowData); + List flowDataList = flowData.getDataList(); + if (flowDataList.size() > 0) { + for (int index = 0; index < flowDataList.size(); index++) { + FlowDataListRes flowDataListRes = flowDataList.get(index); + float score = flowDataListRes.getScore(); + scoreData = score+""; + } + } + } catch (Exception e) { + log.error("getWholeYearKpi2-getScore-Exception:" + e.getMessage()); + } + return scoreData; + } + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkAchievementsCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkAchievementsCmd.java new file mode 100644 index 0000000..cc2b10f --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkAchievementsCmd.java @@ -0,0 +1,816 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +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; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.teams.security.context.UserContext; +import com.weaver.workflow.common.constant.list.api.DateTimeConditionEnum; +import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum; +import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import com.weaver.workrelate.performance.api.rest.RemotePerformanceService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 本年工作成果信息(按类型) + * + * @author shil + * @version 1.00版本 + * @Date 2024/5/22 + */ +@Component +public class CockpitWorkAchievementsCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitWorkAchievementsCmd.class); + + @RpcReference + public RemotePerformanceService remotePerformanceService; + + @Autowired + private JucailinPortalUtils jucailinPortalUtils; + + @Autowired + private DatabaseUtils databaseUtils; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + + public Map getDataInfo(SimpleEmployee simpleEmployee, Map paramMap,String tenantKey) { + + Map recordMap = new HashMap(); + + List> list = new ArrayList<>(100); + Map oneMap = new HashMap<>(100); + Map twoMap = new HashMap<>(100); + Map threeMap = new HashMap<>(100); + Map fourMap = new HashMap<>(100); + + + String startday = String.valueOf(paramMap.get("startday")); + String endday = String.valueOf(paramMap.get("endday")); + + String one = "0"; + String oneword = ""; + String oneurl = ""; + + String two = "0"; + String twoword = ""; + String twourl = ""; + + String three = "0"; + String threeword = ""; + String threeurl = ""; + + String four = "0"; + String fourword = ""; + String foururl = ""; + + try { + String employeeId = String.valueOf(simpleEmployee.getEmployeeId()); + + //销售 0,项目 1,技术 2,其它 3 + String znlx = getUserType(simpleEmployee,tenantKey); + + //销售 0,项目 1,技术 2,其它 3 + if("2".equals(znlx)){ + + one = getQuestInfo(startday, endday, employeeId,tenantKey); + oneword = "本年问题处理数"; + String pkey = "workdata.technology.wtclsl"; + oneurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + two = getDaysInfo(startday, endday, employeeId,tenantKey); + twoword = "本年开发人天"; + pkey = "workdata.technology.kfrt"; + twourl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + three = getCoWorkInfo(startday,endday, employeeId,tenantKey); + threeword = "本年协作沟通数"; + pkey = "workdata.technology.gtxz"; + threeurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + four = getWfInfo(simpleEmployee); + fourword = "本年处理流程数"; + pkey = "workdata.technology.cllc"; + foururl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + }else if("1".equals(znlx)){ + + one = "0.00"; + oneword = "本年验收指标"; + String pkey = "workdata.project.yszb"; + oneurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + //项目验收信息 + two = getYsInfo(employeeId,startday,endday); + two = parseJe(two); + twoword = "本年验收金额"; + pkey = "workdata.project.ysje"; + twourl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + three = "0.00"; + threeword = "本年指标达成率"; + pkey = "workdata.project.zbdcl"; + threeurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + //项目收款信息 + four = getSkInfo(employeeId,startday,endday,tenantKey); + four = parseJe(four); + fourword = "本年收款金额"; + pkey = "workdata.project.skje"; + foururl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + }else if("3".equals(znlx)){ + + one = getWfInfo(simpleEmployee); + oneword = "本年处理流程数"; + String pkey = "workdata.other.cllc"; + oneurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + two = getDocInfo(startday,endday,employeeId,tenantKey); + twoword = "本年文档贡献度"; + pkey = "workdata.other.wdgx"; + twourl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + three = getDailyInfo(startday,endday,employeeId,tenantKey); + threeword = "本年微博填写数"; + pkey = "workdata.other.wbtx"; + threeurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + four = getCoWorkInfo(startday,endday,employeeId,tenantKey); + fourword = "本年沟通协作数"; + pkey = "workdata.other.gtxz"; + foururl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + }else{ + + one = getWfInfo(simpleEmployee); + oneword = "本年处理流程数"; + String pkey = "workdata.other.cllc"; + oneurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + two = getDocInfo(startday,endday,employeeId,tenantKey); + twoword = "本年文档贡献度"; + pkey = "workdata.other.wdgx"; + twourl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + three = getDailyInfo(startday,endday,employeeId,tenantKey); + threeword = "本年微博填写数"; + pkey = "workdata.other.wbtx"; + threeurl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + four = getCoWorkInfo(startday,endday,employeeId,tenantKey); + fourword = "本年沟通协作数"; + pkey = "workdata.other.gtxz"; + foururl = jucailinPortalUtils.getUfPropData(pkey,tenantKey); + + } + + + oneMap.put("name",oneword); + oneMap.put("value",one); + oneMap.put("url",oneurl); + twoMap.put("name",twoword); + twoMap.put("value",two); + twoMap.put("url",twourl); + threeMap.put("name",threeword); + threeMap.put("value",three); + threeMap.put("url",threeurl); + fourMap.put("name",fourword); + fourMap.put("value",four); + fourMap.put("url",foururl); + + list.add(oneMap); + list.add(twoMap); + list.add(threeMap); + list.add(fourMap); + + recordMap.put("list",list); + } catch (Exception e) { + e.printStackTrace(); + log.error("PortalPerformanceInfoCmd :" + e); + } + return recordMap; + } + + + public String getScore( List userList,String startDay, String endDay,String dateType,String tenantKey) { + String scoreData = "0.00" ; + try { + FlowDataListReq flowDataListReq = new FlowDataListReq(); + flowDataListReq.setCurrent(1); + flowDataListReq.setPageSize(20); + flowDataListReq.setStartTime(startDay + ""); + flowDataListReq.setEndTime(endDay + ""); + flowDataListReq.setDateType(dateType); + flowDataListReq.setTenantKey(tenantKey); + + flowDataListReq.setUserList(userList); + FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq); + log.error("getWholeYearKpi2-flowData:" + flowData); + List flowDataList = flowData.getDataList(); + if (flowDataList.size() > 0) { + for (int index = 0; index < flowDataList.size(); index++) { + FlowDataListRes flowDataListRes = flowDataList.get(index); + float score = flowDataListRes.getScore(); + scoreData = score+""; + } + } + } catch (Exception e) { + log.error("getWholeYearKpi2-getScore-Exception:" + e.getMessage()); + } + return scoreData; + } + + /*** + * + * @param startday + * @param endday + * @param employeeId + * @param tenantKey + * @return + */ + public String getQuestInfo(String startday, String endday, String employeeId,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String quecou = "0"; + + String groupId = "weaver-workflow-report-serviceworkflowreport"; + String sourceType = "LOGIC"; + + try { + + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + if (StringUtils.isBlank(startday)) { + startday = year + "-01-01"; + } + if (StringUtils.isBlank(endday)) { + endday = sdf.format(new Date()); + } + + if (StringUtils.isBlank(employeeId)) { + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + if (StringUtils.isNotBlank(employeeId)) { + String dataSql =" select ifnull(sum(d.integer2),0) as devcou \n" + + " from wfc_form_data l\n" + + " inner join fto_62 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.multiresource5=?\n" + + " and d.date2 >=?" + + " and d.date2 <=?" + + " and d.tenant_key=?\n" + + " and d.is_delete='0'\n" + + " and l.tenant_key=?\n" + + " and l.delete_type=0\n" + + " and p.tenant_key=?\n" + + " and p.delete_type=0\n" + + " order by d.id desc "; + + log.info("DevQuestCountCmd dataSql:" + dataSql); + + List strlist = new ArrayList<>(100); + strlist.add(employeeId); + strlist.add(startday); + strlist.add(endday); + strlist.add(tenantKey); + strlist.add(tenantKey); + strlist.add(tenantKey); + + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + quecou = String.valueOf(recordList.get(0).get("devcou")); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return quecou; + } + + + /** + * 获取人员类型 + * @param employee + * @return + */ + public String getUserType(SimpleEmployee employee,String tenantkey) { + String sourceType = "LOGIC"; + String userType = "3"; + try{ + long formdata = employee.getFormdata(); + String pkey = "field69.groupId"; + String groupId = jucailinPortalUtils.getUfPropData(pkey,tenantkey); + log.error("groupId:"+groupId); + + String field69 = ""; + String sql =" select field69 from eteams.Hrmemployeedefined where form_data_id = ?" ; + log.error("getSelfServiceData--sql:"+sql); + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(formdata+""); + sqlparam.add(sqlParamEntity); + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + // 销售 0,项目 1,技术 2,其它 3 + field69 = String.valueOf(recordList.get(0).get("field69")); + } + log.error("field69:"+field69); + if(StringUtils.isNotBlank(field69)){ + switch (field69){ + case "1": + userType = "0"; + break; + case "2": + userType = "1"; + break; + case "3": + userType = "2"; + break; + default: + userType = "3"; + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("getUserType-e:"+e); + } + return userType; + } + + /*** + * + * @param startday + * @param endday + * @param employeeId + * @return + */ + public String getDaysInfo(String startday, String endday, String employeeId,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String devcou = "0"; + + String groupId = "weaver-workflow-report-serviceworkflowreport"; + String sourceType = "LOGIC"; + + try { + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if (StringUtils.isBlank(startday)) { + startday = year + "-01-01"; + } + if (StringUtils.isBlank(endday)) { + endday = sdf.format(new Date()); + } + if (StringUtils.isBlank(employeeId)) { + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + if (StringUtils.isNotBlank(employeeId)) { + String dataSql =" select count(1) as devcou \n" + + " from wfc_form_data l\n" + + " inner join fto_83 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.mutiresource= ?\n" + + " and d.xsjfrq >= ?" + + " and d.xsjfrq <= ?" + + " and d.tenant_key= ?\n" + + " and d.is_delete='0'\n" + + " and l.tenant_key=?\n" + + " and l.delete_type=0\n" + + " and p.tenant_key=?\n" + + " and p.delete_type=0\n" + + " order by d.id desc "; + + List strlist = new ArrayList<>(100); + strlist.add(employeeId); + strlist.add(startday); + strlist.add(endday); + strlist.add(tenantKey); + strlist.add(tenantKey); + strlist.add(tenantKey); + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + log.info("DevDaysCountCmd sql:" + dataSql); + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + devcou = String.valueOf(recordList.get(0).get("devcou")); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("getDaysInfo-Exception:" + e); + } + return devcou; + } + + /** + * 本年沟通协作数 + * + * @param + * @return + */ + public String getCoWorkInfo(String startday, String endday, String employeeId,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String groupId = "weaver-cowork-service"; + String sourceType = "LOGIC"; + String count = "0"; + try { + + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if (StringUtils.isBlank(startday)) { + startday = year + "-01-01"; + } + if (StringUtils.isBlank(endday)) { + endday = sdf.format(new Date()); + } + if (StringUtils.isBlank(employeeId)) { + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + String sql =" select count(1) as count from cw_content " + + " where CREATOR=?\n" + + " and left(create_time,10)>=? " + + " and left(create_time,10) <= ?" + + " and tenant_key = ?" + + " and delete_type = 0 "; + + log.error("getInteractInfo sql:" + sql); + + List strlist = new ArrayList<>(100); + strlist.add(employeeId); + strlist.add(startday); + strlist.add(endday); + strlist.add(tenantKey); + + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if (recordList.size() > 0) { + count = String.valueOf(recordList.get(0).get("count")); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("getCoWorkInfo-Exception:"+e.getMessage()); + } + return count; + } + + + /** + * 本年流程处理数量 + * + * @param + * @return + */ + public String getWfInfo(SimpleEmployee employee) { + String wfcount = "0"; + try{ + RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); + conditionEntity.setOperatedate(DateTimeConditionEnum.CURRENT_YEAR); + WeaResult requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity); + int code = requestCountInfo.getCode(); + if(code == 200){ + RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData(); + Long count = requestCountInfoPAEntity.getCount(); + wfcount = count+"" ; + } + } catch (Exception e) { + e.printStackTrace(); + log.error("getWfInfo-Exception:" + e); + } + return wfcount; + } + + + /*** + * + * @param employeeId + * @param startday + * @param endday + * @return + */ + public String getSkInfo(String employeeId,String startday,String endday,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + String htzje = "0.00"; + try { + + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if(StringUtils.isBlank(startday)){ + startday = year+"-01-01"; + } + if(StringUtils.isBlank(endday)){ + endday = sdf.format(new Date()); + } + + if(StringUtils.isBlank(employeeId)){ + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + + String sql =" SELECT \n" + + " CONVERT(ifnull(sum(cast(t1.skje as decimal(18,2))),0),CHAR) as skje,\n" + //收款金额 + " CONVERT(ifnull(sum(cast(t1.xmskje as decimal(18,2))),0),CHAR) as xmskje,\n" + // 项目收款金额 + " CONVERT(ifnull(sum(cast(t1.xsyxje as decimal(18,2))),0),CHAR) as xsyxje," + // 销售有效金额 + " CONVERT(ifnull(sum(cast(t1.xsje as decimal(18,2))),0),CHAR) as xsje," + // 销售金额 + " CONVERT(ifnull(sum(cast(t1.xmyxje as decimal(18,2))),0),CHAR) as xmyxje," + //项目有效金额 + " CONVERT(ifnull(sum(cast(t1.xsjxhk as decimal(18,2))),0),CHAR) as xsjxhk," + //有效绩效回款 + " CONVERT(ifnull(sum(cast(t1.sumsk as decimal(18,2))),0),CHAR) as sumsk," + //总收款金额 + " CONVERT(ifnull(sum(cast(t1.sjjsk as decimal(18,2))),0),CHAR) as sjjsk," + //实际结算款 + " CONVERT(ifnull(sum(cast(t1.skjs as decimal(18,2))),0),CHAR) as skjs " + //收款结算 + " FROM uf_jxhs_skmx t1\n" + + " LEFT JOIN uf_jxhs_zxhtzb t2 ON t1.hth = t2.hth AND t2.hth != '' AND t2.hth IS NOT NULL \n" + + " LEFT JOIN ebdf_physical_data epd on t1.id = epd.form_data_id and epd.delete_type = 0 \n" + + " WHERE t1.skje != 0 \n" + + " and t1.skje IS NOT NULL " + + " and t1.xshsny >= ? and t1.xshsny <=? "+ + " and (" + + " ? IN ( 2, 27, 166, 10285, 11661, 300, 876, 3593, 1416, 1647, 1844,3044480226941419013,794508876297846787 ) \n" + + " or cast(t1.xsjl AS decimal(25,0)) in( \n" + + " SELECT cid AS id FROM eteams.emp_link WHERE pid = ? and RELATION in ('othersenior','senior') \n" + + " UNION " + + " SELECT id FROM eteams.employee WHERE id = ? " + + " )\n" + + " or cast(t1.kfry AS decimal(25,0)) in(\n" + + " SELECT cid AS id FROM eteams.emp_link WHERE pid = ? and RELATION in ('othersenior','senior') \n" + + " UNION " + + " SELECT id FROM eteams.employee WHERE id = ? " + + " )\n" + + " or cast(t1.qdjl AS decimal(25,0)) in(\n" + + " SELECT cid AS id FROM eteams.emp_link WHERE pid = ? and RELATION in ('othersenior','senior') \n" + + " UNION " + + " SELECT id FROM eteams.employee WHERE id = ? " + + " )\n" + + " or cast(t1.xmjl AS decimal(25,0)) in(\n" + + " SELECT cid AS id FROM eteams.emp_link WHERE pid = ? and RELATION in ('othersenior','senior') \n" + + " UNION " + + " SELECT id FROM eteams.employee WHERE id = ? " + + " )\n" + + " )\n" + + " order by t1.id " ; + + log.error("PorojectReceiptsInfoCmd sql:"+sql); + List strlist = new ArrayList<>(100); + strlist.add(startday); + strlist.add(endday); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + + List> recordList = databaseUtils.getDataSourceList(result); + if(!CollectionUtils.isEmpty(recordList)){ + htzje = String.valueOf(recordList.get(0).get("htzje")); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("PorojectReceiptsInfoCmd Exception:"+e); + } + return htzje; + } + + + public String getYsInfo(String employeeId,String startday,String endday){ + + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + String htzje = "0.00" ; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if(StringUtils.isBlank(startday)){ + startday = year+"-01-01"; + } + if(StringUtils.isBlank(endday)){ + endday = sdf.format(new Date()); + } + if(StringUtils.isBlank(employeeId)){ + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + String sql =" select CONVERT(ifnull(sum(cast(t1.htzje as decimal(18,2))),0),CHAR) as htzje," + + " CONVERT(ifnull(sum(cast(t1.htyxje as decimal(18,2))),0),CHAR) as htyxje," + + " CONVERT(ifnull(sum(cast(t1.sumsk as decimal(18,2))),0),CHAR) as sumsk " + + " from uf_jxhs_xmys t1 \n" + + " where t1.ysrq>=? and t1.ysrq<=? " + + " and ( t1.qyjl = ? "+ + " or t1.qyjl in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.ysry = ?\n" + + " or t1.ysry in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.dqfzr = ?\n" + + " or t1.dqfzr in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.tdjl = ?\n" + + " or t1.tdjl in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.tdfzr = ?\n" + + " or t1.tdfzr in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.jgfzr = ?\n" + + " or t1.jgfzr in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?)\n" + + " or t1.dqzj = ?\n" + + " or t1.dqzj in (select cid from eteams.EMP_LINK where RELATION in ('othersenior','senior') and pid= ?) " + + " ) " ; + + List strlist = new ArrayList<>(100); + strlist.add(startday); + strlist.add(endday); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + strlist.add(employeeId); + + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + if(!recordList.isEmpty() && recordList.size()>0){ + htzje = String.valueOf(recordList.get(0).get("htzje")); + } + + } catch (Exception e) { + e.printStackTrace(); + log.error("PorojectAcceptanceInfoCmd:"+e.getMessage()); + } + return htzje; + } + + + /** + * 本年文档创建贡献数 + * @param + * @return + */ + public String getDocInfo(String startday,String endday,String employeeId,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String groupId = "weaver-doc-service"; + String sourceType = "LOGIC"; + + String count = "0"; + try{ + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if(StringUtils.isBlank(startday)){ + startday = year+"-01-01"; + } + if(StringUtils.isBlank(endday)){ + endday = sdf.format(new Date()); + } + + if(StringUtils.isBlank(employeeId)){ + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + String sql = " select count(1) as count " + + " from document " + + " where CREATOR=?\n" + + " and left(create_time,10)>=? " + + " and left(create_time,10) <= ?" ; + + log.error("PortalDocCreateCountCmd sql:"+sql); + 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(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("count")); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("getDocInfo-e:"+e); + } + return count; + } + + + public String getDailyInfo(String startday,String endday,String employeeId,String tenantKey) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + String groupId = "weaver-blog-service"; + String sourceType = "LOGIC"; + String count = "0"; + try{ + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + if(StringUtils.isBlank(startday)){ + startday = year+"-01-01"; + } + if(StringUtils.isBlank(endday)){ + endday = sdf.format(new Date()); + } + + if(StringUtils.isBlank(employeeId)){ + employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); + } + + String sql =" select count(1) as count\n" + + " from blog " + + " where creator=?\n" + + " and left(BLOG_TIME,10) >=?\n" + + " and left(BLOG_TIME,10) <=?\n" + + " and type='blog'\n" + + " and TENANT_KEY = ?\n" + + " and MODULE = 'blog'\n" + + " and DELETE_TYPE = 0\n" + + " and CONTENT is not null" ; + + List strlist = new ArrayList<>(100); + strlist.add(employeeId); + strlist.add(startday); + strlist.add(endday); + strlist.add(tenantKey); + + List sqlparam = databaseUtils.getSqlParamEntity(strlist); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("count")); + } + + }catch (Exception e){ + e.printStackTrace(); + log.error("getDailyInfo-e:"+e); + } + return count; + } + + + + public static String parseJe(String value){ + if("".equals(value)){ + return "0.00"; + } + BigDecimal dividend = new BigDecimal(value); // 被除数 + BigDecimal divisor = new BigDecimal("10000"); // 除数 + + // 设置小数点后两位,并进行四舍五入 + BigDecimal result = dividend.divide(divisor, 2, RoundingMode.HALF_UP); + + return result.toString(); + } + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkDate4TypeCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkDate4TypeCmd.java new file mode 100644 index 0000000..fa7a11d --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkDate4TypeCmd.java @@ -0,0 +1,570 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.calendar.service.RemoteAgendaService; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.seconddev.cockpit.util.DatabaseUtils; +import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils; +import com.weaver.teams.client.doc.remote.DocClientService; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.teams.security.context.UserContext; +import com.weaver.workflow.common.constant.list.api.DateTimeConditionEnum; +import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum; +import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import com.weaver.workrelate.performance.api.rest.RemotePerformanceService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 流程、日程、协助、文档 4个类型数据 + * + * @author shil + * @version 1.00版本 + * @Date 2024/5/22 + */ +@Component +public class CockpitWorkDate4TypeCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitWorkDate4TypeCmd.class); + + @RpcReference + public RemotePerformanceService remotePerformanceService; + + @Autowired + private JucailinCockpitUtils jucailinCockpitUtils; + + @Autowired + private DatabaseUtils databaseUtils; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + @RpcReference + DocClientService docClientService; + + @RpcReference + RemoteAgendaService remoteAgendaService; + + public Map getDataInfo(SimpleEmployee employee, Map paramMap,String tenantKey) { + + Map recordMap = new HashMap(); + + List> wfList = new ArrayList>(); + List> docList = new ArrayList>(); + List> coworkList = new ArrayList>(); + List> calendarList = new ArrayList>(); + + try { + wfList = getWorkflowDate(employee,tenantKey); + + docList = getDocumentDate(employee,tenantKey); + + coworkList = getCoWorkDate(employee,tenantKey); + + calendarList = getCalendarDate(employee,tenantKey); + } catch (Exception e) { + e.printStackTrace(); + log.error("PortalPerformanceInfoCmd :" + e); + } + + recordMap.put("wfdata",wfList); + recordMap.put("docdata",docList); + recordMap.put("coworkdata",coworkList); + recordMap.put("calendardata",calendarList); + + return recordMap; + } + + /*** + * + * @return + */ + public List> getWorkflowDate(SimpleEmployee employee,String tenantKey) { + + List> wflist = new ArrayList<>(100); + try { + Map wfMap = new HashMap(); + String wf_count1 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid()); + String wf_name1 = "待办流程数"; + String wf_pkey1 = "workflow.todo.amount"; + String wf_url1 = jucailinCockpitUtils.getUfPropData(wf_pkey1,tenantKey); + wfMap.put("count",wf_count1); + wfMap.put("name",wf_name1); + wfMap.put("url",wf_url1); + wflist.add(wfMap); + + wfMap = new HashMap(); + String wf_count2 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid()); + String wf_name2 = "我发起的流程"; + String wf_pkey2 = "workflow.mine.amount"; + String wf_url2 = jucailinCockpitUtils.getUfPropData(wf_pkey2,tenantKey); + wfMap.put("count",wf_count2); + wfMap.put("name",wf_name2); + wfMap.put("url",wf_url2); + wflist.add(wfMap); + + wfMap = new HashMap(); + String wf_count3 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid()); + String wf_name3 = "已办流程"; + String wf_pkey3 = "workflow.done.amount"; + String wf_url3 = jucailinCockpitUtils.getUfPropData(wf_pkey3,tenantKey); + wfMap.put("count",wf_count3); + wfMap.put("name",wf_name3); + wfMap.put("url",wf_url3); + wflist.add(wfMap); + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return wflist; + } + + /*** + * + * @param employee + * @param tenantKey + * @return + */ + public List> getDocumentDate(SimpleEmployee employee,String tenantKey) { + + List> doclist = new ArrayList<>(100); + try { + long employeeId = employee.getEmployeeId(); + + Map docMap = new HashMap(); + String doc_count1 = getDocumentDateAmount(employeeId,"1",tenantKey); + String doc_name1 = "创建文档"; + String doc_pkey1 = "document.create.amount"; + String doc_url1 = jucailinCockpitUtils.getUfPropData(doc_pkey1,tenantKey); + docMap.put("count",doc_count1); + docMap.put("name",doc_name1); + docMap.put("url",doc_url1); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count2 = getDocumentDateAmount(employeeId,"2",tenantKey); + String doc_name2 = "查阅文档"; + String doc_pkey2 = "document.read.amount"; + String doc_url2 = jucailinCockpitUtils.getUfPropData(doc_pkey2,tenantKey); + docMap.put("count",doc_count2); + docMap.put("name",doc_name2); + docMap.put("url",doc_url2); + doclist.add(docMap); + + docMap = new HashMap(); + String doc_count3 = getDocumentDateAmount(employeeId,"3",tenantKey); + String doc_name3 = "查阅次数"; + String doc_pkey3 = "document.number.amount"; + String doc_url3 = jucailinCockpitUtils.getUfPropData(doc_pkey3,tenantKey); + docMap.put("count",doc_count3); + docMap.put("name",doc_name3); + docMap.put("url",doc_url3); + doclist.add(docMap); + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return doclist; + } + + /*** + * + * @param employee + * @param tenantKey + * @return + */ + public List> getCoWorkDate(SimpleEmployee employee,String tenantKey) { + + List> datalist = new ArrayList<>(100); + try { + long employeeId = employee.getEmployeeId(); + + Map coworkMap = new HashMap(); + String cowork_count = getCoWorkDateAmount(employeeId,"1",tenantKey); + String cowork_name = "协作区发表"; + String cowork_pkey = "cowork.create.amount"; + String cowork_url = jucailinCockpitUtils.getUfPropData(cowork_pkey,tenantKey); + coworkMap.put("count",cowork_count); + coworkMap.put("name",cowork_name); + coworkMap.put("url",cowork_url); + datalist.add(coworkMap); + + Map imMap = new HashMap(); + String im_count2 = getCoWorkDateAmount(employeeId,"2",tenantKey); + String im_name2 = "参与群聊"; + String im_pkey2 = "im.group.amount"; + String im_url2 = jucailinCockpitUtils.getUfPropData(im_pkey2,tenantKey); + imMap.put("count",im_count2); + imMap.put("name",im_name2); + imMap.put("url",im_url2); + datalist.add(imMap); + + imMap = new HashMap(); + String im_count3 = getCoWorkDateAmount(employeeId,"3",tenantKey); + String im_name3 = "平均每日沟通人数"; + String im_pkey3 = "im.chatday.amount"; + String im_url3 = jucailinCockpitUtils.getUfPropData(im_pkey3,tenantKey); + imMap.put("count",im_count3); + imMap.put("name",im_name3); + imMap.put("url",im_url3); + datalist.add(imMap); + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return datalist; + } + + + public List> getCalendarDate(SimpleEmployee employee,String tenantKey) { + + List> datalist = new ArrayList<>(100); + try { + long employeeId = employee.getEmployeeId(); + + Map calendarMap = new HashMap(); + String calendar_count = getCalendarDateAmount(employeeId,"1",tenantKey); + String calendar_name = "日程"; + String calendar_pkey = "calendar.create.amount"; + String calendar_url = jucailinCockpitUtils.getUfPropData(calendar_pkey,tenantKey); + calendarMap.put("count",calendar_count); + calendarMap.put("name",calendar_name); + calendarMap.put("url",calendar_url); + datalist.add(calendarMap); + + calendarMap = new HashMap(); + String calendar_count2 = getCalendarDateAmount(employeeId,"2",tenantKey); + String calendar_name2 = "我的任务"; + String calendar_pkey2 = "task.mine.amount"; + String calendar_url2 = jucailinCockpitUtils.getUfPropData(calendar_pkey2,tenantKey); + calendarMap.put("count",calendar_count2); + calendarMap.put("name",calendar_name2); + calendarMap.put("url",calendar_url2); + datalist.add(calendarMap); + + calendarMap = new HashMap(); + String calendar_count3 = getCalendarDateAmount(employeeId,"3",tenantKey); + String calendar_name3 = "关注任务"; + String calendar_pkey3 = "task.watch.amount"; + String calendar_url3 = jucailinCockpitUtils.getUfPropData(calendar_pkey3,tenantKey); + calendarMap.put("count",calendar_count3); + calendarMap.put("name",calendar_name3); + calendarMap.put("url",calendar_url3); + datalist.add(calendarMap); + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return datalist; + } + + + /** + * 获取文档数量 + * + * @param employeeId + * @return + */ + + public String getCoWorkDateAmount(Long employeeId,String type,String tenantKey) { + String count = "0"; + if("1".equals(type)){ + + String groupId = "weaver-cowork-service"; + String sourceType = "LOGIC"; + + String sql =" select count(1) as cou " + + " from cw_content " + + " where creator=?\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + }else if("2".equals(type)){ + + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + String sql =" select amount " + + " from uf_nj_pjmrdlhhsl " + + " where ry = ?\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("amount")); + } + }else if("3".equals(type)){ + + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + String sql =" select amount " + + " from uf_nj_cyqltjb " + + " where ry = ?\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("amount")); + } + } + return count; + } + + public String getDocumentDateAmount(Long employeeId,String type,String tenantKey) { + String count = "0"; + String groupId = "weaver-doc-service"; + String sourceType = "LOGIC"; + + try { + if("1".equals(type)){ + + int doccreatecount = docClientService.countByCreator(employeeId); + count = doccreatecount + ""; + + }else if("2".equals(type)){ + + String sql =" select count(1) as cou " + + " from document " + + " where id in( select targetid from doc_documentlogs where log_operator <> ? and operatetype = 'read' and delete_type = 0 and tenant_key=? and doc_status = 2 ) \n" + + " and creator = ?\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + }else if("3".equals(type)){ + String sql =" select count(1) as cou \n" + + " from doc_documentlogs \n" + + " where targetid in( select id from document where creator = ? and delete_type = 0 and tenant_key=? and doc_status = 2) \n" + + " and log_operator <> ? \n" + + " and OPERATETYPE = 'read' \n" + + " and delete_type = 0 \n" + + " and tenant_key=? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("getDocCreateNum:" + e); + } + + return count; + } + + + + public String getCalendarDateAmount(Long employeeId,String type,String tenantKey) { + String count = "0"; + String groupId = "weaver-doc-service"; + String sourceType = "LOGIC"; + + try { + if("1".equals(type)){ + + int clendarcount = remoteAgendaService.countCalendar(employeeId,tenantKey); + count = clendarcount + ""; + + }else if("2".equals(type)){ + + String sql =" select count(1) as cou " + + " from task " + + " where creator = ? \n" + + " and STATUS = 'todo'\n" + + " and delete_type = 0\n" + + " and tenant_key= ? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + }else if("3".equals(type)){ + String sql =" select count(1) as cou \n" + + " from my_watch \n" + + " where watcher = ? \n" + + " and module='task' \n" + + " and delete_type = 0 \n" + + " and tenant_key=? " ; + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setValue(employeeId+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenantKey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + if(recordList.size()>0){ + count = String.valueOf(recordList.get(0).get("cou")); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("getDocCreateNum:" + e); + } + + return count; + } + + /** + * + * @param employee + * @return + */ + public String getWorkflowDataAmount(SimpleEmployee employee,int Type) { + Map data = new HashMap<>(100); + String count = "0"; + try{ + RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); +// conditionEntity.setOperatedate(DateTimeConditionEnum.CURRENT_YEAR); + WeaResult requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, Type, conditionEntity); + int code = requestCountInfo.getCode(); + if(code == 200){ + RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData(); + count = String.valueOf(requestCountInfoPAEntity.getCount()); + } + } catch (Exception e) { + log.error("PortalWfDealCountCmd-Exception:" + e); + + } + return count; + } + + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkflowAnalysisCmd.java b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkflowAnalysisCmd.java new file mode 100644 index 0000000..7fca273 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/cmd/CockpitWorkflowAnalysisCmd.java @@ -0,0 +1,204 @@ +package com.weaver.seconddev.cockpit.cmd; + +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum; +import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity; +import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; + +/** + * 流程、日程、协助、文档 4个类型数据 + * + * @author shil + * @version 1.00版本 + * @Date 2024/5/22 + */ +@Component +public class CockpitWorkflowAnalysisCmd { + //日志 + private final static Logger log = LoggerFactory.getLogger(CockpitWorkDate4TypeCmd.class); + + @Autowired + private JucailinCockpitUtils jucailinCockpitUtils; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + public Map getDataInfo(SimpleEmployee employee, Map paramMap,String tenantKey) { + + Map recordMap = new HashMap(); + try { + List> dataList = getWorkflowDate(employee,tenantKey); + recordMap.put("leftdata",dataList); + Map chartMap = new HashMap(); + chartMap.put("项目管理类流程","16.6"); + chartMap.put("日常办公类流程","16.6"); + chartMap.put("行政事务类流程","40.8"); + chartMap.put("人事类流程","10.0"); + chartMap.put("销售类流程","8.6"); + recordMap.put("rightdata",chartMap); + } catch (Exception e) { + e.printStackTrace(); + log.error("PortalPerformanceInfoCmd :" + e); + } + return recordMap; + } + + /*** + * + * @return + */ + public List> getWorkflowDate(SimpleEmployee employee,String tenantKey) { + + List> wflist = new ArrayList<>(100); + try { + Map wfMap = new HashMap(); + String wf_count1 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid()); + String wf_name1 = "待处理流程数量"; + String wf_pkey1 = "workflow.todo.amount"; + String wf_url1 = jucailinCockpitUtils.getUfPropData(wf_pkey1,tenantKey); + wfMap.put("count",wf_count1); + wfMap.put("name",wf_name1); + wfMap.put("url",wf_url1); + wflist.add(wfMap); + + wfMap = new HashMap(); + String wf_count2 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid()); + String wf_name2 = "我创建的流程"; + String wf_pkey2 = "workflow.mine.amount"; + String wf_url2 = jucailinCockpitUtils.getUfPropData(wf_pkey2,tenantKey); + wfMap.put("count",wf_count2); + wfMap.put("name",wf_name2); + wfMap.put("url",wf_url2); + wflist.add(wfMap); + + wfMap = new HashMap(); + String wf_count3 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid()); + String wf_name3 = "我处理的流程"; + String wf_pkey3 = "workflow.done.amount"; + String wf_url3 = jucailinCockpitUtils.getUfPropData(wf_pkey3,tenantKey); + wfMap.put("count",wf_count3); + wfMap.put("name",wf_name3); + wfMap.put("url",wf_url3); + wflist.add(wfMap); + + + wfMap = new HashMap(); + String wf_count4 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.SUPERVISE_ALL.getTabid()); + String wf_name4 = "我督办的流程"; + String wf_pkey4 = "workflow.supervise.amount"; + String wf_url4 = jucailinCockpitUtils.getUfPropData(wf_pkey4,tenantKey); + wfMap.put("count",wf_count4); + wfMap.put("name",wf_name4); + wfMap.put("url",wf_url4); + wflist.add(wfMap); + + + wfMap = new HashMap(); + String wf_count5 = getWorkflowDataAmount(employee,RequestListInitDimensionTabEnum.ATTENTION_ALL.getTabid()); + String wf_name5 = "我关注的流程"; + String wf_pkey5 = "workflow.attention.amount"; + String wf_url5 = jucailinCockpitUtils.getUfPropData(wf_pkey5,tenantKey); + wfMap.put("count",wf_count5); + wfMap.put("name",wf_name5); + wfMap.put("url",wf_url5); + wflist.add(wfMap); + + wfMap = new HashMap(); + String wf_count6 = "2.6"; + String wf_name6 = "平均每天处理"; + String wf_pkey6 = "workflow.average.amount"; + String wf_url6 = jucailinCockpitUtils.getUfPropData(wf_pkey6,tenantKey); + wfMap.put("count",wf_count6); + wfMap.put("name",wf_name6); + wfMap.put("url",wf_url6); + wflist.add(wfMap); + + + } catch (Exception e) { + e.printStackTrace(); + log.error("DevQuestCountCmd-Exception:" + e); + } + return wflist; + } + + /** + * + * @param employee + * @return + */ + public String getWorkflowDataAmount(SimpleEmployee employee,int Type) { + String count = "0"; + try{ + RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); + WeaResult requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, Type, conditionEntity); + int code = requestCountInfo.getCode(); + if(code == 200){ + RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData(); + count = String.valueOf(requestCountInfoPAEntity.getCount()); + } + + } catch (Exception e) { + log.error("PortalWfDealCountCmd-Exception:" + e); + + } + return count; + } + + + /*** + * + * @param employee + * @param tenantKey + * @return + */ + public Map getWorkflowOperateAverageTime(SimpleEmployee employee,String tenantKey) { + String count = "0.0"; + try{ + RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); + WeaResult> requestListData = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid(), 1, 10, conditionEntity); + + int code = requestListData.getCode(); + if(code == 200){ + Long minutescount = 0L; + List requestCountInfoPAEntityList = requestListData.getData(); + int requestLength = requestCountInfoPAEntityList.size() ; + for(int i=0;i 0 && minutescount > 0){ + double average = minutescount/requestLength ; + count = String.valueOf(average); + } + } + } catch (Exception e) { + log.error("PortalWfDealCountCmd-Exception:" + e); + } + + Map wfMap = new HashMap(); + String wf_name1 = "平均流程处理时间"; + String wf_pkey1 = "workflow.time.amount"; + String wf_url1 = jucailinCockpitUtils.getUfPropData(wf_pkey1,tenantKey); + wfMap.put("count",count); + wfMap.put("name",wf_name1); + wfMap.put("url",wf_url1); + + return wfMap; + } + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/controller/JucailinCockpitController.java b/src/main/java/com/weaver/seconddev/cockpit/controller/JucailinCockpitController.java new file mode 100644 index 0000000..b2f9e42 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/controller/JucailinCockpitController.java @@ -0,0 +1,755 @@ +package com.weaver.seconddev.cockpit.controller; + +import com.weaver.common.authority.annotation.WeaPermission; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.framework.rpc.annotation.RpcReference; +import com.weaver.seconddev.cockpit.service.JucailinCockpitService; +import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils; +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.teams.security.context.UserContext; +import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; +import java.util.*; + + +@RestController +@RequestMapping("/api/secondev/njjucailin/cockpit") +public class JucailinCockpitController { + + private final Logger log = LoggerFactory.getLogger(JucailinCockpitController.class); + + public String tenant_key = "t7akvdnf84" ; + + @Autowired + private JucailinCockpitService jucailinCockpitService; + + @RpcReference(group = "workflow") + WflRequestListRest wflRequestListRest; + + @Autowired + private JucailinCockpitUtils jucailinCockpitUtils; + + + /** + * 绩效信息 + * @param request + * @return + */ + @GetMapping("/getMonthPerformanceData") + @WeaPermission(publicPermission = true) + public WeaResult getMonthPerformanceData(HttpServletRequest request){ + + Map recordMap = new HashMap(); + Map params = jucailinCockpitUtils.request2Map(request); + SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); + + try{ + recordMap = jucailinCockpitService.getMonthPerformanceData(simpleEmployee,params,tenant_key); + }catch (Exception e){ + log.error("testSapi-Exception:"+e); + } + + return WeaResult.success(recordMap); + } + + + /** + * 工作数据接口(根据职能分类返回不同数据) + * @param request + * @return + */ + @GetMapping("/getWorkAchievementsData") + @WeaPermission(publicPermission = true) + public WeaResult getWorkAchievementsData(HttpServletRequest request){ + log.error("getWorkData"); + Map dataList = new HashMap(); + SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); + Map params = jucailinCockpitUtils.request2Map(request); + + try{ + dataList = jucailinCockpitService.getWorkAchievementsData(simpleEmployee,params,tenant_key); + }catch (Exception e){ + log.error("getWorkData-Exception:"+e.getMessage()); + } + return WeaResult.success(dataList); + } + + + @GetMapping("/getUserData4Type") + @WeaPermission(publicPermission = true) + public WeaResult getUserData4Type(HttpServletRequest request){ + log.error("getWorkData"); + Map dataList = new HashMap(); + SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); + Map params = jucailinCockpitUtils.request2Map(request); + + try{ + dataList = jucailinCockpitService.getUserData4Type(simpleEmployee,params,tenant_key); + }catch (Exception e){ + log.error("getWorkData-Exception:"+e.getMessage()); + } + return WeaResult.success(dataList); + } + + + + @GetMapping("/getWorkflowAnalysis") + @WeaPermission(publicPermission = true) + public WeaResult getWorkflowAnalysis(HttpServletRequest request){ + log.error("getWorkData"); + Map dataList = new HashMap(); + SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); + Map params = jucailinCockpitUtils.request2Map(request); + + try{ + dataList = jucailinCockpitService.getWorkflowAnalysis(simpleEmployee,params,tenant_key); + }catch (Exception e){ + log.error("getWorkData-Exception:"+e.getMessage()); + } + return WeaResult.success(dataList); + } + + + + @GetMapping("/getBlogData") + @WeaPermission(publicPermission = true) + public WeaResult getBlogData(HttpServletRequest request){ + log.error("getWorkData"); + Map dataList = new HashMap(); + SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); + Map params = jucailinCockpitUtils.request2Map(request); + + try{ + dataList = jucailinCockpitService.getBlogData(simpleEmployee,params,tenant_key); + }catch (Exception e){ + log.error("getWorkData-Exception:"+e.getMessage()); + } + return WeaResult.success(dataList); + } + + + + + + + + +// +// +// +// +// +// /** +// * 人员基本信息接口 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalUser") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalUser(HttpServletRequest request){ +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// +// try{ +// recordMap = jucailinPortalService.getPortalUserData(simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalUser-Exception:"+e); +// } +// return WeaResult.success(recordMap); +// } +// +// /** +// * +// * @param request +// * @return +// */ +// @GetMapping("/getPortalAttendance") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalAttendance(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// +// Long employeeId = UserContext.getCurrentEmployeeId(); +// +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// +// try{ +// recordMap = jucailinPortalService.getPortalAttendanceData(simpleEmployee); +// }catch (Exception e){ +// log.error("testSapi-Exception:"+e); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// +// +// +// +// /** +// * 人员生日祝福 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalBirthdayWishes") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalBirthdayWishes(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// +// try{ +// recordMap = jucailinPortalService.getPortalBirthdayWishes(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalBirthdayWishes-Exception:"+e); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /** +// * 风险信息 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalRiskInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalRiskInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// +// try{ +// recordMap = jucailinPortalService.getPortalRiskInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalRiskInfo-Exception:"+e); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /** +// * 绩效信息 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalPerformanceInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalPerformanceInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalPerformanceInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalPerformanceInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// +// /** +// * 流程信息(我发起的) +// * @param request +// * @return +// */ +// @GetMapping("/getWorkFlowInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getWfInfoCreate(HttpServletRequest request){ +// +// List requestListInfoPAEntityList = new ArrayList(); +// try{ +// RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); +// SimpleEmployee employee = UserContext.getCurrentUser(); +// String keyword = CommonUtils.null2String(request.getParameter("keyword")); +// if(!"".equals(keyword)){ +// conditionEntity.setRequestname(keyword); +// } +// String type = CommonUtils.null2String(request.getParameter("type"),"0"); +// int pageSize = CommonUtils.getIntValue(request.getParameter("pageSize"),10); +// int pageNo = CommonUtils.getIntValue(request.getParameter("pageNo"),1); +// // 0 我发起的; 1 我的待办; 2 我的已办 +// if("0".equals(type)){ +// WeaResult> requestResult = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid(), pageNo, pageSize, conditionEntity); +// int code = requestResult.getCode(); +// if(code == 200){ +// requestListInfoPAEntityList = requestResult.getData(); +// } +// }else if("1".equals(type)){ +// WeaResult> requestResult = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid(), pageNo, pageSize, conditionEntity); +// +// int code = requestResult.getCode(); +// if(code == 200){ +// requestListInfoPAEntityList = requestResult.getData(); +// } +// +// }else if("2".equals(type)){ +// WeaResult> requestResult = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), pageNo, pageSize, conditionEntity); +// +// int code = requestResult.getCode(); +// if(code == 200){ +// requestListInfoPAEntityList = requestResult.getData(); +// } +// } +// }catch (Exception e){ +// log.error("getWorkFlowInfo-Exception:"+e.getMessage()); +// return WeaResult.fail(500,"程序执行异常"); +// } +// return WeaResult.success(requestListInfoPAEntityList); +// } +// +// /** +// * 流程信息(我发起的)数量 +// * @param request +// * @return +// */ +// @GetMapping("/getWorkFlowInfoCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getWorkFlowInfoCount(HttpServletRequest request){ +// int code = 0; +// long count = 0; +// Map dataMap = new HashMap(); +// String type = CommonUtils.null2String(request.getParameter("type"),"0"); +// try { +// RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity(); +// String keyword = CommonUtils.null2String(request.getParameter("keyword")); +// +// if(!"".equals(keyword)){ +// conditionEntity.setRequestname(keyword); +// } +// SimpleEmployee employee = UserContext.getCurrentUser(); +// +// if("0".equals(type)){ +// WeaResult requestResult = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid(), conditionEntity); +// +// code = requestResult.getCode(); +// if(code == 200){ +// RequestCountInfoPAEntity requestCountInfoPAEntity = requestResult.getData(); +// count = requestCountInfoPAEntity.getCount(); +// } +// }else if("1".equals(type)){ +// WeaResult requestResult = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid(), conditionEntity); +// +// code = requestResult.getCode(); +// if(code == 200){ +// RequestCountInfoPAEntity requestCountInfoPAEntity = requestResult.getData(); +// count = requestCountInfoPAEntity.getCount(); +// } +// +// }else if("2".equals(type)){ +// WeaResult requestResult = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity); +// +// code = requestResult.getCode(); +// if(code == 200){ +// RequestCountInfoPAEntity requestCountInfoPAEntity = requestResult.getData(); +// count = requestCountInfoPAEntity.getCount(); +// } +// }else{ +// WeaResult requestResult = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid(), conditionEntity); +// +// code = requestResult.getCode(); +// if(code == 200){ +// RequestCountInfoPAEntity requestCountInfoPAEntity = requestResult.getData(); +// count = requestCountInfoPAEntity.getCount(); +// } +// } +// dataMap.put("code",code); +// dataMap.put("count",count); +// } catch (Exception e) { +// e.printStackTrace(); +// log.error("testSapi10:"+e); +// dataMap.put("count","-1"); +// dataMap.put("code","500"); +// } +// return WeaResult.success(dataMap); +// } +// +// /*** +// * 本年沟通协作数 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalInteractCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalInteractCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalInteractCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalInteractCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// /*** +// * 本年文档贡献数 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalDocCreateCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalDocCreateCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalDocCreateCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalDocCreateCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 本年流程处理数量 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalWfDealCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalWfDealCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalWfDealCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalWfDealCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// /*** +// * 本年日报数量 +// * @param request +// * @return +// */ +// @GetMapping("/getPortalDailyCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalDailyCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalDailyCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalDailyCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 本年人员综合信息(沟通协作数+文档贡献度+处理流程数+微博数量) +// * @param request +// * @return +// */ +// @GetMapping("/getPortalCollaborationInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPortalCollaborationInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getPortalCollaborationInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPortalCollaborationInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// +// /*** +// * 项目人员验收信息 +// * @param request +// * @return +// */ +// @GetMapping("/getPorojectAcceptanceInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPorojectAcceptanceInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getProjectAcceptanceInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPorojectAcceptanceInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 项目人员收款信息 +// * @param request +// * @return +// */ +// @GetMapping("/getPorojectReceiptsInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPorojectReceiptsInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getProjectReceiptsInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPorojectReceiptsInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 项目人员综合信息(收款信息+验收信息) +// * @param request +// * @return +// */ +// @GetMapping("/getPorojectCollaborationInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getPorojectCollaborationInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getProjectCollaborationInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getPorojectCollaborationInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 开发人员问题支持数量 +// * @param request +// * @return +// */ +// @GetMapping("/getDevQuestCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getDevQuestCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getDevQuestCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getDevQuestCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 开发人员人员支持数量 +// * @param request +// * @return +// */ +// @GetMapping("/getDevDaysCount") +// @WeaPermission(publicPermission = true) +// public WeaResult getDevDaysCount(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getDevDaysCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getDevDaysCount-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /*** +// * 开发人员综合信息 +// * @param request +// * @return +// */ +// @GetMapping("/getDevCollaborationInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult getDevCollaborationInfo(HttpServletRequest request){ +// +// Map recordMap = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// recordMap = jucailinPortalService.getDevCollaborationInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getDevCollaborationInfo-Exception:"+e.getMessage()); +// } +// +// return WeaResult.success(recordMap); +// } +// +// +// /** +// * 自助服务信息入口 +// * @param request +// * @return +// */ +// @GetMapping("/selfServiceInfo") +// @WeaPermission(publicPermission = true) +// public WeaResult selfServiceInfo(HttpServletRequest request){ +// log.error("selfServiceInfo"); +// Map dataList = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// dataList = jucailinPortalService.getSelfServiceInfo(request,simpleEmployee); +// }catch (Exception e){ +// log.error("selfServiceInfo-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataList); +// } +// +// +// /** +// * 自助服务(新增点击次数接口) +// * @param request +// * @return +// */ +// @GetMapping("/addSelfServiceCount") +// @WeaPermission(publicPermission = true) +// public WeaResult addSelfServiceCount(HttpServletRequest request){ +// log.error("addSelfServiceCount"); +// Map dataList = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// dataList = jucailinPortalService.addSelfServiceCount(request,simpleEmployee); +// }catch (Exception e){ +// log.error("addSelfServiceCount-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataList); +// } +// +// + +// +// +// /** +// * 工作数据接口(根据职能分类返回不同数据) +// * @param request +// * @return +// */ +// @GetMapping("/getWorkDataByType") +// @WeaPermission(publicPermission = true) +// public WeaResult getWorkDataByType(HttpServletRequest request){ +// log.error("getWorkDataByType"); +// Map dataList = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// dataList = jucailinPortalService.getWorkDataByType(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getWorkDataByType-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataList); +// } +// +// +// /** +// * 用户类型 +// * @param request +// * @return +// */ +// @GetMapping("/getUserType") +// @WeaPermission(publicPermission = true) +// public WeaResult getUserType(HttpServletRequest request){ +// log.error("getUserType"); +// Map dataList = new HashMap(); +// SimpleEmployee simpleEmployee = UserContext.getCurrentUser(); +// try{ +// dataList = jucailinPortalService.getUserType(request,simpleEmployee); +// }catch (Exception e){ +// log.error("getUserType-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataList); +// } +// +// +// /** +// * 自助服务(新增点击次数接口) +// * @param request +// * @return +// */ +// @GetMapping("/initSelfServiceData") +// @WeaPermission(publicPermission = true) +// public WeaResult initSelfServiceData(HttpServletRequest request){ +// log.error("initSelfServiceData"); +// Map dataMap = new HashMap(); +// +// try{ +// SimpleEmployee employee = UserContext.getCurrentUser(); +// +// String employeeId = request.getParameter("employeeId"); +// if(StringUtils.isBlank(employeeId)){ +// employeeId = String.valueOf(employee.getEmployeeId()); +// } +// log.error("employeeId:"+employeeId); +// +// Map paramMap = jucailinPortalUtils.request2Map(request); +// paramMap.put("employeeId",employeeId); +// +// dataMap = jucailinPortalService.initSelfServiceData(paramMap); +// }catch (Exception e){ +// log.error("addSelfServiceCount-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataMap); +// } +// +// +// /** +// * 自助服务(新增点击次数接口) +// * @param request +// * @return +// */ +// @GetMapping("/updateSelfServiceData") +// @WeaPermission(publicPermission = true) +// public WeaResult updateSelfServiceData(HttpServletRequest request){ +// log.error("updateSelfServiceData"); +// Map dataMap = new HashMap(); +// try{ +// String employeeId = request.getParameter("employeeId"); +// if(StringUtils.isBlank(employeeId)){ +// employeeId = String.valueOf(UserContext.getCurrentEmployeeId()); +// } +// log.error("employeeId:"+employeeId); +// dataMap = jucailinPortalService.updateSelfServiceData(employeeId); +// }catch (Exception e){ +// log.error("addSelfServiceCount-Exception:"+e.getMessage()); +// } +// return WeaResult.success(dataMap); +// } + + + + + + + + + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/service/JucailinCockpitService.java b/src/main/java/com/weaver/seconddev/cockpit/service/JucailinCockpitService.java new file mode 100644 index 0000000..3e3f752 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/service/JucailinCockpitService.java @@ -0,0 +1,19 @@ +package com.weaver.seconddev.cockpit.service; + +import com.weaver.teams.domain.user.SimpleEmployee; + +import java.util.Map; + +public interface JucailinCockpitService { + + Map getMonthPerformanceData(SimpleEmployee simpleEmployee,Map paramMap,String tenantKey); + + Map getWorkAchievementsData(SimpleEmployee simpleEmployee,Map paramMap,String tenantKey); + + Map getUserData4Type(SimpleEmployee simpleEmployee,Map paramMap,String tenantKey); + + Map getWorkflowAnalysis(SimpleEmployee simpleEmployee,Map paramMap,String tenantKey); + + Map getBlogData(SimpleEmployee simpleEmployee,Map paramMap,String tenantKey); + +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/service/impl/JucailinCockpitServiceimpl.java b/src/main/java/com/weaver/seconddev/cockpit/service/impl/JucailinCockpitServiceimpl.java new file mode 100644 index 0000000..48837c9 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/service/impl/JucailinCockpitServiceimpl.java @@ -0,0 +1,56 @@ +package com.weaver.seconddev.cockpit.service.impl; + +import com.weaver.seconddev.cockpit.cmd.CockpitMonthPerformanceInfoCmd; +import com.weaver.seconddev.cockpit.cmd.CockpitWorkAchievementsCmd; +import com.weaver.seconddev.cockpit.cmd.CockpitWorkDate4TypeCmd; +import com.weaver.seconddev.cockpit.service.JucailinCockpitService; +import com.weaver.teams.domain.user.SimpleEmployee; +import groovy.util.logging.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.*; + +@Slf4j +@Service +public class JucailinCockpitServiceimpl implements JucailinCockpitService { + @Autowired + private CockpitMonthPerformanceInfoCmd cockpitMonthPerformanceInfoCmd; + + @Autowired + private CockpitWorkAchievementsCmd cockpitWorkAchievementsCmd; + + @Autowired + private CockpitWorkDate4TypeCmd cockpitWorkDate4TypeCmd; + + + @Override + public Map getMonthPerformanceData(SimpleEmployee simpleEmployee, Map paramMap,String tenantKey) { + + Map dataMap = cockpitMonthPerformanceInfoCmd.getDataInfo(simpleEmployee,paramMap,tenantKey); + return dataMap; + } + + @Override + public Map getWorkAchievementsData(SimpleEmployee simpleEmployee, Map paramMap, String tenantKey) { + Map dataMap = cockpitWorkAchievementsCmd.getDataInfo(simpleEmployee,paramMap,tenantKey); + return dataMap; + } + + @Override + public Map getUserData4Type(SimpleEmployee simpleEmployee, Map paramMap, String tenantKey) { + Map dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey); + return dataMap; + } + + @Override + public Map getWorkflowAnalysis(SimpleEmployee simpleEmployee, Map paramMap, String tenantKey) { + Map dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey); + return dataMap; + } + + @Override + public Map getBlogData(SimpleEmployee simpleEmployee, Map paramMap, String tenantKey) { + Map dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey); + return dataMap; + } +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/util/CommonUtils.java b/src/main/java/com/weaver/seconddev/cockpit/util/CommonUtils.java new file mode 100644 index 0000000..60b6d82 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/util/CommonUtils.java @@ -0,0 +1,395 @@ +package com.weaver.seconddev.cockpit.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.Map; + +@Component +public class CommonUtils { + + private final static Logger log = LoggerFactory.getLogger(CommonUtils.class); + + public static JSONObject toJSON(String data){ + if(!StringUtils.isEmpty(data)){ + try { + return JSONObject.parseObject(data); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return null; + } + + public static Long getJSONLong(JSONObject json,String key){ + if(json != null && json.containsKey(key)){ + try { + return json.getLong(key); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return null; + } + + public static Integer getJSONInteger(JSONObject json,String key){ + if(json != null && json.containsKey(key)){ + try { + return json.getInteger(key); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return -1; + } + + public static String getJSONString(JSONObject json,String key){ + if(json != null && json.containsKey(key)){ + try { + return null2String(json.getString(key)); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return ""; + } + + public static JSONObject getJSONObject(JSONObject json,String key){ + if(json != null && json.containsKey(key)){ + try { + return json.getJSONObject(key); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return null; + } + + public static JSONArray getJSONArray(JSONObject json, String key){ + if(json != null && json.containsKey(key)){ + try { + return json.getJSONArray(key); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return null; + } + + public static JSONObject getJSONObject(JSONArray json, int idx){ + if(json != null && json.size() > idx){ + try { + return json.getJSONObject(idx); + }catch (Throwable t){ + log.error(t.getMessage(),t); + } + } + return null; + } + + public static String mapToStrData(Map para){ + if(para != null) { + return JSONObject.toJSON(para).toString(); + } + return ""; + } + + public static void strToLongList(List list,String strs){ + strToLongList(list,strs,true); + } + + public static void strToLongList(List list,String strs,boolean isDist){ + if(list == null){ + return; + } + if(StringUtils.isEmpty(strs)){ + return; + } + + String[] strList = StringUtils.split(strs, ","); + for(String str:strList){ + if(StringUtils.isEmpty(str)){ + continue; + } + + long id = getLongValue(str); + if(id > 0l && (isDist == false || !list.contains(id))){ + list.add(id); + } + } + } + + public static long getLongValue(Object v){ + return getLongValue(null2String(v)); + } + + public static long getLongValue(String v) { + return getLongValue(v, -1); + } + + public static long getLongValue(String v, long def) { + try { + return Long.parseLong(v); + } catch (Exception ex) { + return def; + } + } + + public static int getIntValue(Object o){ + return getIntValue(null2String(o)); + } + + public static int getIntValue(String s){ + return getIntValue(s,-1); + } + + public static int getIntValue(String s, int def){ + try { + return NumberUtils.toInt(s); + } catch (Exception ex) { + return def; + } + + } + + public static String null2String(Object s) { + return s == null ? "" : s.toString(); + } + + public static String null2String(Object s, String def) { + return s == null ? (def == null ? "" : def) : s.toString(); + } + + + public static String stringReplace(String sou, String s1, String s2) { + //int idx = sou.indexOf(s1); + //if (idx < 0) { + // return sou; + //} + //return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2); + sou = null2String(sou); + s1 = null2String(s1); + s2 = null2String(s2); + try{ + sou = sou.replace(s1, s2); + }catch(Exception e){ + //System.out.println(e);//将未知异常打印出来,便于检查错误。 + } + return sou; + } + + /** + * 替换特殊字符 + * + * @param s 要替换特殊的字符串 + * @return 替换完成的字符串 + */ + public static String toScreen(String s) { + char c[] = s.toCharArray(); + char ch; + int i = 0; + StringBuffer buf = new StringBuffer(); + + while (i < c.length) { + ch = c[i++]; + + if (ch == '\r') + buf.append(""); + else if (ch == '\n') + buf.append(""); + else + buf.append(ch); + } + return buf.toString(); + } + + /** + * 替换特殊字符 + * + * @param s 要替换特殊的字符串 + * @return 替换完成的字符串 + */ + public static String toExcel(String s) { + if (s == null) return ""; + //因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码 + s = s.replaceAll("€", "\u20AC"); + String str = toScreen(s); + str = stringReplace(str, "∠", "∠"); + str = stringReplace(str, "φ", "φ"); + str = stringReplace(str, """, "\""); + str = stringReplace(str, " ", "%nbsp"); + //str=Util.StringReplace(str,"'","‘"); + str = stringReplace(str, "<", "<"); + str = stringReplace(str, ">", ">"); + str = stringReplace(str, "&dt;&at;", "
"); + str = stringReplace(str, "&", "&"); + str = stringReplace(str, "
", "&dt;&at;"); + if ("&dt;&at;".equals(str)) { + str = ""; + } + //在方法最后,又将欧元符号置换为转义符 + str = str.replaceAll("\u20AC", "€"); + return str; + } + + public static String delHtml(final String inputString) { + String htmlStr = toExcel(inputString); // 含html标签的字符串 + + String textStr = ""; + java.util.regex.Pattern p_script; + java.util.regex.Matcher m_script; + java.util.regex.Pattern p_html; + java.util.regex.Matcher m_html; + + try { + String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式 + + String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或]*?>[/s/S]*? + + p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE); + m_script = p_script.matcher(htmlStr); + htmlStr = m_script.replaceAll(""); // 过滤script标签 + + p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE); + m_html = p_html.matcher(htmlStr); + htmlStr = m_html.replaceAll(""); // 过滤html标签 + + textStr = htmlStr; + + } catch (Exception e) { + System.err.println("Html2Text: " + e.getMessage()); + } + + return htmlToTxt(textStr).trim();// 返回文本字符串 + } + + /** + * 删除字符串中的html格式 + * + * @param input + * @return + */ + public static String htmlToTxt(String input) { + if (input == null || input.trim().equals("")) { + return ""; + } + // 去掉所有html元素, + String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", ""); + return str; + } + + + //==new= + + public static int getIntValue(Object s, int def){ + return getIntValue(null2String(s)); + } + + public static List strToLongList(String strs){ + List list = new ArrayList(); + strToLongList(list,strs,true); + return list; + } + + + public static int dateInterval(String fromdate, String todate) { + Calendar fromcalendar = getCalendar(fromdate); + Calendar tocalendar = getCalendar(todate); + + if (fromcalendar == null || tocalendar == null) + return 0; + + return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000); + } + + /** + * @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12' + * @return 返回给定日历, 如果格式不正确,返回null + */ + public static Calendar getCalendar(String datetime) { + int datetimelength = datetime.length() ; + + switch(datetimelength) { + case 19 : + return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ; + case 10 : + return getCalendar(datetime , "yyyy'-'MM'-'dd") ; + default : + return null ; + } + + } + + + /** + * @param datetime - 给定的日期时间 + * @param formart - 给定的日期时间的格式 + * @return 返回给定日历, 如果格式不正确,返回null + */ + public static Calendar getCalendar(String datetime, String formart) { + SimpleDateFormat SDF = new SimpleDateFormat(formart) ; + + Calendar calendar = Calendar.getInstance() ; + try { + calendar.setTime(SDF.parse(datetime)) ; + } catch (ParseException e) { + return null ; + } + + return calendar ; + } + + /** + * @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd + * + * 返回当前时间字符,默认格式为yyyy'-'MM'-'dd + * + * 如 2004-09-07 + */ + public static String getCurrentDateString() { + String timestrformart = "yyyy'-'MM'-'dd" ; + SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ; + Calendar calendar = Calendar.getInstance() ; + + return SDF.format(calendar.getTime()) ; + } + + public static String getMessage(String msgMode,String key,String val){ + key = null2String(key).trim(); + val = null2String(val).trim(); + msgMode = null2String(msgMode).trim(); + if(!"".equals(msgMode) && !"".equals(key)) { + msgMode = msgMode.replaceAll(key, val); + } + return msgMode; + } + + public static List tranStrToLongList(Object idListObj){ + List docIds = new ArrayList(); + if(idListObj != null) { + try { + JSONArray idObjs = JSONArray.parseArray(null2String(idListObj)); + for (Object idObj : idObjs) { + long id = getLongValue(idObj); + if (id > 0l) { + docIds.add(id); + } + } + } catch (Exception e) { + log.error("trans error :{}", idListObj); + log.error(e.getMessage(), e); + } + } + return docIds; + } +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/util/DatabaseUtils.java b/src/main/java/com/weaver/seconddev/cockpit/util/DatabaseUtils.java new file mode 100644 index 0000000..5324027 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/util/DatabaseUtils.java @@ -0,0 +1,293 @@ +package com.weaver.seconddev.cockpit.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSONObject; +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto; +import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery; +import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery; +import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery; +import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity; +import com.weaver.ebuilder.datasource.api.enums.SourceType; +import com.weaver.ebuilder.datasource.api.service.DataSetService; +import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。 + */ + + +@Component +public class DatabaseUtils { + + private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class); + + @Autowired + private DataSetService dataSetService; + + @Autowired + private EbFormDataService dataService; + + + /** + * 执行 SQL 并返回结果。 + * + * @param entity 包含执行 SQL 的相关信息的对象 + * @return 包含查询结果的 Map 对象 + * @throws RuntimeException 当 SQL 执行失败时抛出异常 + */ + public Map executeSql(ExecuteSqlEntity entity) { + Map map = dataSetService.executeSql(entity); + if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) { + log.error("sql执行失败=>{}", JSONObject.toJSONString(map)); + throw new RuntimeException("sql执行异常"); + } else { + return map; + } + } + + /** + * 执行分页 SQL 查询并返回结果。 + * + * @param entity 包含执行 SQL 和分页信息的对象 + * @param pageNo 当前页码 + * @param pageSize 每页的数据条数 + * @return 包含查询结果的 Map 对象 + * @throws RuntimeException 当 SQL 执行失败时抛出异常 + */ + public Map executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) { + entity.setPageNo(pageNo); + entity.setPageSize(pageSize); + Map map = dataSetService.executeForQuery(entity); + if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) { + log.error("sql执行失败=>{}", JSONObject.toJSONString(map)); + throw new RuntimeException("sql执行异常"); + } else { + return map; + } + } + + /** + * 创建一个包含执行 SQL 的对象。 + * + * @param sql 需要执行的 SQL + * @param groupId 数据源分组的 ID + * @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】 + * @return 包含执行 SQL 的对象 + */ + public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) { + log.error("sql=>{}", sql); + ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity(); + executeSqlEntity.setSql(base64(sql)); + executeSqlEntity.setGroupId(groupId); + executeSqlEntity.setSourceType(SourceType.LOGIC); + executeSqlEntity.setGroupKey("0"); + return executeSqlEntity; + } + + /** + * 对 SQL 进行 Base64 编码。 + * + * @param sql 需要进行编码的 SQL + * @return 编码后的字符串 + */ + public String base64(String sql) { + return Base64.encode(sql); + } + + /** + * 获取数据源列表。 + * + * @param map 包含数据源列表信息的 Map 对象 + * @return 数据源列表的 Map 对象 + */ + public List> getDataSourceList(Map map) { + List> entity = new ArrayList(); + if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) { + entity = (List) map.get("records"); + } + + return keyToLowerCase((List) entity); + } + + public Map getOneDataSource(Map map) { + List> entity = getDataSourceList(map); + return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap()); + } + + /** + * 将 Map 对象中的键转换为小写。 + * + * @param orgMapList 需要转换键的 Map 对象列表 + * @return 转换后的 Map 对象列表 + */ + public List> keyToLowerCase(List> orgMapList) { + List> resultList = new ArrayList(); + Iterator var2 = orgMapList.iterator(); + + while (var2.hasNext()) { + Map stringObjectMap = (Map) var2.next(); + resultList.add(keyToLowerCase(stringObjectMap)); + } + + return resultList; + } + + /** + * 将 Map 对象中的键转换为小写。 + * + * @param orgMap 需要转换键的 Map 对象 + * @return 转换后的 Map 对象 + */ + public Map keyToLowerCase(Map orgMap) { + Map resultMap = new HashMap(); + if (orgMap != null && !orgMap.isEmpty()) { + Set> entrySet = orgMap.entrySet(); + Iterator var3 = entrySet.iterator(); + + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + String key = (String) entry.getKey(); + Object value = entry.getValue(); + resultMap.put(key.toLowerCase(), value); + } + return resultMap; + } else { + return resultMap; + } + } + + + /** + * 根据数据库类型 找到对应数据库 + * + * @param sourceType sourceType 枚举类 + * ETEAMS :数据仓库 + * FORM: ebuilder表单 + * LOGIC: 各模块提供业务数据(逻辑表) + * EXTERNAL: 外部数据源 + * @return + */ + public List> getDataGroups(String sourceType, Boolean flag) { + GroupQuery query = new GroupQuery(); + query.setSourceType(SourceType.valueOf(sourceType)); + query.setShowSqlDataset(flag); + + + DynamicParamDto dynamicParamDto = new DynamicParamDto(); + dynamicParamDto.setUserId(10000L); + dynamicParamDto.setTenantKey("tk"); + + query.setDynamicParamDto(dynamicParamDto); + + return dataSetService.getDataGroups(query); + } + + + /** + * 获取数据表 + * + * @param sourceType + * @param groupId + * @param pageNum + * @param pageSize + * @return + */ + public Map getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) { + + TableQuery tableQuery = new TableQuery(); + tableQuery.setSourceType(SourceType.valueOf(sourceType)); + tableQuery.setGroupId(groupId); + //非必传 + //tableQuery.setName(name); + tableQuery.setPageNo(pageNum); + tableQuery.setPageSize(pageSize); + return dataSetService.getDataSetsByPage(tableQuery); + } + + /** + * 获取表字段 + * sourceType :LOGIC + * sourceId : 8494845523559165780 + * groupId : weaver-crm-service + * + * @param + * @return + */ + public List> getFields(String sourceType, String sourceId, String groupId) { + FieldQuery query = new FieldQuery(); + query.setSourceType(SourceType.valueOf(sourceType)); + query.setSourceId(sourceId); + query.setGroupId(groupId); + return dataSetService.getFields(query); + } + + /** + * 执行sql + * sourceType :LOGIC + * groupId : weaver-ebuilder-app-service + * sql : select * from ebda_app limit 10 + * + * @param + * @return + */ + public Map execute(String sourceType, String groupId, String sql) { + //执行sql 参数sourceType groupId sql + ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity(); + executeSqlEntity.setSql(base64(sql)); + executeSqlEntity.setGroupId(groupId); + executeSqlEntity.setSourceType(SourceType.valueOf(sourceType)); + return dataSetService.executeSql(executeSqlEntity); + } + + + public Map executeForQuery(String sourceType, String groupId, String sql,List sqlparam) { + //执行sql 参数sourceType groupId sql sqlparam + ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity(); + executeSqlEntity.setSql(base64(sql)); + executeSqlEntity.setGroupId(groupId); + executeSqlEntity.setSourceType(SourceType.valueOf(sourceType)); + executeSqlEntity.setParams(sqlparam); + return dataSetService.executeSql(executeSqlEntity); + } + + public String getMysqlPagedSql(String sql,int pageNo, int pageSize) { + if(pageNo<=0){ + pageNo = 1; + } + + if(pageSize<=0){ + pageSize = 20; + } + + int start = (pageNo-1)*pageSize; + int end = pageNo*pageSize; + + return new StringBuffer().append(sql).append( + " LIMIT "+start+","+(end-start)).toString(); + } + + /** + * 获取sql入参 + * @param list + * @return + */ + public List getSqlParamEntity(List list){ + List sqlparam = new ArrayList(); + for (String str : list){ + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(str); + sqlparam.add(sqlParamEntity); + } + return sqlparam; + } +} diff --git a/src/main/java/com/weaver/seconddev/cockpit/util/JucailinCockpitUtils.java b/src/main/java/com/weaver/seconddev/cockpit/util/JucailinCockpitUtils.java new file mode 100644 index 0000000..464f2f3 --- /dev/null +++ b/src/main/java/com/weaver/seconddev/cockpit/util/JucailinCockpitUtils.java @@ -0,0 +1,160 @@ +package com.weaver.seconddev.cockpit.util; + +import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; +import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.ebuilder.form.client.entity.data.*; +import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService; +import com.weaver.framework.rpc.annotation.RpcReference; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +public class JucailinCockpitUtils { + + private final Logger log = LoggerFactory.getLogger(JucailinCockpitUtils.class); + + + @Autowired + private DatabaseUtils databaseUtils; + + + @RpcReference(group="ebuilderform") + private RemoteSimpleDataService remoteSimpleDataService; + + + + /*** + * + * @param pkey + * @param tenant_key + * @return + */ + public String getUfPropData(String pkey,String tenant_key) { + String pvalue = "" ; + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + try{ + log.error("pkey:"+pkey); + if(StringUtils.isNotBlank(pkey)) + { + String dataSql =" select pvalue \n" + + " from uf_nj_prop \n" + + " where pkey = ? \n" + + " and delete_type = 0 \n" + + " and tenant_key='"+tenant_key+"'" ; + + log.error("dataSql:"+dataSql); + + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(pkey); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + log.error("recordList:"+recordList.size()); + + if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) { + Map recordMap = recordList.get(0); + if(recordMap.containsKey("pvalue")){ + pvalue = String.valueOf(recordMap.get("pvalue")); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("getUfPropData-Exception:"+e); + } + return pvalue; + } + + + public void saveModeData(String objId,String operator,String tenant_key,List datas){ + + log.error("saveModeData-objid:"+objId); + log.error("saveModeData-operator:"+operator); + log.error("saveModeData-tenant_key:"+tenant_key); + log.error("saveModeData-datas:"+datas.size()); + EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto(); + // 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户 + ebDataChangeReqDto.setHeader(new EBDataReqHeader(objId, operator,tenant_key)); + + ebDataChangeReqDto.setDatas(datas); + EBDataChangeResult insertEbDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto); + log.error("insertEbDataChangeResult:"+insertEbDataChangeResult.getMessage()); + log.error("insertEbDataChangeResult:"+insertEbDataChangeResult.toString()); + log.error("insertEbDataChangeResult:"+insertEbDataChangeResult.getStatus()); + } + + + /*** + * + */ + public void updateModeDataById(String objId,String operator,String tenant_key,List datas,boolean isNeedAdd){ + /** + * 直接通过id更新数据, 即update table set a = '11' where id = 1 + */ + EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto(); + // 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户 + ebDataChangeReqDto.setHeader(new EBDataReqHeader(objId, operator, tenant_key)); + // 请求操作信息 + EBDataReqOperation ebDataReqOperation = new EBDataReqOperation(); + ebDataReqOperation.setUpdateType(EBDataUpdateType.ids); + // 数据没有找到的时候是否新增数据 + EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo(); + ebDataReqOperationInfo.setNeedAdd(isNeedAdd); + ebDataReqOperation.setMainData(ebDataReqOperationInfo); + ebDataChangeReqDto.setOperation(ebDataReqOperation); + + ebDataChangeReqDto.setDatas(datas); + EBDataChangeResult updateEbDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto); + + log.error("updateEbDataChangeResult:"+updateEbDataChangeResult.getMessage()); + log.error("updateEbDataChangeResult:"+updateEbDataChangeResult.toString()); + log.error("updateEbDataChangeResult:"+updateEbDataChangeResult.getStatus()); + } + + + /*** + * + * @param request + * @return + */ + public Map request2Map(HttpServletRequest request) { + // 参数Map + Map properties = request.getParameterMap(); + // 返回值Map + Map returnMap = new HashMap(); + Iterator entries = properties.entrySet().iterator(); + Map.Entry entry; + String name = ""; + Object value = null; + while (entries.hasNext()) { + entry = (Map.Entry) entries.next(); + name = (String) entry.getKey(); + Object valueObj = entry.getValue(); + if (null == valueObj) { + value = null; + } else if (valueObj instanceof String[]) { + String[] values = (String[]) valueObj; + if (values.length == 1) { + value = values[0]; + } else { + value = values; + } + } else { + value = valueObj.toString(); + } + returnMap.put(name, value); + } + return returnMap; + } + + +}