|
|
@@ -11,6 +11,7 @@ use App\CommodityBarcode;
|
|
|
use App\Events\CancelOrder;
|
|
|
use App\Log;
|
|
|
use App\Logistic;
|
|
|
+use App\LogisticTiming;
|
|
|
use App\OracleActAllocationDetails;
|
|
|
use App\OracleBasCode;
|
|
|
use App\OracleBasSKU;
|
|
|
@@ -21,6 +22,7 @@ use App\OracleDOCWaveDetails;
|
|
|
use App\Order;
|
|
|
use App\OrderIssue;
|
|
|
use App\OrderPackage;
|
|
|
+use App\OrderPackageCommodities;
|
|
|
use App\OrderTracking;
|
|
|
use App\OrderTrackingOwner;
|
|
|
use App\Owner;
|
|
|
@@ -28,14 +30,20 @@ use App\Package;
|
|
|
use App\Process;
|
|
|
use App\ProcessDaily;
|
|
|
use App\ProcessStatistic;
|
|
|
+use App\Province;
|
|
|
use App\RejectedBill;
|
|
|
use App\RejectedBillItem;
|
|
|
+use App\Services\CityService;
|
|
|
+use App\Services\CommodityService;
|
|
|
use App\Services\common\BatchUpdateService;
|
|
|
use App\Services\common\DataHandlerService;
|
|
|
use App\Services\InventoryCompareService;
|
|
|
use App\Services\LogService;
|
|
|
+use App\Services\OracleActAllocationDetailService;
|
|
|
use App\Services\OracleDOCOrderHeaderService;
|
|
|
+use App\Services\OrderIssuePerformanceService;
|
|
|
use App\Services\OrderIssueService;
|
|
|
+use App\Services\OrderPackageCommoditiesService;
|
|
|
use App\Services\OrderPackageService;
|
|
|
use App\Services\OrderService;
|
|
|
use App\Services\OrderTrackingOwnerService;
|
|
|
@@ -100,10 +108,10 @@ class TestController extends Controller
|
|
|
{
|
|
|
/** @var OrderPackageService $orderPackageService */
|
|
|
$orderPackageService = app('orderPackageService');
|
|
|
- $ids = [741,739,738,736,735,733,732,731,730,729,728,725,724,723,721,720,719,718,717,715,714,713,712,711,710,705,703,702,701,700,699,698,696,694,693,692,691,690];
|
|
|
- $orderIssues = OrderIssue::query()->whereIn('id',$ids)->get();
|
|
|
- $order_ids = data_get($orderIssues,'*.order_id');
|
|
|
- $orders = Order::query()->whereIn('id',$order_ids)->get();
|
|
|
+ $ids = [741, 739, 738, 736, 735, 733, 732, 731, 730, 729, 728, 725, 724, 723, 721, 720, 719, 718, 717, 715, 714, 713, 712, 711, 710, 705, 703, 702, 701, 700, 699, 698, 696, 694, 693, 692, 691, 690];
|
|
|
+ $orderIssues = OrderIssue::query()->whereIn('id', $ids)->get();
|
|
|
+ $order_ids = data_get($orderIssues, '*.order_id');
|
|
|
+ $orders = Order::query()->whereIn('id', $order_ids)->get();
|
|
|
foreach ($orders as $item) {
|
|
|
$orderPackageService->createdByOrder($item);
|
|
|
}
|
|
|
@@ -126,34 +134,36 @@ class TestController extends Controller
|
|
|
Cache::put('storedTest', $today);
|
|
|
return "cacheing:'$today'<script>localStorage.setItem('storedTest','{$today}')</script>";
|
|
|
}
|
|
|
+
|
|
|
function getCache(Request $request)
|
|
|
{
|
|
|
- $cache=Cache::get('storedTest');
|
|
|
+ $cache = Cache::get('storedTest');
|
|
|
return "cacheing get:'$cache'<script>document.write('<br>localStorage:'+localStorage.getItem('storedTest'))</script>";
|
|
|
}
|
|
|
+
|
|
|
function t1(Request $request)
|
|
|
{
|
|
|
{
|
|
|
- $username=config('database.connections.oracle.username');
|
|
|
- $password=config('database.connections.oracle.password');
|
|
|
- $host=config('database.connections.oracle.host');
|
|
|
- $service_name=config('database.connections.oracle.service_name');
|
|
|
- $conn=oci_connect($username,$password,$host.'/'.$service_name); //连接oracle数据库
|
|
|
- $IN_WarehouseID='';
|
|
|
- $IN_TraceID='' ;
|
|
|
- $IN_WavenNo='';
|
|
|
- $IN_UserID='';
|
|
|
- $IN_Language='';
|
|
|
- $OUT_Return_Code='';
|
|
|
- $sql_sp="begin SPCUS_EDI_WCS001(:IN_WarehouseID,:IN_Process_Action_C,:IN_Process_By_C,
|
|
|
+ $username = config('database.connections.oracle.username');
|
|
|
+ $password = config('database.connections.oracle.password');
|
|
|
+ $host = config('database.connections.oracle.host');
|
|
|
+ $service_name = config('database.connections.oracle.service_name');
|
|
|
+ $conn = oci_connect($username, $password, $host . '/' . $service_name); //连接oracle数据库
|
|
|
+ $IN_WarehouseID = '';
|
|
|
+ $IN_TraceID = '';
|
|
|
+ $IN_WavenNo = '';
|
|
|
+ $IN_UserID = '';
|
|
|
+ $IN_Language = '';
|
|
|
+ $OUT_Return_Code = '';
|
|
|
+ $sql_sp = "begin SPCUS_EDI_WCS001(:IN_WarehouseID,:IN_Process_Action_C,:IN_Process_By_C,
|
|
|
:IN_WaveNO_C,:IN_OrderNO_C,:IN_OrderLineNO_C,:IN_AllocationDetailsID,:IN_Language,:IN_UserID,:OUT_Return_Code); end;";
|
|
|
$stmt = oci_parse($conn, $sql_sp);
|
|
|
- oci_bind_by_name($stmt,':IN_Warehouse',$IN_WarehouseID);
|
|
|
- oci_bind_by_name($stmt,':IN_TraceID',$IN_TraceID);
|
|
|
- oci_bind_by_name($stmt,':IN_WavenNo',$IN_WavenNo);
|
|
|
- oci_bind_by_name($stmt,':IN_Language',$IN_Language);
|
|
|
- oci_bind_by_name($stmt,':IN_UserID',$IN_UserID);
|
|
|
- oci_bind_by_name($stmt,':OUT_Return_Code',$OUT_Return_Code);
|
|
|
+ oci_bind_by_name($stmt, ':IN_Warehouse', $IN_WarehouseID);
|
|
|
+ oci_bind_by_name($stmt, ':IN_TraceID', $IN_TraceID);
|
|
|
+ oci_bind_by_name($stmt, ':IN_WavenNo', $IN_WavenNo);
|
|
|
+ oci_bind_by_name($stmt, ':IN_Language', $IN_Language);
|
|
|
+ oci_bind_by_name($stmt, ':IN_UserID', $IN_UserID);
|
|
|
+ oci_bind_by_name($stmt, ':OUT_Return_Code', $OUT_Return_Code);
|
|
|
return oci_execute($stmt);
|
|
|
|
|
|
}
|
|
|
@@ -164,7 +174,7 @@ class TestController extends Controller
|
|
|
|
|
|
function packageT(Request $request)
|
|
|
{
|
|
|
- $package=Package::where('created_at','<','2020-07-08')->whereNotNull('logistic_number')->first();
|
|
|
+ $package = Package::where('created_at', '<', '2020-07-08')->whereNotNull('logistic_number')->first();
|
|
|
$package->fetchLogistic();
|
|
|
}
|
|
|
|
|
|
@@ -178,27 +188,29 @@ class TestController extends Controller
|
|
|
|
|
|
public function tj2(Request $request)
|
|
|
{
|
|
|
- $numbersesOfBatch=OracleDOCWaveDetails::select('picktotraceid as logistic_number','act_allocation_details.orderno')->where('doc_wave_details.waveno','W190630000042')
|
|
|
- ->leftJoin('act_allocation_details','doc_wave_details.orderno','act_allocation_details.orderno')->get();
|
|
|
-
|
|
|
- $oneIdxAsrsReceive=OracleDocOrderPackingSummary::where('traceid',$numbersesOfBatch[0]['logistic_number'])->first();
|
|
|
- if(!$oneIdxAsrsReceive){
|
|
|
- $inserts='';
|
|
|
- $values=[];
|
|
|
- foreach($numbersesOfBatch as $numbers){
|
|
|
+ $numbersesOfBatch = OracleDOCWaveDetails::select('picktotraceid as logistic_number', 'act_allocation_details.orderno')->where('doc_wave_details.waveno', 'W190630000042')
|
|
|
+ ->leftJoin('act_allocation_details', 'doc_wave_details.orderno', 'act_allocation_details.orderno')->get();
|
|
|
+
|
|
|
+ $oneIdxAsrsReceive = OracleDocOrderPackingSummary::where('traceid', $numbersesOfBatch[0]['logistic_number'])->first();
|
|
|
+ if (!$oneIdxAsrsReceive) {
|
|
|
+ $inserts = '';
|
|
|
+ $values = [];
|
|
|
+ foreach ($numbersesOfBatch as $numbers) {
|
|
|
$inserts .= " into doc_order_packing_summary (traceid,orderno,grossweight,addwho,addtime,editwho,edittime)values(?,?,?,?,?,?,?) ";
|
|
|
- $values[] = $numbers['logistic_number']??'';
|
|
|
- $values[] = $numbers['orderno']??'';
|
|
|
+ $values[] = $numbers['logistic_number'] ?? '';
|
|
|
+ $values[] = $numbers['orderno'] ?? '';
|
|
|
$values[] = 12;
|
|
|
$values[] = 'WAS';
|
|
|
$values[] = Carbon::now();
|
|
|
$values[] = 'WAS';
|
|
|
$values[] = Carbon::now();
|
|
|
}
|
|
|
- DB::connection('oracle')->insert("insert all {$inserts} select * from dual",$values);
|
|
|
- }else{
|
|
|
- $logisticNumbers=$numbersesOfBatch->map(function($numbers){return $numbers['logistic_number'];});
|
|
|
- OracleDocOrderPackingSummary::whereIn('traceid',$logisticNumbers)->update(['grossweight'=>32]);
|
|
|
+ DB::connection('oracle')->insert("insert all {$inserts} select * from dual", $values);
|
|
|
+ } else {
|
|
|
+ $logisticNumbers = $numbersesOfBatch->map(function ($numbers) {
|
|
|
+ return $numbers['logistic_number'];
|
|
|
+ });
|
|
|
+ OracleDocOrderPackingSummary::whereIn('traceid', $logisticNumbers)->update(['grossweight' => 32]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -213,49 +225,50 @@ class TestController extends Controller
|
|
|
'doc_order_header.customerid',
|
|
|
'doc_order_header.Consigneename'
|
|
|
];
|
|
|
- if(''){
|
|
|
- $resultOracleObj=OracleDOCOrderHeader::select($fields)->where('orderno','SO200603004708');
|
|
|
- }else{
|
|
|
- $resultOracleObj=OracleActAllocationDetails::select($fields);
|
|
|
- $resultOracleObj->where('picktotraceid','546152742096');
|
|
|
- $resultOracleObj->leftJoin('DOC_Order_Header','act_allocation_details.orderno','doc_order_header.orderno');
|
|
|
+ if ('') {
|
|
|
+ $resultOracleObj = OracleDOCOrderHeader::select($fields)->where('orderno', 'SO200603004708');
|
|
|
+ } else {
|
|
|
+ $resultOracleObj = OracleActAllocationDetails::select($fields);
|
|
|
+ $resultOracleObj->where('picktotraceid', '546152742096');
|
|
|
+ $resultOracleObj->leftJoin('DOC_Order_Header', 'act_allocation_details.orderno', 'doc_order_header.orderno');
|
|
|
}
|
|
|
- $_temOracleInfo=$resultOracleObj->first();
|
|
|
+ $_temOracleInfo = $resultOracleObj->first();
|
|
|
|
|
|
dd($_temOracleInfo);
|
|
|
}
|
|
|
|
|
|
- public function mergerPackageData(){
|
|
|
- ini_set('max_execution_time',36000);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
+ public function mergerPackageData()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 36000);
|
|
|
+ ini_set('memory_limit', '1526M');
|
|
|
$number = 3000;
|
|
|
$start_at = 1;
|
|
|
- $sum = Package::query()->where('id','>', $start_at)->count();
|
|
|
+ $sum = Package::query()->where('id', '>', $start_at)->count();
|
|
|
$len = ceil($sum / $number);
|
|
|
$id = $start_at;
|
|
|
- for ($i = 1;$i <= $len; $i++){
|
|
|
- $packages = Package::query()->orderBy('id')->where('id','>',$id)->limit($number)->get();
|
|
|
+ for ($i = 1; $i <= $len; $i++) {
|
|
|
+ $packages = Package::query()->orderBy('id')->where('id', '>', $id)->limit($number)->get();
|
|
|
$error = [];
|
|
|
- foreach ($packages as $package){
|
|
|
+ foreach ($packages as $package) {
|
|
|
/** @var $service OrderPackageService */
|
|
|
$service = app('orderPackageService');
|
|
|
- $orderPackage = $service->firstOrCreate($package->logistic_number,
|
|
|
- ['batch_number'=>$package->batch_number,
|
|
|
- 'batch_rule'=>$package->batch_rule,
|
|
|
- 'bulk'=>$package->bulk,
|
|
|
- 'weight'=>$package->weight,
|
|
|
- 'length'=>$package->length,
|
|
|
- 'width'=>$package->width,
|
|
|
- 'height'=>$package->height,
|
|
|
- 'paper_box_id'=>$package->paper_box_id,
|
|
|
- 'measuring_machine_id'=>$package->measuring_machine_id,
|
|
|
- 'weighed_at'=>$package->weighed_at,
|
|
|
- 'status'=>$package->status]);
|
|
|
- if (!$orderPackage)array_push($error,$package->id);
|
|
|
+ $orderPackage = $service->firstOrCreate($package->logistic_number,
|
|
|
+ ['batch_number' => $package->batch_number,
|
|
|
+ 'batch_rule' => $package->batch_rule,
|
|
|
+ 'bulk' => $package->bulk,
|
|
|
+ 'weight' => $package->weight,
|
|
|
+ 'length' => $package->length,
|
|
|
+ 'width' => $package->width,
|
|
|
+ 'height' => $package->height,
|
|
|
+ 'paper_box_id' => $package->paper_box_id,
|
|
|
+ 'measuring_machine_id' => $package->measuring_machine_id,
|
|
|
+ 'weighed_at' => $package->weighed_at,
|
|
|
+ 'status' => $package->status]);
|
|
|
+ if (!$orderPackage) array_push($error, $package->id);
|
|
|
}
|
|
|
- LogService::log(__METHOD__,"同步时WMS中未找到这些订单",json_encode($error));
|
|
|
- $id = $packages[count($packages)-1]->id;
|
|
|
- echo $number.' a bunch done at:'.now()->toFormattedDateString().'<br>';
|
|
|
+ LogService::log(__METHOD__, "同步时WMS中未找到这些订单", json_encode($error));
|
|
|
+ $id = $packages[count($packages) - 1]->id;
|
|
|
+ echo $number . ' a bunch done at:' . now()->toFormattedDateString() . '<br>';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -330,112 +343,117 @@ class TestController extends Controller
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function test(){
|
|
|
+ function test()
|
|
|
+ {
|
|
|
$ids = [];
|
|
|
- $logs = Log::query()->select('description')->where('type','同步时WMS中未找到这些订单')->get();
|
|
|
- foreach ($logs as $log){
|
|
|
+ $logs = Log::query()->select('description')->where('type', '同步时WMS中未找到这些订单')->get();
|
|
|
+ foreach ($logs as $log) {
|
|
|
$arr = [];
|
|
|
- eval("\$arr = ".$log->description.'; ');
|
|
|
- if (count($arr) < 1)continue;
|
|
|
- $ids = array_merge($ids,$arr);
|
|
|
+ eval("\$arr = " . $log->description . '; ');
|
|
|
+ if (count($arr) < 1) continue;
|
|
|
+ $ids = array_merge($ids, $arr);
|
|
|
}
|
|
|
$ids = array_unique($ids);
|
|
|
$error = [];
|
|
|
- foreach($ids as $id){
|
|
|
+ foreach ($ids as $id) {
|
|
|
$package = Package::query()->find($id);
|
|
|
/** @var OrderPackageService */
|
|
|
- $orderPackage = app('orderPackageService')->firstOrCreate($package->logistic_number,
|
|
|
- ['batch_number'=>$package->batch_number,
|
|
|
- 'batch_rule'=>$package->batch_rule,
|
|
|
- 'bulk'=>$package->bulk,
|
|
|
- 'weight'=>$package->weight,
|
|
|
- 'length'=>$package->length,
|
|
|
- 'width'=>$package->width,
|
|
|
- 'height'=>$package->height,
|
|
|
- 'paper_box_id'=>$package->paper_box_id,
|
|
|
- 'measuring_machine_id'=>$package->measuring_machine_id,
|
|
|
- 'weighed_at'=>$package->weighed_at,
|
|
|
- 'status'=>$package->status]);
|
|
|
- if (!$orderPackage)array_push($error,$package->id);
|
|
|
+ $orderPackage = app('orderPackageService')->firstOrCreate($package->logistic_number,
|
|
|
+ ['batch_number' => $package->batch_number,
|
|
|
+ 'batch_rule' => $package->batch_rule,
|
|
|
+ 'bulk' => $package->bulk,
|
|
|
+ 'weight' => $package->weight,
|
|
|
+ 'length' => $package->length,
|
|
|
+ 'width' => $package->width,
|
|
|
+ 'height' => $package->height,
|
|
|
+ 'paper_box_id' => $package->paper_box_id,
|
|
|
+ 'measuring_machine_id' => $package->measuring_machine_id,
|
|
|
+ 'weighed_at' => $package->weighed_at,
|
|
|
+ 'status' => $package->status]);
|
|
|
+ if (!$orderPackage) array_push($error, $package->id);
|
|
|
}
|
|
|
- if (count($error) > 0)LogService::log(__METHOD__,"同步时WMS中未找到这些订单_two",json_encode($error));
|
|
|
+ if (count($error) > 0) LogService::log(__METHOD__, "同步时WMS中未找到这些订单_two", json_encode($error));
|
|
|
}
|
|
|
|
|
|
- function test1(){
|
|
|
+ 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();
|
|
|
+ $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);
|
|
|
+ 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;
|
|
|
+ $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){
|
|
|
+ $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);
|
|
|
+ if ($processDailyParticipant->unit_count) {
|
|
|
+ $total_cost += ($processDailyParticipant->unit_count) * ($processDailyParticipant->unit_price);
|
|
|
continue;
|
|
|
}
|
|
|
- $total_cost += ($processDailyParticipant->hour_count)*($processDailyParticipant->hour_price);
|
|
|
+ $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;
|
|
|
+ $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){
|
|
|
+ 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;
|
|
|
+ $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();
|
|
|
- $this->log(__METHOD__,"修改二次加工单统计单_".__FUNCTION__,json_encode($processStatistic),Auth::user()['id']);
|
|
|
+ $this->log(__METHOD__, "修改二次加工单统计单_" . __FUNCTION__, json_encode($processStatistic), Auth::user()['id']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function cleanBarcode(){
|
|
|
+ private function cleanBarcode()
|
|
|
+ {
|
|
|
|
|
|
- $logCommodityBarcodes = CommodityBarcode::query()->where('code',"")->get();
|
|
|
- if (count($logCommodityBarcodes) > 0)LogService::log(__METHOD__,"纠正商品-删除空条码",json_encode($logCommodityBarcodes,JSON_UNESCAPED_UNICODE));
|
|
|
+ $logCommodityBarcodes = CommodityBarcode::query()->where('code', "")->get();
|
|
|
+ if (count($logCommodityBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-删除空条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
- CommodityBarcode::query()->where('code',"")->delete();
|
|
|
+ CommodityBarcode::query()->where('code', "")->delete();
|
|
|
$barcodes = DB::select(DB::raw('select * from commodity_barcodes c
|
|
|
where (c.code,c.commodity_id) in (select code,commodity_id from commodity_barcodes group by code,commodity_id having count(*) > 1) order by commodity_id'));
|
|
|
$barcodeMap = [];
|
|
|
$barcodeDelete = [];
|
|
|
- foreach ($barcodes as $barcode){
|
|
|
- if (isset($barcodeMap[$barcode->code.'_'.$barcode->commodity_id]))$barcodeDelete[] = $barcode->id;
|
|
|
- else $barcodeMap[$barcode->code.'_'.$barcode->commodity_id] = $barcode->id;
|
|
|
+ foreach ($barcodes as $barcode) {
|
|
|
+ if (isset($barcodeMap[$barcode->code . '_' . $barcode->commodity_id])) $barcodeDelete[] = $barcode->id;
|
|
|
+ else $barcodeMap[$barcode->code . '_' . $barcode->commodity_id] = $barcode->id;
|
|
|
}
|
|
|
|
|
|
- $logCommodityBarcodes = CommodityBarcode::query()->whereIn('id',$barcodeDelete)->get();
|
|
|
- if (count($logCommodityBarcodes) > 0)LogService::log(__METHOD__,"纠正商品-删除重复条码",json_encode($logCommodityBarcodes,JSON_UNESCAPED_UNICODE));
|
|
|
+ $logCommodityBarcodes = CommodityBarcode::query()->whereIn('id', $barcodeDelete)->get();
|
|
|
+ if (count($logCommodityBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-删除重复条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
CommodityBarcode::destroy($barcodeDelete);
|
|
|
}
|
|
|
- public function correctCommodity(){
|
|
|
- ini_set('max_execution_time',2500);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
+
|
|
|
+ public function correctCommodity()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 2500);
|
|
|
+ ini_set('memory_limit', '1526M');
|
|
|
//清理冗余条码
|
|
|
$this->cleanBarcode();
|
|
|
|
|
|
@@ -447,58 +465,58 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$commodityMap = [];
|
|
|
//需要删除项
|
|
|
$commodityDelete = [];
|
|
|
- foreach ($commodities as $index => $commodity){
|
|
|
- $commodity->barcode_code=strtolower(trim($commodity->barcode_code));
|
|
|
+ foreach ($commodities as $index => $commodity) {
|
|
|
+ $commodity->barcode_code = strtolower(trim($commodity->barcode_code));
|
|
|
//货主+条码 为唯一key值 设想正常数据下同货主不应该有同条码
|
|
|
- $key = $commodity->owner_id.'_'.$commodity->barcode_code;
|
|
|
+ $key = $commodity->owner_id . '_' . $commodity->barcode_code;
|
|
|
//使用map池对比为重复数据
|
|
|
- if(isset($commodityMap[$key])){
|
|
|
+ if (isset($commodityMap[$key])) {
|
|
|
//获取下标指针指向的源数据
|
|
|
$c = $commodities[$commodityMap[$key]];
|
|
|
//源数据不符合规范,当前数据替换掉它
|
|
|
- if (($c->sku == null || $c->sku == "") && ($commodity->sku != null && $commodity->sku != "")){
|
|
|
+ if (($c->sku == null || $c->sku == "") && ($commodity->sku != null && $commodity->sku != "")) {
|
|
|
$commodityDelete[] = $commodityMap[$key];
|
|
|
$commodityMap[$key] = $index;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//当前数据比源数据更符合预期,替换掉
|
|
|
- if (($c->sku == $commodity->sku) && (strlen($c->name) < strlen($commodity->name))){
|
|
|
+ if (($c->sku == $commodity->sku) && (strlen($c->name) < strlen($commodity->name))) {
|
|
|
$commodityDelete[] = $commodityMap[$key];
|
|
|
$commodityMap[$key] = $index;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//扔进处理池
|
|
|
$commodityDelete[] = $index;
|
|
|
}
|
|
|
}
|
|
|
- //第一次出现的新数据,val为下标,当作指针指向源数据
|
|
|
- }else $commodityMap[$key] = $index;
|
|
|
+ //第一次出现的新数据,val为下标,当作指针指向源数据
|
|
|
+ } else $commodityMap[$key] = $index;
|
|
|
}
|
|
|
$createBarcodes = []; //批量生成条码
|
|
|
$deleteCommodities = []; //批量删除商品及商品条码
|
|
|
|
|
|
$updateCommodities = [];
|
|
|
- foreach ($commodityDelete as $index){
|
|
|
+ foreach ($commodityDelete as $index) {
|
|
|
//获取到被处理数据 与 目标数据
|
|
|
$del = $commodities[$index];
|
|
|
- $target = $commodities[$commodityMap[$del->owner_id.'_'.$del->barcode_code]];
|
|
|
+ $target = $commodities[$commodityMap[$del->owner_id . '_' . $del->barcode_code]];
|
|
|
|
|
|
//记录ID删除商品与条码
|
|
|
$deleteCommodities[] = $del->commodity_id;
|
|
|
|
|
|
//有效条码合并
|
|
|
$barcodes = DB::select(DB::raw("select * from
|
|
|
- (select * from commodity_barcodes where commodity_id = ".$del->commodity_id.")a
|
|
|
+ (select * from commodity_barcodes where commodity_id = " . $del->commodity_id . ")a
|
|
|
where (select count(1) as num from commodity_barcodes b
|
|
|
- where commodity_id = ".$target->commodity_id." and b.code = a.code) = 0"));
|
|
|
- if (count($barcodes) > 0){
|
|
|
- foreach ($barcodes as $barcode){
|
|
|
- $createBarcodes[] = ['code'=>$barcode->code, 'commodity_id'=>$target->commodity_id];
|
|
|
+ where commodity_id = " . $target->commodity_id . " and b.code = a.code) = 0"));
|
|
|
+ if (count($barcodes) > 0) {
|
|
|
+ foreach ($barcodes as $barcode) {
|
|
|
+ $createBarcodes[] = ['code' => $barcode->code, 'commodity_id' => $target->commodity_id];
|
|
|
}
|
|
|
}
|
|
|
$updateCommodities[$del->commodity_id] = $target->commodity_id;
|
|
|
}
|
|
|
- if (count($updateCommodities) > 0){
|
|
|
- $targets=array_chunk($updateCommodities,1000);
|
|
|
- foreach($targets as $targetCommodities){
|
|
|
+ if (count($updateCommodities) > 0) {
|
|
|
+ $targets = array_chunk($updateCommodities, 1000);
|
|
|
+ foreach ($targets as $targetCommodities) {
|
|
|
app('inventoryAccountMissionService')->batchUpdateItself('commodity_id', $targetCommodities);//批量更新库存盘点任务
|
|
|
app('inventoryCompareService')->batchUpdateItself('commodity_id', $targetCommodities);//批量更新库存对比
|
|
|
app('inventoryDailyLogService')->batchUpdateItself('commodity_id', $targetCommodities);//批量更新库存每日记录
|
|
|
@@ -508,16 +526,16 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (count($createBarcodes) > 0)LogService::log(__METHOD__,"纠正商品-录入合并条码",json_encode(data_get($createBarcodes,'*.id'),JSON_UNESCAPED_UNICODE));
|
|
|
+ if (count($createBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-录入合并条码", json_encode(data_get($createBarcodes, '*.id'), JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
CommodityBarcode::query()->insert($createBarcodes);
|
|
|
- $logCommodityBarcodes = CommodityBarcode::query()->whereIn('commodity_id',$deleteCommodities)->get();
|
|
|
- if (count($logCommodityBarcodes) > 0)LogService::log(__METHOD__,"纠正商品-删除无用商品条码",json_encode(data_get($logCommodityBarcodes,'*.id'),JSON_UNESCAPED_UNICODE));
|
|
|
+ $logCommodityBarcodes = CommodityBarcode::query()->whereIn('commodity_id', $deleteCommodities)->get();
|
|
|
+ if (count($logCommodityBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-删除无用商品条码", json_encode(data_get($logCommodityBarcodes, '*.id'), JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
- CommodityBarcode::query()->whereIn('commodity_id',$deleteCommodities)->delete();
|
|
|
+ CommodityBarcode::query()->whereIn('commodity_id', $deleteCommodities)->delete();
|
|
|
|
|
|
// $logCommodities = Commodity::query()->whereIn('id',$deleteCommodities)->get();
|
|
|
- if (count($deleteCommodities) > 0)LogService::log(__METHOD__,"纠正商品-删除无用商品",json_encode($deleteCommodities,JSON_UNESCAPED_UNICODE));
|
|
|
+ if (count($deleteCommodities) > 0) LogService::log(__METHOD__, "纠正商品-删除无用商品", json_encode($deleteCommodities, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
Commodity::destroy($deleteCommodities);
|
|
|
}
|
|
|
@@ -562,7 +580,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
if ($socket < 0) {
|
|
|
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
echo "OK.\n";
|
|
|
}
|
|
|
|
|
|
@@ -570,15 +588,15 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$result = socket_connect($socket, $ip, $port);
|
|
|
if ($result < 0) {
|
|
|
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
echo "连接OK\n";
|
|
|
}
|
|
|
$b = microtime(true);
|
|
|
- echo "连接耗时:".($b-$a)."\n";
|
|
|
+ echo "连接耗时:" . ($b - $a) . "\n";
|
|
|
$content = Commodity::query()->limit(200)->get();
|
|
|
|
|
|
- $c= microtime(true);
|
|
|
- echo "查询数据耗时:".($c-$b)."\n";
|
|
|
+ $c = microtime(true);
|
|
|
+ echo "查询数据耗时:" . ($c - $b) . "\n";
|
|
|
$content->toArray();
|
|
|
/*$chunks=$content->chunk(100);
|
|
|
foreach ($chunks as $chunk){
|
|
|
@@ -586,11 +604,11 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
var_dump(mb_strlen($chunk->toJson()));
|
|
|
//socket_write($socket, $chunk->toJson(), mb_strlen($chunk->toJson()));
|
|
|
}*/
|
|
|
- $d= microtime(true);
|
|
|
- echo "发送数据耗时:".($d-$c)."\n";
|
|
|
+ $d = microtime(true);
|
|
|
+ echo "发送数据耗时:" . ($d - $c) . "\n";
|
|
|
socket_close($socket);
|
|
|
- $e= microtime(true);
|
|
|
- echo "共耗时:".($e-$a)."\n";
|
|
|
+ $e = microtime(true);
|
|
|
+ echo "共耗时:" . ($e - $a) . "\n";
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -601,68 +619,18 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
/** @var OrderService $orderService */
|
|
|
$orderService = app(OrderService::class);
|
|
|
$owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
|
|
|
- $startDate = \Illuminate\Support\Carbon::parse('2020-09-30 00:00:00')->toDateTimeString();
|
|
|
+ $startDate = \Illuminate\Support\Carbon::parse('2020-10-10 00:00:00')->toDateTimeString();
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
|
|
|
->where('addTime', '>=', $startDate)
|
|
|
->whereIn('customerID', data_get($owners, '*.code'))
|
|
|
->get();
|
|
|
- $orderService->createByWmsOrder($orderHeaders);
|
|
|
- $orderTrackingService->createByWmsOrderHeader($orderHeaders);
|
|
|
$orderService->updateByWmsOrders($orderHeaders);
|
|
|
$orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
|
|
|
}
|
|
|
|
|
|
- public function usage(){
|
|
|
- dd(Request::all());
|
|
|
- $users=User::query();
|
|
|
- }
|
|
|
-
|
|
|
- public function orderTrckingOwnerAll(){
|
|
|
- $owners = Owner::all();
|
|
|
- foreach ($owners as $owner) {
|
|
|
- $orderTrackingOwner = OrderTrackingOwner::query()->where('owner_id',$owner->id)->first();
|
|
|
- if($orderTrackingOwner == null){
|
|
|
- OrderTrackingOwner::query()->create(['owner_id'=>$owner->id,'status'=>'启用']);
|
|
|
- }else{
|
|
|
- if($orderTrackingOwner->status == '禁用'){
|
|
|
- $orderTrackingOwner->status = '启用';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function updateOrderTracking(){
|
|
|
- $orderTrackings = OrderTracking::query()->with('commodities.package.order')->get();
|
|
|
- foreach ($orderTrackings as $orderTracking) {
|
|
|
- $order = $orderTracking->commodities->package->order;
|
|
|
- $order_code = $order->client_code;
|
|
|
- $orderTracking->update(['order_client_code'=>$order_code]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function deleteWmsOrderIsCancel()
|
|
|
- {
|
|
|
- $startDate = \Illuminate\Support\Carbon::parse('2020-09-01 00:00:00')->toDateTimeString();
|
|
|
- $endDate = \Illuminate\Support\Carbon::parse('2020-10-13 00:00:00')->toDateTimeString();
|
|
|
- $owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails','oracleBASCode'])
|
|
|
- ->where('addTime','>=',$startDate)
|
|
|
- ->where('addTime','<=',$endDate)
|
|
|
- ->whereIn('customerID',data_get($owners,'*.code'))
|
|
|
- ->get();
|
|
|
- app(OrderTrackingService::class)->删除订单追踪_订单取消($orderHeaders);
|
|
|
- }
|
|
|
-
|
|
|
- public function deleteRedundantOrderTrackingAndOrderInfo()
|
|
|
+ public function usage()
|
|
|
{
|
|
|
- $startDate = \Illuminate\Support\Carbon::parse('2020-10-01 00:00:00')->toDateTimeString();
|
|
|
- $owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails','oracleBASCode'])
|
|
|
- ->where('addTime','>=',$startDate)
|
|
|
- ->whereIn('customerID',data_get($owners,'*.code'))
|
|
|
- ->get();
|
|
|
- app(OrderPackageService::class)->删除多余的订单包裹_根据WMS订单($orderHeaders);
|
|
|
+ dd(Request::all());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|