郭齐峰 2 лет назад
Родитель
Сommit
f45f509352
1 измененных файлов с 47 добавлено и 40 удалено
  1. 47 40
      src/custom/restcontroller/sale/cashbill/cashbill.java

+ 47 - 40
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -58,7 +58,7 @@ public class cashbill extends Controller {
         for (int i = 0; i <= 10; i++) {
             sheet.setDefaultColumnStyle(i, style);
         }
-        if(content.getString("type").equals("收入")){
+        if (content.getString("type").equals("收入")) {
             IncomeExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
             XSSFCellStyle titleCellStyle1 = IncomeExportExcel.createTitleCellStyle1(xssfFWorkbook);
             XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
@@ -67,7 +67,7 @@ public class cashbill extends Controller {
             IncomeExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
                     xssfFWorkbook);// 写入标题
 
-        }else if(content.getString("type").equals("支出")){
+        } else if (content.getString("type").equals("支出")) {
             PayExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
             XSSFCellStyle titleCellStyle1 = PayExportExcel.createTitleCellStyle1(xssfFWorkbook);
             XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
@@ -75,7 +75,7 @@ public class cashbill extends Controller {
             XSSFCellStyle titleCellStyle4 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
             PayExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
                     xssfFWorkbook);// 写入标题
-        }else{
+        } else {
             return getErrReturnObject().setErrMsg("凭证类型不匹配,无法下载导入文件").toString();
         }
 
@@ -116,10 +116,10 @@ public class cashbill extends Controller {
             keys.add("type");
             keys.add("typemx");
             keys.add("remarks");
-            Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid,accountname from sa_accountclass where siteid='"+siteid+"' and isused=1");
+            Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid,accountname from sa_accountclass where siteid='" + siteid + "' and isused=1");
             RowsMap accountclassRowsMap = accountclassRows.toRowsMap("accountname");
 
-            Rows agentRows = dbConnect.runSqlQuery("select agentnum,sys_enterpriseid from sa_agents where siteid='"+siteid+"'");
+            Rows agentRows = dbConnect.runSqlQuery("select agentnum,sys_enterpriseid from sa_agents where siteid='" + siteid + "'");
             RowsMap agentRowsMap = agentRows.toRowsMap("agentnum");
             if (!(content.getString("type") + "凭证导入")
                     .equals(((String) getCellFormatValue(e.getSheet(0).getRow(0).getCell(0))).replace(" ", ""))) {
@@ -136,11 +136,11 @@ public class cashbill extends Controller {
                 String msg = "";
                 if (StringUtils.isEmpty(row.getString("agentnum"))) {
                     iserr = true;
-                    msg =msg + "【经销商编码为空】";
+                    msg = msg + "【经销商编码为空】";
                 }
                 if (StringUtils.isEmpty(row.getString("accountname"))) {
                     iserr = true;
-                    msg = msg +"【账户名称为空】";
+                    msg = msg + "【账户名称为空】";
 
                 }
                 if (!isBigDecimal(row.getString("amount"))) {
@@ -150,25 +150,25 @@ public class cashbill extends Controller {
                 }
                 if (StringUtils.isEmpty(row.getString("type"))) {
                     iserr = true;
-                    msg = msg +"【分类为空】";
+                    msg = msg + "【分类为空】";
 
                 }
-                if(!agentRowsMap.containsKey(row.getString("agentnum"))){
+                if (!agentRowsMap.containsKey(row.getString("agentnum"))) {
                     iserr = true;
-                    msg = msg +"【该经销商编码找不到匹配的经销商】";
-                }else{
-                    if(agentRowsMap.get(row.getString("agentnum")).isEmpty()){
+                    msg = msg + "【该经销商编码找不到匹配的经销商】";
+                } else {
+                    if (agentRowsMap.get(row.getString("agentnum")).isEmpty()) {
                         iserr = true;
-                        msg = msg +"【该经销商编码找不到匹配的经销商】";
+                        msg = msg + "【该经销商编码找不到匹配的经销商】";
                     }
                 }
-                if(!accountclassRowsMap.containsKey(row.getString("accountname"))){
+                if (!accountclassRowsMap.containsKey(row.getString("accountname"))) {
                     iserr = true;
-                    msg = msg +"【该账户名称找不到匹配的账户】";
-                }else{
-                    if(accountclassRowsMap.get(row.getString("accountname")).isEmpty()){
+                    msg = msg + "【该账户名称找不到匹配的账户】";
+                } else {
+                    if (accountclassRowsMap.get(row.getString("accountname")).isEmpty()) {
                         iserr = true;
-                        msg = msg +"【该账户名称找不到匹配的账户】";
+                        msg = msg + "【该账户名称找不到匹配的账户】";
                     }
                 }
 
@@ -202,24 +202,24 @@ public class cashbill extends Controller {
                     SQLFactory sqlFactoryupload = new SQLFactory(this, "收支凭证新增");
                     sqlFactoryupload.addParameter("sa_cashbillid", sa_cashbillid[i]);
                     sqlFactoryupload.addParameter("billno", createBillCode("cashbill"));
-                    if(agentRowsMap.containsKey(row.getString("agentnum"))){
+                    if (agentRowsMap.containsKey(row.getString("agentnum"))) {
                         sqlFactoryupload.addParameter("sys_enterpriseid", agentRowsMap.get(row.getString("agentnum")).get(0).getLong("sys_enterpriseid"));
-                    }else {
+                    } else {
                         continue;
                     }
-                    if(accountclassRowsMap.containsKey(row.getString("accountname"))){
+                    if (accountclassRowsMap.containsKey(row.getString("accountname"))) {
                         sqlFactoryupload.addParameter("sa_accountclassid", accountclassRowsMap.get(row.getString("accountname")).get(0).getLong("sa_accountclassid"));
-                    }else {
+                    } else {
                         continue;
                     }
-                    if(content.getString("type").equals("收入")){
+                    if (content.getString("type").equals("收入")) {
                         sqlFactoryupload.addParameter("type", 1);
-                    }else{
+                    } else {
                         sqlFactoryupload.addParameter("type", 0);
                     }
                     sqlFactoryupload.addParameter("siteid", siteid);
                     sqlFactoryupload.addParameter("remarks", row.getString("remarks"));
-                    sqlFactoryupload.addParameter("amount",  row.getDouble("amount"));
+                    sqlFactoryupload.addParameter("amount", row.getDouble("amount"));
                     sqlFactoryupload.addParameter("subclass", row.getString("typemx"));
                     sqlFactoryupload.addParameter("class", row.getString("type"));
                     sqlFactoryupload.addParameter("userid", userid);
@@ -262,9 +262,9 @@ public class cashbill extends Controller {
                 keytypemap.put("msg", String.class);
                 rowserr.setFieldList(colNameList);
                 rowserr.setFieldTypeMap(keytypemap);
-                if(content.getString("type").equals("收入")){
+                if (content.getString("type").equals("收入")) {
                     addSheetIncome(excelFactory, "Sheet1", rowserr, map);
-                }else {
+                } else {
                     addSheetPay(excelFactory, "Sheet1", rowserr, map);
                 }
 
@@ -288,7 +288,6 @@ public class cashbill extends Controller {
     }
 
 
-
     @API(title = "收支凭证新建更新", apiversion = R.ID20221009102803.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
     public String insertormodify_creditbill() throws YosException {
@@ -300,7 +299,13 @@ public class cashbill extends Controller {
         String subclass = content.getString("subclass");
         String class1 = content.getString("class");
         String period = content.getStringValue("period");
-
+        if (StringUtils.isEmpty(period)) {
+            if (type == 0) {
+                return getErrReturnObject().setErrMsg("未填写归属日期").toString();
+            } else if (type == 1 && subclass.equals("拨款")) {
+                period = getDate_Str();
+            }
+        }
         //String billcode = "123456789";
         BigDecimal amount = content.getBigDecimal("amount");
         String remarks = content.getString("remarks");
@@ -437,7 +442,7 @@ public class cashbill extends Controller {
                 where = where + " and ifnull(t3.isrebate,0) ='" + whereObject.getLongValue("isrebate") + "'";
             }
             if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
-                where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo")+ "%'"
+                where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
                         + "  or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
                         + ")";
             }
@@ -502,7 +507,7 @@ public class cashbill extends Controller {
                 where = where + " and ifnull(t3.isrebate,0) ='" + whereObject.getLongValue("isrebate") + "'";
             }
             if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
-                where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo")+ "%'"
+                where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
                         + "  or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
                         + ")";
             }
@@ -632,6 +637,7 @@ public class cashbill extends Controller {
         dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
     }
+
     /**
      * 收支凭证反审核
      *
@@ -652,7 +658,7 @@ public class cashbill extends Controller {
                 return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核")
                         .toString();
             }
-            if ( rows.get(0).getLong("type")!=1) {
+            if (rows.get(0).getLong("type") != 1) {
                 return getErrReturnObject().setErrMsg("非收入凭证无法反审核")
                         .toString();
             }
@@ -665,7 +671,7 @@ public class cashbill extends Controller {
             long sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
             long type = rows.get(0).getLong("type");
             Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
-             System.out.println("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
+            System.out.println("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
             if (type == 1) {
                 Rows offsettingRows = dbConnect.runSqlQuery("select amount from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and ownerid=" + rows.get(0).getLong("ownerid"));
                 if (offsettingRows.isNotEmpty()) {
@@ -798,11 +804,11 @@ public class cashbill extends Controller {
 
             }
             if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
-                where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') >=DATE_FORMAT('"+whereObject.getString("begindate")+"','%Y-%m-%d')";
+                where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') >=DATE_FORMAT('" + whereObject.getString("begindate") + "','%Y-%m-%d')";
 
             }
             if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
-                where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') <=DATE_FORMAT('"+whereObject.getString("enddate")+"','%Y-%m-%d')";
+                where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') <=DATE_FORMAT('" + whereObject.getString("enddate") + "','%Y-%m-%d')";
 
             }
 
@@ -813,7 +819,7 @@ public class cashbill extends Controller {
          */
         boolean isExport = content.getBooleanValue("isExport");
         SQLFactory factory = new SQLFactory(this, "资金流水账查询", pageSize, pageNumber, pageSorting);
-        if(isExport){
+        if (isExport) {
             factory = new SQLFactory(this, "资金流水账查询导出");
         }
         factory.addParameter("sys_enterpriseid", sys_enterpriseid);
@@ -841,8 +847,8 @@ public class cashbill extends Controller {
         factoryhz.addParameter("siteid", siteid);
         factoryhz.addParameter_SQL("where", where);
         Rows rowszh = dbConnect.runSqlQuery(factoryhz.getSQL());
-        if(!rows.isEmpty()){
-            rows.get(0).put("total",rowszh);
+        if (!rows.isEmpty()) {
+            rows.get(0).put("total", rowszh);
         }
 
         return getSucReturnObject().setData(rows).toString();
@@ -952,7 +958,7 @@ public class cashbill extends Controller {
     }
 
     public XSSFSheet addSheetIncome(ExcelFactory excelFactory, String sheetname, Rows datarows,
-                              HashMap<String, String> titlemap) {
+                                    HashMap<String, String> titlemap) {
         ArrayList<String> keylist = datarows.getFieldList();
         XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
         XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
@@ -996,7 +1002,7 @@ public class cashbill extends Controller {
     }
 
     public XSSFSheet addSheetPay(ExcelFactory excelFactory, String sheetname, Rows datarows,
-                                    HashMap<String, String> titlemap) {
+                                 HashMap<String, String> titlemap) {
         ArrayList<String> keylist = datarows.getFieldList();
         XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
         XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
@@ -1038,6 +1044,7 @@ public class cashbill extends Controller {
         }
         return sheet;
     }
+
     //返回导出的标题
     public HashMap<String, String> getTitleMap() {
         HashMap<String, String> titleMap = new HashMap<>();