|
|
@@ -0,0 +1,36 @@
|
|
|
+package com.uas.platform.b2c.prod.product.common;
|
|
|
+
|
|
|
+import com.uas.platform.b2c.prod.product.common.dao.CommonCountDao;
|
|
|
+import com.uas.platform.b2c.prod.product.common.model.CommonCount;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 通用模块任务
|
|
|
+ *
|
|
|
+ * @version 2017/10/21 18:03 wangyc
|
|
|
+ */
|
|
|
+@Component("CommonTask")
|
|
|
+public class CommonTask {
|
|
|
+
|
|
|
+ private final CommonCountDao commonCountDao;
|
|
|
+
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public CommonTask(CommonCountDao commonCountDao, JdbcTemplate jdbcTemplate) {
|
|
|
+ this.commonCountDao = commonCountDao;
|
|
|
+ this.jdbcTemplate = jdbcTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateCount() {
|
|
|
+ List<CommonCount> commonCounts = commonCountDao.findByStatusOrderByDetno((short) 1);
|
|
|
+ for (CommonCount commonCount : commonCounts) {
|
|
|
+ commonCount.setCount(jdbcTemplate.queryForLong(commonCount.getSql()));
|
|
|
+ }
|
|
|
+ commonCountDao.save(commonCounts);
|
|
|
+ }
|
|
|
+}
|