Prechádzať zdrojové kódy

波次同步-反向同步订单
客户管理-作业起步费页面修改为选项卡形式
自动冻结-增加条件限制,不允许重复冻结

Zhouzhendong 5 rokov pred
rodič
commit
6bef58d760

+ 24 - 3
app/Console/Commands/SyncBatchTask.php

@@ -150,6 +150,7 @@ sql;
         $nos = [];
         $orderCodes = [];
         $seqnos = [];
+        $batchMapping = [];
         foreach ($details as $detail){
             if (isset($map[$detail->waveno]))$map[$detail->waveno][] = $detail->orderno;
             else {
@@ -158,9 +159,10 @@ sql;
             }
             $orderCodes[] = $detail->orderno;
             $seqnos[$detail->orderno] = $detail->seqno;
+            $batchMapping[$detail->orderno] = $detail->waveno;
         }
-        $orders = Order::query()->select("id","code")->whereIn("code",$orderCodes)->get();
-        if (count($orderCodes) != count($orders))LogService::log(__METHOD__,"波次同步-本地订单缺失",json_encode($orderCodes)." | ".count($orderCodes)." | ".count($orders));
+        $orders = Order::query()->select("id","batch_id","code")->whereIn("code",$orderCodes)->get();
+        //if (count($orderCodes) != count($orders))LogService::log(__METHOD__,"波次同步-本地订单缺失",json_encode($orderCodes)." | ".count($orderCodes)." | ".count($orders));
         if ($orders){
             $orderIds = [];
             $orderMap = [];
@@ -202,10 +204,29 @@ sql;
             }
         }
         $batches = $this->batchService->get(["code"=>$nos]);
+        $batchDiff = array_keys(array_flip(array_diff($nos,array_column($batches->toArray(),"code"))));
+        if (count($batchDiff)>0){
+            $sql = <<<sql
+SELECT * FROM DOC_WAVE_HEADER WHERE WAVENO IN (''
+sql;
+            foreach ($batchDiff as $bd)$sql .= ",'".$bd."'";
+            $sql .= ')';
+            $wmsBatches = DB::connection("oracle")->select(DB::raw($sql));
+            $this->headerExe($wmsBatches);
+            $batches = $this->batchService->get(["code"=>$nos]);
+        }
+        $updateOrder = [["code","batch_id"]];
         foreach ($batches as $batch){
-            app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
+            $updateOrder[] = [
+                "code"=>$map[$batch->code],
+                "batch_id"=>$batch->id
+            ];
             unset($map[$batch->code]);
         }
+        if (count($updateOrder)>1){
+            app("OrderService")->batchUpdate($updateOrder);//反向修改订单
+            LogService::log(__METHOD__,"波次同步-修改订单波次号",json_encode($updateOrder));
+        }
         if ($map){
             $waveCodes = array_keys($map);
             $waves = $this->service->get(["waveno"=>$waveCodes],["waveno"=>"in"]);

+ 26 - 53
app/Http/Controllers/TestController.php

@@ -12,6 +12,7 @@ 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;
@@ -163,6 +164,31 @@ sql;
             }
         });
     }
+    public function test1(){
+        $a = [1,2,3];
+        $b = [2,3];
+        dd(array_diff($a,$b));
+   /*     $sql = <<<sql
+    select * from DOC_ORDER_HEADER WHERE ORDERNO in ('SO190628006175','SO190628006415',
+'SO190628007767','SO190628007535','SO190628007503','SO190628006567','SO190628006569','SO190628006995')
+sql;
+
+        DB::connection("oracle")->select(DB::raw($sql));*/
+   $a = new SyncWMSOrderTask();
+   $a->handle();
+        /*$order = new  OracleDOCOrderHeaderService();
+        $arr = $order->getOrderInfoByOrderNos(['SO190628006175','SO190628006415',
+            'SO190628007767','SO190628007535','SO190628007503','SO190628006567','SO190628006569','SO190628006995']);
+        dump($arr[0]);
+        app("OrderService")->syncOrder($arr);*/
+    }
+
+    public function test2(){
+        $a = new SyncBatchTask();
+        $a->handle();
+        //DB::connection("oracle")->select(DB::raw("select * from DOC_WAVE_DETAILS where waveno = 'W210121000004'"));
+    }
+
 
     public function zzd()
     {
@@ -586,59 +612,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);

+ 1 - 0
app/Jobs/OrderFreeze.php

@@ -51,6 +51,7 @@ class OrderFreeze implements ShouldQueue
     {
         $freezeOrders = [];
         foreach ($this->params as $param){
+            if (!$param["frozen"]=='是')continue;
             if (!$param["logistic_id"])continue;
             if ($this->isFreeze($param))$freezeOrders[] = $param["code"];
         }

+ 3 - 2
app/Services/OwnerPriceOperationService.php

@@ -253,10 +253,11 @@ Class OwnerPriceOperationService
                     }
                     break;
                 default:
