Przeglądaj źródła

查询过滤,按权限项目

longht 3 lat temu
rodzic
commit
7770325162

Plik diff jest za duży
+ 12 - 11
hrwa/METADATA/waexplain/wa_data_explain.bmf


+ 46 - 0
hrwa/nccloud/src/client/nccloud/web/hrwa/pubinfo/wadataexplain/action/HrwaClassdevFilter.java

@@ -0,0 +1,46 @@
+package nccloud.web.hrwa.pubinfo.wadataexplain.action;
+
+import nc.vo.pubapp.AppContext;
+import nc.vo.pubapp.pattern.pub.PubAppTool;
+import nccloud.framework.web.processor.IRefSqlBuilder;
+import nccloud.framework.web.processor.refgrid.RefQueryInfo;
+import nccloud.framework.web.ui.meta.RefMeta;
+import nccloud.framework.web.container.SessionContext;
+import nccloud.pubitf.platform.db.SqlParameterCollection;
+
+public class HrwaClassdevFilter implements IRefSqlBuilder {
+
+	@Override
+	public String getExtraSql(RefQueryInfo para, RefMeta meta) {
+		// TODO Auto-generated method stub
+	
+		if("pk_country".equals(meta.getPkField()))
+			return "";
+		String pk_org = para.getQueryCondition().get("pk_org");
+		String cuser =  SessionContext.getInstance().getClientInfo().getUserid();
+		 //add by longht 增加查询过滤,按权限项目 20211220  start
+		String powersql = "SELECT  classid" + 
+				"  FROM wa_clspower where 1=1"
+				+ "   and ( pk_subject = '"
+				+ cuser + "'"
+				+ " or pk_subject in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
+				+ cuser + "') ) and pk_org = '"+pk_org+"'    and subject_type = '1' \n";
+		
+		
+		return "  wa_waclass.class_id in("+powersql+")";
+
+	}
+
+	@Override
+	public SqlParameterCollection getExtraSqlParameter(RefQueryInfo para, RefMeta meta) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getOrderSql(RefQueryInfo para, RefMeta meta) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

+ 36 - 19
hrwa/nccloud/src/client/nccloud/web/hrwa/pubinfo/wadataexplain/action/WadataexplainQueryAction.java

@@ -38,8 +38,27 @@ public <T> Object execute(IRequest request, T para) throws Exception {
     String wherepart = scheme.getWhereSQLOnly();
     wherepart = wherepart == null ? "1=1" : wherepart;
     
-    //add by longht 增加查询过滤,按权限项目 20211220  start
-	String powersql = "select wa_classitem.pk_wa_classitem "
+	// add by longht 增加查询过滤,按权限项目 20211220 start
+	String powersqlorg = " SELECT pk_org FROM sm_subject_org   where 1=1 "
+			+ "   and ( subjectid = '"
+			+ AppContext.getInstance().getPkUser() + "'"
+			+ " or subjectid in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
+			+ AppContext.getInstance().getPkUser() + "'))\n";
+	wherepart = wherepart + " and pk_org in (" + powersqlorg + ")";
+	
+	// add by longht 增加查询过滤,按权限项目 20211220 start
+	String powersqlclass = "SELECT  classid" + 
+			"  FROM wa_clspower where 1=1"
+			+ "   and ( pk_subject = '"
+			+ AppContext.getInstance().getPkUser() + "'"
+			+ " or pk_subject in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
+			+ AppContext.getInstance().getPkUser() + "'))   "
+			+ " and subject_type = '1' \n";
+
+	wherepart = wherepart + " and pk_wa_class in (" + powersqlclass + ")";
+
+	// add by longht 增加查询过滤,按权限项目 20211220 start
+	String powersqlpro = "select wa_classitem.pk_wa_classitem "
 //			"select wa_itempower.pk_itempower,\n" 
 //	        + "       wa_classitem.pk_wa_class,\n"
 //			+ "       wa_classitem.pk_wa_item,\n" 
@@ -53,28 +72,26 @@ public <T> Object execute(IRequest request, T para) throws Exception {
 //			+ "       wa_classitem.ifromflag,\n"
 //			+ "       wa_itempower.subject_type,\n" 
 //			+ "       wa_itempower.pk_subject\n" 
-			+ "   from wa_classitem\n"
-			+ "   inner join wa_waclass\n" 
+			+ "   from wa_classitem\n" + "   inner join wa_waclass\n"
 			+ "   on wa_waclass.pk_org = wa_classitem.pk_org\n"
 			+ "   and wa_waclass.pk_wa_class = wa_classitem.pk_wa_class\n"
-			+ "   and wa_waclass.cyear = wa_classitem.cyear\n"
-			+ "   and wa_waclass.cperiod = wa_classitem.cperiod\n" 
-			+ "   inner join wa_item\n"
-			+ "   on wa_classitem.pk_wa_item = wa_item.pk_wa_item\n" 
-			+ "   left outer join wa_itempower\n"
-			+ "   on wa_itempower.pk_wa_item = wa_classitem.pk_wa_item\n"
+			+ "   and wa_waclass.cyear = wa_classitem.cyear\n" + "   and wa_waclass.cperiod = wa_classitem.cperiod\n"
+			+ "   inner join wa_item\n" + "   on wa_classitem.pk_wa_item = wa_item.pk_wa_item\n"
+			+ "   left outer join wa_itempower\n" + "   on wa_itempower.pk_wa_item = wa_classitem.pk_wa_item\n"
 			+ "   and wa_itempower.pk_wa_class = wa_classitem.pk_wa_class\n"
-			+ "   and wa_itempower.pk_org = wa_classitem.pk_org\n" 
-			+ "   and ( wa_itempower.pk_subject = '"+ AppContext.getInstance().getPkUser() + "'"
-		    +" or pk_subject in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
-			+ AppContext.getInstance().getPkUser() +"'))\n" 
-			//+ "   where wa_waclass.pk_org = '"+pk_org+"' \n"
+			+ "   and wa_itempower.pk_org = wa_classitem.pk_org\n" + "   and ( wa_itempower.pk_subject = '"
+			+ AppContext.getInstance().getPkUser() + "'"
+			+ " or pk_subject in ( SELECT sur.pk_role FROM sm_user_role sur where sur.cuserid = '"
+			+ AppContext.getInstance().getPkUser() + "'))\n"
+//+ "   where wa_waclass.pk_org = '"+pk_org+"' \n"
 			+ "   where 1=1 \n"
-			//+ "    wa_waclass.pk_wa_class = '"+pk_wa_class+"'\n" 
-			+ "   and wa_item.mid = 'N'\n"
-			+ "   and wa_itempower.editflag ='Y'";
+//+ "    wa_waclass.pk_wa_class = '"+pk_wa_class+"'\n" 
+			+ "   and wa_item.mid = 'N'\n" + "   and wa_itempower.editflag ='Y'";
+	
+	wherepart = wherepart +" and pk_wa_classitem in ("+powersqlpro+")";
+	
+	
 	
-	wherepart = wherepart +" and pk_wa_classitem in ("+powersql+")";
     //add by longht 增加查询过滤,按权限项目 20211220  end 
     String[] ids = service.queryPKs(wherepart);
     if(ids == null || ids.length <= 0) {