浏览代码

Merge remote-tracking branch 'origin/develop' into develop

shenjingwei 4 月之前
父节点
当前提交
2408b0884c

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6966,6 +6966,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025121613554803 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 2 - 2
src/custom/restcontroller/sale/cashbill/SQL/收支凭证新增.sql

@@ -1,7 +1,7 @@
 insert into sa_cashbill (siteid, sa_cashbillid, createuserid, createby, createdate, billno, changeuserid, changeby,
                          changedate,
                          sys_enterpriseid, sa_accountclassid, type, remarks, amount, status, source, sourcenote,
-                         subclass, class, ownertable, ownerid,period,discountamount,billdate)
+                         subclass, class, ownertable, ownerid,period,discountamount,billdate,isupload)
 values ($siteid$, $sa_cashbillid$, $userid$, $username$, CURRENT_TIME, $billno$, $userid$, $username$, CURRENT_TIME,
         $sys_enterpriseid$, $sa_accountclassid$, $type$, $remarks$,
-        $amount$, '新建', $source$, $sourcenote$, $subclass$, $class$, $ownertable$, $ownerid$,$period$,$discountamount$,$billdate$);
+        $amount$, '新建', $source$, $sourcenote$, $subclass$, $class$, $ownertable$, $ownerid$,$period$,$discountamount$,$billdate$,0);

+ 1 - 0
src/custom/restcontroller/sale/cashbill/SQL/收支凭证详情查询.sql

@@ -27,6 +27,7 @@ SELECT t1.sa_cashbillid,
        t1.balance,
        t1.period,
        t1.billdate,
+       t1.isupload,
        (t1.amount - t1.writeoffamount) unwriteoffamount,
        t4.billno                       offsettingbillno
 FROM sa_cashbill t1

+ 61 - 0
src/custom/restcontroller/sale/cashbill/TxtFactory.java

@@ -0,0 +1,61 @@
+package restcontroller.sale.cashbill;
+
+import beans.parameter.Parameter;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import common.YosException;
+import common.data.Row;
+import common.data.Rows;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
+public class TxtFactory {
+    private String filename;
+    public static String filetype = "txt";
+    String filepath = "";
+
+    public TxtFactory(String filename) throws YosException {
+        this.filename = filename + Calendar.getInstance().getTimeInMillis();
+        String var10001 = Parameter.getExcelExportPath();
+        this.filepath = var10001 + "/" + this.filename + "." + filetype;
+    }
+
+    public void write(String str) throws YosException {
+        try {
+            PrintWriter out = new PrintWriter(new FileWriter(this.filepath));
+
+            // 写入文本
+            out.println(str);
+            // 确保所有缓冲的输出都被写出
+            out.flush();
+
+            // 关闭PrintWriter,虽然在这个例子中System.out不需要显式关闭
+            out.close();
+            out.flush();
+        } catch (IOException var16) {
+            var16.printStackTrace();
+        }
+
+    }
+
+    public String getFilename() {
+        return this.filename + "." + filetype;
+    }
+
+    public String getFilepath() {
+        return this.filepath;
+    }
+
+    public File getFile() throws YosException {
+        return new File(this.filepath);
+    }
+
+    public void deletefile() {
+        File file = new File(this.filepath);
+        file.delete();
+    }
+}

+ 71 - 0
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -18,7 +18,10 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import restcontroller.R;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -1090,6 +1093,74 @@ public class cashbill extends Controller {
         return queryCashbillMain();
     }
 
+    @API(title = "导出u8凭证", apiversion = R.ID2025121613554803.v1.class)
+    public String download() throws YosException {
+        Date date =new Date();
+        Calendar cal = Calendar.getInstance();
+        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
+        String now =sdf.format(date);
+        StringBuffer buf = new StringBuffer();
+        LinkedHashSet<String> agentList = new LinkedHashSet();
+        JSONArray sa_cashbillids = content.getJSONArray("sa_cashbillids");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "*");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid",
+                "agentnum","u8subject");
+        querySQL.setTableAlias("t1");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t1.sa_cashbillid",sa_cashbillids);
+        querySQL.setWhere("t1.status='审核' and t1.isupload=0");
+        System.err.println(querySQL.getSQL());
+        Rows rows =querySQL.query();
+        if(rows.isNotEmpty()){
+            now=sdf.format(rows.get(0).getDate("billdate"));
+            cal.setTime(rows.get(0).getDate("billdate"));
+            buf.append(
+                    "凭证输出,V800,016,新浙江美大节能电器销售有限公司,"+cal.get(Calendar.YEAR)+",F1日期F2类别,F3凭证号F4附单据数,F5摘要F6科目编码,F7借方F8贷方,F9数量F10原币,F11汇率,F12制单人,F13结算方式,F14票号,F15发生日期,F16部门编码,F17个人编码,F18客户编码,F19供应商编码,F20业务员,F21项目编码,F22自定义项1,F23自定义项2,F24自由项1,F25自由项2,F26自由项3,F27自由项4,F28自由项5,F29自由项6,F30自由项7,F31自由项8,F32自由项9,F33自由项10,F34外部系统标识,F35业务类型,F36单据类型,F37单据日期,F38单据号,F39凭证是否可改,F40分录是否可增删,F41合计金额是否保值,F42数值是否可改,F43科目是否可改,F44受控科目,F45往来是否可改,F46部门是否可改,F47项目是否可改,F48往来项是否必输,F49账套号,F50核算单位,F51会计年度,F52会计期间,F53类别顺序号,F54凭证号,F55审核人,F56记账人,F57是否记账,F58出纳人,F59行号,F60原币名称,数量单位,F61单价,F62科目名称,F63部门名称,F64个人名称,F65客户简称,F66供应商简称,F67项目名称,F68项目大类编码,F69项目大类名称,F70对方科目,F71银行两清标志,F72往来两清标志,F73银行核销标志,F74外部系统名称,F75外部账套号,F76外部会计年度,F77外部会计期间,F78外部制单日期,F79外部系统版本,F80凭证标识,F81分录自动编号,F82唯一标识,F83主管签字,F84自由项11,F85自由项12,F86自由项13,F87自由项14,F88自由项15,F89自由项16,F90审核日期:\r\n");
+            int count = 1;
+            for(Row row :rows){
+                String u8subject=row.getString("u8subject");
+                if(!StringUtils.isBlank(u8subject)){
+                    buf.append(now+",记,"+count+",,农行收到货款,100201,"+row.getDouble("amount")+",0,,0,,朱群美,,,"+now+",,,,,,,,,,,,,0,,0,,,,,,,,,FALSE,FALSE,FALSE,FALSE,FALSE,,FALSE,FALSE,FALSE,FALSE,016,新浙江美大节能电器销售有限公司,"+cal.get(Calendar.YEAR)+","+(cal.get(Calendar.MONTH)+1)+",1,,,,0,,1,,,,海宁农行01810,,,,,,,,"+u8subject+",0,0,FALSE,,,0,0,,,,0,0,,,,,,0,0,\r\n");
+                    buf.append(now+",记,"+count+",,农行收到货款,"+u8subject+",0,"+row.getDouble("amount")+",,0,,朱群美,,,"+now+",,,,,,,,,,,,,0,,0,,,,,,,,,FALSE,FALSE,FALSE,FALSE,FALSE,,FALSE,FALSE,FALSE,FALSE,016,新浙江美大节能电器销售有限公司,"+cal.get(Calendar.YEAR)+","+(cal.get(Calendar.MONTH)+1)+",1,,,,0,,2,,台,,,,,,,,,,100201,0,0,FALSE,,,0,0,,,,0,0,,,,,,0,0,\r\n");
+                    count++;
+                    // 如果成功,则进行审核操作
+                    sqlList.add("update sa_cashbill set isupload=1 where sa_cashbillid="+row.getLong("sa_cashbillid"));
+                }else{
+                    agentList.add(row.getString("agentnum"));
+                }
+            }
+        }else{
+            return getErrReturnObject().setErrMsg("选择审核且已导出的收入凭证的数量不能为0").toString();
+        }
+        TxtFactory txtFactory =new TxtFactory("Logisticslabel");
+        txtFactory.write(buf.toString());
+        Rows filerows = saveToAttachment(txtFactory.getFile());
+        String url = "";
+        if (!filerows.isEmpty()) {
+            url = filerows.get(0).getString("url");
+        }
+
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("url", url);
+        if(agentList.isEmpty()){
+            result.put("errinfo", "");
+        }else{
+            StringBuffer fagentnums = new StringBuffer();
+            for(String str : agentList){
+                fagentnums.append(str+",");
+            }
+            result.put("errinfo", "以下经销商"+fagentnums.toString().substring(0, fagentnums.toString().length()-1)+"凭证未导出,原因:未维护U8科目");
+        }
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().setData(result).toString();
+
+    }
+
+
+
     public Object getCellFormatValue(Cell cell) {
         Object cellValue = null;
         if (cell != null) {