Browse Source

新增方法检测ERP取消单据对应B2B状态问题等

hejq 7 years ago
parent
commit
d54f1e3c6a

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

@@ -5,12 +5,16 @@ import com.uas.erp.schedular.core.Status;
 import com.uas.erp.schedular.task.support.Method;
 import com.uas.erp.schedular.task.support.Role;
 import com.uas.erp.schedular.task.support.TaskMapping;
+import com.uas.erp.schedular.util.ArrayUtil;
 import com.uas.erp.schedular.util.CollectionUtil;
 import com.uas.erp.schedular.util.ContextHolder;
+import com.uas.erp.schedular.util.DateUtil;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -203,4 +207,32 @@ public class PurchaseNotifyTask extends AbstractTask {
         }
     }
 
+    /**
+     * 从8点到18点,每一小时检查一次
+     */
+    @TaskMapping(title = "校验结案提醒", cron = "0 0 8,9,10,11,12,13,14,15,16,17,18 * * ? ")
+    public void uploadEndNotify() {
+        // 每次最多传输数据
+        int maxNum = 100;
+        // 筛选当天的数据
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        // 数据库时间格式
+        String format = "yyyy-MM-dd HH:mm:ss";
+        // 最近1小时的操作记录
+        Long time = System.currentTimeMillis() - 1 * 60 * 60 * 1000;
+        String startTime = DateUtil.parseDateToOracleString(format, new Date(time));
+        String endTime = DateUtil.parseDateToOracleString(format, new Date(System.currentTimeMillis()));
+        String sql = "select pn_id,pn_b2bid,pn_cmdRemark pn_remark from purchaseNotify "
+                + "where pn_b2bid is not null and pn_cmdRemark like '%勾选取消  " + dateFormat.format(new Date()) + "%' "
+                + "and to_date(subStr(pn_cmdRemark, -20), 'yyyy-MM-dd hh24:mi:ss') between " + startTime + " and " + endTime;
+        List<PurchaseNotify> notifyList = jdbcTemplate.queryForBeanList(sql, PurchaseNotify.class);
+        if (!CollectionUtils.isEmpty(notifyList)) {
+            List<List<PurchaseNotify>> notifyLists = ArrayUtil.splitAry(notifyList, maxNum);
+            for (List<PurchaseNotify> notifies : notifyLists) {
+                ContextHolder.setDataSize(notifies.size());
+                post("/erp/purchase/notice/endCheck", dataWrap(notifies));
+            }
+        }
+    }
+
 }

+ 36 - 0
src/main/java/com/uas/erp/schedular/util/ArrayUtil.java

@@ -0,0 +1,36 @@
+package com.uas.erp.schedular.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 数组工具类
+ *
+ * @author hejq
+ * @date 2018-08-24 9:55
+ */
+public class ArrayUtil {
+
+    /**
+     * 集合大小拆分
+     *
+     * @param ary 数组
+     * @param subSize 分割数量
+     * @return List<List<T>>
+     */
+    public static <T> List<List<T>> splitAry(List<T> ary, int subSize) {
+        int count = ary.size() % subSize == 0 ? ary.size() / subSize: ary.size() / subSize + 1;
+        List<List<T>> subAryList = new ArrayList<List<T>>();
+        for (int i = 0; i < count; i++) {
+            int index = i * subSize;
+            List<T> list = new ArrayList<T>();
+            int j = 0;
+            while (j < subSize && index < ary.size()) {
+                list.add(ary.get(index++));
+                j++;
+            }
+            subAryList.add(list);
+        }
+        return subAryList;
+    }
+}