#E10-47# 接口优化
parent
44393e45b6
commit
184b88fb00
@ -0,0 +1,133 @@
|
|||||||
|
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.cockpit.util.DatabaseUtils;
|
||||||
|
import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils;
|
||||||
|
import com.weaver.seconddev.jcldoor.util.CommonUtils;
|
||||||
|
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||||
|
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.common.entity.list.api.publicapi.RequestListInfoPAEntity;
|
||||||
|
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
||||||
|
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 org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
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 CockpitWorkflowAvgProcessTimeCmd {
|
||||||
|
//日志
|
||||||
|
private final static Logger log = LoggerFactory.getLogger(CockpitWorkflowAnalysisCmd.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JucailinCockpitUtils jucailinCockpitUtils;
|
||||||
|
|
||||||
|
@RpcReference(group = "workflow")
|
||||||
|
WflRequestListRest wflRequestListRest;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DatabaseUtils databaseUtils;
|
||||||
|
|
||||||
|
public Map<String, Object> getDataInfo(SimpleEmployee employee, Map<String, Object> paramMap,String tenantKey) {
|
||||||
|
|
||||||
|
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||||
|
try {
|
||||||
|
|
||||||
|
Map<String,String> wfMap = getWorkflowOperateAverageTime(employee,tenantKey);
|
||||||
|
recordMap.put("data",wfMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("PortalPerformanceInfoCmd :" + e);
|
||||||
|
}
|
||||||
|
return recordMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* @param employee
|
||||||
|
* @param tenantKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String,String> getWorkflowOperateAverageTime(SimpleEmployee employee,String tenantKey) {
|
||||||
|
String count = "0.0";
|
||||||
|
try{
|
||||||
|
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
|
||||||
|
conditionEntity.setOperatedate(DateTimeConditionEnum.CURRENT_YEAR);
|
||||||
|
|
||||||
|
int wfcount = 0 ;
|
||||||
|
WeaResult<RequestCountInfoPAEntity> requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity);
|
||||||
|
log.error("requestCountInfo--:"+requestCountInfo.toString());
|
||||||
|
int code1 = requestCountInfo.getCode();
|
||||||
|
log.error("code1--:"+code1);
|
||||||
|
if(code1 == 200){
|
||||||
|
RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData();
|
||||||
|
Long wf_count = requestCountInfoPAEntity.getCount();
|
||||||
|
log.error("wfcount--:"+wfcount);
|
||||||
|
wfcount = wf_count.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wfcount > 0){
|
||||||
|
WeaResult<List<RequestListInfoPAEntity>> requestListData = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), 1, wfcount, conditionEntity);
|
||||||
|
int code2 = requestListData.getCode();
|
||||||
|
if(code2 == 200){
|
||||||
|
Long minutescount = 0L;
|
||||||
|
List<RequestListInfoPAEntity> requestCountInfoPAEntityList = requestListData.getData();
|
||||||
|
int requestLength = requestCountInfoPAEntityList.size() ;
|
||||||
|
log.error("requestLength:"+requestLength);
|
||||||
|
for(int i=0;i<requestLength;i++){
|
||||||
|
RequestListInfoPAEntity requestListInfoPAEntity = requestCountInfoPAEntityList.get(i);
|
||||||
|
LocalDateTime receiveDateTime = requestListInfoPAEntity.getReceiveTime();
|
||||||
|
LocalDateTime operateDateTime = requestListInfoPAEntity.getOperateTime();
|
||||||
|
log.error("receiveDateTime:"+receiveDateTime);
|
||||||
|
log.error("operateDateTime:"+operateDateTime);
|
||||||
|
Long minutesDiff = ChronoUnit.MINUTES.between(receiveDateTime, operateDateTime);
|
||||||
|
log.error("minutesDiff:"+minutesDiff);
|
||||||
|
minutescount += minutesDiff ;
|
||||||
|
}
|
||||||
|
log.error("minutescount:"+minutescount);
|
||||||
|
if(requestLength > 0 && minutescount > 0){
|
||||||
|
double average = minutescount/(requestLength*1.0) ;
|
||||||
|
BigDecimal dividend = new BigDecimal(average);
|
||||||
|
dividend = dividend.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
count = dividend.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("PortalWfDealCountCmd-Exception:" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,String> wfMap = new HashMap<String,String>();
|
||||||
|
String wf_name1 = "平均流程处理时间";
|
||||||
|
String wf_pkey1 = "workflow.processtime.amount";
|
||||||
|
String wf_url1 = jucailinCockpitUtils.getUfPropData(wf_pkey1,tenantKey);
|
||||||
|
wfMap.put("count",count);
|
||||||
|
wfMap.put("name",wf_name1);
|
||||||
|
wfMap.put("url",wf_url1);
|
||||||
|
wfMap.put("key","pjlcclsj");
|
||||||
|
|
||||||
|
return wfMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue