|
|
@@ -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) {
|