diff --git a/src/main/java/com/weaver/seconddev/njprojectreport/controller/ProjectColumnsController.java b/src/main/java/com/weaver/seconddev/njprojectreport/controller/ProjectColumnsController.java index 73ff795..dd1a4aa 100644 --- a/src/main/java/com/weaver/seconddev/njprojectreport/controller/ProjectColumnsController.java +++ b/src/main/java/com/weaver/seconddev/njprojectreport/controller/ProjectColumnsController.java @@ -767,4 +767,32 @@ public class ProjectColumnsController { // } + + @GetMapping("/queryDeptid") + @WeaPermission(publicPermission = true) + public WeaResult queryDeptid(HttpServletRequest request){ + String deptid = CommonUtils.null2String(request.getParameter("deptid")).trim(); + + Map recordMap = new HashMap(); + String deptids = columnsUtils.getDepartmentIds(deptid,tenant_key); + recordMap.put("data",deptids); + return WeaResult.success(recordMap); + } + + + @GetMapping("/querySubcompanyid") + @WeaPermission(publicPermission = true) + public WeaResult querySubcompanyid(HttpServletRequest request){ + String subcompanyid = CommonUtils.null2String(request.getParameter("subcompanyid")).trim(); + Map recordMap = new HashMap(); + String subCompanyIds = columnsUtils.getSubCompanyIds(subcompanyid,tenant_key); + recordMap.put("data",subCompanyIds); + return WeaResult.success(recordMap); + } + + + + + + } diff --git a/src/main/java/com/weaver/seconddev/njprojectreport/util/ColumnsUtils.java b/src/main/java/com/weaver/seconddev/njprojectreport/util/ColumnsUtils.java index 89c3165..27eaa23 100644 --- a/src/main/java/com/weaver/seconddev/njprojectreport/util/ColumnsUtils.java +++ b/src/main/java/com/weaver/seconddev/njprojectreport/util/ColumnsUtils.java @@ -37,8 +37,8 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(customerid)){ String sql =" select id,name from customer " + - " where id= ? " + - " and tenant_key= ? " ; + " where id= ? " + + " and tenant_key= ? " ; List sqlparam = new ArrayList(); SqlParamEntity sqlParamEntity = new SqlParamEntity(); @@ -73,20 +73,20 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(departmentid)) { String dataSql =" select id,username" + - " from eteams.employee " + - " where id in( " + - " select oxmfzr from uf_proj_teams where td1= ? and tenant_key=? and delete_type = 0 " + - " ) " + - " and tenant_key=? \n" + - " and status='normal'" + - " and type='inside'"; + " from eteams.employee " + + " where id in( " + + " select oxmfzr from uf_proj_teams where td1= ? and tenant_key=? and delete_type = 0 " + + " ) " + + " and tenant_key=? \n" + + " and status='normal'" + + " and type='inside'"; log.info("getSubcompanyFzr--dataSql:"+dataSql); List sqlparam = new ArrayList(); SqlParamEntity sqlParamEntity = new SqlParamEntity(); - sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); sqlParamEntity.setValue(departmentid+""); sqlparam.add(sqlParamEntity); @@ -123,14 +123,14 @@ public class ColumnsUtils { Map recordMap = new HashMap() ; if(StringUtils.isNotBlank(mainline_id)){ String sql =" select group_concat(pc.hth) as hth "+ - " from uf_proj_contract pc "+ - " where pc.glxm_p402 = ? " + - " and pc.tenant_key = ? \n" + - " and pc.delete_type = 0 " ; + " from uf_proj_contract pc "+ + " where pc.glxm_p402 = ? " + + " and pc.tenant_key = ? \n" + + " and pc.delete_type = 0 " ; List sqlparam = new ArrayList(); SqlParamEntity sqlParamEntity = new SqlParamEntity(); - sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); sqlParamEntity.setValue(mainline_id+""); sqlparam.add(sqlParamEntity); @@ -181,35 +181,35 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(mainlineid)) { String dataSql =" select w.* from (\n" + - " select d.id,p.requestname,l.requestid,d.create_time\n" + - " from wfc_form_data l\n" + - " inner join formtable_main_3786 d on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where d.xm= ? \n" + - " and d.TENANT_KEY=? \n" + - " and d.DELETE_TYPE=0\n" + - " and l.TENANT_KEY=? \n" + - " and l.DELETE_TYPE=0\n" + - " and p.TENANT_KEY=? \n" + - " and p.DELETE_TYPE=0\n" + - " union \n" + - " select d.id,p.requestname,l.requestid,d.CREATE_TIME\n" + - " from wfc_form_data l\n" + - " inner join formtable_main_961 d on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where d.xm= ?\n" + - " and d.TENANT_KEY= ? \n" + - " and d.DELETE_TYPE=0\n" + - " and l.TENANT_KEY=? \n" + - " and l.DELETE_TYPE=0 \n" + - " and p.TENANT_KEY=? \n" + - " and p.DELETE_TYPE=0 \n" + - " ) w\n" + - " order by w.id desc " ; + " select d.id,p.requestname,l.requestid,d.create_time\n" + + " from wfc_form_data l\n" + + " inner join formtable_main_3786 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.xm= ? \n" + + " and d.TENANT_KEY=? \n" + + " and d.DELETE_TYPE=0\n" + + " and l.TENANT_KEY=? \n" + + " and l.DELETE_TYPE=0\n" + + " and p.TENANT_KEY=? \n" + + " and p.DELETE_TYPE=0\n" + + " union \n" + + " select d.id,p.requestname,l.requestid,d.CREATE_TIME\n" + + " from wfc_form_data l\n" + + " inner join formtable_main_961 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.xm= ?\n" + + " and d.TENANT_KEY= ? \n" + + " and d.DELETE_TYPE=0\n" + + " and l.TENANT_KEY=? \n" + + " and l.DELETE_TYPE=0 \n" + + " and p.TENANT_KEY=? \n" + + " and p.DELETE_TYPE=0 \n" + + " ) w\n" + + " order by w.id desc " ; List sqlparam = new ArrayList(); 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); @@ -265,26 +265,26 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(mainlineid)) { String dataSql =" select p.requestname,l.requestid,d.zht,d.cjrq,d.sqyy,d.wdfj\n" + - " from wfc_form_data l\n" + - " inner join formtable_main_963 d on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where (d.xm = ? or d.xmid = ?)" + - " and d.tenant_key= ? \n" + - " and d.delete_type=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 " ; + " from wfc_form_data l\n" + + " inner join formtable_main_963 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where (d.xm = ? or d.xmid = ?)" + + " and d.tenant_key= ? \n" + + " and d.delete_type=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 sqlparam = new ArrayList(); 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); @@ -335,24 +335,24 @@ public class ColumnsUtils { int yqys = 0; dataSql = " select p.requestname,l.requestid,ifnull(yqys,0) as yqys\n" + - " from wfc_form_data l\n" + - " inner join formtable_main_3785 d on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where d.xm = ? \n" + - " and d.tenant_key = ? \n" + - " and d.delete_type=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 " ; + " from wfc_form_data l\n" + + " inner join formtable_main_3785 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.xm = ? \n" + + " and d.tenant_key = ? \n" + + " and d.delete_type=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.error("dataSql:"+dataSql); List sqlparam2 = new ArrayList(); SqlParamEntity sqlParamEntity2 = new SqlParamEntity(); - sqlParamEntity2.setParamType(SqlParamType.LONG); + sqlParamEntity2.setParamType(SqlParamType.VARCHAR); sqlParamEntity2.setValue(mainlineid); sqlparam2.add(sqlParamEntity2); @@ -473,23 +473,23 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(mainlineid)) { String dataSql =" select p.requestname,l.requestid,ifnull(yqys,0) as yqys\n" + - " from wfc_form_data l\n" + - " inner join formtable_main_3785 d on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where d.xm=? \n" + - " and d.tenant_key= ? \n" + - " and d.delete_type=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 " ; + " from wfc_form_data l\n" + + " inner join formtable_main_3785 d on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.xm=? \n" + + " and d.tenant_key= ? \n" + + " and d.delete_type=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("dataSql:"+dataSql); List sqlparam = new ArrayList(); SqlParamEntity sqlParamEntity = new SqlParamEntity(); - sqlParamEntity.setParamType(SqlParamType.LONG); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); sqlParamEntity.setValue(mainlineid); sqlparam.add(sqlParamEntity); @@ -669,17 +669,17 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(mainlineid)) { String dataSql =" select p.requestname,l.requestid " + - " from formtable_main_963 d \n" + - " inner join wfc_form_data l on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where (d.xm=? or d.xmid=?)\n" + - " and d.tenant_key=?\n" + - " and d.delete_type=0\n" + - " and l.tenant_key=?\n" + - " and l.delete_type=0\n" + - " and p.tenant_key=?\n" + - " and p.delete_type=0 " + - " order by d.id desc " ; + " from formtable_main_963 d \n" + + " inner join wfc_form_data l on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where (d.xm=? or d.xmid=?)\n" + + " and d.tenant_key=?\n" + + " and d.delete_type=0\n" + + " and l.tenant_key=?\n" + + " and l.delete_type=0\n" + + " and p.tenant_key=?\n" + + " and p.delete_type=0 " + + " order by d.id desc " ; log.info("dataSql:"+dataSql); @@ -785,16 +785,16 @@ public class ColumnsUtils { recordList = databaseUtils.getDataSourceList(result); if(CollectionUtils.isEmpty(recordList)) { dataSql = " select p.requestname,l.requestid " + - " from formtable_main_3785 d \n" + - " inner join wfc_form_data l on d.id = l.dataid\n" + - " inner join wfc_requestbase p on p.requestid = l.requestid\n" + - " where d.xm=?\n" + - " and d.tenant_key=?\n" + - " and d.delete_type=0\n" + - " and l.tenant_key=?\n" + - " and l.delete_type=0\n" + - " and p.tenant_key=?\n" + - " and p.delete_type=0\n" ; + " from formtable_main_3785 d \n" + + " inner join wfc_form_data l on d.id = l.dataid\n" + + " inner join wfc_requestbase p on p.requestid = l.requestid\n" + + " where d.xm=?\n" + + " and d.tenant_key=?\n" + + " and d.delete_type=0\n" + + " and l.tenant_key=?\n" + + " and l.delete_type=0\n" + + " and p.tenant_key=?\n" + + " and p.delete_type=0\n" ; log.info("dataSql:"+dataSql); @@ -949,13 +949,46 @@ public class ColumnsUtils { // sqlparam.add(sqlParamEntity); } - + log.error("queryProjectList--xm_bm:"+xm_bm); if(StringUtils.isNotBlank(xm_bm)){ - sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(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)){ - sqlwhere += " and d.subcompanyid in("+SecurityUtil.ecodeForSql(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); @@ -970,8 +1003,8 @@ public class ColumnsUtils { sqlwhere += " order by actual_val_date desc " ; String dataSql =" select u.* from ( " + - " select w.*,(@i:=@i+1) as xh from (" + baseSql + sqlwhere + " ) w,(select @i:=0) b " + - " ) u " ; + " select w.*,(@i:=@i+1) as xh from (" + baseSql + sqlwhere + " ) w,(select @i:=0) b " + + " ) u " ; log.error("queryProjectList---dataSql:"+dataSql); Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); @@ -1046,24 +1079,24 @@ public class ColumnsUtils { String group_id = "4527875868755238091"; String dataSql =" select convert(m.id,char) as mainline_id,m.name as mainline_name," + - " convert(m.manager,char) as manager_id,e.username as manager_name, "+ - " convert(d.id,char) as department_id,d.name as department_name,"+ - " convert(d.subcompanyid,char) as subcompany_id,d2.name as subcompany_name,"+ - " convert(p.rel_custom,char) as rel_custom," + - " p.proj_amount,p.proj_approval_date,p.actual_val_date "+ - " from mainline m " + - " inner join (select distinct mainline_id,form_data_id from mainline_form_data where delete_type = 0 and tenant_key = ?) fd on fd.mainline_id = m.id "+ - " inner join proj_pms_base p on p.form_data_id = fd.form_data_id "+ - " inner join (select distinct mainline_id,status_id from mainline_status_custom where delete_type = 0 and tenant_key = ?) msc on msc.mainline_id = m.id and msc.status_id = m.status_id "+ - " inner join mainline_cust_status mcs on msc.status_id = mcs.id "+ - " inner join ( select id,username,department from eteams.employee where tenant_key = ? ) e on m.manager = e.id "+ - " inner join ( select id,name,subcompanyid from eteams.department where type = 'department' and tenant_key = ? ) d on e.department = d.id "+ - " inner join ( select id,name,subcompanyid from eteams.department where type = 'subcompany' and tenant_key = ? ) d2 on d.subcompanyid = d2.id "+ - " where m.group_id = '"+group_id+"' " + - " and m.delete_type = 0 and m.tenant_key = ? " + - " and p.delete_type = 0 and p.tenant_key = ? " + - " and mcs.name in ('验收','结案') and mcs.tenant_key = ? "+ - " and p.actual_val_date is not null " ; + " convert(m.manager,char) as manager_id,e.username as manager_name, "+ + " convert(d.id,char) as department_id,d.name as department_name,"+ + " convert(d.subcompanyid,char) as subcompany_id,d2.name as subcompany_name,"+ + " convert(p.rel_custom,char) as rel_custom," + + " p.proj_amount,p.proj_approval_date,p.actual_val_date "+ + " from mainline m " + + " inner join (select distinct mainline_id,form_data_id from mainline_form_data where delete_type = 0 and tenant_key = ?) fd on fd.mainline_id = m.id "+ + " inner join proj_pms_base p on p.form_data_id = fd.form_data_id "+ + " inner join (select distinct mainline_id,status_id from mainline_status_custom where delete_type = 0 and tenant_key = ?) msc on msc.mainline_id = m.id and msc.status_id = m.status_id "+ + " inner join mainline_cust_status mcs on msc.status_id = mcs.id "+ + " inner join ( select id,username,department from eteams.employee where tenant_key = ? ) e on m.manager = e.id "+ + " inner join ( select id,name,subcompanyid from eteams.department where type = 'department' and tenant_key = ? ) d on e.department = d.id "+ + " inner join ( select id,name,subcompanyid from eteams.department where type = 'subcompany' and tenant_key = ? ) d2 on d.subcompanyid = d2.id "+ + " where m.group_id = '"+group_id+"' " + + " and m.delete_type = 0 and m.tenant_key = ? " + + " and p.delete_type = 0 and p.tenant_key = ? " + + " and mcs.name in ('验收','结案') and mcs.tenant_key = ? "+ + " and p.actual_val_date is not null " ; log.error("queryProjectSql--dataSql:"+dataSql); return dataSql; @@ -1083,17 +1116,17 @@ public class ColumnsUtils { if(StringUtils.isNotBlank(jtjname)){ String countSql = " select subcompanyid from ( " + - " select distinct subcompanyid as subcompanyid" + - " from eteams.department " + - " where id in( " + - " select td1 from uf_proj_teams " + - " where jtj= ? and tenant_key = ? and delete_type = 0 " + - " ) " + - " and delete_type = 0 " + - " and type='department' " + - " and tenant_key= ? " + - " ) p " + - " where p.subcompanyid <> ? "; + " select distinct subcompanyid as subcompanyid" + + " from eteams.department " + + " where id in( " + + " select td1 from uf_proj_teams " + + " where jtj= ? and tenant_key = ? and delete_type = 0 " + + " ) " + + " and delete_type = 0 " + + " and type='department' " + + " and tenant_key= ? " + + " ) p " + + " where p.subcompanyid <> ? "; List sqlparam = new ArrayList(); @@ -1145,18 +1178,18 @@ public class ColumnsUtils { List> recordList = new ArrayList>(); if(StringUtils.isNotBlank(jtjname)){ String countSql = " select subcompanyid from ( " + - " select distinct subcompanyid as subcompanyid" + - " from eteams.department " + - " where id in( " + - " select td1 from uf_proj_teams " + - " where jtj=? and tenant_key=?' and delete_type=0 " + - " and (oxmfzr=? or axmfzr=? or jtjxmfzr=?)" + - " ) " + - " and delete_type= 0 " + - " and type='department' " + - " and tenant_key=?" + - " ) p " + - " where p.subcompanyid <> ?"; + " select distinct subcompanyid as subcompanyid" + + " from eteams.department " + + " where id in( " + + " select td1 from uf_proj_teams " + + " where jtj=? and tenant_key=? and delete_type=0 " + + " and (oxmfzr=? or axmfzr=? or jtjxmfzr=?)" + + " ) " + + " and delete_type= 0 " + + " and type='department' " + + " and tenant_key=?" + + " ) p " + + " where p.subcompanyid <> ?"; List sqlparam = new ArrayList(); @@ -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); @@ -1547,13 +1580,13 @@ public class ColumnsUtils { String sourceType = "LOGIC"; String dataSql =" select id,username" + - " from eteams.employee " + - " where id in( " + - " select oxmfzr from uf_proj_teams where jtj=? and tenant_key=? " + - " ) " + - " and tenant_key=? \n" + - " and status='normal'" + - " and type='inside'"; + " from eteams.employee " + + " where id in( " + + " select oxmfzr from uf_proj_teams where jtj=? and tenant_key=? " + + " ) " + + " and tenant_key=? \n" + + " and status='normal'" + + " and type='inside'"; log.error("getSubcompanyManagerData--dataSql:"+dataSql); @@ -1870,7 +1903,15 @@ public class ColumnsUtils { log.error("xm_bm:"+xm_bm); if(StringUtils.isNotBlank(xm_bm)){ - sqlwhere += " and d.id in ("+SecurityUtil.ecodeForSql(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)){ - sqlwhere += " and d.subcompanyid in ("+SecurityUtil.ecodeForSql(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 sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) { + for(int i=0;i 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 sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) { + for(int i=0;i 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 sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) { + for(int i=0;i 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 sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam); + List> recordList = databaseUtils.getDataSourceList(result); + + if(CollectionUtils.isNotEmpty(recordList) && recordList.size() >0 ) { + for(int i=0;i 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); + } + } + + } \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..b5a1cd3 --- /dev/null +++ b/src/main/resources/application.properties @@ -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 + diff --git a/src/main/resources/applicationContext-secondev-dubbo.xml b/src/main/resources/applicationContext-secondev-dubbo.xml new file mode 100644 index 0000000..9076e8f --- /dev/null +++ b/src/main/resources/applicationContext-secondev-dubbo.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/main/webapp/remote/health.jsp b/src/main/webapp/remote/health.jsp new file mode 100644 index 0000000..0a080cd --- /dev/null +++ b/src/main/webapp/remote/health.jsp @@ -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 result = new HashMap();//返回结果 + 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 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); +%>