sandm преди 2 години
родител
ревизия
7d0959e1b1
променени са 3 файла, в които са добавени 162 реда и са изтрити 3 реда
  1. 26 3
      app/admin/api/DataApi.php
  2. 36 0
      app/admin/controller/TalentTypeChange.php
  3. 100 0
      app/job/Jjhc.php

+ 26 - 3
app/admin/api/DataApi.php

@@ -49,7 +49,7 @@ class DataApi{
         }
     }
 
-    public function InsuranceRecordSearch($card,$start,$end){
+    public function InsuranceRecordSearch(){
         $this->getGuid();
         $options = [
             'cache_wsdl'     => WSDL_CACHE_NONE,
@@ -66,6 +66,11 @@ class DataApi{
         ];
 
         $client = new \SoapClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl", $options);
+        return $client;
+    }
+
+    public function queryUnemploymentInsuranceByIdAndTime($card,$start,$end){
+        $client = $this->InsuranceRecordSearch();
         $param = [
             'guid' => $this->guid,
             'requestid' => 'null_00001',
@@ -77,10 +82,28 @@ class DataApi{
         $rst = $client->queryUnemploymentInsuranceByIdAndTime($param);
         $ret = json_decode($rst->return, true);
         if($ret['code'] == '01'){
-            dd($ret);
+            return $ret;
         }else{
-            $this->guid = '';
+            return false;
         }
+    }
 
+    public function queryOldAgeSecurityInsuranceByIdAndTime($card,$start,$end){
+        $client = $this->InsuranceRecordSearch();
+        $param = [
+            'guid' => $this->guid,
+            'requestid' => 'null_00001',
+            'id' => $card,
+            'startTime' => $start,
+            'endTime' => $end
+        ];
+
+        $rst = $client->queryOldAgeSecurityInsuranceByIdAndTime($param);
+        $ret = json_decode($rst->return, true);
+        if($ret['code'] == '01'){
+            return $ret;
+        }else{
+            return false;
+        }
     }
 }

+ 36 - 0
app/admin/controller/TalentTypeChange.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\admin\common\AdminController;
+
+class TalentTypeChange extends AdminController {
+
+    public function gotoIndex(){
+        $tpl = null;
+        $process = $this->request->param('process');
+        switch ($process) {
+            case -1:
+                $tpl = "talentTypeChange_before";
+                break;
+            case 1:
+                $tpl = "talentTypeChange_first";
+                break;
+            case 2:
+                $tpl = "talentTypeChange_dep";
+                break;
+            case 3:
+                $tpl = "talentTypeChange_third";
+                break;
+            case 4:
+                $tpl = "talentTypeChange_prepare";
+
+                break;
+            case 5:
+                $tpl = "talentTypeChange_library";
+                break;
+        }
+        dd($tpl);
+        return view($tpl);
+    }
+}

+ 100 - 0
app/job/Jjhc.php

@@ -0,0 +1,100 @@
+<?php
+namespace app\job;
+
+use app\common\api\BatchApi;
+use app\common\api\TalentLogApi;
+use app\common\model\TalentChecklog;
+use app\common\state\ProjectState;
+use think\queue\Job;
+use think\facade\Log;
+use think\facade\Db;
+use app\common\api\ChuanglanSmsApi;
+// 给类文件的命名空间起个别名
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+//Xlsx类  保存文件功能类
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+use app\admin\api\DataApi;
+
+class Jjhc {
+
+    public function fire(Job $job, $data) {
+        if ($this->deal($data)) {
+            Log::info(json_encode($data));
+            $job->delete();
+            return true;
+        }
+        Log::error(json_encode($data));
+        if ($job->attempts() >= 3) {
+            $job->delete();
+            return false;
+        }
+        $job->release(10); //10秒后重试
+    }
+
+    /**
+     * 处理业务逻辑
+     * @param type $data
+     * @return bool
+     */
+    public function deal($data): bool {
+        switch ($data['type']){
+            case '1':
+                $path = dirname(dirname(dirname(__FILE__)));
+                $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path . "/test.xlsx");
+                $sheet = $spreadsheet->getSheet(0);
+                $datas = $sheet->toArray();
+                $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
+                $dataapi = new DataApi();
+                for ($index = 0; $index <= count($datas); $index++) {
+                    echo "正在查询第" . ($index + 1) . "人({$datas[$index][3]})的失业险\r\n";
+                    $res = $dataapi->queryUnemploymentInsuranceByIdAndTime($datas[$index][3],'202201','202301');
+                    if($res){
+                        $i = 0;
+                        foreach ($res['data'] as $k => $v){
+                            if(strpos($v['AAB069'],"晋华") !== false || strpos($v['AAB069'],"渠梁") !== false){
+                                $i++;
+                            }
+                        }
+                        $res_str = "2022年共缴费{$i}个月";
+                        echo "第". ($index + 1) . "失业险整理完毕,姓名:{$datas[$index][1]},".$res_str."\r\n";
+                        $sheet->setCellValue('F' . ($index+1), $res_str);
+                    }
+                    sleep(5);
+                }
+                $writer->save($path . "/test.xlsx");
+                return false;
+                break;
+            case '2':
+
+                $path = dirname(dirname(dirname(__FILE__)));
+                $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path . "/test.xlsx");
+                $sheet = $spreadsheet->getSheet(0);
+                $datas = $sheet->toArray();
+                $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
+                $dataapi = new DataApi();
+                for ($index = 0; $index < count($datas); $index++) {
+                    echo "正在查询第" . ($index+1) . "人({$datas[$index][3]})的养老险\r\n";
+                    $res = $dataapi->queryOldAgeSecurityInsuranceByIdAndTime($datas[$index][3],'202201','202301');
+                    if($res){
+                        $i = 0;
+                        foreach ($res['data'] as $k => $v){
+                            if(strpos($v['AAB004'],"晋华") !== false || strpos($v['AAB004'],"渠梁") !== false){
+                                $i++;
+                            }
+                        }
+                        $res_str = "2022年共缴费{$i}个月";
+                        echo "第". ($index + 1) . "养老险整理完毕,姓名:{$datas[$index][1]},".$res_str."\r\n";
+                        $sheet->setCellValue('E' . ($index+1), $res_str);
+                    }
+                    sleep(2);
+                }
+                $writer->save($path . "/test.xlsx");
+                return false;
+                break;
+            default:
+                return false;
+
+        }
+    }
+
+}