#E10-37# 聚才林驾驶舱接口

main
shilei 11 months ago
parent 1a3ca73a5d
commit 9d647996e7

@ -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<String, Object> getDataInfo(SimpleEmployee simpleEmployee, Map<String, Object> paramMap,String tenantKey) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> recordMap = new HashMap<String, Object>();
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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
List<Map<String,Object>> blogList = new ArrayList<Map<String,Object>>();
Map<String,Object> blogMap = null;
if(recordList.size()>0){
for(int i=0;i<recordList.size();i++){
Map<String,Object> 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<String,Object>();
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;
}
}

@ -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<String, Object> getDataInfo(SimpleEmployee employee, Map<String, Object> paramMap,String tenantKey) {
Map<String, Object> recordMap = new HashMap<String, Object>();
try {
List<Map<String,String>> dataList = getDocumentDate(employee,tenantKey);
recordMap.put("leftdata",dataList);
Map<String,String> chartMap = new HashMap<String,String>();
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<Map<String,String>> getDocumentDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> doclist = new ArrayList<>(100);
try {
long employeeId = employee.getEmployeeId();
Map<String,String> docMap = new HashMap<String,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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;
}
}

@ -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<String, Object> getDataInfo(SimpleEmployee simpleEmployee, Map<String, Object> paramMap,String tenantKey) {
Map<String, Object> dataMap = new HashMap<String, Object>(100);
String dateType = "month";
try {
long employeeId = simpleEmployee.getEmployeeId();
List<Long> userList = new ArrayList<Long>();
userList.add(employeeId);
LocalDate currentDate = LocalDate.now();
Map<String, Object> scoreMap = new HashMap<String, Object>();
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<Long> 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<FlowDataListRes> 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;
}
}

@ -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<String, Object> getDataInfo(SimpleEmployee simpleEmployee, Map<String, Object> paramMap,String tenantKey) {
Map<String, Object> recordMap = new HashMap<String, Object>();
List<Map<String,String>> list = new ArrayList<>(100);
Map<String,String> oneMap = new HashMap<>(100);
Map<String,String> twoMap = new HashMap<>(100);
Map<String,String> threeMap = new HashMap<>(100);
Map<String,String> 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<Long> 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<FlowDataListRes> 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<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startday);
strlist.add(endday);
strlist.add(tenantKey);
strlist.add(tenantKey);
strlist.add(tenantKey);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setValue(formdata+"");
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startday);
strlist.add(endday);
strlist.add(tenantKey);
strlist.add(tenantKey);
strlist.add(tenantKey);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
log.info("DevDaysCountCmd sql:" + dataSql);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> 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<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startday);
strlist.add(endday);
strlist.add(tenantKey);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql, sqlparam);
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
if (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<RequestCountInfoPAEntity> 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<String> 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<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(!CollectionUtils.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<String> 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<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startday);
strlist.add(endday);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(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<String> strlist = new ArrayList<>(100);
strlist.add(employeeId);
strlist.add(startday);
strlist.add(endday);
strlist.add(tenantKey);
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(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();
}
}

@ -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<String, Object> getDataInfo(SimpleEmployee employee, Map<String, Object> paramMap,String tenantKey) {
Map<String, Object> recordMap = new HashMap<String, Object>();
List<Map<String,String>> wfList = new ArrayList<Map<String,String>>();
List<Map<String,String>> docList = new ArrayList<Map<String,String>>();
List<Map<String,String>> coworkList = new ArrayList<Map<String,String>>();
List<Map<String,String>> calendarList = new ArrayList<Map<String,String>>();
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<Map<String,String>> getWorkflowDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> wflist = new ArrayList<>(100);
try {
Map<String,String> wfMap = new HashMap<String,String>();
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,String>();
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,String>();
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<Map<String,String>> getDocumentDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> doclist = new ArrayList<>(100);
try {
long employeeId = employee.getEmployeeId();
Map<String,String> docMap = new HashMap<String,String>();
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,String>();
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,String>();
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<Map<String,String>> getCoWorkDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> datalist = new ArrayList<>(100);
try {
long employeeId = employee.getEmployeeId();
Map<String,String> coworkMap = new HashMap<String,String>();
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<String,String> imMap = new HashMap<String,String>();
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,String>();
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<Map<String,String>> getCalendarDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> datalist = new ArrayList<>(100);
try {
long employeeId = employee.getEmployeeId();
Map<String,String> calendarMap = new HashMap<String,String>();
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,String>();
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,String>();
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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
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<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> 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<String,Object> data = new HashMap<>(100);
String count = "0";
try{
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
// conditionEntity.setOperatedate(DateTimeConditionEnum.CURRENT_YEAR);
WeaResult<RequestCountInfoPAEntity> 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;
}
}

@ -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<String, Object> getDataInfo(SimpleEmployee employee, Map<String, Object> paramMap,String tenantKey) {
Map<String, Object> recordMap = new HashMap<String, Object>();
try {
List<Map<String,String>> dataList = getWorkflowDate(employee,tenantKey);
recordMap.put("leftdata",dataList);
Map<String,String> chartMap = new HashMap<String,String>();
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<Map<String,String>> getWorkflowDate(SimpleEmployee employee,String tenantKey) {
List<Map<String,String>> wflist = new ArrayList<>(100);
try {
Map<String,String> wfMap = new HashMap<String,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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,String>();
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<RequestCountInfoPAEntity> 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<String,String> getWorkflowOperateAverageTime(SimpleEmployee employee,String tenantKey) {
String count = "0.0";
try{
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
WeaResult<List<RequestListInfoPAEntity>> requestListData = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid(), 1, 10, conditionEntity);
int code = requestListData.getCode();
if(code == 200){
Long minutescount = 0L;
List<RequestListInfoPAEntity> requestCountInfoPAEntityList = requestListData.getData();
int requestLength = requestCountInfoPAEntityList.size() ;
for(int i=0;i<requestLength;i++){
RequestListInfoPAEntity requestListInfoPAEntity = requestCountInfoPAEntityList.get(i);
LocalDateTime receiveDateTime = requestListInfoPAEntity.getReceiveTime();
LocalDateTime operateDateTime = requestListInfoPAEntity.getOperateTime();
Long minutesDiff = ChronoUnit.MINUTES.between(receiveDateTime, operateDateTime);
minutescount += minutesDiff ;
}
if(requestLength > 0 && minutescount > 0){
double average = minutescount/requestLength ;
count = String.valueOf(average);
}
}
} catch (Exception e) {
log.error("PortalWfDealCountCmd-Exception:" + e);
}
Map<String,String> wfMap = new HashMap<String,String>();
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;
}
}

@ -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<Object> getMonthPerformanceData(HttpServletRequest request){
Map<String, Object> recordMap = new HashMap<String, Object>();
Map<String,Object> 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<Object> getWorkAchievementsData(HttpServletRequest request){
log.error("getWorkData");
Map<String, Object> dataList = new HashMap<String, Object>();
SimpleEmployee simpleEmployee = UserContext.getCurrentUser();
Map<String,Object> 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<Object> getUserData4Type(HttpServletRequest request){
log.error("getWorkData");
Map<String, Object> dataList = new HashMap<String, Object>();
SimpleEmployee simpleEmployee = UserContext.getCurrentUser();
Map<String,Object> 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<Object> getWorkflowAnalysis(HttpServletRequest request){
log.error("getWorkData");
Map<String, Object> dataList = new HashMap<String, Object>();
SimpleEmployee simpleEmployee = UserContext.getCurrentUser();
Map<String,Object> 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<Object> getBlogData(HttpServletRequest request){
log.error("getWorkData");
Map<String, Object> dataList = new HashMap<String, Object>();
SimpleEmployee simpleEmployee = UserContext.getCurrentUser();
Map<String,Object> 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<Object> getPortalUser(HttpServletRequest request){
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPortalAttendance(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
//
// 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<Object> getPortalBirthdayWishes(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
//
// 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<Object> getPortalRiskInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
//
// 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<Object> getPortalPerformanceInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getWfInfoCreate(HttpServletRequest request){
//
// List<RequestListInfoPAEntity> requestListInfoPAEntityList = new ArrayList<RequestListInfoPAEntity>();
// 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<List<RequestListInfoPAEntity>> 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<List<RequestListInfoPAEntity>> 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<List<RequestListInfoPAEntity>> 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<Object> getWorkFlowInfoCount(HttpServletRequest request){
// int code = 0;
// long count = 0;
// Map<String,Object> dataMap = new HashMap<String,Object>();
// 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<RequestCountInfoPAEntity> 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<RequestCountInfoPAEntity> 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<RequestCountInfoPAEntity> requestResult = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity);
//
// code = requestResult.getCode();
// if(code == 200){
// RequestCountInfoPAEntity requestCountInfoPAEntity = requestResult.getData();
// count = requestCountInfoPAEntity.getCount();
// }
// }else{
// WeaResult<RequestCountInfoPAEntity> 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<Object> getPortalInteractCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPortalDocCreateCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPortalWfDealCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPortalDailyCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPortalCollaborationInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPorojectAcceptanceInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPorojectReceiptsInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getPorojectCollaborationInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getDevQuestCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getDevDaysCount(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> getDevCollaborationInfo(HttpServletRequest request){
//
// Map<String, Object> recordMap = new HashMap<String, Object>();
// 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<Object> selfServiceInfo(HttpServletRequest request){
// log.error("selfServiceInfo");
// Map<String, Object> dataList = new HashMap<String, Object>();
// 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<Object> addSelfServiceCount(HttpServletRequest request){
// log.error("addSelfServiceCount");
// Map<String, Object> dataList = new HashMap<String, Object>();
// 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<Object> getWorkDataByType(HttpServletRequest request){
// log.error("getWorkDataByType");
// Map<String, Object> dataList = new HashMap<String, Object>();
// 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<Object> getUserType(HttpServletRequest request){
// log.error("getUserType");
// Map<String, Object> dataList = new HashMap<String, Object>();
// 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<Object> initSelfServiceData(HttpServletRequest request){
// log.error("initSelfServiceData");
// Map<String, Object> dataMap = new HashMap<String, Object>();
//
// try{
// SimpleEmployee employee = UserContext.getCurrentUser();
//
// String employeeId = request.getParameter("employeeId");
// if(StringUtils.isBlank(employeeId)){
// employeeId = String.valueOf(employee.getEmployeeId());
// }
// log.error("employeeId:"+employeeId);
//
// Map<String, Object> 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<Object> updateSelfServiceData(HttpServletRequest request){
// log.error("updateSelfServiceData");
// Map<String, Object> dataMap = new HashMap<String, Object>();
// 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);
// }
}

@ -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<String, Object> getMonthPerformanceData(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getWorkAchievementsData(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getUserData4Type(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getWorkflowAnalysis(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getBlogData(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
}

@ -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<String, Object> getMonthPerformanceData(SimpleEmployee simpleEmployee, Map<String, Object> paramMap,String tenantKey) {
Map<String,Object> dataMap = cockpitMonthPerformanceInfoCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
@Override
public Map<String, Object> getWorkAchievementsData(SimpleEmployee simpleEmployee, Map<String, Object> paramMap, String tenantKey) {
Map<String,Object> dataMap = cockpitWorkAchievementsCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
@Override
public Map<String, Object> getUserData4Type(SimpleEmployee simpleEmployee, Map<String, Object> paramMap, String tenantKey) {
Map<String,Object> dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
@Override
public Map<String, Object> getWorkflowAnalysis(SimpleEmployee simpleEmployee, Map<String, Object> paramMap, String tenantKey) {
Map<String,Object> dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
@Override
public Map<String, Object> getBlogData(SimpleEmployee simpleEmployee, Map<String, Object> paramMap, String tenantKey) {
Map<String,Object> dataMap = cockpitWorkDate4TypeCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
}

@ -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<String, Object> para){
if(para != null) {
return JSONObject.toJSON(para).toString();
}
return "";
}
public static void strToLongList(List<Long> list,String strs){
strToLongList(list,strs,true);
}
public static void strToLongList(List<Long> 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("&euro;", "\u20AC");
String str = toScreen(s);
str = stringReplace(str, "&ang;", "∠");
str = stringReplace(str, "&phi;", "φ");
str = stringReplace(str, "&quot;", "\"");
str = stringReplace(str, "&nbsp", "%nbsp");
//str=Util.StringReplace(str,"'","");
str = stringReplace(str, "&lt;", "<");
str = stringReplace(str, "&gt;", ">");
str = stringReplace(str, "&dt;&at;", "<br>");
str = stringReplace(str, "&", "&amp;");
str = stringReplace(str, "<br>", "&dt;&at;");
if ("&dt;&at;".equals(str)) {
str = "";
}
//在方法最后,又将欧元符号置换为转义符
str = str.replaceAll("\u20AC", "&euro;");
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的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
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<Long> strToLongList(String strs){
List<Long> list = new ArrayList<Long>();
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<Long> tranStrToLongList(Object idListObj){
List<Long> docIds = new ArrayList<Long>();
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;
}
}

@ -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<String, Object> executeSql(ExecuteSqlEntity entity) {
Map<String, Object> 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<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
entity.setPageNo(pageNo);
entity.setPageSize(pageSize);
Map<String, Object> 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<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
List<Map<String, Object>> 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<String, Object> getOneDataSource(Map<String, Object> map) {
List<Map<String, Object>> entity = getDataSourceList(map);
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
}
/**
* Map
*
* @param orgMapList Map
* @return Map
*/
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
List<Map<String, Object>> resultList = new ArrayList();
Iterator var2 = orgMapList.iterator();
while (var2.hasNext()) {
Map<String, Object> stringObjectMap = (Map) var2.next();
resultList.add(keyToLowerCase(stringObjectMap));
}
return resultList;
}
/**
* Map
*
* @param orgMap Map
* @return Map
*/
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
Map<String, Object> resultMap = new HashMap();
if (orgMap != null && !orgMap.isEmpty()) {
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
Iterator var3 = entrySet.iterator();
while (var3.hasNext()) {
Map.Entry<String, Object> 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<Map<String, Object>> 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<String, Object> 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<Map<String, Object>> 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<String, Object> 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<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> 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<SqlParamEntity> getSqlParamEntity(List<String> list){
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
for (String str : list){
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(str);
sqlparam.add(sqlParamEntity);
}
return sqlparam;
}
}

@ -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<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(pkey);
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
log.error("recordList:"+recordList.size());
if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) {
Map<String,Object> 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<EBDataReqDto> 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<EBDataReqDto> 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<String, Object> request2Map(HttpServletRequest request) {
// 参数Map
Map properties = request.getParameterMap();
// 返回值Map
Map<String, Object> returnMap = new HashMap<String, Object>();
Iterator<Map.Entry> 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;
}
}
Loading…
Cancel
Save