Browse Source

更新发货提醒取消增加异常统计方法

hejq 7 years ago
parent
commit
247d666c90

+ 1 - 1
src/main/java/com/uas/platform/b2b/erp/model/NoticeRecord.java

@@ -66,7 +66,7 @@ public class NoticeRecord implements Serializable {
     private String kind = "";
 
     /**
-     * 对应的采购单详情List
+     * 对应的详情List
      */
     @OneToMany(mappedBy = "record", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.EAGER)
     private List<NoticeRecordDetail> details;

+ 11 - 0
src/main/java/com/uas/platform/b2b/erp/model/NoticeRecordDetail.java

@@ -104,6 +104,9 @@ public class NoticeRecordDetail implements Serializable {
     @Column(name = "nod_remark")
     private String  remark = "";
 
+    @Transient
+    private int errorCount;
+
     public Long getId() {
         return id;
     }
@@ -191,4 +194,12 @@ public class NoticeRecordDetail implements Serializable {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public int getErrorCount() {
+        return errorCount;
+    }
+
+    public void setErrorCount(int errorCount) {
+        this.errorCount = errorCount;
+    }
 }

+ 13 - 7
src/main/java/com/uas/platform/b2b/erp/service/impl/NoticeRecordServiceImpl.java

@@ -17,6 +17,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 发货提醒校验记录
@@ -51,9 +52,13 @@ public class NoticeRecordServiceImpl implements NoticeRecordService {
         record.setEnUU(enterprise.getUu());
         record.setKind("end");
         List<NoticeRecordDetail> details = new ArrayList<>();
-        int errorCount = 0;
-        notifyList.forEach(notify -> details.add(covert(notify, errorCount)));
-        record.setErrorCount(errorCount);
+        final int[] errorCount = {0};
+        notifyList.forEach(notify -> {
+            NoticeRecordDetail detail = covert(notify);
+            details.add(detail);
+            errorCount[0] += detail.getErrorCount();
+        });
+        record.setErrorCount(errorCount[0]);
         record.setDetails(details);
         recordDao.save(record);
     }
@@ -62,15 +67,15 @@ public class NoticeRecordServiceImpl implements NoticeRecordService {
      * 将ERP发货提醒明细转成B2B记录明细
      *
      * @param notify ERP发货提醒明细
-     * @param errorCount 异常数
      * @return NoticeRecordDetail
      */
-    private NoticeRecordDetail covert(PurchaseNotify notify, int errorCount) {
+    private NoticeRecordDetail covert(PurchaseNotify notify) {
         NoticeRecordDetail detail = new NoticeRecordDetail();
         PurchaseNotice notice = noticeDao.findOne(notify.getPn_b2bid());
         detail.setErpId(notify.getPn_id());
         detail.setOkStatus(Constant.NO);
         detail.setRemark(notify.getPn_remark());
+        detail.setErrorCount(0);
         if (null != notice) {
             detail.setB2bId(notice.getId());
             detail.setNeedQty(notice.getQty());
@@ -79,10 +84,11 @@ public class NoticeRecordServiceImpl implements NoticeRecordService {
             detail.setNoDate(notice.getDate());
             if (detail.getSendQty() == 0) {
                 detail.setOkStatus(Constant.YES);
-            } else {
-                errorCount++;
             }
         }
+        if (Objects.equals(detail.getOkStatus(), Constant.NO)) {
+            detail.setErrorCount(1);
+        }
         return detail;
     }