Explorar o código

开票订单行修改2022年3月23日15:42:50

hu %!s(int64=4) %!d(string=hai) anos
pai
achega
64f4688f0b

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

@@ -1,24 +1,24 @@
-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
-left join tproject tp on sa.fprojectnum = tp.fprojectnum
-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 * from sainvoice_closedate sdate left join saorderdetail t1 on sdate.fsourceid = t1.saorderdetailid
-                where sdate.closedate1 is not null and $where$)
-and exists(select * from tproject tp left join saorder sa on sa.fprojectnum = tp.fprojectnum
-                left join saorderdetail t1 on t1.fparentid = sa.saorderid where $where$)
-and exists(
-        select * from saorder
-        where fstatus in('ÉóºË','¹Ø±Õ') and siteid=t1.siteid
-        and saorderid=t1.fparentid and fpayagentnum=$fagentnum$ --and finvoicetaxnumber=$finvoicetaxnumber$
-)
-and not exists(
-    select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
+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
+left join tproject tp on sa.fprojectnum = tp.fprojectnum
+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$
+)
+and not exists(
+    select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
 )

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

@@ -227,26 +227,23 @@ public class Tinvoiceapply extends Controller {
      * @return
      * @throws ParseException 
      */
-    public String querySaorderDetail() throws ParseException {
+    public String querySaorderDetail() {
         //String finvoicetaxnumber = content.getString("finvoicetaxnumber");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
-        JSONObject where = content.getJSONObject("where");
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        String wherestr="1=1";
-        if(where!=null){
-            if(where.containsKey("closedate1")&&!StringUtils.isBlank(where.getString("closedate1"))){
-                wherestr = "sdate.closedate1 >="+sdf.parse( where.getString("fbegdate"))+"and sdate.closedate1 <="+sdf.parse( where.getString("fenddate"));
-            }
-            if(where.containsKey("fprojectname")&&!StringUtils.isBlank(where.getString("fprojectname"))){
-                wherestr = "tp.fprojectname like '%"+where.getString("fprojectname")+"%'";
-            }
-        }
+        String fbegdate = content.getString("fbegdate");
+        String fenddate = content.getString("fenddate");
+        String fprojectname = content.getString("fprojectname");
+
+        String wherestr1 = "sdate.closedate1 >='"+fbegdate+"' and sdate.closedate1 <='"+fenddate+"'";
+        String wherestr2 = "tp.fprojectname like '%"+fprojectname+"%'";
         SQLFactory factory = new SQLFactory(this, "¿ªÆ±¶©µ¥ÐÐÑ¡Ôñ²éѯ");
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
-        factory.addParameter_SQL("where", wherestr);
+        factory.addParameter_SQL("where1", wherestr1);
+        factory.addParameter_SQL("where2", wherestr2);
         //factory.addParameter("finvoicetaxnumber", finvoicetaxnumber);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
+        System.out.println("factory.getSQL()==="+factory.getSQL());
 
         DBConnect connect = new DBConnect();
         Rows rows = connect.runSqlQuery(factory.getSQL());

+ 10 - 13
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/Tinvoiceapply_saler.java

@@ -258,26 +258,23 @@ public class Tinvoiceapply_saler extends Controller {
      *
      * @return
      */
-    public String querySaorderDetail() throws ParseException {
+    public String querySaorderDetail() {
         //String finvoicetaxnumber = content.getString("finvoicetaxnumber");
         long tinvoiceapplyid = content.getLong("tinvoiceapplyid");
-        JSONObject where = content.getJSONObject("where");
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        String wherestr="1=1";
-        if(where!=null){
-            if(where.containsKey("closedate1")&&!StringUtils.isBlank(where.getString("closedate1"))){
-                wherestr = "sdate.closedate1 >="+sdf.parse( where.getString("fbegdate"))+"and sdate.closedate1 <="+sdf.parse( where.getString("fenddate"));
-            }
-            if(where.containsKey("fprojectname")&&!StringUtils.isBlank(where.getString("fprojectname"))){
-                wherestr = "tp.fprojectname like '%"+where.getString("fprojectname")+"%'";
-            }
-        }
+        String fbegdate = content.getString("fbegdate");
+        String fenddate = content.getString("fenddate");
+        String fprojectname = content.getString("fprojectname");
+
+        String wherestr1 = "sdate.closedate1 >='"+fbegdate+"' and sdate.closedate1 <='"+fenddate+"'";
+        String wherestr2 = "tp.fprojectname like '%"+fprojectname+"%'";
         SQLFactory factory = new SQLFactory(this, "¿ªÆ±¶©µ¥ÐÐÑ¡Ôñ²éѯ");
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
-        factory.addParameter_SQL("where", wherestr);
+        factory.addParameter_SQL("where1", wherestr1);
+        factory.addParameter_SQL("where2", wherestr2);
         //factory.addParameter("finvoicetaxnumber", finvoicetaxnumber);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
+        System.out.println("factory.getSQL()==="+factory.getSQL());
 
         DBConnect connect = new DBConnect();
         Rows rows = connect.runSqlQuery(factory.getSQL());