Просмотр исходного кода

增加查询已上传单据是否上传的方法,检测遗漏掉的单据

hejq 8 лет назад
Родитель
Сommit
cdef339a3a

+ 9 - 0
src/main/java/com/uas/erp/schedular/b2b/domain/Inquiry.java

@@ -30,6 +30,7 @@ public class Inquiry extends KeyEntity {
 	private String in_attach;
 	private List<Attach> attaches;// 所有的附件信息
 	private String in_pricetype;
+	private Long in_b2bid;// B2B存储的id信息
 	// 主动报价用字段
 	private Long b2b_qu_id;
 	private Long in_buyeruu;
@@ -174,6 +175,14 @@ public class Inquiry extends KeyEntity {
 		this.in_kind = in_kind;
 	}
 
+	public Long getIn_b2bid() {
+		return in_b2bid;
+	}
+
+	public void setIn_b2bid(Long in_b2bid) {
+		this.in_b2bid = in_b2bid;
+	}
+
 	/**
 	 * 主动报价SQL封装
 	 * 

+ 9 - 0
src/main/java/com/uas/erp/schedular/b2b/domain/Purchase.java

@@ -46,6 +46,7 @@ public class Purchase extends KeyEntity {
 	private String pu_refcode; // 销售单号
 	private String pu_custcode; // 客户编号,
 	private String pu_custname; // 客户名称。
+	private Long pu_b2bid; // b2bid
 
 	public String getPu_vendcode() {
 		return pu_vendcode;
@@ -314,6 +315,14 @@ public class Purchase extends KeyEntity {
 		this.pu_vendname = pu_vendname;
 	}
 
+	public Long getPu_b2bid() {
+		return pu_b2bid;
+	}
+
+	public void setPu_b2bid(Long pu_b2bid) {
+		this.pu_b2bid = pu_b2bid;
+	}
+
 	@Override
 	public Object getKey() {
 		return this.pu_id;

+ 67 - 0
src/main/java/com/uas/erp/schedular/b2b/task/CheckTransTask.java

@@ -0,0 +1,67 @@
+package com.uas.erp.schedular.b2b.task;
+
+import com.uas.erp.schedular.b2b.domain.*;
+import com.uas.erp.schedular.task.support.Role;
+import com.uas.erp.schedular.task.support.TaskMapping;
+import com.uas.erp.schedular.util.ContextHolder;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 查询数据传输(买家)
+ * Created by hejq on 2018-04-19.
+ */
+@Component
+@TaskMapping(title = "单据传输同步更新", role = Role.BUYER)
+public class CheckTransTask extends AbstractTask {
+
+    @TaskMapping(title = "采购询价单", fixedDelay = 60000)
+    public void uploadInquiry() {
+        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from (select in_id from Inquiry left join employee on in_recorderid = em_id where in_statuscode='AUDITED' and IN_SENDSTATUS='已上传' and in_b2bid is null and nvl(in_class,' ')<>'主动报价' and exists (select 1 from InquiryDetail left join vendor on id_vendcode=ve_code where id_inid=in_id and ve_uu is not null and nvl(ve_b2benable,0)=1) order by in_date desc) where rownum <= 100",
+                Inquiry.class);
+        if (!CollectionUtils.isEmpty(inquiries)) {
+            ContextHolder.setDataSize(inquiries.size());
+            List<Inquiry> inquiryList = postForList("/erp/buyer/inquiry", Inquiry.class, dataWrap(inquiries));
+            if (!CollectionUtils.isEmpty(inquiryList)) {
+                List<String> sqls = new ArrayList<>();
+               for (Inquiry inquiry : inquiryList) {
+                   if (null != inquiry.getIn_b2bid()) {
+                       sqls.add("update inquiry set in_b2bid = " + inquiry.getIn_b2bid() + " where in_id = " + inquiry.getIn_id());
+                   } else {
+                       sqls.add("update inquiry set in_sendStatus = '待上传' where in_id = " + inquiry.getIn_id());
+                   }
+               }
+               if (!CollectionUtils.isEmpty(sqls)) {
+                   jdbcTemplate.batchExecute(sqls);
+               }
+            }
+        }
+    }
+
+    @TaskMapping(title = "采购订单", fixedDelay = 60000)
+    public void uploadPurchase() {
+        List<Purchase> purchaseList = jdbcTemplate.queryForBeanList("select * from (select pu_id from purchase left join vendor on pu_vendcode=ve_code left join employee on pu_buyerid=em_id where PU_SENDSTATUS='已上传' and pu_statuscode='AUDITED' and nvl(pu_ordertype,' ')<>'B2C' and ve_uu is not null and nvl(ve_b2benable,0)=1 and not exists (select 1 from purchasedetail,product where pd_puid=pu_id and pr_code=pd_prodcode and pr_sendstatus<>'已上传' and pu_b2bid is null) order by pu_code) where rownum <= 100",
+                Purchase.class);
+        if (!CollectionUtils.isEmpty(purchaseList)) {
+            ContextHolder.setDataSize(purchaseList.size());
+            purchaseList = postForList("/erp/buyer/purchase", Purchase.class, dataWrap(purchaseList));
+            if (!CollectionUtils.isEmpty(purchaseList)) {
+                List<String> sqls = new ArrayList<>();
+                for (Purchase purchase : purchaseList) {
+                    if (null != purchase.getPu_b2bid()) {
+                        sqls.add("update purchase set pu_b2bid = " + purchase.getPu_b2bid() + " where pu_id = " + purchase.getPu_id());
+                    } else {
+                        sqls.add("update purchase set pu_sendStatus = '待上传' where pu_id = " + purchase.getPu_id());
+                    }
+                }
+                if (!CollectionUtils.isEmpty(sqls)) {
+                    jdbcTemplate.batchExecute(sqls);
+                }
+            }
+        }
+    }
+
+}