getCellAtIndex(0)?->getValue() ?? throw new ImportException('未填写身份证号码');//身份证号 $name = $row->getCellAtIndex(1)?->getValue() ?? throw new ImportException('未填写姓名');//姓名 $sex = $row->getCellAtIndex(2)?->getValue() ?? throw new ImportException('未填写性别');//性别 $birthDate = $row->getCellAtIndex(3)?->getValue() ?? throw new ImportException('未填写生日');//生日 $cardCity = $row->getCellAtIndex(4)?->getValue() ?? throw new ImportException('未填写地址省份');//省 $cardProvince = $row->getCellAtIndex(5)?->getValue() ?? throw new ImportException('未填写地址-市');//市 $cardArea = $row->getCellAtIndex(6)?->getValue() ?? throw new ImportException('未填写地址-区');//区 $cardAddress = $row->getCellAtIndex(7)?->getValue() ?? throw new ImportException('未填写详细地址');//详细地址 $agreementNo = $row->getCellAtIndex(8)?->getValue() ?? '';//协议号码 $nurseLvName = $row->getCellAtIndex(9)?->getValue() ?? throw new ImportException('未填写护理等级');//护理等级 $clientName = $row->getCellAtIndex(10)?->getValue() ?? throw new ImportException('未填写监护人姓名');//监护人姓名 $clientPhone = $row->getCellAtIndex(11)?->getValue() ?? throw new ImportException('未填写监护人手机号码');//监护人手机号 $clientCity = $row->getCellAtIndex(12)?->getValue() ?? throw new ImportException('未填写监护人地址省份'); $clientProvince = $row->getCellAtIndex(13)?->getValue() ?? throw new ImportException('未填写监护人地址-市');//市 $clientArea = $row->getCellAtIndex(14)?->getValue() ?? throw new ImportException('未填写监护人地址-区');//区 $clientAddress = $row->getCellAtIndex(15)?->getValue() ?? throw new ImportException('未填写监护人详细地址');//详细地址 if(ModelsOldmen::where('card_no', $cardNo)->exists()){//如果已存在,则为更新 $oldman = ModelsOldmen::where('card_no', $cardNo)->first(); $newLv = Keyword::where(['type_key'=>'nurse_lv', 'name'=>$nurseLvName])->value('value'); if($oldman->nurse_lv !== $newLv && $oldman->live_in > 0){ throw new ImportException('当前入住状态无法直接变更护理等级'); }K; }else{ $oldman = new ModelsOldmen(); $oldman->card_no = $cardNo; $oldman->nurse_lv = Keyword::where(['type_key'=>'nurse_lv', 'name'=>$nurseLvName])->value('value'); } $oldman->name = $name; $sexArr = [ '未知'=>0, '男'=>1, '女'=>2 ]; $oldman->sex = $sexArr[$sex]; $oldman->birthday = Carbon::parse($birthDate); $oldman->card_city_code = Zone::where(['name' => $cardArea, 'type'=>'area'])->value('code') ?? ''; $oldman->card_address = $cardAddress; $oldman->agreement_no = $agreementNo; $oldman->client_name = $clientName; $oldman->client_phone = $clientPhone; $oldman->client_city_code = Zone::where(['name' => $clientArea, 'type'=>'area'])->value('code') ?? ''; $oldman->client_address = $clientAddress; $oldman->save(); } }