|
|
@@ -12,9 +12,11 @@ use App\CommodityBarcode;
|
|
|
use App\Console\Commands\CreateOwnerAreaReport;
|
|
|
use App\Console\Commands\CreateOwnerBillReport;
|
|
|
use App\Console\Commands\CreateOwnerReport;
|
|
|
+use App\Console\Commands\SyncBatchTask;
|
|
|
use App\Console\Commands\SyncWmsCommoditiesInformation;
|
|
|
use App\Console\Commands\SyncWMSOrderTask;
|
|
|
use App\Console\Commands\WasSyncWmsAsnInformation;
|
|
|
+use App\Exceptions\ErrorException;
|
|
|
use App\Events\CancelOrder;
|
|
|
use App\Events\SendEmailEvent;
|
|
|
use App\Http\Requests\ForeignHaiRobotic_taskUpdateRequest;
|
|
|
@@ -43,6 +45,7 @@ use App\OrderCommodity;
|
|
|
use App\OrderIssue;
|
|
|
use App\OrderPackage;
|
|
|
use App\OrderPackageCommodities;
|
|
|
+use App\OrderPackageCountingRecord;
|
|
|
use App\OrderTracking;
|
|
|
use App\Owner;
|
|
|
use App\OwnerPriceOperation;
|
|
|
@@ -81,6 +84,7 @@ use App\Services\RejectedBillService;
|
|
|
use App\Services\ShopService;
|
|
|
use App\Services\StoreService;
|
|
|
use App\Services\WarehouseService;
|
|
|
+use App\StationRuleBatch;
|
|
|
use App\Store;
|
|
|
use App\StationTaskBatch;
|
|
|
use App\StoreCheckingReceiveItem;
|
|
|
@@ -92,6 +96,7 @@ use App\Warehouse;
|
|
|
use App\Waybill;
|
|
|
use App\WaybillPriceModel;
|
|
|
use Carbon\Carbon;
|
|
|
+use Carbon\CarbonPeriod;
|
|
|
use ChangeColumnOrderIdToOrderIssues;
|
|
|
use Doctrine\DBAL\Query\QueryBuilder;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
@@ -125,80 +130,46 @@ class TestController extends Controller
|
|
|
return call_user_func([$this, $method], $request);
|
|
|
}
|
|
|
|
|
|
- public function updateInventory()
|
|
|
- {
|
|
|
- $inventoryAccounts = InventoryAccount::query()->get();
|
|
|
- $updateParams = [[
|
|
|
- 'id', 'processed', 'ignored', 'updated_at'
|
|
|
- ]];
|
|
|
- $updated_at = Carbon::now()->toDateTimeString();
|
|
|
- foreach ($inventoryAccounts as $inventoryAccount) {
|
|
|
- if ($inventoryAccount->getIgnoredAmount() > 0) {
|
|
|
- $updateParams[] = [
|
|
|
- 'id' => $inventoryAccount->id,
|
|
|
- 'processed' => $inventoryAccount->getProcessedAmount(),
|
|
|
- 'ignored' => $inventoryAccount->getIgnoredAmount(),
|
|
|
- 'updated_at' => $updated_at,
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- if (count($updateParams) > 1) {
|
|
|
- app(BatchUpdateService::class)->batchUpdate('inventory_accounts', $updateParams);
|
|
|
- }
|
|
|
- }
|
|
|
- public function disposeDetail($date = null)
|
|
|
- {
|
|
|
- DB::transaction(function ()use($date){
|
|
|
- if (!$date){
|
|
|
- $valueStore = ValueStore::query()->where("name","wave_detail_last_sync_date")->lockForUpdate()->first();
|
|
|
- $date = $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
|
|
|
- }
|
|
|
- $count = DB::connection("oracle")->selectOne(DB::raw("SELECT count(*) count FROM DOC_WAVE_DETAILS WHERE EDITTIME >= TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')"),[$date]);
|
|
|
- if ($count->count > 1000){
|
|
|
- $sql = <<<sql
|
|
|
- SELECT * FROM (SELECT ORDERNO,WAVENO,SEQNO,EDITTIME, ROWNUM AS rowno FROM (
|
|
|
- SELECT * FROM DOC_WAVE_DETAILS WHERE EDITTIME >= TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
|
|
|
- ORDER BY EDITTIME) WHERE ROWNUM <= 1000)wave WHERE wave.rowno >= 0
|
|
|
-sql;
|
|
|
- $details = DB::connection("oracle")->select(DB::raw($sql),[$date]);
|
|
|
- //$this->detailExe($details);
|
|
|
- $this->disposeDetail($details[count($details)-1]->edittime);dump($details[count($details)-1]->edittime);
|
|
|
- }else{
|
|
|
- $sql = "SELECT ORDERNO,WAVENO,SEQNO FROM DOC_WAVE_DETAILS WHERE EDITTIME >= TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')";
|
|
|
- $details = DB::connection("oracle")->select(DB::raw($sql),[$date]);dd($details ? $details[count($details)-1]->edittime : Carbon::now()->toDateTimeString());
|
|
|
- //$this->detailExe($details);
|
|
|
- //ValueStore::query()->where("name","wave_detail_last_sync_date")->update(["value"=>$details ? $details[count($details)-1]->edittime : Carbon::now()->toDateTimeString()]);
|
|
|
- }
|
|
|
- });
|
|
|
+ public function zzd(){
|
|
|
+ $update = [
|
|
|
+ ["id","wms_status","remark","updated_at"],
|
|
|
+ ["id"=>6,"wms_status"=>"完全收货",
|
|
|
+ "remark"=>"01.[ALLBLU]普通波次","updated_at"=>"2021-01-27 08:58:53"]
|
|
|
+ ];
|
|
|
+ dd(app(BatchUpdateService::class)->batchUpdate("batches",$update));
|
|
|
}
|
|
|
|
|
|
- public function zzd()
|
|
|
+ public function syncWeight()
|
|
|
{
|
|
|
- $province = [
|
|
|
- "a"=>["安徽","澳门"],
|
|
|
- "b"=>["北京"],
|
|
|
- "c"=>["重庆"],
|
|
|
- "f"=>["福建"],
|
|
|
- "g"=>["广东","甘肃","广西","贵州"],
|
|
|
- "h"=>["河北","湖北","黑龙江","湖南","河南","海南"],
|
|
|
- "j"=>["吉林","江苏","江西"],
|
|
|
- "l"=>["辽宁"],
|
|
|
- "n"=>["内蒙古","宁夏"],
|
|
|
- "q"=>["青海"],
|
|
|
- "s"=>["四川","山东","上海","陕西","山西"],
|
|
|
- "t"=>["天津","台湾"],
|
|
|
- "x"=>["香港","新疆","西藏"],
|
|
|
- "y"=>["云南"],
|
|
|
- "z"=>["浙江"],
|
|
|
- ];
|
|
|
- foreach ($province as $arr){
|
|
|
- foreach ($arr as $name){
|
|
|
- Region::query()->create([
|
|
|
- "name" => $name,
|
|
|
- "type" => 1,
|
|
|
- ]);
|
|
|
- }
|
|
|
- }
|
|
|
+ $pack = OrderPackageCountingRecord::query()->get();
|
|
|
+ foreach ($pack as $p){
|
|
|
+ $yesterday = $p->targeted_at;
|
|
|
+ Cache::pull("weight.".$yesterday);
|
|
|
+ OrderPackageCountingRecord::query()->where("targeted_at",$yesterday)->delete();
|
|
|
+ $sql = <<<sql
|
|
|
+SELECT DATE_FORMAT(created_at,'%Y-%m-%d') date,
|
|
|
+SUM(CASE WHEN weighed_at IS NOT NULL THEN 1 ELSE 0 END) AS count,
|
|
|
+COUNT(1) total FROM order_packages WHERE created_at BETWEEN '{$yesterday} 00:00:00' AND '{$yesterday} 23:59:59' GROUP BY date
|
|
|
+sql;
|
|
|
+ $result = DB::selectOne(DB::raw($sql));
|
|
|
+ if (!$result)$obj = [
|
|
|
+ "targeted_at" => $yesterday,
|
|
|
+ "un_weigh_count" => 0,
|
|
|
+ "total_count" => 0
|
|
|
+ ]; else $obj = [
|
|
|
+ "targeted_at" => $result->date,
|
|
|
+ "un_weigh_count" => $result->count,
|
|
|
+ "total_count" => $result->total,
|
|
|
+ ];
|
|
|
+ /** @var \stdClass $model */
|
|
|
+ $model = OrderPackageCountingRecord::query()->create($obj);
|
|
|
+ Cache::put("weight.".$yesterday,[
|
|
|
+ "date"=>$yesterday,
|
|
|
+ "total"=>$model->total_count,
|
|
|
+ "count"=>$model->un_weigh_count,
|
|
|
+ "value"=>$model->total_count ? intval(($model->un_weigh_count/$model->total_count)*100) : 0
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function sync()
|
|
|
@@ -341,40 +312,9 @@ sql;
|
|
|
|
|
|
function t1(Request $request)
|
|
|
{
|
|
|
- $times=12345;
|
|
|
- $start_at = microtime(true);
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Cache::put(md5('k_delme'.$i), 'a');
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
-
|
|
|
- $start_at = microtime(true);
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Cache::get(md5('k_delme'.$i));
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
-
|
|
|
- $start_at = microtime(true);
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Cache::pull(md5('k_delme'.$i));
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Redis::set(md5('k_delme'.$i), 'a');
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
-
|
|
|
- $start_at = microtime(true);
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Redis::get(md5('k_delme'.$i));
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
-
|
|
|
- $start_at = microtime(true);
|
|
|
- for($i=0;$i<$times;$i++){
|
|
|
- Redis::del(md5('k_delme'.$i));
|
|
|
- }
|
|
|
- echo microtime(true)-$start_at, '<br>';
|
|
|
+ throw new ErrorException('eeeff');
|
|
|
+ DB::connection('oracle')->update(DB::raw("update BAS_SKU set HAZARD_FLAG= 'N' where SKU= '13564151055'"));
|
|
|
+// DB::connection('oracle')->update(DB::raw("UPDATE DOC_ORDER_HEADER SET notes = CASE WHEN notes IS NULL THEN '停运' ELSE notes||',停运' END where ORDERNO in ('','SO190628000050','SO190628000001')"));
|
|
|
}
|
|
|
|
|
|
function packageT(Request $request)
|
|
|
@@ -596,59 +536,6 @@ sql;
|
|
|
if (count($error) > 0) app('LogService')->log(__METHOD__, "同步时WMS中未找到这些订单_two", json_encode($error));
|
|
|
}
|
|
|
|
|
|
- function test1()
|
|
|
- {
|
|
|
- $statistics = ProcessStatistic::query()->whereNull('revenue')->get();
|
|
|
- $id = array_column($statistics->toArray(), 'process_id');
|
|
|
- $processes = Process::query()->where(function (Builder $query) {
|
|
|
- $query->where('status', '待交接')->orWhere('status', '交接完成');
|
|
|
- })->whereIn('id', $id)->get();
|
|
|
- $sign_end = true;
|
|
|
- foreach ($processes as $process) {
|
|
|
- if (count($process->processDailies) > 0) {
|
|
|
- $completed_amount = 0;
|
|
|
- foreach ($process->processDailies as $processDaily) {
|
|
|
- $completed_amount = $completed_amount + ($processDaily->output);
|
|
|
- }
|
|
|
- $process->completed_amount = $completed_amount;
|
|
|
- }
|
|
|
- //统计:
|
|
|
- $revenue = ($process->unit_price) * ($process->completed_amount); //收入合计
|
|
|
- $processDailies = ProcessDaily::with('processDailyParticipants')->where('process_id', $process->id)->where('output', '>', 0)->get();
|
|
|
- $duration_days = count($processDailies); //完成天数
|
|
|
- $duration_man_hours = 0; //总工时
|
|
|
- $total_cost = 0; //合计成本
|
|
|
- foreach ($processDailies as $processDailyOne) {
|
|
|
- foreach ($processDailyOne->processDailyParticipants as $processDailyParticipant) {
|
|
|
- if (!$processDailyParticipant->unit_price && !$processDailyParticipant->hour_price) continue;
|
|
|
- $duration_man_hours += $processDailyParticipant->hour_count;
|
|
|
- if ($processDailyParticipant->unit_count) {
|
|
|
- $total_cost += ($processDailyParticipant->unit_count) * ($processDailyParticipant->unit_price);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $total_cost += ($processDailyParticipant->hour_count) * ($processDailyParticipant->hour_price);
|
|
|
- }
|
|
|
- };
|
|
|
- $processStatistic = ProcessStatistic::query()->find($process->id);
|
|
|
- $processStatistic->revenue = $revenue;
|
|
|
- $processStatistic->duration_days = $duration_days;
|
|
|
- $processStatistic->duration_man_hours = $duration_man_hours;
|
|
|
- if ($sign_end) $processStatistic->ended_at = date('Y-m-d H:i:s');
|
|
|
- if (!$revenue || !$total_cost) {
|
|
|
- $processStatistic->update();
|
|
|
- continue;
|
|
|
- }
|
|
|
- $gross_profit = $revenue - $total_cost; //毛利润
|
|
|
- if ($gross_profit != 0) $gross_profit_rate = $gross_profit / $revenue; //毛利率;
|
|
|
- else $gross_profit_rate = 0;
|
|
|
- $processStatistic->total_cost = $total_cost;
|
|
|
- $processStatistic->gross_profit = $gross_profit;
|
|
|
- $processStatistic->gross_profit_rate = $gross_profit_rate;
|
|
|
- $processStatistic->update();
|
|
|
- app('LogService')->log(__METHOD__, "修改二次加工单统计单_" . __FUNCTION__, json_encode($processStatistic), Auth::user()['id']);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function test5()
|
|
|
{
|
|
|
ini_set('max_execution_time', 2500);
|
|
|
@@ -1138,7 +1025,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
|
|
|
public function reNewBatches3()
|
|
|
{
|
|
|
- $batches = Batch::query()->where('id', 6384)->get('code');
|
|
|
+ $batches = Batch::query()->where('id','>', 73620)->get('code');
|
|
|
$batchCodes = $batches->map(function ($batch) {
|
|
|
return $batch['code'];
|
|
|
})->toArray();
|
|
|
@@ -1164,8 +1051,8 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
// dd($logs);
|
|
|
foreach ($batchCodes as $code) {
|
|
|
// $request=Cache::get('temp'.$code)['description'];
|
|
|
- $request = Log::query()->select('description')->where('CREATED_AT', '>', '2020-12-16')
|
|
|
- ->where('type', "issued_newBatch")
|
|
|
+ $request = Log::query()->select('description')->where('CREATED_AT', '>', '2021-01-22')
|
|
|
+ ->where('method', "issued_newBatch")
|
|
|
->where('description', 'like', "%{$code}%")
|
|
|
->first();
|
|
|
if ($request) {
|
|
|
@@ -1529,13 +1416,15 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
|
|
|
public function orderTrackingUpdate()
|
|
|
{
|
|
|
- $start_at = '2021-01-01 00:00:00';
|
|
|
+ $start_at = '2021-01-08 00:00:00';
|
|
|
+ $end_at = '2021-01-12 00:00:00';
|
|
|
// 修改【安桥,锐活】 订单号
|
|
|
$orderHeaderService = new OracleDOCOrderHeaderService();
|
|
|
$orderTrackingService = new OrderTrackingService();
|
|
|
$query = $orderHeaderService->getQuery();
|
|
|
$orderHeaders = $query->whereIn('Doc_Order_Header.customerid',['ONKYO','RUIHUO'])
|
|
|
->where('Doc_Order_Header.AddTime','>=',$start_at)
|
|
|
+ ->where('Doc_Order_Header.AddTime','<=',$end_at)
|
|
|
->get();
|
|
|
$orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
|
|
|
}
|
|
|
@@ -1553,37 +1442,19 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
* @var DataHandlerService $dataService
|
|
|
*/
|
|
|
$service = new OrderTrackingService();
|
|
|
- $orderHeaderService = new OracleDOCOrderHeaderService();
|
|
|
- $dataService = new DataHandlerService();
|
|
|
- $order_nos = array_unique(data_get($orderTrackings,'*.commodities.package.order.code'));
|
|
|
- $order_headers = $orderHeaderService->getQuery()->whereIn('orderno',$order_nos)->get();
|
|
|
- $update[] = ['id','order_client_code','client',];
|
|
|
- $order_header_map = $dataService->dataHeader(['orderno'],$order_headers);
|
|
|
+ $update = [];
|
|
|
+ $update[] = ['id','order_client_code_wms'];
|
|
|
foreach ($orderTrackings as $orderTracking) {
|
|
|
- $params = ['id' => $orderTracking->id];
|
|
|
- $order_package_commodity = $orderTracking->commodities;
|
|
|
- if(!$order_package_commodity)continue;
|
|
|
- if(!$order_package_commodity->package)continue;
|
|
|
- if(!$order_package_commodity->package->order)continue;
|
|
|
- $order= $order_package_commodity->package->order;
|
|
|
- $order_header = $dataService->getKeyValue(['orderno'=>$order->code],$order_header_map);
|
|
|
- $order_remark = $order_header['notes'] ?? ''; // 订单备注
|
|
|
- $params['client'] = $order_header['issuepartyname'];
|
|
|
- if(mb_stristr($order_remark,'天猫') && mb_stristr($order_remark,'赠品')){ // client and order_remark 商铺 和 订单备注
|
|
|
- $params['client'] = '天猫(赠品)';
|
|
|
- $params['order_remark'] = $order_remark;
|
|
|
+ if($orderTracking->commodities->order ?? false){
|
|
|
+ $update = [
|
|
|
+ 'id' => $orderTracking->id,
|
|
|
+ 'order_client_code_wms' => $orderTracking->commodities->order->client_code
|
|
|
+ ];
|
|
|
}
|
|
|
- if(mb_stristr($order_header['issuepartyname'],'天猫') && $params['client'] !== '天猫(赠品)') $params['client'] = '天猫';
|
|
|
- if($params['client'] == '天猫') // order_client_code 订单号 店铺包含天猫
|
|
|
- $params['order_client_code'] = $service->get_d_edit_03($order_header,$order_package_commodity);
|
|
|
- else
|
|
|
- $params['order_client_code'] = $order->client_code;
|
|
|
- if($params['client'] != '天猫' && $params['client'] != '天猫(赠品)')continue;
|
|
|
- if($params['client']!=$orderTracking->client || $params['order_client_code']!=$orderTracking->order_client_code) $update[] = $params;
|
|
|
- }
|
|
|
- if(count($update) > 1){
|
|
|
- $service->batchUpdate($update);
|
|
|
- }
|
|
|
+ }
|
|
|
+ if(count($update) > 1){
|
|
|
+ $service->batchUpdate($update);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|