Authored by LUOXC

add switch

package com.yoho.ufo.service.scheduled;
import com.yoho.core.config.ConfigReader;
import com.yoho.product.model.ProductInfo;
import com.yoho.quartz.annotation.JobType;
import com.yoho.quartz.annotation.MisfiredPolicy;
... ... @@ -26,17 +27,25 @@ import java.util.List;
public class ScheduledProductChain implements YhJob {
private static final Logger LOGGER = LoggerFactory.getLogger("scheduledLog");
@Autowired
private ConfigReader configReader;
@Autowired
private ProductChainService productChainService;
public JobProcessResult process(String jobContext) {
LOGGER.info("scheduledProductChain begin.");
List<ProductInfo> productInfos = productChainService.queryIsuploadIsZero();
boolean open = configReader.getBoolean("ufo.product.chain.switch.close", false);
if(open){
List<ProductInfo> productInfos = productChainService.queryIsuploadIsZero();
productInfos.stream().forEach(item -> {
productChainService.postChainInfoEx(item);
});
productInfos.stream().forEach(item -> {
productChainService.postChainInfoEx(item);
});
}
JobProcessResult result = new JobProcessResult();
... ...
package com.yoho.ufo.service.scheduled;
import com.yoho.core.config.ConfigReader;
import com.yoho.product.model.ProductChain;
import com.yoho.quartz.annotation.JobType;
import com.yoho.quartz.annotation.MisfiredPolicy;
... ... @@ -28,14 +29,21 @@ public class ScheduledTransactionChain implements YhJob {
@Autowired
private ProductChainService productChainService;
@Autowired
private ConfigReader configReader;
public JobProcessResult process(String jobContext) {
LOGGER.info("scheduledTransactionChain begin.");
List<ProductChain> productChains = productChainService.queryProductChain();
boolean open = configReader.getBoolean("ufo.product.chain.switch.close", false);
if(open) {
List<ProductChain> productChains = productChainService.queryProductChain();
productChains.stream().forEach(item -> productChainService.postQuery(item.getChainId(), item.getTagId()));
productChains.stream().forEach(item -> productChainService.postQuery(item.getChainId(), item.getTagId()));
}
JobProcessResult result = new JobProcessResult();
result.setJobResultCode(JobResultCode.SUCCESS);
LOGGER.info("scheduledTransactionChain end.");
... ...