public class QuartzApplication {
private static final Log LOG = LogFactory.getLog(QuartzApplication.class);
/**
* @param args
*/
@SuppressWarnings("resource")
public static void main(String[] args)
{
LOG.info("ApplicationContext init...");
new ClassPathXmlApplicationContext("classpath*:applicationContext-quartz.xml");
LOG.info("ApplicationContext load complete.");
// 防止进程退出
synchronized (QuartzApplication.class) {
try {
QuartzApplication.class.wait();
} catch (InterruptedException e) {
LOG.error(e.getMessage(),e);
}
}
}
}
//是否成功
String result_code ="";
String result_msg="";
if(json_data!=null)
{
result_code = json_data.getString("errorCode");
//失败原因
result_msg = json_data.getString("errorMessage");
}else
{
result_msg="GetWharfCanbinetNum 没有返回完整数据";
}
if(!"0000".equals(result_code)){
logger.error("GetWharfCanbinetNum error:"+result_msg);
}else
{
//解析json里面包含的containers的list
JSONArray containers = json_data.getJSONArray("containers");
for(Object entity : containers)
{
JSONObject entityJson = JSONObject.parseObject(entity.toString());
// entityJson解析出来的属性映射到实体类
System.out.println(entityJson);
//SO表
String SoCode=entityJson.getString("shippingOrderNo");
//箱号
String BoxCode=entityJson.getString("containerNo");
//箱关联号
String containerRefNo=entityJson.getString("containerRefNo");
//仓库箱动态查询
LOG.info("GetEntrepotBoxState--strat");
String result_data=klDataInService.GetEntrepotBoxState(SoCode, BoxCode);
LOG.info("GetEntrepotBoxState--end"+result_data);
//仓库箱动态存库
LOG.info("saveWarehouse--strat");
klDataInService.saveWarehouse(result_data);
LOG.info("saveWarehouse--end"+result_data);
//码头进出口作业动态,码头箱动态
LOG.info("GetWharfImpExpDynOpe--strat");
String result_data2=klDataInService.GetWharfImpExpDynOpe("", BoxCode, containerRefNo);
LOG.info("GetWharfImpExpDynOpe--end"+result_data2);
//仓码箱动态存库
LOG.info("saveStorehouseCode--strat");
klDataInService.saveStorehouseCode(result_data2, SoCode, BoxCode, containerRefNo);
LOG.info("saveStorehouseCode--end"+result_data2);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (LOG.isInfoEnabled()) {
LOG.info("SoKLDataInJob 导入数据 End!!!!");
}
该定时器任务执行时间间隔为30分钟一次,如果在本地测试定时器任务,则用debug模式启动QuartzApplication这个类,任务配置时间(com.ec.scheduler.kldata.BoshipJob=0 0/3 0 * * ?)3分钟一次。