varoldId=_connection.QuerySingleOrDefault<int>(" select id from dc_base_transfer_freight_log where action_log_id=@action_log_id limit 1 ",new{action_log_id=data_log.action_log_id});
varoldId=_connection.QuerySingleOrDefault<int>(" select id from dc_base_transfer_freight_log where action_log_id=@action_log_id limit 1 ",new{action_log_id=data_log.action_log_id});
varlast_data=_connection.QuerySingleOrDefault<int>(" select id from dc_base_transfer_freight_log where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code order by action_date desc limit 1 ",new{
select t2.sku ,t1.targetwareno,t2.deliverycount,t1.estimatedcost,t3.deliverycount as 'order_deliverycount' from dc_base_transfer_info as t1
left join dc_base_transfer_info_skus as t2 on t1.dataid = t2.dataid
left join ( select dataid,sum(deliverycount) as 'deliverycount' from dc_base_transfer_info_skus GROUP BY dataid ) as t3 on t1.dataid = t3.dataid
where t2.sku=@sku and t1.targetwareno=@targetwareno and t1.estimatedcost>0 and t1.creationtime<=@date and t1.stateid=5 and t1.isdeleted=0 order by t1.creationtime DESC
id=(_connection.QueryFirstOrDefault<int?>(" select id from dc_base_transfer_freight where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new
{
bailun_sku=data_log.bailun_sku,
bailun_sku=data_log.bailun_sku,
warehouse_code=data_log.warehouse_code
warehouse_code=data_log.warehouse_code
})??0)
};
if(new_data.id>0)
{
_connection.Update(new_data);
}
else
{
_connection.Insert(new_data);
}
}
catch(Exceptionex)
{
data_log.remarks=ex.Message+"---"+ex.StackTrace;
}
_connection.Insert(data_log);
}
/// <summary>
/// 初始化数据
/// </summary>
publicstaticvoidInit()
{
//查询所有没有记录的数据
vardatas=_connection.Query<stock_dto>(@"select t1.bailun_sku,t1.warehouse_code,t1.usable_stock from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t2.hq_type!='国内仓' and t1.usable_stock>0 ").ToList();
data_log.id=_connection.QuerySingleOrDefault<int?>(" select * from dc_base_transfer_freight_log where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new{