#weaver-njpmsreport-3# 查询条件部门查询增加包含子部门的数据

devlop
shilei 7 months ago
parent b79c52f0f7
commit 2bf175bd82

@ -767,4 +767,32 @@ public class ProjectColumnsController {
// }
@GetMapping("/queryDeptid")
@WeaPermission(publicPermission = true)
public WeaResult<Object> queryDeptid(HttpServletRequest request){
String deptid = CommonUtils.null2String(request.getParameter("deptid")).trim();
Map<String, Object> recordMap = new HashMap<String, Object>();
String deptids = columnsUtils.getDepartmentIds(deptid,tenant_key);
recordMap.put("data",deptids);
return WeaResult.success(recordMap);
}
@GetMapping("/querySubcompanyid")
@WeaPermission(publicPermission = true)
public WeaResult<Object> querySubcompanyid(HttpServletRequest request){
String subcompanyid = CommonUtils.null2String(request.getParameter("subcompanyid")).trim();
Map<String, Object> recordMap = new HashMap<String, Object>();
String subCompanyIds = columnsUtils.getSubCompanyIds(subcompanyid,tenant_key);
recordMap.put("data",subCompanyIds);
return WeaResult.success(recordMap);
}
}

@ -86,7 +86,7 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(departmentid+"");
sqlparam.add(sqlParamEntity);
@ -130,7 +130,7 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainline_id+"");
sqlparam.add(sqlParamEntity);
@ -209,7 +209,7 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainlineid);
sqlparam.add(sqlParamEntity);
@ -229,7 +229,7 @@ public class ColumnsUtils {
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainlineid);
sqlparam.add(sqlParamEntity);
@ -279,12 +279,12 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainlineid);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainlineid);
sqlparam.add(sqlParamEntity);
@ -352,7 +352,7 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam2 = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity2 = new SqlParamEntity();
sqlParamEntity2.setParamType(SqlParamType.LONG);
sqlParamEntity2.setParamType(SqlParamType.VARCHAR);
sqlParamEntity2.setValue(mainlineid);
sqlparam2.add(sqlParamEntity2);
@ -489,7 +489,7 @@ public class ColumnsUtils {
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(mainlineid);
sqlparam.add(sqlParamEntity);
@ -949,15 +949,48 @@ public class ColumnsUtils {
// sqlparam.add(sqlParamEntity);
}
log.error("queryProjectList--xm_bm:"+xm_bm);
if(StringUtils.isNotBlank(xm_bm)){
String deptids = getDepartmentIds(xm_bm,tenant_key);
log.error("queryProjectList--deptids:"+deptids);
if(StringUtils.isNotBlank(deptids)){
sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(deptids)+")" ;
}else{
sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(xm_bm)+")" ;
}
// sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(xm_bm)+")" ;
// sqlParamEntity = new SqlParamEntity();
// sqlParamEntity.setParamType(SqlParamType.VARCHAR);
// sqlParamEntity.setValue(xm_bm);
// sqlparam.add(sqlParamEntity);
}
log.error("queryProjectList--xm_jg:"+xm_jg);
if(StringUtils.isNotBlank(xm_jg)){
String jgids = getSubCompanyIds(xm_jg,tenant_key);
log.error("queryProjectList-jgids:"+jgids);
if(StringUtils.isNotBlank(jgids)){
sqlwhere += " and d.subcompanyid in ("+SecurityUtil.ecodeForSql(jgids)+")" ;
}else{
sqlwhere += " and d.subcompanyid in ("+SecurityUtil.ecodeForSql(xm_jg)+")" ;
}
// sqlwhere += " and d.subcompanyid in("+SecurityUtil.ecodeForSql(xm_jg)+")" ;
// sqlParamEntity = new SqlParamEntity();
// sqlParamEntity.setParamType(SqlParamType.VARCHAR);
// sqlParamEntity.setValue(xm_jg);
// sqlparam.add(sqlParamEntity);
}
log.error("queryProjectList--xm_id:"+xm_id);
if(StringUtils.isNotBlank(xm_id)){
sqlwhere += " and m.id in ("+SecurityUtil.ecodeForSql(xm_id)+")" ;
@ -1149,7 +1182,7 @@ public class ColumnsUtils {
" from eteams.department " +
" where id in( " +
" select td1 from uf_proj_teams " +
" where jtj=? and tenant_key=?' and delete_type=0 " +
" where jtj=? and tenant_key=? and delete_type=0 " +
" and (oxmfzr=? or axmfzr=? or jtjxmfzr=?)" +
" ) " +
" and delete_type= 0 " +
@ -1172,17 +1205,17 @@ public class ColumnsUtils {
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(userid);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(userid);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.LONG);
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(userid);
sqlparam.add(sqlParamEntity);
@ -1870,7 +1903,15 @@ public class ColumnsUtils {
log.error("xm_bm:"+xm_bm);
if(StringUtils.isNotBlank(xm_bm)){
String deptids = getDepartmentIds(xm_bm,tenant_key);
log.error("deptids:"+deptids);
if(StringUtils.isNotBlank(deptids)){
sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(deptids)+")" ;
}else{
sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(xm_bm)+")" ;
}
// sqlParamEntity = new SqlParamEntity();
// sqlParamEntity.setParamType(SqlParamType.VARCHAR);
@ -1880,7 +1921,16 @@ public class ColumnsUtils {
log.error("xm_jg:"+xm_jg);
if(StringUtils.isNotBlank(xm_jg)){
String jgids = getSubCompanyIds(xm_jg,tenant_key);
log.error("jgids:"+jgids);
if(StringUtils.isNotBlank(jgids)){
sqlwhere += " and d.subcompanyid in ("+SecurityUtil.ecodeForSql(jgids)+")" ;
}else{
sqlwhere += " and d.subcompanyid in ("+SecurityUtil.ecodeForSql(xm_jg)+")" ;
}
// sqlParamEntity = new SqlParamEntity();
// sqlParamEntity.setParamType(SqlParamType.VARCHAR);
@ -2158,4 +2208,184 @@ public class ColumnsUtils {
return pvalue;
}
public String getDepartmentIds(String deptid,String tenant_key){
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
String departmentids = "";
try{
if(StringUtils.isNotBlank(deptid))
{
String dataSql =" select id from eteams.department where parent in("+SecurityUtil.ecodeForSql(deptid)+") \n" +
" and delete_type = 0 \n" +
" and tenant_key=? and type = 'department' " ;
log.error("getDepartmentIds--dataSql:"+dataSql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenant_key);
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) {
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
if(recordMap.containsKey("id")){
String id = String.valueOf(recordMap.get("id"));
departmentids += StringUtils.isBlank(departmentids) ? id : ","+id;
}
}
}
}
if(StringUtils.isNotBlank(departmentids)){
getSecDepartmentIds(departmentids,tenant_key,departmentids);
}
}catch (Exception e){
e.printStackTrace();
log.error("getUfPropData-Exception:"+e);
}
return departmentids;
}
public void getSecDepartmentIds(String deptid,String tenant_key,String departmentids){
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
String secDepartmentIds = "";
try{
if(StringUtils.isNotBlank(deptid))
{
String dataSql =" select id from eteams.department where parent in ("+SecurityUtil.ecodeForSql(deptid)+") \n" +
" and delete_type = 0 \n" +
" and tenant_key=? and type = 'department' " ;
log.error("getSecDepartmentIds--dataSql:"+dataSql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenant_key);
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) {
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
if(recordMap.containsKey("id")){
String id = String.valueOf(recordMap.get("id"));
secDepartmentIds += StringUtils.isBlank(secDepartmentIds) ? id : ","+id;
}
}
}
departmentids += StringUtils.isBlank(departmentids) ? secDepartmentIds : ","+secDepartmentIds ;
}
if(StringUtils.isNotBlank(secDepartmentIds)){
getSecDepartmentIds(secDepartmentIds,tenant_key,departmentids);
}
}catch (Exception e){
e.printStackTrace();
log.error("getUfPropData-Exception:"+e);
}
}
public String getSubCompanyIds(String subcompanyid,String tenant_key){
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
String subcompanyids = "";
try{
if(StringUtils.isNotBlank(subcompanyid))
{
String dataSql =" select id from eteams.department where parent in("+SecurityUtil.ecodeForSql(subcompanyid)+") \n" +
" and delete_type = 0 \n" +
" and tenant_key=? and type='subcompany' " ;
log.error("getSubCompanyIds--dataSql:"+dataSql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenant_key);
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) {
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
if(recordMap.containsKey("id")){
String id = String.valueOf(recordMap.get("id"));
subcompanyids += StringUtils.isBlank(subcompanyids) ? id : ","+id;
}
}
}
}
if(StringUtils.isNotBlank(subcompanyids)){
getSecSubcompanyIds(subcompanyids,tenant_key,subcompanyids);
}
}catch (Exception e){
e.printStackTrace();
log.error("getSubCompanyIds-Exception:"+e);
}
return subcompanyids;
}
public void getSecSubcompanyIds(String subcompanyid,String tenant_key,String departmentids){
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
String secDepartmentIds = "";
try{
if(StringUtils.isNotBlank(subcompanyid))
{
String dataSql =" select id from eteams.department where parent in("+SecurityUtil.ecodeForSql(subcompanyid)+") \n" +
" and delete_type = 0 \n" +
" and tenant_key=? and type = 'subcompany' " ;
log.error("getSecSubcompanyIds-dataSql:"+dataSql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(tenant_key);
sqlparam.add(sqlParamEntity);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) {
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
if(recordMap.containsKey("id")){
String id = String.valueOf(recordMap.get("id"));
secDepartmentIds += StringUtils.isBlank(secDepartmentIds) ? id : ","+id;
}
}
}
departmentids += StringUtils.isBlank(departmentids) ? secDepartmentIds : ","+secDepartmentIds ;
}
if(StringUtils.isNotBlank(secDepartmentIds)){
getSecSubcompanyIds(secDepartmentIds,tenant_key,departmentids);
}
}catch (Exception e){
e.printStackTrace();
log.error("getSecSubcompanyIds-Exception:"+e);
}
}
}

