Browse Source

代码合并2018-12-03

chenw 7 years ago
parent
commit
ca542078a2
23 changed files with 430 additions and 54 deletions
  1. 30 0
      src/main/java/com/uas/erp/schedular/b2b/domain/PurchaseDetail.java
  2. 42 4
      src/main/java/com/uas/erp/schedular/b2b/domain/SaleDownDetail.java
  3. 3 3
      src/main/java/com/uas/erp/schedular/b2b/task/CheckTransTask.java
  4. 3 3
      src/main/java/com/uas/erp/schedular/b2b/task/InquiryMouldTask.java
  5. 7 7
      src/main/java/com/uas/erp/schedular/b2b/task/InquiryTask.java
  6. 2 2
      src/main/java/com/uas/erp/schedular/b2b/task/MakeProdInOutTask.java
  7. 5 3
      src/main/java/com/uas/erp/schedular/b2b/task/MakeTask.java
  8. 2 2
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseAPBillTask.java
  9. 1 1
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseChangeTask.java
  10. 1 1
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseForecastTask.java
  11. 1 1
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseMRBTask.java
  12. 4 4
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseNotifyTask.java
  13. 5 4
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseProdInOutTask.java
  14. 4 4
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseSampleTask.java
  15. 4 4
      src/main/java/com/uas/erp/schedular/b2b/task/PurchaseTask.java
  16. 1 1
      src/main/java/com/uas/erp/schedular/b2b/task/VendorPerformanceAssessTask.java
  17. 1 8
      src/main/java/com/uas/erp/schedular/init/ReplyInitializer.java
  18. 90 0
      src/main/java/com/uas/erp/schedular/listen/DiskUtil.java
  19. 46 0
      src/main/java/com/uas/erp/schedular/listen/ListenDomain.java
  20. 172 0
      src/main/java/com/uas/erp/schedular/listen/ListenTask.java
  21. 1 1
      src/main/java/com/uas/erp/schedular/publicinquiry/task/PubInquiryTask.java
  22. 1 1
      src/main/java/com/uas/erp/schedular/publicproduct/task/AbstractTask.java
  23. 4 0
      src/main/java/com/uas/erp/schedular/util/ContextHolder.java

+ 30 - 0
src/main/java/com/uas/erp/schedular/b2b/domain/PurchaseDetail.java

