Commit 92ed3758 authored by Quxl's avatar Quxl

x

parent bd287d08
...@@ -4,7 +4,8 @@ import java.util.Date; ...@@ -4,7 +4,8 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -14,14 +15,12 @@ import com.alibaba.fastjson.JSONArray; ...@@ -14,14 +15,12 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.pds.config.HttpUtil; import com.egolm.pds.config.HttpUtil;
import com.egolm.pds.schedule.service.PdsService;
@Component @Component
public class PriceTask { public class PriceTask {
@Autowired
private PdsService pdsService;
private static final Log log = LogFactory.getLog(PriceTask.class);
@Value("${pds.auth_key}") @Value("${pds.auth_key}")
private String authKey; private String authKey;
...@@ -31,13 +30,9 @@ public class PriceTask { ...@@ -31,13 +30,9 @@ public class PriceTask {
@Value("${pds.url_query}") @Value("${pds.url_query}")
private String urlQuery; private String urlQuery;
@Value("${pds.cron.products_download}") @Scheduled(cron="${pds.cron.price_download}")
private String cron;
@Scheduled(cron="${pds.cron.products_download}")
public void execute() { public void execute() {
System.out.println(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN " + cron); log.debug(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN");
boolean boo = true; boolean boo = true;
int loopCount = 0; int loopCount = 0;
while(boo) { while(boo) {
...@@ -53,60 +48,28 @@ public class PriceTask { ...@@ -53,60 +48,28 @@ public class PriceTask {
JSONArray jsonArray = jsonObject.getJSONArray("data"); JSONArray jsonArray = jsonObject.getJSONArray("data");
if(jsonArray != null) { if(jsonArray != null) {
for(int i = 0; i < jsonArray.size(); i++) { for(int i = 0; i < jsonArray.size(); i++) {
JSONObject productJsonObject = jsonArray.getJSONObject(i); JSONObject priceObject = jsonArray.getJSONObject(i);
String article_description = productJsonObject.getString("article_description"); String barcode = priceObject.getString("barcode");
String article_group_no = productJsonObject.getString("article_group_no"); Integer contract_id = priceObject.getInteger("contract_id");
String article_short_description = productJsonObject.getString("article_short_description"); String effective_date = priceObject.getString("effective_date");
String article_type = productJsonObject.getString("article_type"); String effective_end_date = priceObject.getString("effective_end_date");
String barcode = productJsonObject.getString("barcode"); String new_buying_price_with_tax = priceObject.getString("new_buying_price_with_tax");
String buying_price = productJsonObject.getString("buying_price"); String new_selling_price_with_tax = priceObject.getString("new_selling_price_with_tax");
String buying_price_with_tax = productJsonObject.getString("buying_price_with_tax"); String price_change_type = priceObject.getString("price_change_type");
Integer case_qty = productJsonObject.getInteger("case_qty");
String deduction = productJsonObject.getString("deduction"); Map<String, Object> map = new HashMap<String, Object>();
String made_in = productJsonObject.getString("made_in"); map.put("barcode", barcode);
String order_way = productJsonObject.getString("order_way"); map.put("contract_id", contract_id);
String pack_unit = productJsonObject.getString("pack_unit"); map.put("effective_date", effective_date);
String selling_price = productJsonObject.getString("selling_price"); map.put("effective_end_date", effective_end_date);
String specification = productJsonObject.getString("specification"); map.put("new_buying_price_with_tax", new_buying_price_with_tax);
String stores = productJsonObject.getString("stores"); map.put("new_selling_price_with_tax", new_selling_price_with_tax);
String supplier_article_no = productJsonObject.getString("supplier_article_no"); map.put("price_change_type", price_change_type);
String supplier_no = productJsonObject.getString("supplier_no"); log.debug(JSON.toJSONString(map));
String tax_rate = productJsonObject.getString("tax_rate");
String trade_mode = productJsonObject.getString("trade_mode");
String weight_article = productJsonObject.getString("weight_article");
Object transactionId = productJsonObject.get("transaction_id");
Map<String, Object> productMap = new HashMap<String, Object>();
productMap.put("article_description", article_description);
productMap.put("article_group_no", article_group_no);
productMap.put("article_short_description", article_short_description);
productMap.put("article_type", article_type);
productMap.put("barcode", barcode);
productMap.put("buying_price", buying_price);
productMap.put("buying_price_with_tax", buying_price_with_tax);
productMap.put("case_qty", case_qty);
productMap.put("deduction", deduction);
productMap.put("made_in", made_in);
productMap.put("order_way", order_way);
productMap.put("pack_unit", pack_unit);
productMap.put("selling_price", selling_price);
productMap.put("specification", specification);
productMap.put("stores", stores);
productMap.put("supplier_article_no", supplier_article_no);
productMap.put("supplier_no", supplier_no);
productMap.put("tax_rate", tax_rate);
productMap.put("trade_mode", trade_mode);
productMap.put("weight_article", weight_article);
productMap.put("dLastUpdateTime", new Date());
pdsService.savePdsProduct(transactionId, productMap);;
} }
} }
return jsonArray == null ? 0 : jsonArray.size(); return jsonArray == null ? 0 : jsonArray.size();
} }
public static void main(String[] args) {
Date date = new Date(1568079001765L);
System.out.println(DateUtil.format(date));
}
} }
...@@ -31,13 +31,9 @@ public class ProductsTask { ...@@ -31,13 +31,9 @@ public class ProductsTask {
@Value("${pds.products.url_query}") @Value("${pds.products.url_query}")
private String urlQuery; private String urlQuery;
@Value("${pds.cron.products_download}")
private String cron;
@Scheduled(cron="${pds.cron.products_download}") @Scheduled(cron="${pds.cron.products_download}")
public void execute() { public void execute() {
System.out.println(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN " + cron); System.out.println(DateUtil.format(new Date()) + " PdsProductsUpdateTask RUN");
boolean boo = true; boolean boo = true;
int loopCount = 0; int loopCount = 0;
while(boo) { while(boo) {
......
...@@ -20,6 +20,7 @@ spring: ...@@ -20,6 +20,7 @@ spring:
pds: pds:
cron: cron:
products_download: 0 0 3 * * ? products_download: 0 0 3 * * ?
price_download: 0 0 4 * * ?
auth_key: x-api-key auth_key: x-api-key
auth_value: gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg auth_value: gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
products: products:
......
...@@ -20,6 +20,7 @@ spring: ...@@ -20,6 +20,7 @@ spring:
pds: pds:
cron: cron:
products_download: 0 0 3 * * ? products_download: 0 0 3 * * ?
price_download: 0 0 4 * * ?
auth_key: x-api-key auth_key: x-api-key
auth_value: gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg auth_value: gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
products: products:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<appender name="rollingFileAppender" <appender name="rollingFileAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>/data/logs/pds/${context}-%d{yyyy-MM-dd}.log</FileNamePattern> <FileNamePattern>logs/${context}-%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory> <MaxHistory>30</MaxHistory>
</rollingPolicy> </rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
...@@ -38,14 +38,6 @@ ...@@ -38,14 +38,6 @@
</root> </root>
</springProfile> </springProfile>
<logger name="com.microsoft" level="INFO" />
<logger name="com.alibaba" level="INFO" />
<logger name="springfox" level="ERROR" />
<logger name="javax" level="ERROR" />
<logger name="java" level="ERROR" />
<logger name="net" level="ERROR" />
<logger name="org" level="INFO" />
<logger name="io" level="INFO" />
<logger name="com.egolm" level="DEBUG" /> <logger name="com.egolm" level="DEBUG" />
</configuration> </configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment