#E10-40# 增加项目查询的接口

main
shilei 11 months ago
parent 0365e27476
commit bd1bdf40c5

@ -0,0 +1,216 @@
package com.weaver.seconddev.cockpit.cmd;
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.project.entity.SimpleMainline;
import com.weaver.project.service.RemoteMainlineService;
import com.weaver.seconddev.cockpit.util.DatabaseUtils;
import com.weaver.teams.domain.user.SimpleEmployee;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class CockpitProjectDataCmd {
//日志
private final static Logger log = LoggerFactory.getLogger(CockpitProjectDataCmd.class);
@RpcReference
RemoteMainlineService remoteMainlineService ;
@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>();
List<Map<String,Object>> projectDate2 = new ArrayList<Map<String,Object>>();
List<Map<String,Object>> projectDate3 = new ArrayList<Map<String,Object>>();
try {
projectDate2 = getProjectDate2(employee,tenantKey);
projectDate3 = getProjectDate3(employee,tenantKey);
} catch (Exception e) {
e.printStackTrace();
log.error("PortalPerformanceInfoCmd :" + e);
}
recordMap.put("projectDate2",projectDate2);
recordMap.put("projectDate3",projectDate3);
return recordMap;
}
public List<Map<String,Object>> getProjectDate2(SimpleEmployee employee, String tenantKey) {
List<Map<String,Object>> projectList = new ArrayList<Map<String,Object>>();
String groupId = "weaver-project-service";
String sourceType = "LOGIC";
long employeeid = employee.getEmployeeId();
try {
String sql =" select w.* from (\n" +
" select convert(m.id,char) as mainline_id,m.name as mainline_name,\n" +
" convert(m.manager,char) as manager_id,\n" +
" convert(p.rel_custom,char) as rel_custom,p.proj_amount,p.proj_approval_date,\n" +
" p.actual_val_date \n" +
" from ec_customerservice.mainline m \n" +
" inner JOIN ec_customerservice.mainline_form_data f ON f.mainline_id = m.id \n" +
" inner join ec_customerservice.proj_pms_base p on p.form_data_id = f.form_data_id \n" +
" inner join ec_customerservice.mainline_status_custom msc on msc.mainline_id = m.id \n" +
" inner join ec_customerservice.mainline_cust_status mcs on msc.status_id = mcs.id\n" +
" where m.group_id = '4527875868755238091' \n" +
" and m.manager in( select id\n" +
" from eteams.employee \n" +
" where (superior = "+employeeid+" or id = "+employeeid+")\n" +
" and status='normal'\n" +
" and delete_type=0" +
" and tenant_key = '"+tenantKey+"'\n" +
" and password is not null\n" +
" )\n" +
" and m.delete_type = 0 \n" +
" and m.tenant_key = '"+tenantKey+"'\n" +
" and f.delete_type = 0 \n" +
" and f.tenant_key = '"+tenantKey+"'\n" +
" and p.delete_type = 0\n" +
" and p.tenant_key = '"+tenantKey+"'\n" +
" and msc.delete_type = 0\n" +
" and msc.tenant_key = '"+tenantKey+"'\n" +
" and mcs.delete_type = 0\n" +
" and mcs.tenant_key = '"+tenantKey+"'\n" +
" and mcs.enabled = 1 \n" +
" and mcs.name <> '结案'\n" +
" order by m.create_time desc\n" +
") w limit 6";
log.error("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
projectList = databaseUtils.getDataSourceList(result);
} catch (Exception e) {
e.printStackTrace();
log.error("getProjectDate2-Exception:" + e);
}
return projectList;
}
public List<Map<String,Object>> getProjectDate3(SimpleEmployee employee, String tenantKey) {
List<Map<String,Object>> projectList = new ArrayList<Map<String,Object>>();
String groupId = "weaver-project-service";
String sourceType = "LOGIC";
String groupid = "4527875868755238091";
long employeeid = employee.getEmployeeId();
try {
String sql =" select w.* from (\n" +
" select convert(m.id,char) as mainline_id,m.name as mainline_name,\n" +
" convert(m.manager,char) as manager_id,\n" +
" convert(p.rel_custom,char) as rel_custom,p.proj_amount,p.proj_approval_date,\n" +
" p.actual_val_date \n" +
" from ec_customerservice.mainline m \n" +
" inner JOIN ec_customerservice.mainline_form_data f ON f.mainline_id = m.id \n" +
" inner join ec_customerservice.proj_pms_base p on p.form_data_id = f.form_data_id \n" +
" inner join ec_customerservice.mainline_status_custom msc on msc.mainline_id = m.id \n" +
" inner join ec_customerservice.mainline_cust_status mcs on msc.status_id = mcs.id\n" +
" where m.group_id = ? \n" +
" and m.manager in( select id\n" +
" from eteams.employee \n" +
" where (superior = ? or id = ?)\n" +
" and status='normal'\n" +
" and delete_type=0" +
" and tenant_key = ?\n" +
" and password is not null\n" +
" )\n" +
" and m.delete_type = 0 \n" +
" and m.tenant_key = ?\n" +
" and f.delete_type = 0 \n" +
" and f.tenant_key = ?\n" +
" and p.delete_type = 0\n" +
" and p.tenant_key = ?\n" +
" and msc.delete_type = 0\n" +
" and msc.tenant_key = ?\n" +
" and mcs.delete_type = 0\n" +
" and mcs.tenant_key = ?\n" +
" and mcs.enabled = 1 \n" +
" and mcs.name <> '结案'\n" +
" order by m.create_time desc\n" +
") w limit 6";
log.error("sql:"+sql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setValue(groupid);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setValue(employeeid+"");
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);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenantKey+"");
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenantKey+"");
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenantKey+"");
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenantKey+"");
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);
projectList = databaseUtils.getDataSourceList(result);
} catch (Exception e) {
e.printStackTrace();
log.error("getProjectDate2-Exception:" + e);
}
return projectList;
}
}