@ -0,0 +1,24 @@
server.port=9896
spring.application.name=weaver-secondev-service
#dubbo.mvc.static-path-pattern=/**
#dubbo.resources.static-locations=classpath:/ecode/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
http.filter.exclusions=/health/*
weaver.permission.module-type=SECONDEV
weaver.secondev.localFile.enabled=n
weaver.secondev.release.dir=
weaver.secondev.component.scan.packages=com.weaver,cn.eteams.wechat
#weaver.ecode.resource.ext=png,js,css,jpg,jpeg,gif
weaver.secondev.cas.path=/api/**
weaver.secondev.cas.whiteList=/papi/**,/sapi/**,/api/**
weaver.secondev.token.timeout=1800
weaver.secondev.token.refresh.timeout=7200
weaver.swagger.basePackage=com.weaver.ecode
#logging.level.com.weaver=debug
#weaver.mybatis-plus.monitor-sql.info=true
spring.jackson.serialization.write-dates-as-timestamps=true
spring.jackson.default-property-inclusion=NON_NULL
spring.jackson.deserialization.READ_UNKNOWN_ENUM_VALUES_AS_NULL=true
# dubbo.protocol.port= 6677

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
</beans>

@ -0,0 +1,93 @@
<%@ page trimDirectiveWhitespaces="true" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="java.util.*" %>
<%@page import="org.springframework.web.context.support.*" %>
<%@page import="org.springframework.context.*" %>
<%@ page import="com.alibaba.druid.pool.DruidDataSource" %>
<%@ page import="org.springframework.beans.BeansException" %>
<%@ page import="java.lang.management.ManagementFactory" %>
<%@ page import="java.lang.management.ThreadMXBean" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.slf4j.Logger" %>
<%@ page import="org.slf4j.LoggerFactory" %>
<%@ page import="javax.management.MBeanServer" %>
<%@ page import="javax.management.ObjectName" %>
<%@ page import="javax.management.Query" %>
<%
Map<String, String> result = new HashMap<String, String>();//返回结果
Logger logger = LoggerFactory.getLogger("health.jsp");
try {
ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
/*内存状态 begin*/
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory()/(1024 * 1024);
long totalMemory = runtime.totalMemory() / (1024 * 1024);
long freeMemory = runtime.freeMemory() / (1024 * 1024);
long memoryFreeRate = 100 * (maxMemory - totalMemory + freeMemory) / maxMemory;
result.put("maxMemory", maxMemory + "M");
result.put("totalMemory", totalMemory + "M");
result.put("freeMemory", freeMemory + "M");
result.put("memoryFreeRate", memoryFreeRate + "");
/*内存状态 end*/
/*数据库连接测试 begin*/
try {
DruidDataSource druidDataSource = (DruidDataSource) applicationContext.getBean("dataSource");
int activeConnectCount = druidDataSource.getActiveCount();
int maxActive = druidDataSource.getMaxActive();
int poolConnectCountIdleRate = 100 * (maxActive-activeConnectCount) / maxActive;
result.put("activeConnectCount", activeConnectCount + "");
result.put("maxActive", maxActive + "");
result.put("poolConnectCountIdleRate", poolConnectCountIdleRate + "");
//获得连接是否成功信息
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
boolean databaseConnectStatus = true;
try {
connection = druidDataSource.getConnection();
String sql = "select 1";
ps = connection.prepareStatement(sql);
rs = ps.executeQuery();
} catch (Exception e) {
databaseConnectStatus = false;
} finally {
if(rs!=null && !rs.isClosed()){
rs.close();
}
if(ps!=null && !ps.isClosed()){
ps.close();
}
if(connection!=null && !connection.isClosed()){
connection.close();
}
}
result.put("databaseConnectStatus", databaseConnectStatus + "");
} catch (BeansException e) {
result.put("databaseMap", "NONE");
}
/*数据库连接测试 end*/
/*应用的主线程活跃数监控 begin*/
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
int threadCount = threadBean.getThreadCount();
result.put("threadCount",threadCount + "");
/*应用的主线程活跃数监控 end*/
} catch (Exception e) {
result.put("error", e.getMessage());
}
result.put("abc", "abc");
MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"), Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
String port = ((ObjectName) objectNames.iterator().next()).getKeyProperty("port");
try {
result.put("tomcat_port",port);
} catch (Exception e) {
logger.error(e+":"+ Arrays.toString(e.getStackTrace()));
}
String resultStr = com.alibaba.druid.support.json.JSONUtils.toJSONString(result);
response.getWriter().write(resultStr);
%>
Loading…
Cancel
Save