time(NULL)

timer=NULL时得到机器日历时间,timer=时间数值时,用于设置日历时间,time_t是一个long类型.

timer
Pointer to an object of type time_t, where the time value is stored.
Alternativelly, this parameter can be a null pointer, in which case the parameter is not used, but a time_t object is still returned by the function.


time(NULL);就是返回从1970年元旦午夜0点到现在的秒数。


time(取得目前的时间)
相关函数
ctime,ftime,gettimeofday
表头文件
#i nclude
定义函数
time_t time(time_t *t);
函数说明
此函数会返回从公元1970年1月1日的UTC时间从0时0分0秒算起到现在所经过的秒数。如果t 并非空指针的话,此函数也会将返回值存到t指针所指的内存。
返回值
成功则返回秒数,失败则返回((time_t)-1)错误原因存于errno中。

我负责一个供应链的定时任务,我有一个运营时间,订单表,我要根据运营时间中的订单配送时间,修改我订单还在等待分拣,分拣中的订单的状态,变为配送中,我应该怎么比较,这个业务的逻辑流程是怎么样的,请你帮我分析下怎么做最合理,然后我的具体需求如下: 1.查询所有运营时间 获取订单变配送中时间和跨度 tb_sys_scm_operation_time.delivery_in_progress_time、delivery_in_progress_time_span 取当前时间>=订单变配送中时间的记录 进行步骤2 2.根据运营时间id 关联查询订单表 tb_scm_order.operation_time_id 根据订单创建时间比较上一步的时间和跨度(订单创建时间+跨度天数>=当前时间) 查询到符合条件的等待分拣、分拣中订单 进行步骤3 3.修改订单状态为配送中 4. 判断订单是否创建过分拣任务 没有则创建分拣任务 相关的表如下所示: -- auto-generated definition create table tb_sys_scm_operation_time ( id varchar(20) not null comment '主键' primary key, create_time datetime not null comment '创建时间', modify_time datetime not null comment '修改时间', version int default 0 null comment '乐观锁', deleted smallint default 0 null comment '逻辑删除', orders int default 0 null comment '排序', name varchar(255) null comment '名称', operation_describe varchar(500) null comment '描述', orders_start_time time null comment '用户下单开始时间', orders_end_time time null comment '用户下单结束时间', orders_time_span varchar(20) null comment '用户下单时间跨度', delivery_start_time time null comment '收货开始时间', delivery_start_time_span varchar(20) null comment '收货开始跨度', delivery_end_time time null comment '收货结束时间', delivery_end_time_span varchar(20) null comment '收货结束时间跨度', delivery_in_progress_time time null comment '订单变为配送中时间', delivery_in_progress_time_span varchar(20) null comment '订单变为配送中时间跨度', harvest_interval varchar(20) null comment '收获间隔(单位:小时)', no_delivery_start_time time null comment '不配送开始时间', no_delivery_end_time time null comment '不配送结束时间', presale_flag smallint default 0 null comment '是否预售时间', delivery_date varchar(255) null comment '收货自然日(预售)', early_delivery_date varchar(20) null comment '最早收货日期(预售)', late_delivery_date varchar(20) null comment '最晚收货日期(预售)', daily_delivery_start_time time null comment '每日收货开始时间(预售)', daily_delivery_end_time time null comment '每日收货开始时间(预售)', daily_delivery_time_span varchar(20) null comment '每日收货时间跨度(预售)', daily_harvest_interval varchar(20) null comment '每日收获间隔(预售,单位:小时)' ) comment '运营时间'; -- auto-generated definition create table tb_scm_order ( id varchar(20) not null comment '主键' primary key, create_time datetime not null comment '创建时间', modify_time datetime not null comment '修改时间', version int default 0 null comment '乐观锁', deleted smallint default 0 null comment '逻辑删除', orders int default 0 null comment '排序', merchant_id varchar(20) null comment '商户id', operation_time_id varchar(20) null comment '运营时间id', delivery_start_time datetime not null comment '开始收货时间', delivery_end_time datetime not null comment '结束收货时间', status smallint default 0 not null comment '订单状态', pay_status smallint default 0 not null comment '支付状态', type smallint default 0 null comment '订单类型', remark varchar(500) null comment '订单备注', delivery_method smallint default 0 null comment '收货方式', receiver varchar(125) null comment '收货人', receiver_phone varchar(20) null comment '收货人手机', receiver_address varchar(512) null comment '收货地址', last_operation varchar(255) null comment '最后操作', sign_method smallint null comment '签收方式', total decimal(15, 2) not null comment '订单总金额', pay_type smallint null comment '支付方式 0余额支付', sorting_task_id varchar(36) null comment '分拣任务ID' ) comment '订单'; 基础任务管理器如下所示: package com.jxyunge.sign.job; import org.springframework.beans.factory.annotation.Value; /** * @ClassName BaseJob * @Description 定时任务 * @Author bianmaren * @blog <a href="http://www.bianmaren.com">编码人</a> * @date 2023/9/2 14:01 * @Version 1.0 **/ public class BaseJob { @Value("${spring.profiles.active}") private String env; /** * 环境校验 */ protected boolean checkEnv(){ return !"prd".equals(env); } }
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值