@ -36,6 +36,8 @@ public class CockpitUserDataCmd {
Map<String, Object> recordMap = new HashMap<String, Object>();
String sourceType = "LOGIC";
try {
String subcompanynme = "";
String employeeId = String.valueOf(employee.getEmployeeId());
log.error("employeeId:"+employeeId);
String username = employee.getName();
@ -43,8 +45,7 @@ public class CockpitUserDataCmd {
String deptnme = employee.getDepartment().getName();
log.error("deptnme:"+deptnme);
String subcompanynme = employee.getDepartment().getParent().getName();
log.error("subcompanynme:"+subcompanynme);
long subCompanyid = employee.getDepartment().getSubCompanyId();
String positionname = employee.getPosition().getName();
log.error("positionname:"+positionname);
@ -90,6 +91,32 @@ public class CockpitUserDataCmd {
long jobcallid = employee.getJobCall();
log.error("jobcallid:"+jobcallid);
if(StringUtils.isNotBlank(subCompanyid+"")){
String sql = " select name " +
" from department " +
" where id= ? and type='subcompany' " +
" and delete_type=0 and TENANT_KEY = ? ";
log.error("sql:"+sql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setValue(subCompanyid+"");
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.isEmpty() && recordList.size()>0){
subcompanynme = String.valueOf(recordList.get(0).get("name"));
}
}
log.error("subcompanynme:"+subcompanynme);
if(StringUtils.isNotBlank(jobcallid+"")){
String sql =" select data_name from eteams.hrm_jobcall " +
" where id = ? "+

@ -205,7 +205,7 @@ public class CockpitWorkDate3TypeCmd {
sqlParamEntity.setValue(tenantKey+"");
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
projectList = databaseUtils.getDataSourceList(result);
} catch (Exception e) {

@ -81,6 +81,7 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",wf_count1);
wfMap.put("name",wf_name1);
wfMap.put("url",wf_url1);
wfMap.put("key","dcllcsl");
wflist.add(wfMap);
wfMap = new HashMap<String,String>();
@ -91,6 +92,7 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",wf_count2);
wfMap.put("name",wf_name2);
wfMap.put("url",wf_url2);
wfMap.put("key","wcjdlc");
wflist.add(wfMap);
wfMap = new HashMap<String,String>();
@ -101,6 +103,7 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",wf_count3);
wfMap.put("name",wf_name3);
wfMap.put("url",wf_url3);
wfMap.put("key","wcldlc");
wflist.add(wfMap);
@ -112,6 +115,7 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",wf_count4);
wfMap.put("name",wf_name4);
wfMap.put("url",wf_url4);
wfMap.put("key","wdbdlc");
wflist.add(wfMap);
@ -123,14 +127,16 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",wf_count5);
wfMap.put("name",wf_name5);
wfMap.put("url",wf_url5);
wfMap.put("key","wgzdlc");
wflist.add(wfMap);
wfMap = getWorkflowDayOperateCount(employee,tenantKey,wf_count3);
wflist.add(wfMap);
List<Map<String,String>> daylist = getWorkflowDayOperateCount(employee,tenantKey,wf_count3,wf_count2);
wflist.addAll(daylist);
wfMap = getWorkflowOperateAverageTime(employee,tenantKey);
wflist.add(wfMap);
} catch (Exception e) {
e.printStackTrace();
log.error("DevQuestCountCmd-Exception:" + e);
@ -172,20 +178,27 @@ public class CockpitWorkflowAnalysisCmd {
String count = "0.0";
try{
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
WeaResult<List<RequestListInfoPAEntity>> requestListData = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.TODO_FLOWALL.getTabid(), 1, 10, conditionEntity);
WeaResult<List<RequestListInfoPAEntity>> requestListData = wflRequestListRest.getRequestListByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), 1, 500, conditionEntity);
int code = requestListData.getCode();
if(code == 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 ;
count = String.valueOf(average);
@ -202,14 +215,20 @@ public class CockpitWorkflowAnalysisCmd {
wfMap.put("count",count);
wfMap.put("name",wf_name1);
wfMap.put("url",wf_url1);
wfMap.put("key","pjlcclsj");
return wfMap;
}
public Map<String,String> getWorkflowDayOperateCount(SimpleEmployee employee,String tenantKey,String wf_count3) {
String count = "0.0";
String diffdays = "0";
public List<Map<String,String>> getWorkflowDayOperateCount(SimpleEmployee employee,String tenantKey,String wf_count3,String wf_count2) {
String count2 = "0.0";
String count3 = "0.0";
String diffdays = "1";
log.error("wf_count3:"+wf_count3);
log.error("wf_count2:"+wf_count2);
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
log.error("wf_count3:"+wf_count3);
@ -241,21 +260,44 @@ public class CockpitWorkflowAnalysisCmd {
Long days = Long.parseLong(diffdays);
BigDecimal bg = new BigDecimal((double) dealcount/(days*1.00));
count = String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
count3 = String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
if(StringUtils.isNotBlank(wf_count2) && StringUtils.isNotBlank(diffdays)){
Long dealcount = Long.parseLong(wf_count2);
Long days = Long.parseLong(diffdays);
BigDecimal bg = new BigDecimal((double) dealcount/(days*1.00));
count2 = String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
} catch (Exception e) {
log.error("PortalWfDealCountCmd-Exception:" + e);
}
List<Map<String,String>> dayList = new ArrayList<Map<String,String>>();
Map<String,String> wfMap = new HashMap<String,String>();
String wf_name1 = "平均每天处理";
String wf_pkey1 = "workflow.average.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;
String wf_name2 = "平均每日发起流程";
String wf_pkey2 = "workflow.average.amount";
String wf_url2 = jucailinCockpitUtils.getUfPropData(wf_pkey2,tenantKey);
wfMap.put("count",count2);
wfMap.put("name",wf_name2);
wfMap.put("url",wf_url2);
wfMap.put("key","pjmrfqlc");
dayList.add(wfMap);
wfMap = new HashMap<String,String>();
String wf_name3 = "平均每日处理流程";
String wf_pkey3 = "workflow.average.amount";
String wf_url3 = jucailinCockpitUtils.getUfPropData(wf_pkey3,tenantKey);
wfMap.put("count",count3);
wfMap.put("name",wf_name3);
wfMap.put("url",wf_url3);
wfMap.put("key","pjmrcllc");
dayList.add(wfMap);
return dayList;
}
}

@ -167,6 +167,23 @@ public class JucailinCockpitController {
}
@GetMapping("/getProjectData")
@WeaPermission(publicPermission = true)
public WeaResult<Object> getProjectData(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.getProjectData(simpleEmployee,params,tenant_key);
}catch (Exception e){
log.error("getWorkData-Exception:"+e.getMessage());
}
return WeaResult.success(dataList);
}
@GetMapping("/getBlogData")

@ -20,6 +20,8 @@ public interface JucailinCockpitService {
Map<String, Object> getUserData3Type(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getProjectData(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
Map<String, Object> getBlogData(SimpleEmployee simpleEmployee,Map<String,Object> paramMap,String tenantKey);
}

@ -35,6 +35,10 @@ public class JucailinCockpitServiceimpl implements JucailinCockpitService {
@Autowired
private CockpitWorkDate3TypeCmd cockpitWorkDate3TypeCmd;
@Autowired
private CockpitProjectDataCmd cockpitProjectDataCmd;
@Override
public Map<String, Object> getMonthPerformanceData(SimpleEmployee simpleEmployee, Map<String, Object> paramMap,String tenantKey) {
@ -80,6 +84,11 @@ public class JucailinCockpitServiceimpl implements JucailinCockpitService {
return dataMap;
}
@Override
public Map<String, Object> getProjectData(SimpleEmployee simpleEmployee, Map<String, Object> paramMap, String tenantKey) {
Map<String,Object> dataMap = cockpitProjectDataCmd.getDataInfo(simpleEmployee,paramMap,tenantKey);
return dataMap;
}
@Override

Loading…
Cancel
Save