|
|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|