Переглянути джерело

1、修复工厂利润查询数据有误问题

MY 1 місяць тому
батько
коміт
8724f7aa36
1 змінених файлів з 37 додано та 17 видалено
  1. 37 17
      JLHHJSvr/DataStore/web_factory_profitratelist.xml

+ 37 - 17
JLHHJSvr/DataStore/web_factory_profitratelist.xml

@@ -1,23 +1,43 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <select>
   <selectstr>
-SELECT ISNULL(u_factory_profitrate.deptid,v_temp.deptid) AS deptid
-	,ISNULL(u_factory_profitrate.bednet_or_mattress,@kind) AS bednet_or_mattress
-	,ISNULL(u_factory_profitrate.bednettypeid_mattresstypeid,v_temp.bednettypeid) AS bednettypeid_mattresstypeid
-	,ISNULL(u_factory_profitrate.profitrate, 0) AS profitrate
-	,u_factory_profitrate.createtime
-	,u_factory_profitrate.createby
-	,v_temp.deptname
-	,v_temp.typename
-FROM u_factory_profitrate
-RIGHT OUTER JOIN (
-	SELECT u_dept.deptid
-		,u_bednet_type.bednettypeid
-		,u_dept.deptname
-		,u_bednet_type.typename
-	FROM u_dept CROSS JOIN u_bednet_type
-	) v_temp ON u_factory_profitrate.deptid = v_temp.deptid
-	AND u_factory_profitrate.bednettypeid_mattresstypeid = v_temp.bednettypeid
+SELECT
+	ISNULL( u_factory_profitrate.deptid, v_temp_1.deptid ) AS deptid,
+	ISNULL( u_factory_profitrate.bednet_or_mattress,@kind ) AS bednet_or_mattress,
+	ISNULL( u_factory_profitrate.bednettypeid_mattresstypeid, v_temp_1.bednettypeid ) AS bednettypeid_mattresstypeid,
+	ISNULL( u_factory_profitrate.profitrate, 0 ) AS profitrate,
+	u_factory_profitrate.createtime,
+	u_factory_profitrate.createby,
+	v_temp_1.deptname,
+	v_temp_1.typename 
+FROM
+	u_factory_profitrate
+	INNER JOIN (
+	SELECT
+		u_dept.deptid,
+		v_temp.bednettypeid,
+		u_dept.deptname,
+		v_temp.typename 
+	FROM
+		u_dept,
+		(
+		SELECT
+			1 AS kind,
+			u_mattress_type.mattresstypeid AS bednettypeid,
+			u_mattress_type.typename 
+		FROM
+			u_mattress_type UNION ALL
+		SELECT
+			0 AS kind,
+			u_bednet_type.bednettypeid,
+			u_bednet_type.typename 
+		FROM
+			u_bednet_type 
+		) v_temp 
+	WHERE
+		@kind = v_temp.kind 
+	) v_temp_1 ON u_factory_profitrate.deptid = v_temp_1.deptid 
+	AND u_factory_profitrate.bednettypeid_mattresstypeid = v_temp_1.bednettypeid
   </selectstr>
   <where>
 	<when>