Sfoglia il codice sorgente

feat: 新增筛选增加更新应收金额逻辑

hejq 7 anni fa
parent
commit
af79071d4b

+ 16 - 1
src/main/java/com/uas/platform/b2b/service/impl/ErpProdIODetailServiceImpl.java

@@ -1,15 +1,21 @@
 package com.uas.platform.b2b.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2b.core.util.DateFormatUtils;
 import com.uas.platform.b2b.core.util.DateUtils;
+import com.uas.platform.b2b.core.util.ThreadUtils;
 import com.uas.platform.b2b.dao.CommonDao;
+import com.uas.platform.b2b.erp.model.VendorInfo;
 import com.uas.platform.b2b.model.ApcheckKeyWord;
 import com.uas.platform.b2b.model.ErpProdIODetail;
 import com.uas.platform.b2b.model.ErpProdIo;
+import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.publicapi.model.TradeCount;
 import com.uas.platform.b2b.service.ErpProdIODetailService;
 import com.uas.platform.b2b.service.PurchaseApCheckService;
+import com.uas.platform.b2b.support.CollectionUtil;
 import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.b2b.task.ApCheckTask;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import org.apache.axis.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -101,7 +107,16 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
         erpProdIo.setDetails(details);
         // 应收总额
         List<TradeCount> totalTrades = apCheckService.getDueTrade(enUU, keyword.getCustomerUU());
-        erpProdIo.setTotalCount(totalTrades);
+        if (!CollectionUtil.isEmpty(totalTrades)) {
+            erpProdIo.setTotalCount(totalTrades);
+            String tradeString = JSON.toJSONString(totalTrades);
+            ThreadUtils.task(() -> {
+                VendorInfo vendorInfo = commonDao.queryForObject("select ve_id id from purc$vendors where ve_myenuu = ? and ve_vendenuu = ?", VendorInfo.class, keyword.getCustomerUU(), enUU);
+                if (null != vendorInfo) {
+                    commonDao.getJdbcTemplate().update(String.format(ApCheckTask.UPDATE_COUNT_SQL, tradeString, vendorInfo.getId()));
+                }
+            });
+        }
         // 本月应收
         List<TradeCount> thisMonthTrades = apCheckService.getThisMonthTrade(enUU, keyword.getCustomerUU(), checkDate, fromDate, endDate);
         erpProdIo.setThisMonthCount(thisMonthTrades);

+ 4 - 1
src/main/java/com/uas/platform/b2b/task/ApCheckTask.java

@@ -30,7 +30,10 @@ public class ApCheckTask {
      */
     private static final String TODO_CUSTOMER_SQL = "select ve_id id,ve_myenuu custuu,ve_vendenuu venduu from `purc$vendors` where ve_apcheck = 1 and coalesce(update_time, '') < current_date() limit 500";
 
-    private static final String UPDATE_COUNT_SQL = "update purc$vendors set todo_apchek_count = %s, update_time = now() where ve_id = %d";
+    /**
+     * 更新对账金额语句
+     */
+    public static final String UPDATE_COUNT_SQL = "update purc$vendors set todo_apchek_count = %s, update_time = now() where ve_id = %d";
 
     @Autowired
     private CommonDao commonDao;