-                    if ($isIn)break;
-                    if ($unitName && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
+                    if ($isIn)break;    //入库不计算起步
 
                     if ($rule->amount){ //起步数+起步费
+                        if ($unitName && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
+
                         $money = $rule->unit_price;
                         $startNumber = $rule->amount;
                         $packages = $this->settingCount($packages,$amountColumn,$startNumber);

+ 4 - 4
resources/views/customer/project/create.blade.php

@@ -142,7 +142,7 @@
                         name:"",
                         feature:"",
                         items : [
-                            {strategy:"起步"},
+                            {strategy:"起步",type:"0"},
                             {strategy:"默认"},
                             {strategy:"特征"},
                         ],
@@ -625,7 +625,7 @@
                             name:"",
                             feature:"",
                             items : [
-                                {strategy:"起步"},
+                                {strategy:"起步",type:"0"},
                                 {strategy:"默认"},
                                 {strategy:"特征"},
                             ],
@@ -640,10 +640,10 @@
                         this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
                         sign = true;
                     }else if (!obj.amount) obj.amount = 0;
-                    if (!obj.unit_id){
+                    if (obj.strategy!=='起步' && !obj.unit_id){
                         this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
                         sign = true;
-                    }
+                    }else if (!obj.unit_id) obj.unit_id = 0;
                     if (!obj.unit_price){
                         this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
                     }

+ 35 - 23
resources/views/customer/project/part/_operation.blade.php

@@ -42,29 +42,41 @@
         </div>
         <div class="card-body">
             <div class="row mt-2">
-                <label class="col-3">起步数</label>
-                <label class="col-5 mb-0"><input id="amount" type="number" :class="errors['items.0.amount'] ? 'is-invalid' : ''"
-                       v-model="model.operation.items[0].amount" class="form-control" step="1"></label>
-            </div>
-            <div class="row mt-0" v-if="errors['items.0.amount']">
-                <div class="offset-3"><small class="text-danger font-weight-bold ml-3">起步数为必填项</small></div>
-            </div>
-            <div class="row mt-2">
-                <label class="col-3">单位</label>
-                <label class="col-5 mb-0"><select v-model="model.operation.items[0].unit_id" class="form-control" :class="errors['items.0.unit_id'] ? 'is-invalid' : ''">
-                        <option v-for="unit in pool.units" :value="unit.id">@{{ unit.name }}</option>
-                </select></label>
-            </div>
-            <div class="row mt-0" v-if="errors['items.0.unit_id']">
-                <div class="offset-3"><small class="text-danger font-weight-bold ml-3">单位为必选项</small></div>
-            </div>
-            <div class="row mt-2">
-                <label class="col-3">起步费</label>
-                <label class="col-5 mb-0"><input type="number" min="0" step="0.001" class="form-control" v-model="model.operation.items[0].unit_price"
-                           :class="errors['items.0.unit_price'] ? 'is-invalid' : ''"></label>
-            </div>
-            <div class="row mt-0" v-if="errors['items.0.unit_price']">
-                <div class="offset-3"><small class="text-danger font-weight-bold ml-3">单价为必填项</small></div>
+                <div class="col-3">
+                    <label>
+                        <select class="form-control form-control-sm mt-1" v-model="model.operation.items[0].type">
+                            <option value="0">起步数</option>
+                            <option value="1">起步费</option>
+                        </select>
+                    </label>
+                </div>
+                <div class="col-9">
+                    <div class="row" v-if="model.operation.items[0].type == 0">
+                        <label class="col-3">起步数</label>
+                        <label class="col-5 mb-0"><input id="amount" type="number" :class="errors['items.0.amount'] ? 'is-invalid' : ''"
+                                                         v-model="model.operation.items[0].amount" class="form-control" step="1"></label>
+                    </div>
+                    <div class="row mt-0" v-if="errors['items.0.amount']">
+                        <div class="offset-3"><small class="text-danger font-weight-bold ml-3">起步数为必填项</small></div>
+                    </div>
+                    <div class="row mt-2" v-if="model.operation.items[0].type == 0">
+                        <label class="col-3">单位</label>
+                        <label class="col-5 mb-0"><select v-model="model.operation.items[0].unit_id" class="form-control" :class="errors['items.0.unit_id'] ? 'is-invalid' : ''">
+                                <option v-for="unit in pool.units" :value="unit.id">@{{ unit.name }}</option>
+                            </select></label>
+                    </div>
+                    <div class="row mt-0" v-if="errors['items.0.unit_id']">
+                        <div class="offset-3"><small class="text-danger font-weight-bold ml-3">单位为必选项</small></div>
+                    </div>
+                    <div class="row mt-2">
+                        <label class="col-3">起步费</label>
+                        <label class="col-5 mb-0"><input type="number" min="0" step="0.001" class="form-control" v-model="model.operation.items[0].unit_price"
+                                                         :class="errors['items.0.unit_price'] ? 'is-invalid' : ''"></label>
+                    </div>
+                    <div class="row mt-0" v-if="errors['items.0.unit_price']">
+                        <div class="offset-3"><small class="text-danger font-weight-bold ml-3">起步费为必填项</small></div>
+                    </div>
+                </div>
             </div>
         </div>
     </div>

+ 2 - 2
resources/views/order/index/_freezeModal.blade.php

@@ -39,11 +39,11 @@
                     </span>
                 </div>
                 <div class="row mt-2">
-                    <label class="col-2 offset-1" for="location_id">区</label>
+                    <label class="col-2 offset-1" for="location_id">区/县</label>
                     <select class="col-5 form-control form-control-sm"
                             :class="errors.location_id ? 'is-invalid' : ''" id="location_id" type="text"
                             v-model="freeze.location_id">
-                        <option v-for="district in data.districts" :value="district.id" v-if="city.parent_id == freeze.city_id">@{{ district.name }}</option>
+                        <option v-for="district in data.districts" :value="district.id" v-if="district.parent_id == freeze.city_id">@{{ district.name }}</option>
                     </select>
                     <span class="invalid-feedback mt-0 offset-3" role="alert" v-if="errors.location_id">
                         <strong>@{{ errors.location_id[0] }}</strong>