12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Http\Logics\Admin;
- use App\Http\Models\LinkTask;
- use App\Http\Models\LinkTaskDetail;
- use App\Http\Models\LinkTaskUrl;
- use App\Http\Models\User;
- use \Illuminate\Database\Eloquent\Builder;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\DB;
- class ReportLogic
- {
- public function syncSummary($ym, $siteId, $validated)
- {
- $filter = ['ym' => $ym, 'project_id' => $siteId];
- $summaryRecords = DB::connection('rank')->table('report_summary')->where($filter)->get()->toArray();
- $summaryRecordsIdList = array_column($summaryRecords, 'id');
- $summaryIdList = array_column($validated['dataList'], 'summaryId');
-
- foreach ($summaryRecordsIdList as $item) {
- if (!in_array($item, $summaryIdList)) {
- DB::connection('rank')->table('report_summary')->delete($item);
- }
- };
- foreach ($validated['dataList'] as $item) {
- if (!in_array($item['summaryId'], $summaryRecordsIdList)) {
- DB::connection('rank')->table('report_summary')->insert([
- 'ym' => $ym,
- 'val1' => $item['val1'],
- 'val2' => $item['val2'],
- 'val3' => $item['val3'],
- 'project_id' => $siteId,
- 'create_time' => time()
- ]);
- } else {
- DB::connection('rank')->table('report_summary')->where(['id' => $item['summaryId']])->update([
- 'val1' => $item['val1'],
- 'val2' => $item['val2'],
- 'val3' => $item['val3'],
- ]);
- }
- }
- }
- public function syncFileExtend($ym, $siteId, $validated)
- {
- $selectItem=[
- 'manage'=>$validated['selectManageList']??[],
- 'customer'=>$validated['selectCustomerList']??[],
- ];
- DB::connection('rank')->table('report_extend')->updateOrInsert([
- 'ym' => $ym, 'project_id' => $siteId
- ], [
- 'remark' => $validated['remark'],
- 'file_list' => json_encode($validated['fileList']),
- 'create_time' => time(),
- 'select_item'=>json_encode($selectItem)
- ]);
- }
- }
|