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});
select t2.sku ,t1.targetwareno,t2.deliverycount,t1.estimatedcost,t3.deliverycount as 'order_deliverycount' from dc_base_transfer_info as t1
select t2.sku ,t1.targetwareno,t2.deliverycount,t2.storagecount,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
where t1.isdeleted=0 and t1.stateid not in (5,11,12)
and t2.deliverycount > t2.storagecount
and t1.isexception = 0
and t1.expectarrivaltime >='1991-01-01' and t2.sku=@sku and t1.targetwareno=@targetwareno and t1.estimatedcost>0 order by t1.creationtime DESC
varstock=_connection.QueryFirstOrDefault<int?>(" select usable_stock from dc_base_stock as t1 where t1.bailun_sku=@bailun_sku and t1.warehouse_code=@warehouse_code ",parameters)??0;
if(stock>0)
{
varlogs=_connection.Query<order_transfer_status_log>(" select * from order_transfer_status_log as t1 where t1.bailun_sku=@bailun_sku and t1.warehouse_code=@warehouse_code and is_delete=0 ",parameters).ToList();
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,
warehouse_code=data_log.warehouse_code
})??0)
};
formula=data_log.formula
if(new_data.id>0)
};
mainData.id=_connection.QuerySingleOrDefault<int?>(" select id from dc_base_transfer_freight where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new
{
_connection.Update(new_data);
bailun_sku=mainData.bailun_sku,
warehouse_code=mainData.warehouse_code,
})??0;
if(mainData.id<=0)
{
_connection.Insert(mainData);
}
else
{
_connection.Insert(new_data);
_connection.Update(mainData);
}
}
catch(Exceptionex)
{
data_log.remarks=ex.Message+"---"+ex.StackTrace;
}
_connection.Insert(data_log);
}
/// <summary>
/// 初始化数据
/// </summary>
publicstaticvoidInit()
{
varsql=@"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
data_log.id=_connection.QuerySingleOrDefault<int?>(" select * from dc_base_transfer_freight_log where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new{
bailun_sku=data_log.bailun_sku,
warehouse_code=data_log.warehouse_code,
})??0;
if(data_log.id<=0)
{
_connection.Insert(data_log);
_connection.Insert(newdc_base_transfer_freight
{
bailun_sku=data_log.bailun_sku,
warehouse_code=data_log.warehouse_code,
freight_unit_price=data_log.freight_unit_price,
update_time=DateTime.Now
});
}
}
catch(Exceptionex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine(ex.Message);
}
}
...
...
@@ -251,6 +263,7 @@ where t2.sku=@sku and t1.targetwareno=@targetwareno and t1.estimatedcost>0 and t