|
|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.erp.schedular.b2b.task;
|
|
|
|
|
|
import com.uas.erp.schedular.b2b.domain.NotExistOrders;
|
|
|
+import com.uas.erp.schedular.b2b.domain.Purchase;
|
|
|
import com.uas.erp.schedular.b2b.domain.PurchaseDetail;
|
|
|
import com.uas.erp.schedular.task.support.Role;
|
|
|
import com.uas.erp.schedular.task.support.TaskMapping;
|
|
|
@@ -60,14 +61,26 @@ public class OrderCheckTask extends AbstractTask {
|
|
|
@TaskMapping(title = "获取未上传采购单", fixedDelay = 60000)
|
|
|
public void checkSaleMain() {
|
|
|
List<NotExistOrders> orders = getForList("/erp/notExistOrders/saleMain", NotExistOrders.class);
|
|
|
- List<String> sqlList = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(orders)) {
|
|
|
ContextHolder.setDataSize(orders.size());
|
|
|
+ List<Purchase> purchases = new ArrayList<>();
|
|
|
for (NotExistOrders order : orders) {
|
|
|
- sqlList.add("update purchase set pu_sendStatus = '待上传' where pu_code = '" + order.getCode() + "'");
|
|
|
+ purchases.addAll(getPurchasesUpload(order.getCode()));
|
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(sqlList)) {
|
|
|
- jdbcTemplate.batchExecute(sqlList);
|
|
|
+ if (!CollectionUtils.isEmpty(purchases)) {
|
|
|
+ ContextHolder.setDataSize(purchases.size());
|
|
|
+ purchases = postForList("/erp/purchase", Purchase.class, dataWrap(purchases));
|
|
|
+ if (!CollectionUtils.isEmpty(purchases)) {
|
|
|
+ List<String> sqlList = new ArrayList<>();
|
|
|
+ for (Purchase purchase : purchases) {
|
|
|
+ if (null != purchase.getPu_b2bid()) {
|
|
|
+ sqlList.add("update purchase set pu_sendStatus = '已上传', pu_b2bid = " + purchase.getPu_b2bid() + " where pu_id = " + purchase.getPu_id());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(sqlList)) {
|
|
|
+ jdbcTemplate.batchExecute(sqlList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
String idStr = CollectionUtil.getKeyString(orders, new CollectionUtil.KeyIterator<NotExistOrders>() {
|
|
|
@Override
|
|
|
@@ -78,6 +91,29 @@ public class OrderCheckTask extends AbstractTask {
|
|
|
post("/erp/notExistOrders/back", dataWrap(idStr));
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取需要上传的采购单
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Purchase> getPurchasesUpload(String code) {
|
|
|
+ List<Purchase> purchases = jdbcTemplate.queryForBeanList("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_code = '" + code + "'",
|
|
|
+ Purchase.class);
|
|
|
+ for (Purchase purchase : purchases) {
|
|
|
+ List<PurchaseDetail> purchaseDetails = jdbcTemplate.queryForBeanList("select * from (select p.*,(select max(pv_vendprodspec) from productvendor where pv_prodcode=pd_prodcode and pv_vendcode=?) as pd_vendspec from purchasedetail p where pd_puid=?)",
|
|
|
+ PurchaseDetail.class, purchase.getPu_vendcode(), purchase.getPu_id());
|
|
|
+ if (!CollectionUtils.isEmpty(purchaseDetails)) {
|
|
|
+ for(PurchaseDetail detail : purchaseDetails) {
|
|
|
+ if (StringUtils.hasText(detail.getPd_prattach())) {
|
|
|
+ detail.setAttaches(getAttachs(detail.getPd_prattach().split(";")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ purchase.setPurchaseDetails(purchaseDetails);
|
|
|
+ }
|
|
|
+ return purchases;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* B2B采购验等检测发现订单不存在时记录下来,通过轮询获取去更新采购单的上传状态
|