瀏覽代碼

收支凭证导入判断归属日期是否符合格式

hu 11 月之前
父節點
當前提交
5aa1bf7b11
共有 1 個文件被更改,包括 22 次插入0 次删除
  1. 22 0
      src/custom/restcontroller/sale/cashbill/cashbill.java

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

@@ -21,6 +21,7 @@ import restcontroller.system.attachment.Attachment;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -140,6 +141,17 @@ public class cashbill extends Controller {
                     msg = msg + "【账户名称为空】";
 
                 }
+                if (StringUtils.isEmpty(row.getString("accountname"))) {
+                    iserr = true;
+                    msg = msg + "【账户名称为空】";
+
+                }
+                if (!isValidFormat(row.getString("period"))) {
+                    iserr = true;
+                    msg = msg + "【归属日期格式错误】";
+
+                }
+
                 if (!isBigDecimal(row.getString("amount"))) {
                     iserr = true;
                     msg = msg + "【金额错误:" + row.getString("amount") + "】";
@@ -1319,5 +1331,15 @@ public class cashbill extends Controller {
         remind.setTouserid(userList);
         remind.sendByDialogMsg().createSys_message();
     }
+    public  boolean isValidFormat(String date) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        dateFormat.setLenient(false); // 设置解析日期时是否宽松,即是否允许解析不严格符合格式的日期字符串
+        try {
+            Date parsedDate = dateFormat.parse(date);
+            return true;
+        } catch (ParseException e) {
+            return false;
+        }
+    }
 
 }