Просмотр исходного кода

1:增加清空上架临时表。
2:调整EXCEL验证的方式

yujia 7 лет назад
Родитель
Сommit
9e40bb8d8d

+ 2 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/dao/GoodsDao.java

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import java.math.BigInteger;
 import java.math.BigInteger;
+import java.sql.SQLException;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Set;
 import java.util.Set;
@@ -304,7 +305,7 @@ public interface GoodsDao extends JpaSpecificationExecutor<Goods>, JpaRepository
      * @param code the code 删除的批次
      * @param code the code 删除的批次
      */
      */
 	@Modifying
 	@Modifying
-	@Transactional
+	@Transactional(rollbackFor = SQLException.class)
 	@Query(value = "delete from Goods g where g.batchCode=:code")
 	@Query(value = "delete from Goods g where g.batchCode=:code")
 	void deleteByBatchCode(@Param("code") String code);
 	void deleteByBatchCode(@Param("code") String code);
 
 

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/ReleaseProductByBatchService.java

@@ -110,4 +110,9 @@ public interface ReleaseProductByBatchService {
      * @param list
      * @param list
      */
      */
     void udpatePridAndRrodnum(List<ReleaseProductByBatch> list);
     void udpatePridAndRrodnum(List<ReleaseProductByBatch> list);
+
+    /**
+     * 每天零层删除所有的信息
+     */
+    void deleteAllInfo();
 }
 }

+ 5 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -1044,7 +1044,7 @@ public class GoodsServiceImpl implements GoodsService {
 
 
 	/**
 	/**
 	 * 导入Excel发布产品
 	 * 导入Excel发布产品
-	 * 
+	 *
 	 * @author hejq
 	 * @author hejq
 	 */
 	 */
 	@Override
 	@Override
@@ -2046,7 +2046,10 @@ public class GoodsServiceImpl implements GoodsService {
                     }
                     }
                     goodsInfos.add(new GoodsInfo(goods));
                     goodsInfos.add(new GoodsInfo(goods));
                     goods.setStatus(Status.REMOVED.value());
                     goods.setStatus(Status.REMOVED.value());
-                    goodsDao.deleteByBatchCode(batchCode);
+                    Goods goodses = goodsDao.findByBatchCode(batchCode);
+                    if (goodses != null) {
+                        goodsDao.delete(goodses);
+                    }
 
 
                     GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
                     GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
                             GoodsHistory.OperateType.Down.getPhrase(), false);
                             GoodsHistory.OperateType.Down.getPhrase(), false);

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -2013,4 +2013,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
             return ;
             return ;
         }
         }
     }
     }
+
+	/**
+	 * 每天零层删除所有的信息
+	 */
+	@Override
+	public void deleteAllInfo() {
+		releaseProductByBatchDao.deleteAll();
+	}
 }
 }

+ 32 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/task/ReleaseByBatchTask.java

@@ -0,0 +1,32 @@
+package com.uas.platform.b2c.prod.commodity.task;
+
+import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 每天零层执行清空表操作
+ *
+ * @author yuj 2018-07-31 12:15
+ */
+@Component("releaseByBatchTask")
+public class ReleaseByBatchTask {
+
+    private final ReleaseProductByBatchService releaseProductByBatchService;
+
+    private final Logger logger = Logger.getLogger(getClass());
+
+    @Autowired
+    public ReleaseByBatchTask(ReleaseProductByBatchService releaseProductByBatchService) {
+        this.releaseProductByBatchService = releaseProductByBatchService;
+    }
+
+    /**
+     * 每天清空表信息
+     */
+    public void autoCleanReleaseByBatch() {
+        releaseProductByBatchService.deleteAllInfo();
+    }
+
+}

BIN
src/main/resources/jxls-tpl/trade/releaseByBatch-rmb.xls


BIN
src/main/resources/jxls-tpl/trade/releaseByBatchError-rmb.xls


BIN
src/main/resources/jxls-tpl/trade/releaseByBatchError-usd.xls


BIN
src/main/resources/jxls-tpl/trade/releasebyBatch-usd.xls


+ 5 - 0
src/main/resources/spring/task.xml

@@ -10,6 +10,11 @@
     <task:scheduled-tasks>
     <task:scheduled-tasks>
         <task:scheduled ref="OrderTask" method="autoConfirmOrderRevice" cron="0 0 1 * * ?"/>
         <task:scheduled ref="OrderTask" method="autoConfirmOrderRevice" cron="0 0 1 * * ?"/>
     </task:scheduled-tasks>
     </task:scheduled-tasks>
+
+    <!--每天零层清理上架的临时表-->
+    <task:scheduled-tasks>
+        <task:scheduled ref="releaseByBatchTask" method="autoCleanReleaseByBatch" cron="0 0 1 * * ?"/>
+    </task:scheduled-tasks>
     <!--超时自动初评-->
     <!--超时自动初评-->
     <task:scheduled-tasks>
     <task:scheduled-tasks>
         <task:scheduled ref="RateTask" method="autoRate" cron="0 0 1 * * ?"/>
         <task:scheduled ref="RateTask" method="autoRate" cron="0 0 1 * * ?"/>