@@ -45,8 +45,38 @@ public class PurchaseDetail {
 	private Float pd_purctaxrate;
 	//终端币别
 	private String pd_purccurrency;
+	//税收分类编码
+    private String pd_taxcode;
+    //开票名称
+    private String pd_billname;
+    //开票型号
+    private String pd_orispeccode;
 	private List<Attach> attaches;
 
+	public String getPd_taxcode() {
+		return pd_taxcode;
+	}
+
+	public void setPd_taxcode(String pd_taxcode) {
+		this.pd_taxcode = pd_taxcode;
+	}
+
+	public String getPd_billname() {
+		return pd_billname;
+	}
+
+	public void setPd_billname(String pd_billname) {
+		this.pd_billname = pd_billname;
+	}
+
+	public String getPd_orispeccode() {
+		return pd_orispeccode;
+	}
+
+	public void setPd_orispeccode(String pd_orispeccode) {
+		this.pd_orispeccode = pd_orispeccode;
+	}
+
 	public Float getPd_purcprice() {
 		return pd_purcprice;
 	}

+ 42 - 4
src/main/java/com/uas/erp/schedular/b2b/domain/SaleDownDetail.java

@@ -44,8 +44,38 @@ public class SaleDownDetail {
 	private Float sd_SpecTaxRate;
 	//终端币别
 	private String sd_SpecCurrency;
-
-	public Float getSd_SpecPrice() {
+	//客户物料税收分类编码
+    private String sd_prodtaxcode;
+    //客户物料开票名称
+    private String sd_prodbillname;
+    //客户物料开票型号
+    private String sd_prodorispeccode;
+
+    public String getSd_prodtaxcode() {
+        return sd_prodtaxcode;
+    }
+
+    public void setSd_prodtaxcode(String sd_prodtaxcode) {
+        this.sd_prodtaxcode = sd_prodtaxcode;
+    }
+
+    public String getSd_prodbillname() {
+        return sd_prodbillname;
+    }
+
+    public void setSd_prodbillname(String sd_prodbillname) {
+        this.sd_prodbillname = sd_prodbillname;
+    }
+
+    public String getSd_prodorispeccode() {
+        return sd_prodorispeccode;
+    }
+
+    public void setSd_prodorispeccode(String sd_prodorispeccode) {
+        this.sd_prodorispeccode = sd_prodorispeccode;
+    }
+
+    public Float getSd_SpecPrice() {
 		return sd_SpecPrice;
 	}
 
@@ -264,7 +294,8 @@ public class SaleDownDetail {
 	public String toSqlString(int foreignKey) {
 		return "insert into SaleDownDetail(b2b_pd_id,sd_id,sd_said,sd_code,sd_detno,sd_custprodcode,sd_custproddetail,sd_prodname,sd_custprodspec,sd_prodspec,"
 				+ "sd_custprodunit,sd_replyqty,sd_replydate,sd_replydetail,sd_price,sd_qty,sd_total,sd_taxrate,sd_SpecPrice,sd_SpecTaxRate,sd_SpecCurrency,"
-				+ "sd_taxtotal,sd_delivery,sd_remark,sd_purcvendname,sd_purcvenduu,sd_purcdetno,sd_acceptcustname,sd_acceptcustaddress,sd_purcvendcode) VALUES ("
+				+ "sd_taxtotal,sd_delivery,sd_remark,sd_purcvendname,sd_purcvenduu,sd_purcdetno,sd_acceptcustname,sd_acceptcustaddress,sd_purcvendcode,sd_prodtaxcode,"
+                + "sd_prodbillname,sd_prodorispeccode) VALUES ("
 				+ b2b_pd_id
 				+ ",SaleDownDetail_SEQ.nextval,"
 				+ foreignKey
@@ -320,7 +351,14 @@ public class SaleDownDetail {
 				+StringUtil.nvl(sd_acceptcustname, "")
 				+ "','"
 				+StringUtil.nvl(sd_acceptcustaddress, "")
-				+"',(select ve_code from vendor where ve_uu="+sd_purcvenduu+" and rownum=1))";
+				+"',(select ve_code from vendor where ve_uu="+sd_purcvenduu+" and rownum=1)"
+                +",'"
+                + StringUtil.nvl(sd_prodtaxcode, "")
+                + "','"
+                + StringUtil.nvl(sd_prodbillname, "")
+                + "','"
+                + StringUtil.nvl(sd_prodorispeccode, "")
+                + "')";
 	}
 
 }

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

@@ -20,7 +20,7 @@ public class CheckTransTask extends AbstractTask {
 
     @TaskMapping(title = "采购询价单", fixedDelay = 60000)
     public void uploadInquiry() {
-        List<Inquiry> inquiryList = 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",
+        List<Inquiry> inquiryList = 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 coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) order by in_date desc) where rowNum <= 100",
                 Inquiry.class);
         if (!CollectionUtils.isEmpty(inquiryList)) {
             ContextHolder.setDataSize(inquiryList.size());
@@ -43,7 +43,7 @@ public class CheckTransTask extends AbstractTask {
 
     @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",
+        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 coalesce(ve_uu, '0') <> '0' 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());
@@ -66,7 +66,7 @@ public class CheckTransTask extends AbstractTask {
 
     @TaskMapping(title = "发货提醒", fixedDelay = 60000)
     public void uploadPurchaseNotify() {
-        List<PurchaseNotify> notifyList = jdbcTemplate.queryForBeanList("select * from (select pn_id from purchaseNotify left join purchase on pn_orderCode=pu_code left join vendor on pu_vendCode=ve_code left join product on pr_code=pn_prodCode where nvl(PN_SENDSTATUS,' ')='已上传' and pn_b2bid is null and pn_status<>'已取消' and pu_sendStatus='已上传' and nvl(pu_orderType,' ')<>'B2C' and ve_uu is not null and nvl(ve_b2bEnable, 0)=1 order by pn_inDate) where rowNum <= 100",
+        List<PurchaseNotify> notifyList = jdbcTemplate.queryForBeanList("select * from (select pn_id from purchaseNotify left join purchase on pn_orderCode=pu_code left join vendor on pu_vendCode=ve_code left join product on pr_code=pn_prodCode where nvl(PN_SENDSTATUS,' ')='已上传' and pn_b2bid is null and pn_status<>'已取消' and pu_sendStatus='已上传' and nvl(pu_orderType,' ')<>'B2C' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2bEnable, 0)=1 order by pn_inDate) where rowNum <= 100",
                 PurchaseNotify.class);
         if (!CollectionUtils.isEmpty(notifyList)) {
             ContextHolder.setDataSize(notifyList.size());

+ 3 - 3
src/main/java/com/uas/erp/schedular/b2b/task/InquiryMouldTask.java

@@ -35,7 +35,7 @@ public class InquiryMouldTask extends AbstractTask {
      * @return
      */
     public List<InquiryMould> getInquiryMouldUpload() {
-        List<InquiryMould> inquiryMoulds = jdbcTemplate.queryForBeanList("select InquiryMould.*,ve_uu in_veuu,em_uu in_recorderuu from InquiryMould left join employee on in_recorderid = em_id left join vendor on ve_code=in_vendcode where (in_statuscode='AUDITED' and (IN_SENDSTATUS='待上传' or IN_SENDSTATUS='上传中')) and nvl(in_sourcetype,' ')='模具报价单' and exists (select 1 from InquiryMould left join vendor on in_vendcode=ve_code and ve_uu is not null and nvl(ve_b2benable,0)=1) order by in_code",
+        List<InquiryMould> inquiryMoulds = jdbcTemplate.queryForBeanList("select InquiryMould.*,ve_uu in_veuu,em_uu in_recorderuu from InquiryMould left join employee on in_recorderid = em_id left join vendor on ve_code=in_vendcode where (in_statuscode='AUDITED' and (IN_SENDSTATUS='待上传' or IN_SENDSTATUS='上传中')) and nvl(in_sourcetype,' ')='模具报价单' and exists (select 1 from InquiryMould left join vendor on in_vendcode=ve_code and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) order by in_code",
                 InquiryMould.class);
         for (InquiryMould inquiryMould : inquiryMoulds) {
             List<InquiryMouldDet> dets = jdbcTemplate.queryForBeanList(
@@ -237,7 +237,7 @@ public class InquiryMouldTask extends AbstractTask {
 
     @TaskMapping(title = "上传买家对报价信息是否采纳的决策到平台", fixedDelay = 60000)
     public void uploadInquiryMouldDecide() {
-        List<InquiryMouldDecide> decides = jdbcTemplate.queryForBeanList("select in_id,in_code,in_adoptstatus,b2b_im_id,in_checksendstatus from InquiryMould left join vendor on in_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_sourcetype,' ')='模具报价单' and IN_CHECKSENDSTATUS='待上传' and (in_adoptstatus is not null and nvl (in_adoptstatus,'')<>'待审核') and ve_uu is not null and nvl(ve_b2benable,0)=1 order by in_code,in_id",
+        List<InquiryMouldDecide> decides = jdbcTemplate.queryForBeanList("select in_id,in_code,in_adoptstatus,b2b_im_id,in_checksendstatus from InquiryMould left join vendor on in_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_sourcetype,' ')='模具报价单' and IN_CHECKSENDSTATUS='待上传' and (in_adoptstatus is not null and nvl (in_adoptstatus,'')<>'待审核') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by in_code,in_id",
                 InquiryMouldDecide.class);
         if (!CollectionUtils.isEmpty(decides)) {
             ContextHolder.setDataSize(decides.size());
@@ -250,7 +250,7 @@ public class InquiryMouldTask extends AbstractTask {
 
     @TaskMapping(title = "上传作废模具询价单信息传到平台", fixedDelay = 60000)
     public void invalidateInquiryMould() {
-        List<InquiryMould> moulds = jdbcTemplate.queryForBeanList("select InquiryMould.* from InquiryMould left join vendor on in_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_sourcetype,' ')='模具报价单' and nvl(in_checksendstatus,' ')<>'作废已上传' and in_status = '已作废' and ve_uu is not null order by in_code,in_id",
+        List<InquiryMould> moulds = jdbcTemplate.queryForBeanList("select InquiryMould.* from InquiryMould left join vendor on in_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_sourcetype,' ')='模具报价单' and nvl(in_checksendstatus,' ')<>'作废已上传' and in_status = '已作废' and coalesce(ve_uu, '0') <> '0' order by in_code,in_id",
                 InquiryMould.class);
         if (!CollectionUtils.isEmpty(moulds)) {
             ContextHolder.setDataSize(moulds.size());

+ 7 - 7
src/main/java/com/uas/erp/schedular/b2b/task/InquiryTask.java

@@ -66,7 +66,7 @@ public class InquiryTask extends AbstractTask {
     private Integer uploadProduct() {
         return jdbcTemplate.count("select count(1) from product where exists (select 1 from inquirydetail left join vendor on id_vendcode=ve_code " +
                         "left join inquiry on in_id=id_inid where (IN_SENDSTATUS='待上传' or IN_SENDSTATUS='上传中') and nvl(in_class,' ')<>'主动报价' " +
-                        "and ve_uu is not null and nvl(ve_b2benable,0)=1 and id_prodcode=pr_code) and nvl(pr_sendstatus,' ')<>'已上传'");
+                        "and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and id_prodcode=pr_code) and nvl(pr_sendstatus,' ')<>'已上传'");
     }
 
     /**
@@ -75,11 +75,11 @@ public class InquiryTask extends AbstractTask {
      * @return
      */
     private List<Inquiry> getInquiryUpload() {
-        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select Inquiry.*,em_uu in_recorderuu from Inquiry left join employee on in_recorderid = em_id where in_statuscode='AUDITED' and (IN_SENDSTATUS='待上传' or IN_SENDSTATUS='上传中') 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) and  rowNum <= 200 order by in_code  ",
+        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select Inquiry.*,em_uu in_recorderuu from Inquiry left join employee on in_recorderid = em_id where in_statuscode='AUDITED' and (IN_SENDSTATUS='待上传' or IN_SENDSTATUS='上传中') and nvl(in_class,' ')<>'主动报价' and exists (select 1 from InquiryDetail left join vendor on id_vendcode=ve_code where id_inid=in_id and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) and  rowNum <= 200 order by in_code  ",
                 Inquiry.class);
         for (Inquiry inquiry : inquiries) {
             // 获取询价单明细
-            List<InquiryDetail> details = jdbcTemplate.queryForBeanList("select InquiryDetail.*,ve_uu,nvl(id_vendcontact,ve_contact) ve_contact,nvl(id_vendcontactuu,ve_contactuu) ve_contactuu,em_uu ve_buyeruu from InquiryDetail left join vendor on id_vendcode=ve_code left join employee on ve_buyercode=em_code where id_inid=? and ve_uu is not null and nvl(ve_b2benable,0)=1",
+            List<InquiryDetail> details = jdbcTemplate.queryForBeanList("select InquiryDetail.*,ve_uu,nvl(id_vendcontact,ve_contact) ve_contact,nvl(id_vendcontactuu,ve_contactuu) ve_contactuu,em_uu ve_buyeruu from InquiryDetail left join vendor on id_vendcode=ve_code left join employee on ve_buyercode=em_code where id_inid=? and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1",
                     InquiryDetail.class, inquiry.getIn_id());
             for (InquiryDetail detail : details) {
                 // 获取询价单明细的价格分段
@@ -201,7 +201,7 @@ public class InquiryTask extends AbstractTask {
 
     @TaskMapping(title = "上传买家对报价信息是否采纳的决策到平台", fixedDelay = 60000)
     public void uploadInquiryDecide() {
-        List<InquiryDecide> replies = jdbcTemplate.queryForBeanList("select id_id,in_code,id_detno,id_isagreed id_agreed from InquiryDetail left join Inquiry on id_inid=in_id left join vendor on id_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_class,' ')<>'主动报价' and ID_SENDSTATUS='待上传' and id_isagreed is not null and ve_uu is not null and nvl(ve_b2benable,0)=1 and rownum < 100 order by in_code,id_detno",
+        List<InquiryDecide> replies = jdbcTemplate.queryForBeanList("select id_id,in_code,id_detno,id_isagreed id_agreed from InquiryDetail left join Inquiry on id_inid=in_id left join vendor on id_vendcode=ve_code where IN_SENDSTATUS='已上传' and nvl(in_class,' ')<>'主动报价' and ID_SENDSTATUS='待上传' and id_isagreed is not null and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and rownum < 100 order by in_code,id_detno",
                 InquiryDecide.class);
         if (!CollectionUtils.isEmpty(replies)) {
             ContextHolder.setDataSize(replies.size());
@@ -213,7 +213,7 @@ public class InquiryTask extends AbstractTask {
 
     @TaskMapping(title = "上传买家对报价信息作废的决策到平台", fixedDelay = 60000)
     public void uploadInquiryInvalid() {
-        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from Inquiry left join InquiryDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendstatus <> '作废已上传' and nvl(in_class,' ')<>'主动报价'  and ve_uu is not null and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
+        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from Inquiry left join InquiryDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendstatus <> '作废已上传' and nvl(in_class,' ')<>'主动报价'  and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
                 Inquiry.class);
         if (!CollectionUtils.isEmpty(inquiries)) {
             ContextHolder.setDataSize(inquiries.size());
@@ -297,7 +297,7 @@ public class InquiryTask extends AbstractTask {
 
     @TaskMapping(title = "上传买家对主动报价询价单的报价信息作废的决策到平台", fixedDelay = 60000)
     public void uploadQuotationInvalid() {
-        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from Inquiry left join InquiryDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendstatus <> '作废已上传' and nvl(in_class,' ')='主动报价'  and ve_uu is not null and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
+        List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from Inquiry left join InquiryDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendstatus <> '作废已上传' and nvl(in_class,' ')='主动报价'  and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
                 Inquiry.class);
         if (!CollectionUtils.isEmpty(inquiries)) {
             ContextHolder.setDataSize(inquiries.size());
@@ -309,7 +309,7 @@ public class InquiryTask extends AbstractTask {
 
     @TaskMapping(title = "上传买家对主动报价信息是否采纳的决策到平台", fixedDelay = 60000)
     public void uploadQuotationDecide() {
-        List<InquiryDecide> decides = jdbcTemplate.queryForBeanList("select id_id,id_detno,b2b_qu_id,id_isagreed id_agreed from InquiryDetail left join Inquiry on id_inid=in_id left join vendor on id_vendcode=ve_code where IN_SENDSTATUS='已上传' and in_class='主动报价' and ID_SENDSTATUS='待上传' and id_isagreed is not null and ve_uu is not null and nvl(ve_b2benable,0)=1 and b2b_qu_id is not null order by in_code,id_detno",
+        List<InquiryDecide> decides = jdbcTemplate.queryForBeanList("select id_id,id_detno,b2b_qu_id,id_isagreed id_agreed from InquiryDetail left join Inquiry on id_inid=in_id left join vendor on id_vendcode=ve_code where IN_SENDSTATUS='已上传' and in_class='主动报价' and ID_SENDSTATUS='待上传' and id_isagreed is not null and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and b2b_qu_id is not null order by in_code,id_detno",
                 InquiryDecide.class);
         if (!CollectionUtils.isEmpty(decides)) {
             ContextHolder.setDataSize(decides.size());

+ 2 - 2
src/main/java/com/uas/erp/schedular/b2b/task/MakeProdInOutTask.java

@@ -40,7 +40,7 @@ public class MakeProdInOutTask extends AbstractTask {
                 "select * from (select prodinout.*, ve_uu pi_vendoruu from "
                         + " prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where"
                         + " pi_class='委外验收单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中')"
-                        + "and ve_uu is not null and nvl(ve_b2benable,0)=1 ) where rownum<=200", MakeProdInOut.class);
+                        + "and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 ) where rownum<=200", MakeProdInOut.class);
         for (MakeProdInOut prodInOut : prodInOuts) {
             List<MakeProdInOutDetail> details = jdbcTemplate.queryForBeanList(
                     "select prodiodetail.* , pd_pdno pd_detno from prodiodetail where pd_piid = ? ",
@@ -81,7 +81,7 @@ public class MakeProdInOutTask extends AbstractTask {
     public List<MakeProdInOut> getProdReturnUpload() {
         List<MakeProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from"
                         + " prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where"
-                        + " pi_class='委外验退单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and ve_uu is not null and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
+                        + " pi_class='委外验退单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
                 MakeProdInOut.class);
         for (MakeProdInOut prodInOut : prodInOuts) {
             List<MakeProdInOutDetail> details = jdbcTemplate.queryForBeanList(

+ 5 - 3
src/main/java/com/uas/erp/schedular/b2b/task/MakeTask.java

@@ -19,7 +19,9 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * Created by Pro1 on 2017/8/2.
+ *
+ * @author Pro1
+ * @date 2017/8/2
  */
 @Component
 @TaskMapping(title = "委外工单", role = Role.BUYER)
@@ -29,7 +31,7 @@ public class MakeTask extends AbstractTask {
     public void uploadMake() {
         Integer size = uploadProduct();
         if (size == 0) {
-            List<Make> makes = jdbcTemplate.queryForBeanList("select * from (select make.*, ve_uu from make left join vendor on ma_vendcode=ve_code where nvl(ve_b2benable,0)=1 and ve_uu is not null and nvl(ma_tasktype, '')='OS' and ma_checkstatuscode='APPROVE' and (ma_sendstatus='待上传' or ma_sendstatus='上传中')) where rownum <= 100",
+            List<Make> makes = jdbcTemplate.queryForBeanList("select * from (select make.*, ve_uu from make left join vendor on ma_vendcode=ve_code where nvl(ve_b2benable,0)=1 and coalesce(ve_uu, '0') <> '0' and nvl(ma_tasktype, '')='OS' and ma_checkstatuscode='APPROVE' and (ma_sendstatus='待上传' or ma_sendstatus='上传中')) where rownum <= 100",
                     Make.class);
             if (!CollectionUtils.isEmpty(makes)) {
                 ContextHolder.setDataSize(makes.size());
@@ -43,7 +45,7 @@ public class MakeTask extends AbstractTask {
      * 上传物料资料
      */
     private Integer uploadProduct() {
-        final List<Prod> prods = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_code,pr_detail,pr_spec,pr_unit,pr_zxbzs,pr_zxdhl,pr_leadtime,pr_ltinstock,pr_brand from product where exists (select 1 from make left join vendor on ve_code = ma_vendcode where ma_tasktype='OS'  and ve_uu is not null and nvl(ve_b2benable,0)=1 and make.ma_prodcode = product.pr_code) and nvl(pr_sendstatus,' ')<>'已上传' order by pr_id) where rownum <= 500",
+        final List<Prod> prods = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_code,pr_detail,pr_spec,pr_unit,pr_zxbzs,pr_zxdhl,pr_leadtime,pr_ltinstock,pr_brand from product where exists (select 1 from make left join vendor on ve_code = ma_vendcode where ma_tasktype='OS'  and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and make.ma_prodcode = product.pr_code) and nvl(pr_sendstatus,' ')<>'已上传' order by pr_id) where rownum <= 500",
                 Prod.class);
         if (!CollectionUtils.isEmpty(prods)) {
             return prods.size();

+ 2 - 2
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseAPBillTask.java

@@ -47,7 +47,7 @@ public class PurchaseAPBillTask extends AbstractTask {
         List<PurchaseAPBill> purchaseAPBills = jdbcTemplate.queryForBeanList(
                 "select * from (select apbill.*, ve_uu ab_vendoruu from apbill"
                         + " left join vendor on apbill.ab_vendcode = vendor.ve_code where ab_class = '应付发票' and ab_status = '已过账'"
-                        + " and ab_sendstatus = '待上传' and ve_uu is not null and nvl(ab_kind,' ')<>'货款调账' and nvl(ve_b2benable,0)=1 ) where rownum <= 10",
+                        + " and ab_sendstatus = '待上传' and coalesce(ve_uu, '0') <> '0' and nvl(ab_kind,' ')<>'货款调账' and nvl(ve_b2benable,0)=1 ) where rownum <= 10",
                 PurchaseAPBill.class);
         for (PurchaseAPBill purchaseAPBill : purchaseAPBills) {
             List<PurchaseAPBillDetail> apBillDetails = jdbcTemplate.queryForBeanList(
@@ -89,7 +89,7 @@ public class PurchaseAPBillTask extends AbstractTask {
      */
     private List<PurchaseAPBill> getApbillAdjustmentUpload() {
         List<PurchaseAPBill> purchaseAPBills = jdbcTemplate.queryForBeanList("select * from (select apbill.*, ve_uu ab_vendoruu from apbill left join vendor on apbill.ab_vendcode = vendor.ve_code where vendor.ve_b2bcheck = -1 and ab_class = '其它应付单' and ab_status = '已过账'"
-                                + " and ab_sendstatus = '待上传' and ve_uu is not null  and nvl(ab_kind,' ')='货款调账' and nvl(ve_b2benable,0)=1 ) where rownum <= 200",
+                                + " and ab_sendstatus = '待上传' and coalesce(ve_uu, '0') <> '0'  and nvl(ab_kind,' ')='货款调账' and nvl(ve_b2benable,0)=1 ) where rownum <= 200",
                 PurchaseAPBill.class);
         for (PurchaseAPBill purchaseAPBill : purchaseAPBills) {
             List<PurchaseAPBillDetail> apBillDetails = jdbcTemplate.queryForBeanList(

+ 1 - 1
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseChangeTask.java

@@ -42,7 +42,7 @@ public class PurchaseChangeTask extends AbstractTask {
      * @return
      */
     private List<PurchaseChange> getPurchaseChangeUpload() {
-        List<PurchaseChange> purchaseChanges = jdbcTemplate.queryForBeanList("select purchasechange.* from purchasechange left join Purchase on pc_purccode=pu_code left join vendor on ve_code=pu_vendcode where PC_SENDSTATUS='待上传' and pu_sendstatus='已上传' and nvl(pu_ordertype,' ')<>'B2C' and nvl(pc_agreed,1)<>0 and pc_statuscode in ('AUDITED','TO_CONFIRM') and ve_uu is not null and nvl(ve_b2benable,0)=1 order by pc_code",
+        List<PurchaseChange> purchaseChanges = jdbcTemplate.queryForBeanList("select purchasechange.* from purchasechange left join Purchase on pc_purccode=pu_code left join vendor on ve_code=pu_vendcode where PC_SENDSTATUS='待上传' and pu_sendstatus='已上传' and nvl(pu_ordertype,' ')<>'B2C' and nvl(pc_agreed,1)<>0 and pc_statuscode in ('AUDITED','TO_CONFIRM') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by pc_code",
                 PurchaseChange.class);
         for (PurchaseChange purchaseChange : purchaseChanges) {
             List<PurchaseChangeDetail> changeDetails = jdbcTemplate.queryForBeanList(

+ 1 - 1
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseForecastTask.java

@@ -40,7 +40,7 @@ public class PurchaseForecastTask extends AbstractTask {
                         + "on pf_buyerid=em_id where Pf_SENDSTATUS='待上传' order by pf_code", PurchaseForecast.class);
         for (PurchaseForecast purchaseForecast : purchaseForecasts) {
             List<PurchaseForecastDetail> purchaseForecastDetails = jdbcTemplate.queryForBeanList("select purchaseforecastdetail.*, ve_uu, ve_contact, ve_contactuu from purchaseforecastDetail "
-                                    + "left join vendor on pfd_vendcode=ve_code where pfd_pfid=? and ve_uu is not null and nvl(ve_b2benable,0)=1 ",
+                                    + "left join vendor on pfd_vendcode=ve_code where pfd_pfid=? and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 ",
                     PurchaseForecastDetail.class, purchaseForecast.getPf_id());
             // 存在有效的明细的单上传,明细都无效的不上传
             if (purchaseForecastDetails.size() > 0) {

+ 1 - 1
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseMRBTask.java

@@ -45,7 +45,7 @@ public class PurchaseMRBTask extends AbstractTask {
         List<PurchaseQuaMRB> purchaseMRBs = jdbcTemplate.queryForBeanList(
                 "select qua_mrb.*, vendor.ve_uu mr_venduu, qua_mrb.mr_presult mr_result from qua_mrb "
                         + " left join vendor on qua_mrb.mr_vendcode = vendor.ve_code where mr_sendstatus = '待上传' "
-                        + " and mr_status = '已审核' and mr_qctype = '采购检验单' and ve_uu is not null and nvl(ve_b2benable,0)=1 ",
+                        + " and mr_status = '已审核' and mr_qctype = '采购检验单' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 ",
                 PurchaseQuaMRB.class);
         for (PurchaseQuaMRB purchaseMRB : purchaseMRBs) {
             List<PurchaseQuaMRBCheckItem> checkItems = jdbcTemplate.queryForBeanList("select * from qua_mrbdet where md_mrid = ? ",

+ 4 - 4
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseNotifyTask.java

@@ -26,7 +26,7 @@ public class PurchaseNotifyTask extends AbstractTask {
 
     @TaskMapping(title = "上传送货提醒", fixedDelay = 30000)
     public void uploadPurchaseNotify() {
-        List<PurchaseNotify> notifies = jdbcTemplate.queryForBeanList("select * from (select purchasenotify.*,ve_uu,pr_zxbzs from purchasenotify left join purchase on pn_ordercode=pu_code left join vendor on pu_vendcode=ve_code left join product on pr_code=pn_prodcode where (nvl(PN_SENDSTATUS,' ')='待上传' or nvl(pn_sendstatus,' ')='上传中') and pn_status<>'已取消' and nvl(pu_sendstatus, '') = '已上传' and nvl(pu_ordertype,' ')<>'B2C' and ve_uu is not null and nvl(ve_b2benable,0)=1 order by pn_indate) where rownum <= 100",
+        List<PurchaseNotify> notifies = jdbcTemplate.queryForBeanList("select * from (select purchasenotify.*,ve_uu,pr_zxbzs from purchasenotify left join purchase on pn_ordercode=pu_code left join vendor on pu_vendcode=ve_code left join product on pr_code=pn_prodcode where nvl(PN_SENDSTATUS,' ')='待上传'and pn_status<>'已取消' and nvl(pu_sendstatus, '') = '已上传' and nvl(pu_ordertype,' ')<>'B2C' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by pn_indate) where rownum <= 100",
                 PurchaseNotify.class);
         if (!CollectionUtils.isEmpty(notifies)) {
             ContextHolder.setDataSize(notifies.size());
@@ -126,7 +126,7 @@ public class PurchaseNotifyTask extends AbstractTask {
 
     @TaskMapping(title = "上传结案送货提醒", fixedDelay = 60000)
     public void uploadPurchaseNotifyEnd() {
-        List<PurchaseNotify> notifies = jdbcTemplate.queryForBeanList("select * from (select purchasenotify.pn_id,ve_uu from purchasenotify left join purchase on pn_ordercode=pu_code left join vendor on pu_vendcode=ve_code where PN_SENDSTATUS='待上传' and pn_statuscode='CANCELED' and pu_sendstatus='已上传' and nvl(pu_ordertype,' ')<>'B2C' and pn_b2bid is not null and ve_uu is not null and nvl(ve_b2benable,0)=1 order by pn_indate) where rownum<=50",
+        List<PurchaseNotify> notifies = jdbcTemplate.queryForBeanList("select * from (select purchasenotify.pn_id,ve_uu from purchasenotify left join purchase on pn_ordercode=pu_code left join vendor on pu_vendcode=ve_code where PN_SENDSTATUS='待上传' and pn_statuscode='CANCELED' and pu_sendstatus='已上传' and nvl(pu_ordertype,' ')<>'B2C' and pn_b2bid is not null and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by pn_indate) where rownum<=400",
                 PurchaseNotify.class);
         if (!CollectionUtils.isEmpty(notifies)) {
             ContextHolder.setDataSize(notifies.size());
@@ -155,7 +155,7 @@ public class PurchaseNotifyTask extends AbstractTask {
      * @return
      */
     private List<AcceptNotify> getAcceptNotify() {
-        List<AcceptNotify> accepts = jdbcTemplate.queryForBeanList("select AcceptNotify.* from AcceptNotify left join vendor on an_vendcode=ve_code where AN_SENDSTATUS='待上传' and an_statuscode='AUDITED' and ve_uu is not null and nvl(ve_b2benable,0)=1 and B2B_SS_ID is not null order by an_date",
+        List<AcceptNotify> accepts = jdbcTemplate.queryForBeanList("select AcceptNotify.* from AcceptNotify left join vendor on an_vendcode=ve_code where AN_SENDSTATUS='待上传' and an_statuscode='AUDITED' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and B2B_SS_ID is not null order by an_date",
                 AcceptNotify.class);
         for (AcceptNotify accept : accepts) {
             List<AcceptNotifyDetail> details = jdbcTemplate.queryForBeanList("select * from AcceptNotifyDetail where and_anid=?",
@@ -173,7 +173,7 @@ public class PurchaseNotifyTask extends AbstractTask {
      */
     @TaskMapping(title = "上传收料通知修改的确认数", fixedDelay = 60000)
     public void uploadAcceptNotifyConfirm() {
-        List<AcceptNotifyConfirm> confirms = jdbcTemplate.queryForBeanList("select b2b_ss_id,and_id,and_detno,and_inqty from AcceptNotify left join vendor on an_vendcode=ve_code left join AcceptNotifyDetail on and_anid=an_id where b2b_ss_id is not null and an_statuscode in ('AUDITED','TURNVA', 'PART2VA') and and_sendstatus='待上传' and and_inqty<nvl(and_b2bqty,and_inqty) and ve_uu is not null and nvl(ve_b2benable,0)=1 order by b2b_ss_id,and_detno",
+        List<AcceptNotifyConfirm> confirms = jdbcTemplate.queryForBeanList("select b2b_ss_id,and_id,and_detno,and_inqty from AcceptNotify left join vendor on an_vendcode=ve_code left join AcceptNotifyDetail on and_anid=an_id where b2b_ss_id is not null and an_statuscode in ('AUDITED','TURNVA', 'PART2VA') and and_sendstatus='待上传' and and_inqty<nvl(and_b2bqty,and_inqty) and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by b2b_ss_id,and_detno",
                 AcceptNotifyConfirm.class);
         if (!CollectionUtils.isEmpty(confirms)) {
             ContextHolder.setDataSize(confirms.size());

+ 5 - 4
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseProdInOutTask.java

@@ -37,8 +37,9 @@ public class PurchaseProdInOutTask extends AbstractTask {
      */
     private List<PurchaseProdInOut> getProInOutUpload() {
         List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList(
-                "select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='采购验收单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and ve_uu is not null and nvl(ve_b2benable,0)=1 ) where rownum <= 50 and exists (select 1 from purchase,prodiodetail where pd_piid=pi_id and pu_sendstatus='已上传')",
+                "select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='采购验收单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 ) where rownum <= 2 and exists (select 1 from purchase,prodiodetail where pd_piid=pi_id and pu_sendstatus='已上传')",
                 PurchaseProdInOut.class);
+        System.out.println(CollectionUtil.getKeyString(prodInOuts));
         for (PurchaseProdInOut prodInOut : prodInOuts) {
             List<PurchaseProdInOutDetail> details = jdbcTemplate.queryForBeanList(
                     "select prodiodetail.* , pd_pdno pd_detno from prodiodetail where pd_piid = ? ",
@@ -69,7 +70,7 @@ public class PurchaseProdInOutTask extends AbstractTask {
      * @return
      */
     private List<PurchaseProdInOut> getProdReturnUpload() {
-        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='采购验退单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and exists (select 1 from prodiodetail left join purchase on pu_code=pd_ordercode where pd_piid=pi_id and (pd_ordercode is null or pu_sendstatus='已上传')) and ve_uu is not null and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
+        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='采购验退单' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and exists (select 1 from prodiodetail left join purchase on pu_code=pd_ordercode where pd_piid=pi_id and (pd_ordercode is null or pu_sendstatus='已上传')) and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
                 PurchaseProdInOut.class);
         for (PurchaseProdInOut prodInOut : prodInOuts) {
             List<PurchaseProdInOutDetail> details = jdbcTemplate.queryForBeanList(
@@ -101,7 +102,7 @@ public class PurchaseProdInOutTask extends AbstractTask {
      * @return
      */
     private List<PurchaseProdInOut> getProdBadInUpload() {
-        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='不良品入库单' and pi_type='PURC' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and ve_uu is not null and nvl(ve_b2benable,0)=1) where rownum<=200 ",
+        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='不良品入库单' and pi_type='PURC' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) where rownum<=200 ",
                 PurchaseProdInOut.class);
         for (PurchaseProdInOut prodInOut : prodInOuts) {
             List<PurchaseProdInOutDetail> details = jdbcTemplate.queryForBeanList(
@@ -133,7 +134,7 @@ public class PurchaseProdInOutTask extends AbstractTask {
      * @return
      */
     private List<PurchaseProdInOut> getProdBadOutUpload() {
-        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='不良品出库单' and pi_type = 'PURC' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and ve_uu is not null and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
+        List<PurchaseProdInOut> prodInOuts = jdbcTemplate.queryForBeanList("select * from (select prodinout.*, ve_uu pi_vendoruu from prodinout left join vendor on prodinout.pi_cardcode = vendor.ve_code where pi_class='不良品出库单' and pi_type = 'PURC' and pi_status = '已过账' and (pi_sendstatus = '待上传' or pi_sendstatus='上传中') and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) where rownum <= 200 ",
                 PurchaseProdInOut.class);
         for (PurchaseProdInOut prodInOut : prodInOuts) {
             List<PurchaseProdInOutDetail> details = jdbcTemplate.queryForBeanList(

+ 4 - 4
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseSampleTask.java

@@ -48,11 +48,11 @@ public class PurchaseSampleTask extends AbstractTask {
         List<ProductSample> productSamples = jdbcTemplate.queryForBeanList("select productsample.*,em_uu ps_appmanuu from productsample left join employee"
                         + " on productsample.ps_appmanid = em_id where (ps_sendstatus='待上传' or"
                         + " ps_sendstatus='上传中') and ps_status='已审核' and exists (select 1 from productsampledetail left"
-                        + " join vendor on pd_vendcode=ve_code where pd_psid=ps_id and ve_uu is not null and nvl(ve_b2benable,0)=1) order by ps_code",
+                        + " join vendor on pd_vendcode=ve_code where pd_psid=ps_id and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) order by ps_code",
                 ProductSample.class);
         for (ProductSample productSample : productSamples) {
             List<ProductSampleDetail> details = jdbcTemplate.queryForBeanList("select productsampledetail.*,ve_contactuu pd_contactuu from productsampledetail"
-                            + " left join vendor on pd_vendcode=ve_code where pd_psid=? and ve_uu is not null and nvl(ve_b2benable,0)=1",
+                            + " left join vendor on pd_vendcode=ve_code where pd_psid=? and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1",
                     ProductSampleDetail.class, productSample.getPs_id());
             productSample.setDetails(details);
             // 附件信息
@@ -172,7 +172,7 @@ public class PurchaseSampleTask extends AbstractTask {
         List<ProductSampleApproval> saleSampleSends = jdbcTemplate.queryForBeanList("select * from (select productapproval.*, "
                                 + "to_number(ve_uu) pa_venduu, pr_detail, pr_spec, pr_unit from productapproval left join vendor on "
                                 + "productapproval.pa_providecode = vendor.ve_code left join product on productapproval.pa_prodcode = "
-                                + "product.pr_code where pa_status='已审核' and pa_sendstatus='待上传'  and ve_uu is not null and nvl(ve_b2benable,0)=1 and rownum<10)",
+                                + "product.pr_code where pa_status='已审核' and pa_sendstatus='待上传'  and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and rownum<10)",
                 ProductSampleApproval.class);
         if (!CollectionUtils.isEmpty(saleSampleSends)) {
             for (ProductSampleApproval approval : saleSampleSends) {
@@ -201,7 +201,7 @@ public class PurchaseSampleTask extends AbstractTask {
     public void invalidateSaleSampleSend() {
         List<Long> sampleIds = jdbcTemplate.queryIdList("select productsample.ps_id id from productsample left join employee" +
                 " on productsample.ps_appmanid = em_id where ps_sendstatus = '已上传' and ps_status='已作废' and exists (select 1 from productsampledetail left" +
-                " join vendor on pd_vendcode=ve_code where pd_psid=ps_id and ve_uu is not null and nvl(ve_b2benable,0)=1) order by ps_code",
+                " join vendor on pd_vendcode=ve_code where pd_psid=ps_id and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1) order by ps_code",
                 IdObject.class);
         if (!CollectionUtils.isEmpty(sampleIds)) {
             ContextHolder.setDataSize(sampleIds.size());

+ 4 - 4
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseTask.java

@@ -48,7 +48,7 @@ public class PurchaseTask extends AbstractTask {
      * 上传物料资料
      */
     private Integer uploadProduct() {
-        final List<Prod> prods = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_code,pr_detail,pr_spec,pr_unit,pr_zxbzs,pr_zxdhl,pr_leadtime,pr_ltinstock,pr_brand from product where exists (select 1 from purchase left join vendor on pu_vendcode=ve_code left join purchasedetail on pd_puid=pu_id where (PU_SENDSTATUS='待上传' or PU_SENDSTATUS='上传中' or pu_sendstatus='已上传') and nvl(pu_ordertype,' ')<>'B2C' and pu_statuscode='AUDITED' and ve_uu is not null and nvl(ve_b2benable,0)=1 and pd_prodcode=pr_code) and nvl(pr_sendstatus,' ')<>'已上传' order by pr_id) where rownum <= 500",
+        final List<Prod> prods = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_code,pr_detail,pr_spec,pr_unit,pr_zxbzs,pr_zxdhl,pr_leadtime,pr_ltinstock,pr_brand from product where exists (select 1 from purchase left join vendor on pu_vendcode=ve_code left join purchasedetail on pd_puid=pu_id where (PU_SENDSTATUS='待上传' or PU_SENDSTATUS='上传中' or pu_sendstatus='已上传') and nvl(pu_ordertype,' ')<>'B2C' and pu_statuscode='AUDITED' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and pd_prodcode=pr_code) and nvl(pr_sendstatus,' ')<>'已上传' order by pr_id) where rownum <= 500",
                 Prod.class);
         if (!CollectionUtils.isEmpty(prods)) {
             return prods.size();
@@ -62,7 +62,7 @@ public class PurchaseTask extends AbstractTask {
      * @return
      */
     private List<Purchase> getPurchasesUpload() {
-        List<Purchase> purchases = jdbcTemplate.queryForBeanList("select * from (select purchase.*,em_uu,em_name,em_sex,em_mobile,em_email,vendor.ve_uu,pu_vendcontact ve_contact,purchase.pu_vendcontactuu ve_contactuu from purchase left join vendor on pu_vendcode=ve_code left join employee on pu_buyerid=em_id where (PU_SENDSTATUS='待上传' or 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<>'已上传') order by pu_code) where rownum < 100",
+        List<Purchase> purchases = jdbcTemplate.queryForBeanList("select * from (select purchase.*,em_uu,em_name,em_sex,em_mobile,em_email,vendor.ve_uu,pu_vendcontact ve_contact,purchase.pu_vendcontactuu ve_contactuu from purchase left join vendor on pu_vendcode=ve_code left join employee on pu_buyerid=em_id where (PU_SENDSTATUS='待上传' or PU_SENDSTATUS='上传中') and pu_statuscode='AUDITED' and nvl(pu_ordertype,' ')<>'B2C' and coalesce(ve_uu, '0') <> '0' 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<>'已上传') order by pu_code) where rownum < 100",
                 Purchase.class);
         List<Purchase> thisPost = new ArrayList<>();
         int count = 0;
@@ -174,7 +174,7 @@ public class PurchaseTask extends AbstractTask {
 
     @TaskMapping(title = "上传主动回复的记录到平台", fixedDelay = 60000, enabled = false)
     public void uploadPurchaseReply() {
-        List<PurchaseReply> replies = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_qty,pr_delivery,pr_remark,pr_pucode,pr_pddetno,pr_date,pr_recorder,b2b_pr_id,pr_type from PurchaseReply left join PurchaseDetail on pr_pucode=pd_code and pr_pddetno=pd_detno left join purchase on pd_puid=pu_id left join vendor on pu_vendcode=ve_code where PR_SENDSTATUS='待上传' and ve_uu is not null and nvl(ve_b2benable,0)=1 and nvl(b2b_pr_id,0)=0 order by pr_date) where rownum <= 500",
+        List<PurchaseReply> replies = jdbcTemplate.queryForBeanList("select * from (select pr_id,pr_qty,pr_delivery,pr_remark,pr_pucode,pr_pddetno,pr_date,pr_recorder,b2b_pr_id,pr_type from PurchaseReply left join PurchaseDetail on pr_pucode=pd_code and pr_pddetno=pd_detno left join purchase on pd_puid=pu_id left join vendor on pu_vendcode=ve_code where PR_SENDSTATUS='待上传' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and nvl(b2b_pr_id,0)=0 order by pr_date) where rownum <= 200",
                 PurchaseReply.class);
         if (!CollectionUtils.isEmpty(replies)) {
             ContextHolder.setDataSize(replies.size());
@@ -187,7 +187,7 @@ public class PurchaseTask extends AbstractTask {
 
     @TaskMapping(title = "上传结案、反结案采购订单", fixedDelay = 60000)
     public void uploadPurchaseEnd() {
-        List<PurchaseDetailEnd> details = jdbcTemplate.queryForBeanList("select * from (select pd_id,pd_code,pd_detno,case when pd_mrpstatuscode='FINISH' then 1 else 0 end pd_ended from PurchaseDetail left join purchase on pd_puid=pu_id left join vendor on pu_vendcode=ve_code where PU_SENDSTATUS='已上传' and nvl(pu_ordertype,' ')<>'B2C' and pd_endstatus='待上传' and ve_uu is not null and nvl(ve_b2benable,0)=1 order by pd_code,pd_detno) where rownum <= 200",
+        List<PurchaseDetailEnd> details = jdbcTemplate.queryForBeanList("select * from (select pd_id,pd_code,pd_detno,case when pd_mrpstatuscode='FINISH' then 1 else 0 end pd_ended from PurchaseDetail left join purchase on pd_puid=pu_id left join vendor on pu_vendcode=ve_code where PU_SENDSTATUS='已上传' and nvl(pu_ordertype,' ')<>'B2C' and pd_endstatus='待上传' and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 order by pd_code,pd_detno) where rownum <= 200",
                 PurchaseDetailEnd.class);
         if (!CollectionUtils.isEmpty(details)) {
             ContextHolder.setDataSize(details.size());

+ 1 - 1
src/main/java/com/uas/erp/schedular/b2b/task/VendorPerformanceAssessTask.java

@@ -40,7 +40,7 @@ public class VendorPerformanceAssessTask extends AbstractTask {
     public List<VendorPerformanceAssess> getVendorPerformanceAssesss() {
         try {
             List<VendorPerformanceAssess> vpas = jdbcTemplate.queryForBeanList(
-                    "select * from (select * from VendorPerformanceAssess  LEFT JOIN vendor  on vpa_vendorcode = ve_code where  nvl(vpa_sendstatus,' ')<>'已上传' and  nvl(vpa_status, ' ') = '已审核' and nvl(ve_b2benable, 0) = 1 and ve_uu is not null order by vpa_id) where rownum <= 500",
+                    "select * from (select * from VendorPerformanceAssess  LEFT JOIN vendor  on vpa_vendorcode = ve_code where  nvl(vpa_sendstatus,' ')<>'已上传' and  nvl(vpa_status, ' ') = '已审核' and nvl(ve_b2benable, 0) = 1 and coalesce(ve_uu, '0') <> '0' order by vpa_id) where rownum <= 500",
                     VendorPerformanceAssess.class);
             return vpas;
         } catch (EmptyResultDataAccessException e) {

+ 1 - 8
src/main/java/com/uas/erp/schedular/init/ReplyInitializer.java

@@ -2,26 +2,19 @@ package com.uas.erp.schedular.init;
 
 import com.uas.erp.schedular.entity.MasterTaskConfigEntity;
 import com.uas.erp.schedular.repository.MasterTaskConfigRepository;
-import com.uas.erp.schedular.service.ScheduledTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
-
 import java.util.ArrayList;
 import java.util.List;
 
-
 /**
  * Created by Pro1 on 2017/7/26.
  */
 @Component
 public class ReplyInitializer implements CommandLineRunner {
 
-
-    @Autowired
-    private ScheduledTaskService scheduledTaskService;
-
     @Autowired
     private MasterTaskConfigRepository masterTaskConfigRepository;
 
@@ -40,4 +33,4 @@ public class ReplyInitializer implements CommandLineRunner {
             masterTaskConfigRepository.save(entities);
         }
     }
-}
+}

+ 90 - 0
src/main/java/com/uas/erp/schedular/listen/DiskUtil.java

@@ -0,0 +1,90 @@
+package com.uas.erp.schedular.listen;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * 获取mac地址工具类
+ * @Author: huj
+ * @Date: Created in 15:05 2018/11/27.
+ */
+public class DiskUtil {
+
+    private static String macAddressStr = null;
+    private static final String[] windowsCommand = { "ipconfig", "/all" };
+    private static final String[] linuxCommand = { "/sbin/ifconfig", "-a" };
+    private static final Pattern macPattern = Pattern.compile(".*((:?[0-9a-f]{2}[-:]){5}[0-9a-f]{2}).*",
+            Pattern.CASE_INSENSITIVE);
+
+    /**
+     * 测试用的main方法.
+     *
+     */
+    public static String getAllMacAddress() {
+        if (macAddressStr == null || macAddressStr.equals("")) {
+            // 存放多个网卡地址用,目前只取一个非0000000000E0隧道的值
+            StringBuffer sb = new StringBuffer();
+            try {
+                List<String> macList = getMacAddressList();
+                for (Iterator<String> iter = macList.iterator(); iter.hasNext();) {
+                    String amac = iter.next();
+                    if (!amac.equals("0000000000E0")) {
+                        sb.append(amac);
+                        break;
+                    }
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+            macAddressStr = sb.toString();
+
+        }
+
+        return macAddressStr;
+    }
+
+    /**
+     * 获取多个网卡地址
+     *
+     * @return
+     * @throws IOException
+     */
+    private final static List<String> getMacAddressList() throws IOException {
+        final ArrayList<String> macAddressList = new ArrayList<String>();
+        final String os = System.getProperty("os.name");
+        final String command[];
+
+        if (os.startsWith("Windows")) {
+            command = windowsCommand;
+        } else if (os.startsWith("Linux")) {
+            command = linuxCommand;
+        } else {
+            throw new IOException("Unknow operating system:" + os);
+        }
+        // 执行命令
+        final Process process = Runtime.getRuntime().exec(command);
+
+        BufferedReader bufReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+        for (String line = null; (line = bufReader.readLine()) != null;) {
+            Matcher matcher = macPattern.matcher(line);
+            if (matcher.matches()) {
+                macAddressList.add(matcher.group(1).replaceAll("[-:]","-"));
+//                macAddressList.add(matcher.group(1).replaceAll("[-:]",
+//                ""));//去掉MAC中的“-”
+            }
+        }
+
+        process.destroy();
+        bufReader.close();
+        return macAddressList;
+    }
+
+}

+ 46 - 0
src/main/java/com/uas/erp/schedular/listen/ListenDomain.java

@@ -0,0 +1,46 @@
+package com.uas.erp.schedular.listen;
+
+/**
+ * @Author: huj
+ * @Date: Created in 15:34 2018/11/27.
+ */
+public class ListenDomain {
+
+    String macAddress;
+
+    String name;
+
+    String description;
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getMacAddress() {
+        return macAddress;
+    }
+
+    public void setMacAddress(String macAddress) {
+        this.macAddress = macAddress;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public ListenDomain(String macAddress, String name) {
+        this.macAddress = macAddress;
+        this.name = name;
+    }
+
+    public ListenDomain() {
+    }
+}

+ 172 - 0
src/main/java/com/uas/erp/schedular/listen/ListenTask.java

@@ -0,0 +1,172 @@
+package com.uas.erp.schedular.listen;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.uas.erp.schedular.database.RestJdbcTemplate;
+import com.uas.erp.schedular.entity.Master;
+import com.uas.erp.schedular.entity.MasterTaskConfigEntity;
+import com.uas.erp.schedular.entity.MasterTaskConfigId;
+import com.uas.erp.schedular.service.ScheduledTaskService;
+import com.uas.erp.schedular.service.SettingService;
+import com.uas.erp.schedular.util.ContextHolder;
+import com.uas.erp.schedular.web.ResultListWrap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @Author: huj
+ * @Date: Created in 14:41 2018/11/27.
+ */
+@Component
+public class ListenTask {
+
+    @Autowired
+    private ScheduledTaskService scheduledTaskService;
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private SettingService settingService;
+
+    @Autowired
+    private RestJdbcTemplate jdbcTemplate;
+
+    private String getUrl() {
+        return settingService.getValue("api.database.url");
+    }
+
+    private final static String MACADDRESS = DiskUtil.getAllMacAddress();
+
+    /**
+     * 按账套环境,使用不同接口地址
+     * @return
+     */
+    private String getApiDomain() {
+        return settingService.getValue("api.b2b.url");
+    }
+
+    /**
+     * 每十分钟发送一次
+     */
+    @Scheduled(cron = "0 */10 * * * *")
+    public void listen() {
+        List<Master> masters = new ArrayList<>();
+        List<Master> all = new ArrayList<>();
+        try {
+            String allStr = restTemplate.getForObject(getUrl() + "/v1/master/list", String.class);
+            ResultListWrap<Master> allList = JSON.parseObject(allStr, new TypeReference<ResultListWrap<Master>>(Master.class) {
+            });
+            if (allList.isSuccess()) {
+                all = allList.getContent();
+            }
+            String resultStr = restTemplate.getForObject(getUrl() + "/v1/master/list?cloudEnabled=true", String.class);
+            ResultListWrap<Master> result = JSON.parseObject(resultStr, new TypeReference<ResultListWrap<Master>>(Master.class) {
+            });
+            if (result.isSuccess()) {
+                masters = result.getContent();
+            }
+        } catch (Exception e) {
+
+        } finally {
+            if (CollectionUtils.isEmpty(masters)) {
+                StringBuilder str = new StringBuilder();
+                if (!CollectionUtils.isEmpty(all)) {
+                    for (Master master : all) {
+                        if ("".equals(str.toString())) {
+                            str.append(StringUtils.isEmpty(master.getMa_function()) ? master.getMa_name() : master.getMa_function());
+                        } else {
+                            str.append("、" + (StringUtils.isEmpty(master.getMa_function()) ? master.getMa_name() : master.getMa_function()));
+                        }
+                    }
+                }
+                ListenDomain listenDomain = new ListenDomain(MACADDRESS, str == null ? "" : str.toString());
+                List<ListenDomain> listenDomains = new ArrayList<>();
+                if (!"".equals(str.toString())) {
+                    listenDomain.setDescription("所有账套都未启用轮询");
+                } else {
+                    listenDomain.setDescription("h2数据库查询异常或oracle数据库设置异常");
+                }
+                listenDomains.add(listenDomain);
+                postForList(getApiDomain() + "/erp/listen", ListenDomain.class, dataWrap(listenDomains));
+                return;
+            }
+        }
+        if (!CollectionUtils.isEmpty(masters)) {
+            ContextHolder.setMaster(masters.get(0));
+            int dual = jdbcTemplate.getInt("select 1 from dual");
+            if (dual == 1) {
+                StringBuilder str = new StringBuilder();
+                for (Master master : masters) {
+                    if ("".equals(str.toString())) {
+                        str.append(StringUtils.isEmpty(master.getMa_function()) ? master.getMa_name() : master.getMa_function());
+                    } else {
+                        str.append("、" + (StringUtils.isEmpty(master.getMa_function()) ? master.getMa_name() : master.getMa_function()));
+                    }
+                }
+                MasterTaskConfigId configId = new MasterTaskConfigId(null, null, masters.get(0).getMa_name());
+                List<MasterTaskConfigEntity> taskConfigs = scheduledTaskService.getTaskConfigs(configId, "b2b", "BUYER");
+                if (!CollectionUtils.isEmpty(taskConfigs)) {
+                    ListenDomain listenDomain = new ListenDomain(MACADDRESS,
+                            str == null ? "" : str.toString());
+                    List<ListenDomain> listenDomains = new ArrayList<>();
+                    listenDomains.add(listenDomain);
+                    postForList(getApiDomain() + "/erp/listen", ListenDomain.class, dataWrap(listenDomains));
+                }
+            } else {
+                ListenDomain listenDomain = new ListenDomain(MACADDRESS, "" );
+                List<ListenDomain> listenDomains = new ArrayList<>();
+                listenDomain.setDescription("oracle查询异常");
+                listenDomains.add(listenDomain);
+                postForList(getApiDomain() + "/erp/listen", ListenDomain.class, dataWrap(listenDomains));
+                return;
+            }
+            ContextHolder.clear();
+        }
+    }
+
+    /**
+     * 封装成平台接口数据格式
+     * @param data
+     * @return
+     */
+    protected static MultiValueMap<String, String> dataWrap(Object data) {
+        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
+        String dataStr =  JSON.toJSONString(data);
+        try {
+            dataStr = URLEncoder.encode(dataStr, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+
+        }
+        map.set("data", dataStr);
+        return map;
+    }
+
+    protected ResponseEntity postForEntity(String url, MultiValueMap<String, String> vars) {
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(vars, headers);
+        return restTemplate.postForEntity(url, request, String.class);
+    }
+
+    protected <T> List<T> postForList(String url, Class<T> objectClass, MultiValueMap<String, String> vars) {
+        ResponseEntity<String> resultEntity = postForEntity(url, vars);
+        return JSON.parseArray(resultEntity.getBody(), objectClass);
+    }
+}

+ 1 - 1
src/main/java/com/uas/erp/schedular/publicinquiry/task/PubInquiryTask.java

@@ -194,7 +194,7 @@ public class PubInquiryTask extends AbstractTask {
     public void uploadInquiryInvalid() {
         Enterprise enterprise = getEnterprise();
         if (null != enterprise) {
-            List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from InquiryAuto left join InquiryAutoDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendStatus <> '作废已上传' and nvl(in_class,' ')<>'主动报价'  and ve_uu is not null and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
+            List<Inquiry> inquiries = jdbcTemplate.queryForBeanList("select * from InquiryAuto left join InquiryAutoDetail on id_inid=in_id left join vendor on id_vendcode=ve_code where in_status = '已作废' and in_sendStatus <> '作废已上传' and nvl(in_class,' ')<>'主动报价'  and coalesce(ve_uu, '0') <> '0' and nvl(ve_b2benable,0)=1 and rownum <= 100 order by in_code",
                     Inquiry.class);
             if (!CollectionUtils.isEmpty(inquiries)) {
                 ContextHolder.setDataSize(inquiries.size());

+ 1 - 1
src/main/java/com/uas/erp/schedular/publicproduct/task/AbstractTask.java

@@ -255,7 +255,7 @@ public class AbstractTask {
 
         @Override
         protected void onBefore() {
-            jdbcTemplate.execute(String.format("update %s set %s='上传' where %s in (%s)", tableName, statusColumn, idColumn, idStr));
+            jdbcTemplate.execute(String.format("update %s set %s='上传' where %s in (%s)", tableName, statusColumn, idColumn, idStr));
         }
 
         @Override

+ 4 - 0
src/main/java/com/uas/erp/schedular/util/ContextHolder.java

@@ -13,6 +13,10 @@ public class ContextHolder {
         threadLocalMaster.set(master);
     }
 
+    public static void clear() {
+        threadLocalMaster.set(null);
+    }
+
     public static Master getMaster() {
         return threadLocalMaster.get();
     }