Procházet zdrojové kódy

开票订单行选择查询调整

沈静伟 před 4 roky
rodič
revize
75a0c570f3

+ 4 - 19
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/SQL/开票订单行选择查询.sql

@@ -1,24 +1,9 @@
 select *,t2.freceivedamount,tp.fprojectname,sdate.closedate1 from saorderdetail t1
 select *,t2.freceivedamount,tp.fprojectname,sdate.closedate1 from saorderdetail t1
-left join saorder_receivedview t2 on t1.siteid=t2.siteid and t1.saorderdetailid=t2.saorderdetailid
-left join saorder sa on t1.fparentid = sa.saorderid
+inner join saorder_receivedview t2 on t1.siteid=t2.siteid and t1.saorderdetailid=t2.saorderdetailid and isnull(t2.freceivedamount,0)>isnull(t1.finvoiceamount,0)
+inner join saorder sa on t1.fparentid = sa.saorderid
 left join tproject tp on sa.fprojectnum = tp.fprojectnum
 left join tproject tp on sa.fprojectnum = tp.fprojectnum
 left join sainvoice_closedate sdate on sdate.fsourceid = t1.saorderdetailid
 left join sainvoice_closedate sdate on sdate.fsourceid = t1.saorderdetailid
-where
-t1.siteid=$siteid$ and
-exists(
-        select *from saorder_receivedview
-        where siteid=t1.siteid and saorderid=t1.fparentid and saorderdetailid=t1.saorderdetailid
-        and isnull(freceivedamount,0)>isnull(t1.finvoiceamount,0)
-)
-and exists(select tp.fprojectname,sa.*,t1.* from tproject tp where sa.fprojectnum = tp.fprojectnum
-                and t1.fparentid = sa.saorderid and $where2$)
-and exists(select sdate.closedate1,t1.* from sainvoice_closedate sdate where sdate.fsourceid = t1.saorderdetailid
-                and sdate.closedate1 is not null and $where1$)
-and exists(
-        select * from saorder
-        where fstatus in('ÉóºË','¹Ø±Õ') and siteid=t1.siteid
-        and saorderid=t1.fparentid and fpayagentnum=$fagentnum$ --and finvoicetaxnumber=$finvoicetaxnumber$
-)
+where t1.siteid=$siteid$ and sa.fpayagentnum=$fagentnum$ and sa.fstatus in('ÉóºË','¹Ø±Õ')
 and not exists(
 and not exists(
     select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
     select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
-)
+) and $where$

+ 10 - 16
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/Tinvoiceapply.java

@@ -225,31 +225,25 @@ public class Tinvoiceapply extends Controller {
      * 开票订单行选择
      * 开票订单行选择
      *
      *
      * @return
      * @return
-     * @throws ParseException 
+     * @throws ParseException
      */
      */
     public String querySaorderDetail() {
     public String querySaorderDetail() {
-        //String finvoicetaxnumber = content.getString("finvoicetaxnumber");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
         String fbegdate = content.getString("fbegdate");
         String fbegdate = content.getString("fbegdate");
         String fenddate = content.getString("fenddate");
         String fenddate = content.getString("fenddate");
         String fprojectname = content.getString("fprojectname");
         String fprojectname = content.getString("fprojectname");
+
+        String where = "1=1";
+        if (!"".equals(fbegdate) && !"".equals(fenddate)) {
+            where = where + " and sdate.closedate1>='" + fbegdate + "' and sdate.closedate1<='" + fenddate + "'";
+        }
+        if (!"".equals(fprojectname)) {
+            where = where + " and tp.fprojectname like'" + fprojectname + "'";
+        }
         SQLFactory factory = new SQLFactory(this, "开票订单行选择查询");
         SQLFactory factory = new SQLFactory(this, "开票订单行选择查询");
         factory.addParameter("siteid", siteid);
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
         factory.addParameter("fagentnum", fagentnum);
-        if(!"".equals(fbegdate) && !"".equals(fenddate)){
-            String wherestr1 = " sdate.closedate1 >='"+fbegdate+"' and sdate.closedate1 <='"+fenddate+"'";
-            factory.addParameter_SQL("where1", wherestr1);
-        }else{
-            factory.addParameter_SQL("where1", "1=1");
-        }
-        if(!"".equals(fprojectname)){
-            String wherestr2 = " tp.fprojectname like '%"+fprojectname+"%'";
-            factory.addParameter_SQL("where2", wherestr2);
-        }else{
-            factory.addParameter_SQL("where2", "1=1");
-        }
-
-        //factory.addParameter("finvoicetaxnumber", finvoicetaxnumber);
+        factory.addParameter_SQL("where", where);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
 
 
         DBConnect connect = new DBConnect();
         DBConnect connect = new DBConnect();

+ 11 - 16
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/Tinvoiceapply_saler.java

@@ -11,6 +11,7 @@ import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.pao.PaoSetRemote;
 import tinvoiceapply.tinvoiceapply;
 import tinvoiceapply.tinvoiceapply;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
+
 import java.text.ParseException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -259,33 +260,27 @@ public class Tinvoiceapply_saler extends Controller {
      * @return
      * @return
      */
      */
     public String querySaorderDetail() {
     public String querySaorderDetail() {
-        //String finvoicetaxnumber = content.getString("finvoicetaxnumber");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
         String fbegdate = content.getString("fbegdate");
         String fbegdate = content.getString("fbegdate");
         String fenddate = content.getString("fenddate");
         String fenddate = content.getString("fenddate");
         String fprojectname = content.getString("fprojectname");
         String fprojectname = content.getString("fprojectname");
+        String fagentnum = content.getString("fagentnum");
+
+        String where = "1=1";
+        if (!"".equals(fbegdate) && !"".equals(fenddate)) {
+            where = where + " and sdate.closedate1>='" + fbegdate + "' and sdate.closedate1<='" + fenddate + "'";
+        }
+        if (!"".equals(fprojectname)) {
+            where = where + " and tp.fprojectname like'" + fprojectname + "'";
+        }
         SQLFactory factory = new SQLFactory(this, "¿ªÆ±¶©µ¥ÐÐÑ¡Ôñ²éѯ");
         SQLFactory factory = new SQLFactory(this, "¿ªÆ±¶©µ¥ÐÐÑ¡Ôñ²éѯ");
         factory.addParameter("siteid", siteid);
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
         factory.addParameter("fagentnum", fagentnum);
-        if(!"".equals(fbegdate) && !"".equals(fenddate)){
-            String wherestr1 = " and sdate.closedate1 >='"+fbegdate+"' and sdate.closedate1 <='"+fenddate+"'";
-            factory.addParameter_SQL("where1", wherestr1);
-        }else{
-            factory.addParameter_SQL("where1", "1=1");
-        }
-        if(!"".equals(fprojectname)){
-            String wherestr2 = " and tp.fprojectname like '%"+fprojectname+"%'";
-            factory.addParameter_SQL("where2", wherestr2);
-        }else{
-            factory.addParameter_SQL("where2", "1=1");
-        }
-
-        //factory.addParameter("finvoicetaxnumber", finvoicetaxnumber);
+        factory.addParameter_SQL("where", where);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
 
 
         DBConnect connect = new DBConnect();
         DBConnect connect = new DBConnect();
         Rows rows = connect.runSqlQuery(factory.getSQL());
         Rows rows = connect.runSqlQuery(factory.getSQL());
         return getReturnObject_suc(rows, false).toString();
         return getReturnObject_suc(rows, false).toString();
-
     }
     }
 }
 }