|
|
@@ -0,0 +1,62 @@
|
|
|
+package com.uas.erp.test;
|
|
|
+
|
|
|
+/**
|
|
|
+ * created by shicr on 2018/5/2
|
|
|
+ **/
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.uas.api.b2c_erp.seller.model.ProductReplaceErp;
|
|
|
+import com.uas.api.b2c_erp.seller.service.ProductReplaceService;
|
|
|
+import com.uas.api.crypto.util.SecretUtil;
|
|
|
+import com.uas.erp.schedular.UasSchedulingApplication;
|
|
|
+import com.uas.erp.schedular.database.RestJdbcTemplate;
|
|
|
+import com.uas.erp.schedular.entity.Master;
|
|
|
+import com.uas.erp.schedular.util.ContextHolder;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = UasSchedulingApplication.class)
|
|
|
+public class HessianTest {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ protected RestJdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductReplaceService productReplaceService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void uploadProduct(){
|
|
|
+ Master master = new Master();
|
|
|
+ master.setMa_user("UAS");
|
|
|
+ master.setMa_uu(10041166L);
|
|
|
+ master.setMa_accesssecret("2c1ea0898633796fe050007f01002ea6");
|
|
|
+ master.setMa_env("test");
|
|
|
+ master.setMa_name("UAS");
|
|
|
+ SecretUtil.set(Long.toString(master.getMa_uu()), master.getMa_accesssecret());
|
|
|
+ ContextHolder.setMaster(master);
|
|
|
+
|
|
|
+ List<ProductReplaceErp> prods = jdbcTemplate.queryForBeanList("select BPR_ID,BPR_STATUSCODE,BPR_SENDSTATUS,BPR_PRODCODE,BPR_REPCODE,BPR_DATE,BPR_PRODBRAND,BPR_PRODOSCODE,BPR_REPBAND,BPR_REPOSCODE,BPR_ENUU " +
|
|
|
+ "from B2B_PRODREPLACE where nvl(BPR_SENDSTATUS,' ')<>'已上传' and rownum <=500 ",
|
|
|
+ ProductReplaceErp.class);
|
|
|
+ String jsons = JSON.toJSONString(prods);
|
|
|
+ if (!CollectionUtils.isEmpty(prods)) {
|
|
|
+ productReplaceService.update(jsons);
|
|
|
+ }
|
|
|
+ for (ProductReplaceErp erp : prods) {
|
|
|
+ String sql = "update B2B_PRODREPLACE set BPR_SENDSTATUS = '已上传' where BPR_ID = " + erp.getBPR_ID();
|
|
|
+ jdbcTemplate.execute(sql);
|
|
|
+ }
|
|
|
+ //迭代,
|
|
|
+ while (prods.size() > 500) {
|
|
|
+ uploadProduct();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|