|
|
@@ -130,34 +130,44 @@ class TestController extends Controller
|
|
|
|
|
|
public function test()
|
|
|
{
|
|
|
- ini_set('max_execution_time', 2500);
|
|
|
- $model = MaterialBoxModel::query()->create([
|
|
|
- "code" => "common"
|
|
|
- ]);
|
|
|
- $sql = <<<sql
|
|
|
- select * from INV_LOT_LOC_ID where traceid = '*' and locationid like 'IDE%'
|
|
|
-sql;
|
|
|
- foreach (DB::connection("oracle")->select(DB::raw($sql)) as $inv){
|
|
|
- $materialBox = MaterialBox::query()->firstOrCreate(["code"=>$inv->locationid],[
|
|
|
- "code" => $inv->locationid,
|
|
|
- "material_box_model_id"=>$model
|
|
|
- ]);
|
|
|
- $owner = Owner::query()->firstOrCreate([
|
|
|
- "code" => $inv->customerid
|
|
|
- ],[
|
|
|
- "code" => $inv->customerid,
|
|
|
- "name" => $inv->customerid,
|
|
|
- ]);
|
|
|
- $commodity = Commodity::query()->where("owner_id",$owner->id)->where("sku",$inv->sku)->first();
|
|
|
- if (!$commodity){
|
|
|
- dump($inv->customerid." | ".$inv->sku);
|
|
|
- continue;
|
|
|
+ ini_set('max_execution_time',9999);
|
|
|
+ $mapping = [
|
|
|
+ "43"=>[647],"40"=>[648,649,650],
|
|
|
+ "612"=>[651],"210"=>[652],"274" => [653],"314"=>[654],"327"=>[655],
|
|
|
+ "329"=>[656],"344"=>[657],"159"=>[646,658],"164"=>[660],
|
|
|
+ "206"=>[661,662],"205"=>[663,664,665],"272"=>[666,667],
|
|
|
+ "320"=>[668],"220"=>[669],"223"=>[670],"616"=>[671],"310"=>[672],
|
|
|
+ "348"=>[673],"538"=>[674,675],"311"=>[676],"16"=>[677],"133"=>[678,679],
|
|
|
+ "488"=>[688],"557"=>[689,690]
|
|
|
+
|
|
|
+ ];
|
|
|
+ foreach ($mapping as $key=>$arr){
|
|
|
+ $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$key]);
|
|
|
+ if (!$roles)continue;
|
|
|
+ foreach ($roles as $role){
|
|
|
+ foreach ($arr as $aId){
|
|
|
+ DB::insert(DB::raw("INSERT INTO authority_role(id_authority,id_role) values (?,?)"),[$aId,$role->id_role]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (Authority::query()->where("type","工作组")->get() as $authority){
|
|
|
+ $usId = $authority->relevance;
|
|
|
+ $auId = $authority->id;
|
|
|
+ $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
|
|
|
+ if (!$roles)continue;
|
|
|
+ foreach ($roles as $role){
|
|
|
+ DB::insert(DB::raw("INSERT INTO role_user_work_group(role_id,user_work_group_id) values (?,?)"),[$role->id_role,$usId]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $owners = Authority::query()->where("name","like","\_%")->get();
|
|
|
+ foreach ($owners as $owner){
|
|
|
+ $owId = ltrim($owner->name,"_");
|
|
|
+ $auId = $owner->id;
|
|
|
+ $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
|
|
|
+ if (!$roles)continue;
|
|
|
+ foreach ($roles as $role){
|
|
|
+ DB::insert(DB::raw("INSERT INTO owner_role(owner_id,role_id) values (?,?)"),[$owId,$role->id_role]);
|
|
|
}
|
|
|
- \App\Storage::query()->create([
|
|
|
- "material_box_id" => $materialBox->id,
|
|
|
- "commodity_id" => $commodity->id,
|
|
|
- "amount" => $inv->qty,
|
|
|
- ]);
|
|
|
}
|
|
|
}
|
|
|
public function orderCreateBill()
|