4 changed files with 96 additions and 10 deletions
@ -0,0 +1,31 @@ |
|||||
|
package cn.chjyj.szwh.controller.task; |
||||
|
|
||||
|
import cn.chjyj.szwh.controller.BaseController; |
||||
|
import cn.chjyj.szwh.service.GoodsService; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* 任务控制器 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/task/Goods") |
||||
|
public class TaskGoodsController extends BaseController { |
||||
|
@Autowired |
||||
|
private GoodsService goodsService; |
||||
|
|
||||
|
/** |
||||
|
* 远程获取产品列表 |
||||
|
* @return |
||||
|
*/ |
||||
|
@RequestMapping("/getApiGoods") |
||||
|
public JSONObject getApiGoods(){ |
||||
|
int ret = goodsService.getApiGoods(); |
||||
|
jsonObject.put("data",ret); |
||||
|
jsonObject.put("code",200); |
||||
|
jsonObject.put("msg","成功"); |
||||
|
return jsonObject; |
||||
|
} |
||||
|
} |
||||
@ -1,20 +1,30 @@ |
|||||
package cn.chjyj.szwh.job; |
package cn.chjyj.szwh.job; |
||||
|
|
||||
|
import cn.chjyj.szwh.service.GoodsService; |
||||
import org.apache.commons.logging.Log; |
import org.apache.commons.logging.Log; |
||||
import org.apache.commons.logging.LogFactory; |
import org.apache.commons.logging.LogFactory; |
||||
import org.quartz.Job; |
|
||||
import org.quartz.JobDataMap; |
|
||||
import org.quartz.JobExecutionContext; |
import org.quartz.JobExecutionContext; |
||||
import org.quartz.JobExecutionException; |
import org.quartz.JobExecutionException; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.scheduling.quartz.QuartzJobBean; |
||||
|
|
||||
|
import java.util.Calendar; |
||||
|
import java.util.Date; |
||||
|
|
||||
public class SzwhJob implements Job { |
public class SzwhJob extends QuartzJobBean { |
||||
private static Log log = LogFactory.getLog(SzwhJob.class); |
private static Log log = LogFactory.getLog(SzwhJob.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private GoodsService goodsService; |
||||
|
|
||||
|
|
||||
@Override |
@Override |
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
protected void executeInternal(JobExecutionContext context) throws JobExecutionException { |
||||
//
|
Calendar cal = Calendar.getInstance(); |
||||
JobDataMap data = jobExecutionContext.getTrigger().getJobDataMap(); |
Date xxd =cal.getTime(); |
||||
String invokeParam = (String) data.get("invokeParam"); |
log.info("商品开始更新:"+xxd); |
||||
//在这里实现业务逻辑
|
// 远程获取产品信息
|
||||
log.info("自定义任务 szwhjob"); |
goodsService.getApiGoods(); |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue