Talent.php 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\common\api\EducationApi;
  4. use app\enterprise\common\EnterpriseController;
  5. use app\enterprise\api\TalentApi;
  6. use app\enterprise\model\Talent as TalentModel;
  7. use think\facade\Db;
  8. use think\facade\Log;
  9. use app\common\api\EnterpriseApi;
  10. use app\common\api\DictApi;
  11. use app\common\api\TalentLogApi;
  12. use app\common\api\TalentState;
  13. use think\exception\ValidateException;
  14. use app\enterprise\validate\TalentInfo;
  15. use app\common\state\ProjectState;
  16. use app\common\api\BatchApi;
  17. use app\common\state\CommonConst;
  18. use app\common\api\TalentConditionApi;
  19. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  20. /**
  21. * Description of Talent
  22. *
  23. * @author sgq
  24. */
  25. class Talent extends EnterpriseController {
  26. public function index() {
  27. $isMix = $this->request->param("isMix");
  28. $tpl = "";
  29. if ($isMix == 1) {
  30. $tpl = "newIndex";
  31. }
  32. switch ($this->user["type"]) {
  33. case CommonConst::ENTERPRISE_WJ:
  34. $tpl = "/talent/hospital/index";
  35. break;
  36. }
  37. return view($tpl, ['type' => $this->user["type"]]);
  38. }
  39. public function list() {
  40. $step = 2;
  41. $res = TalentApi::getList($this->request, $step);
  42. return json($res);
  43. }
  44. public function export() {
  45. $request = $this->request->param();
  46. $name = trim($request["name"]);
  47. $idCard = trim($request["card_number"]);
  48. $sex = trim($request["sex"]);
  49. $nation = trim($request["nation"]);
  50. $nationality = trim($request["nationality"]);
  51. $talentArrange = trim($request["talent_arrange"]);
  52. $checkState = trim($request["checkState"]);
  53. $type = $this->user["type"];
  54. $where = [];
  55. $where[] = ["delete", "=", 0];
  56. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  57. $where[] = ["checkState", "not in", [TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL, TalentState::BASE_VERIFY_FAIL]];
  58. switch ($checkState) {
  59. case -1:
  60. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
  61. break;
  62. case 1:
  63. $where[] = ["checkState", "in", [TalentState::SCND_SAVE, TalentState::FST_SAVE]];
  64. break;
  65. case 2:
  66. $where[] = ["checkState", "in", [TalentState::BASE_REJECT, TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  67. break;
  68. case 3:
  69. $where[] = ["checkState", "in", [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,
  70. TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];
  71. break;
  72. case 4:
  73. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  74. break;
  75. }
  76. if ($name) {
  77. $where[] = ["name", "like", "%" . $name . "%"];
  78. }
  79. if ($idCard) {
  80. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  81. }
  82. if ($sex) {
  83. $where[] = ["sex", "=", $sex];
  84. }
  85. if ($nation) {
  86. $where[] = ["nation", "=", $nation];
  87. }
  88. if ($nationality) {
  89. $where[] = ["nationality", "=", $nationality];
  90. }
  91. if ($talentArrange) {
  92. $where[] = ["talent_arrange", "=", $talentArrange];
  93. }
  94. $list = TalentModel::where($where)->order("createTime " . $order)->select()->toArray();
  95. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  96. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  97. $industries = DictApi::selectByParentCode("industry_field"); //产业
  98. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  99. $conditions = TalentConditionApi::getKvList([]);
  100. $rows = [];
  101. foreach ($list as $key => $item) {
  102. $last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["active", "=", 1]);
  103. $checkStateStr = "";
  104. if ($last_log["state"] != $item["checkState"]) {
  105. switch ($last_log["state"]) {
  106. case 4:
  107. $checkStateStr = "总院驳回";
  108. break;
  109. case 6:
  110. $checkStateStr = "基础信息复审驳回";
  111. break;
  112. case 11:
  113. $checkStateStr = "初审驳回";
  114. break;
  115. case 13:
  116. $checkStateStr = "部门驳回";
  117. break;
  118. case 15:
  119. $checkStateStr = "复审驳回";
  120. break;
  121. }
  122. } else {
  123. switch ($item["checkState"]) {
  124. case - 2:
  125. $checkStateStr = "初审失败";
  126. break;
  127. case - 1:
  128. $checkStateStr = "基础信息审核失败";
  129. break;
  130. case 7:
  131. $checkStateStr = "基础信息复审失败";
  132. break;
  133. case 1:
  134. $checkStateStr = "保存未提交";
  135. break;
  136. case 2:
  137. if ($last_log["state"] == 4) {
  138. $checkStateStr = "待审核(重新提交)";
  139. }
  140. $checkStateStr = "待审核";
  141. break;
  142. case 3:
  143. $checkStateStr = "待基础条件复审";
  144. break;
  145. case 5:
  146. $checkStateStr = "待详细填报";
  147. break;
  148. case 8:
  149. $checkStateStr = "保存未提交";
  150. break;
  151. case 9:
  152. if ($last_log["last_state"] == 11) {
  153. $checkStateStr = "待初审(重新提交)";
  154. }
  155. $checkStateStr = "待初审";
  156. break;
  157. case 10:
  158. if ($item["companyIds"]) {
  159. $checkStateStr = "待部门审核";
  160. } else {
  161. $checkStateStr = "待复审";
  162. }
  163. break;
  164. case 12:
  165. $checkStateStr = "待复审";
  166. break;
  167. case 14:
  168. $checkStateStr = "复审通过待核查征信";
  169. break;
  170. case 16:
  171. $checkStateStr = "复审失败";
  172. break;
  173. case 21:
  174. $checkStateStr = "征信通过";
  175. break;
  176. case 22:
  177. $checkStateStr = "征信不通过";
  178. break;
  179. case 23:
  180. $checkStateStr = "公示待审核";
  181. break;
  182. case 24:
  183. $checkStateStr = "待公布审核";
  184. break;
  185. case 25:
  186. $checkStateStr = "公示审核不通过";
  187. break;
  188. case 26:
  189. $checkStateStr = "公布通过";
  190. break;
  191. case 27:
  192. $checkStateStr = "公布不通过";
  193. break;
  194. case 28:
  195. $checkStateStr = "已发放人才码";
  196. break;
  197. }
  198. }
  199. $rows[] = [
  200. $item["apply_year"], $item["name"], isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "", $item["card_number"], $conditions[$item["talent_condition"]], $checkStateStr
  201. ];
  202. }
  203. $columns = ["申报年度", "姓名", "人才层次", "证件号码", "认定条件", "审核状态"];
  204. $filename = "申报人才基础信息导出";
  205. if ($rows) {
  206. export($columns, $rows, $filename);
  207. exit();
  208. }
  209. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  210. }
  211. public function zrIndex() {
  212. return view();
  213. }
  214. /**
  215. * 新人才申报企业端统一申报入口,混合基础信息及人才信息
  216. */
  217. public function apply(\think\Request $request) {
  218. $type = $this->user["type"];
  219. $tpl = "";
  220. switch ($type) {
  221. case CommonConst::ENTERPRISE_NORMAL:
  222. $tpl = "apply"; //晋江人才
  223. break;
  224. case CommonConst::ENTERPRISE_JC:
  225. $tpl = "ic_apply"; //集成电路
  226. break;
  227. case CommonConst::ENTERPRISE_WJ:
  228. $tpl = "/talent/hospital/apply"; //卫健医院
  229. break;
  230. case CommonConst::ENTERPRISE_GJ:
  231. $tpl = "/talent/school/apply"; //高教学校
  232. break;
  233. }
  234. $param = $request->param();
  235. $id = isset($param["id"]) ? $param["id"] : 0;
  236. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  237. if ($info["isImport"]) {
  238. //$tpl = "no_file_apply"; //晋江人才
  239. }
  240. $ep = EnterpriseApi::getOne($this->user["uid"]);
  241. if (!chkEnterpriseFull($ep))
  242. return;
  243. $tagList = DictApi::selectByParentCode('enterprise_tag');
  244. $streetList = DictApi::selectByParentCode('street');
  245. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  246. $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
  247. $ep->streetName = $streetList[$ep->street];
  248. $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
  249. if ($info) {
  250. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  251. }
  252. if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
  253. return $this->view($request);
  254. exit();
  255. }
  256. if ($request->isPost()) {
  257. $checkState = $info["checkState"] ?: 0;
  258. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE || $checkState == 0) {
  259. switch ($type) {
  260. case CommonConst::ENTERPRISE_NORMAL:
  261. $this->mixSave($info, $request, TalentState::SCND_SAVE);
  262. exit();
  263. break;
  264. case CommonConst::ENTERPRISE_JC:
  265. $this->icSave($info, $request, TalentState::SCND_SAVE);
  266. exit();
  267. break;
  268. case CommonConst::ENTERPRISE_WJ:
  269. if ($ep->isGeneral == 1 || ($ep->isGeneral == 2 && !\app\common\api\Nhc::hasGeneralHospital($ep->medicalCommunityId))) {
  270. $this->wjSave($info, $request, TalentState::SCND_SAVE);
  271. } else {
  272. $this->wjSave($info, $request, TalentState::FST_SAVE);
  273. }
  274. exit();
  275. break;
  276. case CommonConst::ENTERPRISE_GJ:
  277. $this->gjSave($info, $request, TalentState::SCND_SAVE);
  278. exit();
  279. break;
  280. }
  281. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  282. $res = ["msg" => "审核不通过,不能再保存"];
  283. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  284. exit;
  285. }
  286. $res = ["msg" => "已提交审核,请耐心等待"];
  287. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  288. exit;
  289. }
  290. $checkState = $info["checkState"] ?: 0;
  291. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $this->user["type"])["batch"];
  292. $info["enterprise"] = $ep;
  293. if ($type == CommonConst::ENTERPRISE_WJ) {
  294. $info["talent_type_list"] = DictApi::findChildDictByCode("wj_talent_type");
  295. } else {
  296. $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
  297. }
  298. if ($info["talent_condition"]) {
  299. $info["isSalary"] = TalentConditionApi::getOne($info["talent_condition"])["isSalary"] ?: 0;
  300. }
  301. $modify_fields = explode(",", $info["modify_fields"]);
  302. if ($info["talent_condition"] && $info["real_state"] == TalentState::FST_VERIFY_REJECT && in_array("talent_condition", $modify_fields)) {
  303. //高教或者以后有相同类型的附件分栏且带有认定附件,需要特殊加入认定附件进入
  304. $condition = TalentConditionApi::getOne($info["talent_condition"]);
  305. if ($condition && $condition["bindFileTypes"]) {
  306. $modify_files = array_filter(explode(",", $info["modify_files"]));
  307. $bindFileTypes = explode(",", $condition["bindFileTypes"]);
  308. $modify_files = array_merge($modify_files, $bindFileTypes);
  309. $info["modify_files"] = implode(",", $modify_files);
  310. }
  311. }
  312. return view($tpl, ["year" => $batch, "checkState" => $checkState, "row" => $info]);
  313. }
  314. /**
  315. * 旧第二步
  316. * @param \think\Request $request
  317. * @return type
  318. */
  319. public function second(\think\Request $request) {
  320. if ($this->user["type"] != 1)
  321. return "此入口仅供晋江市人才申报,晋江集成电路人才请使用新统一申报入口";
  322. $params = $request->param();
  323. $id = $params["id"];
  324. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  325. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  326. if ($request->isPost()) {
  327. if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
  328. $res = ["msg" => "没有对应的人才认定申报信息"];
  329. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  330. exit;
  331. }
  332. $checkState = $info["checkState"];
  333. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  334. $this->save($info, $request, TalentState::SCND_SAVE);
  335. exit();
  336. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  337. $res = ["msg" => "审核不通过,不能再保存"];
  338. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  339. exit;
  340. }
  341. $res = ["msg" => "已提交审核,请耐心等待"];
  342. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  343. exit;
  344. }
  345. $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
  346. $info["enterprise"] = $enterprise_info;
  347. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $enterprise_info["type"])["batch"];
  348. return view("second", ["year" => $batch, "row" => $info]);
  349. }
  350. public function view(\think\Request $request) {
  351. switch ($this->user["type"]) {
  352. case CommonConst::ENTERPRISE_NORMAL:
  353. $tpl = "view"; //晋江人才
  354. break;
  355. case CommonConst::ENTERPRISE_JC:
  356. $tpl = "ic_view"; //集成电路
  357. break;
  358. case CommonConst::ENTERPRISE_WJ:
  359. $tpl = "/talent/hospital/view"; //卫健医院
  360. break;
  361. case CommonConst::ENTERPRISE_GJ:
  362. $tpl = "/talent/school/view"; //高教学校
  363. break;
  364. }
  365. $id = $request->param("id");
  366. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  367. if ($info["isImport"]) {
  368. //$tpl = "no_file_view";
  369. }
  370. return view($tpl, ["row" => $info]);
  371. }
  372. /**
  373. * 提交表单(旧第二步)
  374. */
  375. public function submit() {
  376. $params = $this->request->param();
  377. $id = $params["id"];
  378. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  379. $res = ["msg" => "没有对应的人才认定申报信息"];
  380. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  381. exit;
  382. }
  383. if ($info) {
  384. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  385. }
  386. $checkState = $info["checkState"];
  387. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  388. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  389. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  390. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  391. $where = [];
  392. $where[] = ["rel", "=", "study_abroad"];
  393. $where[] = ["step", "=", 2];
  394. $where[] = ["project", "=", 1];
  395. $where[] = ["active", "=", 1];
  396. $where[] = ["delete", "=", 0];
  397. $where[] = ["type", "=", $this->user["type"]];
  398. $where[] = ["isConditionFile", "<>", 1];
  399. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  400. $abroad_file_ids = null;
  401. if ($abroad_files)
  402. $abroad_file_ids = array_column($abroad_files, "id");
  403. if ($params["study_abroad"] == 1) {
  404. $no_empty[] = "abroad_school";
  405. $no_empty[] = "abroad_major";
  406. }
  407. if (in_array($params["source"], [1, 3])) {
  408. $no_empty[] = "source_batch";
  409. $no_empty[] = "fujian_highcert_pubtime";
  410. $no_empty[] = "fujian_highcert_exptime";
  411. if ($params["source"] == 3) {
  412. $no_empty[] = "source_city";
  413. }
  414. }
  415. if (in_array($params["source"], [2, 4])) {
  416. $no_empty[] = "source_batch";
  417. $no_empty[] = "quanzhou_highcert_pubtime";
  418. $no_empty[] = "quanzhou_highcert_exptime";
  419. if ($params["source"] == 4) {
  420. $no_empty[] = "source_county";
  421. }
  422. }
  423. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  424. if ($condition_info["isSalary"] == 1) {
  425. $no_empty[] = "annual_salary";
  426. }
  427. $no_empty = array_filter($no_empty);
  428. $return = [];
  429. foreach ($no_empty as $key) {
  430. if (!$params[$key]) {
  431. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  432. }
  433. }
  434. if (count($return) > 0) {
  435. $res = ["msg" => implode("<br>", $return)];
  436. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  437. exit;
  438. }
  439. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5])) {
  440. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  441. $whr[] = ["must", "=", 1];
  442. }
  443. $where = [];
  444. $where[] = ["step", "=", 2];
  445. $where[] = ["project", "=", 1];
  446. $where[] = ["type", "=", $this->user["type"]];
  447. $where[] = ["must", "=", 1];
  448. $where[] = ["active", "=", 1];
  449. $where[] = ["delete", "=", 0];
  450. $where[] = ["isConditionFile", "<>", 1];
  451. if ($whr) {
  452. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  453. } else {
  454. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  455. }
  456. $ft_ids = array_column($filetypes, "id");
  457. if ($params["study_abroad"] == 1) {
  458. //选中留学,如果存在留学附件变成必传
  459. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  460. } else {
  461. //没选中,留学附件就算设成必传也不用验证
  462. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  463. }
  464. $whr = [];
  465. $whr[] = ["typeId", "in", $ft_ids];
  466. $whr[] = ["mainId", "=", $id];
  467. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  468. $upload_type_counts = count($distinct_filetypes);
  469. if ($upload_type_counts != count($ft_ids)) {
  470. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  471. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  472. exit;
  473. }
  474. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  475. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  476. $res = ["msg" => "审核不通过,不能再提交审核"];
  477. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  478. exit;
  479. }
  480. $res = ["msg" => "已提交审核,请耐心等待"];
  481. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  482. exit;
  483. }
  484. public function submitToCheck() {
  485. switch ($this->user["type"]) {
  486. case CommonConst::ENTERPRISE_NORMAL:
  487. return $this->submitToCheck_JJRC();
  488. case CommonConst::ENTERPRISE_JC:
  489. return $this->submitToCheck_IC();
  490. case CommonConst::ENTERPRISE_WJ:
  491. return $this->submitToCheck_WJ();
  492. case CommonConst::ENTERPRISE_GJ:
  493. return $this->submitToCheck_GJ();
  494. }
  495. }
  496. /**
  497. * 提交表单(新:混合基础信息人才申报信息)晋江人才
  498. */
  499. private function submitToCheck_JJRC() {
  500. $params = $this->request->param();
  501. $id = $params["id"];
  502. $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  503. if ($info) {
  504. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  505. }
  506. $checkState = $info["checkState"];
  507. if ($checkState == TalentState::SCND_SAVE || !$id) {
  508. $field_dict = \app\common\api\DictApi::getTalentFields(4, $info["isImport"]);
  509. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type", "experience", "education",
  510. "talent_arrange", "talent_condition", "identifyGetTime", "bank", "bank_number", "bank_branch_name",
  511. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"]; //"highest_degree", "graduate_school", "major",
  512. $where = [];
  513. $where[] = ["rel", "=", "study_abroad"];
  514. $where[] = ["project", "=", 1];
  515. $where[] = ["active", "=", 1];
  516. $where[] = ["delete", "=", 0];
  517. $where[] = ["type", "=", $this->user["type"]];
  518. $where[] = ["isConditionFile", "<>", 1];
  519. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  520. $abroad_file_ids = null;
  521. if ($abroad_files)
  522. $abroad_file_ids = array_column($abroad_files, "id");
  523. if (in_array($params["talent_type"], [1, 2])) {
  524. $no_empty[] = "tax_insurance_month";
  525. $no_empty[] = "labor_contract_rangetime";
  526. }
  527. if ($params["talent_type"] == 3) {
  528. $no_empty[] = "pre_import_type";
  529. }
  530. if ($params["study_abroad"] == 1) {
  531. $no_empty[] = "abroad_school";
  532. $no_empty[] = "abroad_major";
  533. }
  534. if (in_array($params["source"], [1, 3])) {
  535. //$no_empty[] = "source_batch";
  536. //$no_empty[] = "fujian_highcert_pubtime";
  537. //$no_empty[] = "fujian_highcert_exptime";
  538. if ($params["source"] == 3) {
  539. $no_empty[] = "source_city";
  540. }
  541. }
  542. if (in_array($params["source"], [2, 4])) {
  543. //$no_empty[] = "source_batch";
  544. //$no_empty[] = "quanzhou_highcert_pubtime";
  545. //$no_empty[] = "quanzhou_highcert_exptime";
  546. if ($params["source"] == 4) {
  547. $no_empty[] = "source_county";
  548. }
  549. }
  550. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  551. if ($condition_info["isSalary"] == 1) {
  552. $no_empty[] = "annual_salary";
  553. }
  554. $no_empty = array_filter($no_empty);
  555. $return = [];
  556. foreach ($no_empty as $key) {
  557. if (!$params[$key]) {
  558. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  559. }
  560. }
  561. if (count($return) > 0) {
  562. $res = ["msg" => implode("<br>", $return)];
  563. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  564. exit;
  565. }
  566. $isMatchZhiren = $info["isImport"] && $params["isMatchZhiren"] == 1 ? true : false;
  567. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5]) && !$isMatchZhiren) {
  568. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  569. $whr[] = ["must", "=", 1];
  570. }
  571. $where = [];
  572. $where[] = ["project", "=", 1];
  573. $where[] = ["type", "=", $this->user["type"]];
  574. $where[] = ["must", "=", 1];
  575. $where[] = ["active", "=", 1];
  576. $where[] = ["delete", "=", 0];
  577. $where[] = ["isConditionFile", "<>", 1];
  578. if ($whr) {
  579. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  580. } else {
  581. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  582. }
  583. $age = 0;
  584. if ($params["birthday"]) {
  585. $birthtime = strtotime($params["birthday"]);
  586. $currentYear = date("Y");
  587. $currentMonth = date("n");
  588. $birthdayYear = date("Y", $birthtime);
  589. $birthdayMonth = date("n", $birthtime);
  590. $age = ($currentYear * 12 + $currentMonth - $birthdayYear * 12 - $birthdayMonth) / 12;
  591. }
  592. $ft_ids = [];
  593. $deletes = [];
  594. foreach ($filetypes as $ft) {
  595. if ($ft["option"]) {
  596. if ($ft["rel"] == "birthday") {
  597. if ($age < $ft["option"]) {
  598. $deletes[] = $ft["id"];
  599. continue;
  600. }
  601. } else {
  602. $selectVal = $params[$ft["rel"]];
  603. $conditions = array_filter(explode(",", $ft["option"]));
  604. if (!in_array($selectVal, $conditions)) {
  605. $deletes[] = $ft["id"];
  606. continue;
  607. }
  608. }
  609. }
  610. $ft_ids[] = $ft["id"];
  611. }
  612. if ($params["study_abroad"] == 1) {
  613. //选中留学,如果存在留学附件变成必传
  614. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  615. } else {
  616. //没选中,留学附件就算设成必传也不用验证
  617. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  618. }
  619. $whr = [];
  620. if ($id) {
  621. $whr[] = ["mainId", "=", $id];
  622. } else {
  623. if ($params["uploadFiles"])
  624. $whr[] = ["id", "in", $params["uploadFiles"]];
  625. }
  626. $whr[] = ["typeId", "in", $ft_ids];
  627. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  628. $upload_type_counts = count($distinct_filetypes);
  629. if ($upload_type_counts != count($ft_ids)) {
  630. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  631. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  632. exit;
  633. }
  634. return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
  635. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  636. $res = ["msg" => "审核不通过,不能再提交审核"];
  637. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  638. exit;
  639. }
  640. $res = ["msg" => "已提交审核,请耐心等待"];
  641. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  642. exit;
  643. }
  644. /**
  645. * 提交表单(新:混合基础信息人才申报信息)晋江电路
  646. */
  647. private function submitToCheck_IC() {
  648. $params = $this->request->param();
  649. $id = $params["id"];
  650. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  651. return json(["msg" => "没有对应的人才认定申报信息"]);
  652. }
  653. if ($info) {
  654. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  655. }
  656. $checkState = $info["checkState"];
  657. if ($checkState == TalentState::SCND_SAVE) {
  658. $field_dict = \app\common\api\DictApi::getTalentFields_IC();
  659. $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
  660. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
  661. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
  662. "bank", "bank_branch_name", "bank_account", "experience", "education"];
  663. $no_empty = array_filter($no_empty);
  664. $return = [];
  665. foreach ($no_empty as $key) {
  666. if (!$info[$key]) {
  667. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  668. }
  669. }
  670. if (count($return) > 0) {
  671. return json(["msg" => implode("<br>", $return)]);
  672. }
  673. $where = [];
  674. $where[] = ["project", "=", 1];
  675. $where[] = ["type", "=", $this->user["type"]];
  676. $where[] = ["must", "=", 1];
  677. $where[] = ["active", "=", 1];
  678. $where[] = ["delete", "=", 0];
  679. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  680. $ft_ids = array_column($filetypes, "id");
  681. $whr = [];
  682. $whr[] = ["typeId", "in", $ft_ids];
  683. $whr[] = ["mainId", "=", $id];
  684. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  685. $upload_type_counts = count($distinct_filetypes);
  686. if ($upload_type_counts != count($ft_ids)) {
  687. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  688. }
  689. return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
  690. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  691. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  692. }
  693. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  694. }
  695. /**
  696. * 提交表单:卫健
  697. */
  698. private function submitToCheck_WJ() {
  699. $params = $this->request->param();
  700. $id = $params["id"];
  701. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  702. $res = ["msg" => "没有对应的人才认定申报信息"];
  703. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  704. exit;
  705. }
  706. if ($info) {
  707. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  708. }
  709. $checkState = $info["checkState"];
  710. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  711. $field_dict = \app\common\api\DictApi::getTalentFields_WJ();
  712. $no_empty = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  713. "highest_degree", "graduate_school", "major", "position", "cur_entry_time", "labor_contract_rangetime",
  714. "talent_arrange", "talent_condition",
  715. "bank", "bank_account", "bank_number", "bank_branch_name"];
  716. $no_empty = array_filter($no_empty);
  717. $return = [];
  718. foreach ($no_empty as $key) {
  719. if (!$params[$key]) {
  720. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  721. }
  722. }
  723. if (count($return) > 0) {
  724. $res = ["msg" => implode("<br>", $return)];
  725. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  726. exit;
  727. }
  728. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  729. if ($condition_info["bindFileTypes"]) {
  730. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  731. $whr[] = ["must", "=", 1];
  732. }
  733. $where = [];
  734. $where[] = ["project", "=", ProjectState::TALENT];
  735. $where[] = ["type", "=", $this->user["type"]];
  736. $where[] = ["must", "=", 1];
  737. $where[] = ["active", "=", 1];
  738. $where[] = ["delete", "=", 0];
  739. $where[] = ["isConditionFile", "<>", 1];
  740. if ($whr) {
  741. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  742. } else {
  743. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  744. }
  745. $ft_ids = array_column($filetypes, "id");
  746. $whr = [];
  747. $whr[] = ["typeId", "in", $ft_ids];
  748. $whr[] = ["mainId", "=", $id];
  749. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  750. $upload_type_counts = count($distinct_filetypes);
  751. if ($upload_type_counts != count($ft_ids)) {
  752. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  753. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  754. exit;
  755. }
  756. if ($checkState == TalentState::FST_SAVE) {
  757. $ep = EnterpriseApi::getOne($this->user["uid"]);
  758. if ($ep->isGeneral == 2 && !\app\common\api\Nhc::hasGeneralHospital($ep->medicalCommunityId)) {
  759. return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
  760. }
  761. return $this->wjSave($info, $this->request, TalentState::FST_SUBMIT);
  762. } else {
  763. return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
  764. }
  765. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  766. $res = ["msg" => "审核不通过,不能再提交审核", "code" => 500];
  767. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  768. exit;
  769. }
  770. $res = ["msg" => "已提交审核,请耐心等待", "code" => 500];
  771. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  772. exit;
  773. }
  774. /**
  775. * 提交表单:高教
  776. */
  777. private function submitToCheck_GJ() {
  778. $params = $this->request->param();
  779. $id = $params["id"];
  780. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  781. return json(["msg" => "没有对应的人才认定申报信息"]);
  782. }
  783. if ($info) {
  784. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  785. }
  786. $checkState = $info["checkState"];
  787. if ($checkState == TalentState::SCND_SAVE) {
  788. $field_dict = \app\common\api\DictApi::getTalentFields_GJ();
  789. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type",
  790. "position", "cur_entry_time", "labor_contract_rangetime", "highest_degree", "graduate_school", "major", "study_abroad", "phone",
  791. "talent_arrange", "talent_condition", "identifyGetTime",
  792. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  793. if ($info["study_abroad"] == 1) {
  794. $no_empty[] = "abroad_school";
  795. $no_empty[] = "abroad_major";
  796. }
  797. $no_empty = array_filter($no_empty);
  798. $return = [];
  799. foreach ($no_empty as $key) {
  800. if (!$info[$key]) {
  801. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  802. }
  803. }
  804. if (count($return) > 0) {
  805. return json(["msg" => implode("<br>", $return)]);
  806. }
  807. $condition_info = Db::table("new_talent_condition")->findOrEmpty($info["talent_condition"]);
  808. if ($condition_info["bindFileTypes"]) {
  809. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  810. $whr[] = ["must", "=", 1];
  811. }
  812. $where = [];
  813. $where[] = ["project", "=", ProjectState::TALENT];
  814. $where[] = ["type", "=", $this->user["type"]];
  815. $where[] = ["must", "=", 1];
  816. $where[] = ["active", "=", 1];
  817. $where[] = ["delete", "=", 0];
  818. $where[] = ["isConditionFile", "<>", 1];
  819. if ($whr) {
  820. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  821. } else {
  822. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  823. }
  824. $ft_ids = array_column($filetypes, "id");
  825. $whr = [];
  826. $whr[] = ["typeId", "in", $ft_ids];
  827. $whr[] = ["mainId", "=", $id];
  828. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  829. $upload_type_counts = count($distinct_filetypes);
  830. if ($upload_type_counts != count($ft_ids)) {
  831. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  832. }
  833. return $this->gjSave($info, $this->request, TalentState::SCND_SUBMIT);
  834. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  835. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  836. }
  837. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  838. }
  839. /**
  840. * 保存表单(旧第二步)
  841. * @param type $info talent_info
  842. * @param type $param request->param();
  843. */
  844. private function save($info, \think\Request $request, $checkState) {
  845. try {
  846. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  847. if ($batch["code"] != 200) {
  848. throw new ValidateException($batch["msg"]);
  849. }
  850. $param = $request->param();
  851. validate(TalentInfo::class)->check($param);
  852. $data["apply_year"] = $batch["batch"];
  853. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  854. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  855. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  856. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  857. foreach ($all_valid_keys as $key) {
  858. $data[$key] = trim($param[$key]);
  859. }
  860. if ($data["study_abroad"] == 1) {
  861. $data["abroad_school"] = $param["abroad_school"];
  862. $data["abroad_major"] = $param["abroad_major"];
  863. } else {
  864. $data["abroad_school"] = null;
  865. $data["abroad_major"] = null;
  866. }
  867. switch ($data["source"]) {
  868. case 1:
  869. $data["source_batch"] = $param["source_batch"];
  870. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  871. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  872. $data["source_city"] = null;
  873. break;
  874. case 2:
  875. $data["source_batch"] = $param["source_batch"];
  876. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  877. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  878. $data["source_county"] = null;
  879. break;
  880. case 3:
  881. $data["source_batch"] = $param["source_batch"];
  882. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  883. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  884. $data["source_city"] = $param["source_city"];
  885. break;
  886. case 4:
  887. $data["source_batch"] = $param["source_batch"];
  888. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  889. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  890. $data["source_county"] = $param["source_county"];
  891. break;
  892. }
  893. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  894. if ($condition_info["isSalary"] == 1) {
  895. $data["annual_salary"] = $param["annual_salary"];
  896. } else {
  897. $data["annual_salary"] = null;
  898. }
  899. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  900. //真实状态8是驳回,需要判断什么字段可以提交
  901. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  902. $tmp_data = $data;
  903. $data = [];
  904. foreach ($modify_fields as $field) {
  905. $data[$field] = $tmp_data[$field];
  906. }
  907. }
  908. $data["checkState"] = $checkState;
  909. $data["id"] = $info["id"];
  910. $success_msg = "提交成功";
  911. $error_msg = "提交失败";
  912. if ($checkState == TalentState::SCND_SAVE) {
  913. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  914. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  915. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  916. }
  917. TalentModel::update($data);
  918. } else if ($checkState == TalentState::SCND_SUBMIT) {
  919. $success_msg = "提交成功";
  920. $error_msg = "提交失败";
  921. $data["new_submit_time"] = date("Y-m-d H:i:s");
  922. TalentModel::update($data);
  923. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  924. } else {
  925. throw new ValidateException($error_msg);
  926. }
  927. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  928. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  929. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  930. exit();
  931. } catch (ValidateException $e) {
  932. $res = ["msg" => $e->getMessage()];
  933. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  934. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  935. exit();
  936. }
  937. }
  938. /**
  939. * 保存表单(新:混合基础信息人才申报信息)
  940. * @param type $info talent_info
  941. * @param type $param request->param();
  942. */
  943. private function mixSave($info, \think\Request $request, $checkState) {
  944. try {
  945. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  946. if ($batch["code"] != 200) {
  947. throw new ValidateException($batch["msg"]);
  948. }
  949. $param = $request->param();
  950. validate(TalentInfo::class)->check($param);
  951. $id = $param["id"];
  952. if ($id) {
  953. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  954. throw new ValidateException("没有对应的人才认定申报信息");
  955. }
  956. }
  957. $files = $param["uploadFiles"];
  958. $data["headimgurl"] = $info["headimgurl"];
  959. if ($request->file()) {
  960. $headimg = $request->file("photo");
  961. $upload = new \app\common\api\UploadApi();
  962. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  963. if ($result->code != 200) {
  964. throw new ValidateException($result->msg);
  965. }
  966. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  967. $width = imagesx($file);
  968. $height = imagesy($file);
  969. //免冠二寸照长宽413:579
  970. if ($width * 579 != $height * 413) {
  971. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  972. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  973. }
  974. if ($info && $info["headimgurl"]) {
  975. //如果新照片符合像素要求,则删除旧照片
  976. $old_head_url = "storage/" . $info["headimgurl"];
  977. //if (file_exists($old_head_url))
  978. //@unlink($old_head_url);
  979. }
  980. $data["headimgurl"] = $result->filepath;
  981. }
  982. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  983. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  984. $where = [];
  985. $where[] = ["project", "=", 1];
  986. $where[] = ["type", "=", $this->user["type"]];
  987. $where[] = ["must", "=", 1];
  988. $where[] = ["active", "=", 1];
  989. $where[] = ["delete", "=", 0];
  990. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  991. $age = 0;
  992. if ($param["birthday"]) {
  993. $birthday = $param["birthday"];
  994. $birthdayYear = substr($birthday, 0, 4);
  995. $currentYear = date("Y");
  996. $age = $currentYear - $birthdayYear;
  997. }
  998. $ft_ids = [];
  999. $deletes = [];
  1000. foreach ($filetypes as $ft) {
  1001. if ($ft["option"]) {
  1002. if ($ft["rel"] == "birthday") {
  1003. if ($age < $ft["option"]) {
  1004. $deletes[] = $ft["id"];
  1005. continue;
  1006. }
  1007. } else {
  1008. $selectVal = $param[$ft["rel"]];
  1009. $conditions = array_filter(explode(",", $ft["option"]));
  1010. if (!in_array($selectVal, $conditions)) {
  1011. $deletes[] = $ft["id"];
  1012. continue;
  1013. }
  1014. }
  1015. }
  1016. $ft_ids[] = $ft["id"];
  1017. }
  1018. $data["apply_year"] = $batch["batch"];
  1019. $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
  1020. $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
  1021. "import_way", "cur_entry_time", "position",
  1022. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  1023. "talent_arrange", "talent_condition", "identifyGetTime", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  1024. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  1025. foreach ($all_valid_keys as $key) {
  1026. $data[$key] = trim($param[$key]);
  1027. }
  1028. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  1029. if (in_array($data["talent_type"], [1, 2])) {
  1030. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  1031. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  1032. $data["salary_pay_way"] = $param["salary_pay_way"];
  1033. $data["salary_pay_month"] = $param["salary_pay_month"];
  1034. $data["fst_work_time"] = $param["fst_work_time"];
  1035. $data['pre_import_type'] = null;
  1036. if ($data["talent_type"] == 2) {
  1037. $data["return"] = $param["return"];
  1038. }
  1039. } else {
  1040. $data["tax_insurance_month"] = null;
  1041. $data["labor_contract_rangetime"] = null;
  1042. $data["salary_pay_way"] = null;
  1043. $data["salary_pay_month"] = null;
  1044. $data["fst_work_time"] = null;
  1045. $data['pre_import_type'] = $param["pre_import_type"];
  1046. }
  1047. if ($data["study_abroad"] == 1) {
  1048. $data["abroad_school"] = $param["abroad_school"];
  1049. $data["abroad_major"] = $param["abroad_major"];
  1050. } else {
  1051. $data["abroad_school"] = null;
  1052. $data["abroad_major"] = null;
  1053. }
  1054. switch ($data["source"]) {
  1055. case 1:
  1056. $data["source_batch"] = $param["source_batch"];
  1057. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  1058. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  1059. $data["source_city"] = null;
  1060. break;
  1061. case 2:
  1062. $data["source_batch"] = $param["source_batch"];
  1063. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  1064. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  1065. $data["source_county"] = null;
  1066. break;
  1067. case 3:
  1068. $data["source_batch"] = $param["source_batch"];
  1069. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  1070. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  1071. $data["source_city"] = $param["source_city"];
  1072. break;
  1073. case 4:
  1074. $data["source_batch"] = $param["source_batch"];
  1075. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  1076. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  1077. $data["source_county"] = $param["source_county"];
  1078. break;
  1079. }
  1080. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  1081. if ($condition_info["isSalary"] == 1) {
  1082. $data["annual_salary"] = $param["annual_salary"];
  1083. } else {
  1084. $data["annual_salary"] = null;
  1085. }
  1086. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1087. //真实状态11是驳回,需要判断什么字段可以提交
  1088. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1089. $tmp_data = $data;
  1090. $data = [];
  1091. foreach ($modify_fields as $field) {
  1092. $data[$field] = $tmp_data[$field];
  1093. }
  1094. }
  1095. $data["check_companys"] = $condition_info["companyIds"];
  1096. $data["checkState"] = $checkState;
  1097. $data["id"] = $id;
  1098. $success_msg = "提交成功";
  1099. $error_msg = "提交失败";
  1100. if ($checkState == TalentState::SCND_SAVE) {
  1101. $success_msg = "保存成功";
  1102. if ($data["id"]) {
  1103. //编辑
  1104. $data["updateTime"] = date("Y-m-d H:i:s");
  1105. TalentModel::update($data);
  1106. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1107. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1108. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1109. } else {
  1110. if (!$last_log["companyId"]) {
  1111. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1112. }
  1113. }
  1114. } else {
  1115. //新增
  1116. $data["enterprise_id"] = $this->user["uid"];
  1117. $data["type"] = $this->user["type"];
  1118. $data["createTime"] = date("Y-m-d H:i:s");
  1119. $id = TalentModel::insertGetId($data);
  1120. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1121. $whr = [];
  1122. $whr[] = ["fileId", "in", $files];
  1123. $upd_checklog["mainId"] = $id;
  1124. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1125. }
  1126. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1127. if (!$info["first_submit_time"]) {
  1128. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1129. } else {
  1130. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1131. }
  1132. if ($data["id"]) {
  1133. $data["updateTime"] = date("Y-m-d H:i:s");
  1134. TalentModel::update($data);
  1135. } else {
  1136. //新增
  1137. $data["enterprise_id"] = $this->user["uid"];
  1138. $data["type"] = $this->user["type"];
  1139. $data["createTime"] = date("Y-m-d H:i:s");
  1140. $id = TalentModel::insertGetId($data);
  1141. $whr = [];
  1142. $whr[] = ["fileId", "in", $files];
  1143. $upd_checklog["mainId"] = $id;
  1144. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1145. }
  1146. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  1147. } else {
  1148. throw new ValidateException($error_msg);
  1149. }
  1150. if ($id) {
  1151. if ($deletes) {
  1152. //删除多余的附件,一般是选择人才类型留下来的
  1153. $whr = [];
  1154. $whr[] = ["typeId", "in", $deletes];
  1155. $whr[] = ["id", "in", $files];
  1156. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  1157. $_logfileIds[] = [];
  1158. foreach ($_wait_del_files as $_del_file) {
  1159. $_logfileIds[] = $_del_file["id"];
  1160. //@unlink("storage/" . $_del_file["url"]);
  1161. }
  1162. Db::table("new_talent_file")->where($whr)->delete();
  1163. if ($_logfileIds) {
  1164. $whr = [];
  1165. $whr[] = ["fileId", "in", $_logfileIds];
  1166. $_upd_checklog["description"] = "删除附件";
  1167. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  1168. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  1169. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  1170. }
  1171. }
  1172. $whr = [];
  1173. $whr[] = ["id", "in", $files];
  1174. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  1175. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1176. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1177. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1178. exit();
  1179. } else {
  1180. throw new ValidateException($error_msg);
  1181. }
  1182. } catch (ValidateException $e) {
  1183. $res = ["msg" => $e->getMessage()];
  1184. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1185. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1186. exit();
  1187. } catch (\think\Exception $e) {
  1188. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1189. $logInfo = [
  1190. "enterprise_id" => $this->user["uid"],
  1191. "data" => $data,
  1192. "controller" => $this->request->controller(),
  1193. "action" => $this->request->action(),
  1194. "errCode" => $e->getCode(),
  1195. "errMsg" => $e->getMessage()
  1196. ];
  1197. Log::write($logInfo, "error");
  1198. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1199. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1200. exit();
  1201. }
  1202. }
  1203. private function icSave($info, \think\Request $request, $checkState) {
  1204. try {
  1205. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1206. if ($batch["code"] != 200) {
  1207. throw new ValidateException($batch["msg"]);
  1208. }
  1209. $param = $request->param();
  1210. validate(TalentInfo::class)->check($param);
  1211. $id = $param["id"];
  1212. if ($id) {
  1213. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1214. throw new ValidateException("没有对应的人才认定申报信息");
  1215. }
  1216. }
  1217. $files = $param["uploadFiles"];
  1218. $data["headimgurl"] = $info["headimgurl"];
  1219. if ($request->file()) {
  1220. $headimg = $request->file("photo");
  1221. $upload = new \app\common\api\UploadApi();
  1222. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1223. if ($result->code == 500) {
  1224. throw new ValidateException($result->msg);
  1225. }
  1226. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1227. $width = imagesx($file);
  1228. $height = imagesy($file);
  1229. //免冠二寸照长宽413:579
  1230. if ($width * 579 != $height * 413) {
  1231. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1232. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1233. }
  1234. if ($info && $info["headimgurl"]) {
  1235. //如果新照片符合像素要求,则删除旧照片
  1236. $old_head_url = "storage/" . $info["headimgurl"];
  1237. //if (file_exists($old_head_url))
  1238. //@unlink($old_head_url);
  1239. }
  1240. $data["headimgurl"] = $result->filepath;
  1241. }
  1242. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1243. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1244. $data["apply_year"] = $batch["batch"];
  1245. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  1246. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  1247. "position", "cur_entry_time", "labor_contract_rangetime",
  1248. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  1249. "bank", "bank_branch_name", "bank_account", "description"];
  1250. foreach ($all_valid_keys as $key) {
  1251. $value = trim($param[$key]);
  1252. if ($value) {
  1253. $data[$key] = $value;
  1254. }
  1255. }
  1256. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1257. //真实状态11是驳回,需要判断什么字段可以提交
  1258. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1259. $tmp_data = $data;
  1260. $data = [];
  1261. foreach ($modify_fields as $field) {
  1262. $data[$field] = $tmp_data[$field];
  1263. }
  1264. }
  1265. $success_msg = "提交成功";
  1266. $error_msg = "提交失败";
  1267. if ($checkState == TalentState::SCND_SAVE) {
  1268. $data["checkState"] = $checkState;
  1269. $data["id"] = $id;
  1270. $success_msg = "保存成功";
  1271. if ($data["id"]) {
  1272. //编辑
  1273. $data["updateTime"] = date("Y-m-d H:i:s");
  1274. TalentModel::update($data);
  1275. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1276. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1277. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1278. } else {
  1279. if (!$last_log["companyId"]) {
  1280. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1281. }
  1282. }
  1283. } else {
  1284. //新增
  1285. $data["enterprise_id"] = $this->user["uid"];
  1286. $data["type"] = $this->user["type"];
  1287. $data["createTime"] = date("Y-m-d H:i:s");
  1288. $id = TalentModel::insertGetId($data);
  1289. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1290. $whr = [];
  1291. $whr[] = ["fileId", "in", $files];
  1292. $upd_checklog["mainId"] = $id;
  1293. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1294. }
  1295. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1296. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1297. exit();
  1298. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1299. unset($data);
  1300. $data["checkState"] = $checkState;
  1301. $data["id"] = $id;
  1302. if (!$info["first_submit_time"]) {
  1303. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1304. } else {
  1305. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1306. }
  1307. $data["updateTime"] = date("Y-m-d H:i:s");
  1308. TalentModel::update($data);
  1309. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1310. return json(["msg" => $success_msg, "code" => 200]);
  1311. } else {
  1312. throw new ValidateException($error_msg);
  1313. }
  1314. } catch (ValidateException $e) {
  1315. if ($checkState == TalentState::SCND_SAVE) {
  1316. $res = ["msg" => $e->getMessage()];
  1317. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1318. exit();
  1319. } else {
  1320. return json(["msg" => $e->getMessage()]);
  1321. }
  1322. } catch (\think\Exception $e) {
  1323. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1324. $logInfo = [
  1325. "enterprise_id" => $this->user["uid"],
  1326. "data" => $data,
  1327. "controller" => $this->request->controller(),
  1328. "action" => $this->request->action(),
  1329. "errCode" => $e->getCode(),
  1330. "errMsg" => $e->getMessage()
  1331. ];
  1332. Log::write($logInfo, "error");
  1333. if ($checkState == TalentState::SCND_SAVE) {
  1334. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1335. exit();
  1336. } else {
  1337. return json($res);
  1338. }
  1339. }
  1340. }
  1341. /**
  1342. * 卫健保存
  1343. * @param type $info
  1344. * @param \think\Request $request
  1345. * @param type $checkState
  1346. * @return type
  1347. * @throws ValidateException
  1348. */
  1349. private function wjSave($info, \think\Request $request, $checkState) {
  1350. $callback = "infoCallback";
  1351. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT])) {
  1352. $callback = "submitCallback";
  1353. }
  1354. try {
  1355. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1356. if ($batch["code"] != 200) {
  1357. throw new ValidateException($batch["msg"]);
  1358. }
  1359. $param = $request->param();
  1360. validate(TalentInfo::class)->check($param);
  1361. $id = $param["id"];
  1362. if ($id) {
  1363. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1364. throw new ValidateException("没有对应的人才认定申报信息");
  1365. }
  1366. }
  1367. $files = $param["uploadFiles"];
  1368. $data["headimgurl"] = $info["headimgurl"];
  1369. if ($request->file()) {
  1370. $headimg = $request->file("photo");
  1371. $upload = new \app\common\api\UploadApi();
  1372. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1373. if ($result->code == 500) {
  1374. throw new ValidateException($result->msg);
  1375. }
  1376. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1377. $width = imagesx($file);
  1378. $height = imagesy($file);
  1379. //免冠二寸照长宽413:579
  1380. if ($width * 579 != $height * 413) {
  1381. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1382. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1383. }
  1384. if ($info && $info["headimgurl"]) {
  1385. //如果新照片符合像素要求,则删除旧照片
  1386. $old_head_url = "storage/" . $info["headimgurl"];
  1387. //if (file_exists($old_head_url))
  1388. //@unlink($old_head_url);
  1389. }
  1390. $data["headimgurl"] = $result->filepath;
  1391. }
  1392. if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
  1393. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1394. $data["apply_year"] = $batch["batch"];
  1395. $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  1396. "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
  1397. "position", "cur_entry_time", "labor_contract_rangetime", "title", "fst_city_work_time",
  1398. "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition",
  1399. "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1400. foreach ($all_valid_keys as $key) {
  1401. $value = trim($param[$key]);
  1402. if ($value) {
  1403. $data[$key] = $value;
  1404. }
  1405. }
  1406. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
  1407. //真实状态11是驳回,需要判断什么字段可以提交
  1408. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1409. $tmp_data = $data;
  1410. $data = [];
  1411. foreach ($modify_fields as $field) {
  1412. $data[$field] = $tmp_data[$field];
  1413. }
  1414. }
  1415. $data["checkState"] = $checkState;
  1416. $data["id"] = $id;
  1417. $success_msg = "提交成功";
  1418. $error_msg = "提交失败";
  1419. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1420. $success_msg = "保存成功";
  1421. if ($data["id"]) {
  1422. //编辑
  1423. $data["updateTime"] = date("Y-m-d H:i:s");
  1424. TalentModel::update($data);
  1425. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1426. if ($last_log["new_state"] != TalentState::SCND_SAVE && $last_log["new_state"] != TalentState::FST_SAVE) {
  1427. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1428. } else {
  1429. if (!$last_log["companyId"]) {
  1430. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1431. }
  1432. }
  1433. } else {
  1434. //新增
  1435. $data["enterprise_id"] = $this->user["uid"];
  1436. $data["type"] = $this->user["type"];
  1437. $data["createTime"] = date("Y-m-d H:i:s");
  1438. $id = TalentModel::insertGetId($data);
  1439. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1440. $whr = [];
  1441. $whr[] = ["fileId", "in", $files];
  1442. $upd_checklog["mainId"] = $id;
  1443. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1444. }
  1445. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1446. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1447. //exit();
  1448. } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
  1449. if (!$info["first_submit_time"]) {
  1450. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1451. } else {
  1452. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1453. }
  1454. $data["updateTime"] = date("Y-m-d H:i:s");
  1455. TalentModel::update($data);
  1456. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1457. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1458. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1459. //exit();
  1460. } else {
  1461. throw new ValidateException($error_msg);
  1462. }
  1463. if ($id) {
  1464. $whr = [];
  1465. $whr[] = ["id", "in", $files];
  1466. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  1467. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1468. //$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1469. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1470. exit();
  1471. } else {
  1472. throw new ValidateException($error_msg);
  1473. }
  1474. } catch (ValidateException $e) {
  1475. $res = ["msg" => $e->getMessage()];
  1476. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1477. exit();
  1478. } catch (\think\Exception $e) {
  1479. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1480. $logInfo = [
  1481. "enterprise_id" => $this->user["uid"],
  1482. "data" => $data,
  1483. "controller" => $this->request->controller(),
  1484. "action" => $this->request->action(),
  1485. "errCode" => $e->getCode(),
  1486. "errMsg" => $e->getMessage()
  1487. ];
  1488. Log::write($logInfo, "error");
  1489. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1490. exit();
  1491. }
  1492. }
  1493. private function gjSave($info, \think\Request $request, $checkState) {
  1494. try {
  1495. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1496. if ($batch["code"] != 200) {
  1497. throw new ValidateException($batch["msg"]);
  1498. }
  1499. $param = $request->param();
  1500. validate(TalentInfo::class)->check($param);
  1501. $id = $param["id"];
  1502. if ($id) {
  1503. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1504. throw new ValidateException("没有对应的人才认定申报信息");
  1505. }
  1506. }
  1507. $files = $param["uploadFiles"];
  1508. $data["headimgurl"] = $info["headimgurl"];
  1509. if ($request->file()) {
  1510. $headimg = $request->file("photo");
  1511. $upload = new \app\common\api\UploadApi();
  1512. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1513. if ($result->code == 500) {
  1514. throw new ValidateException($result->msg);
  1515. }
  1516. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1517. $width = imagesx($file);
  1518. $height = imagesy($file);
  1519. //免冠二寸照长宽413:579
  1520. if ($width * 579 != $height * 413) {
  1521. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1522. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1523. }
  1524. if ($info && $info["headimgurl"]) {
  1525. //如果新照片符合像素要求,则删除旧照片
  1526. $old_head_url = "storage/" . $info["headimgurl"];
  1527. //if (file_exists($old_head_url))
  1528. //@unlink($old_head_url);
  1529. }
  1530. $data["headimgurl"] = $result->filepath;
  1531. }
  1532. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1533. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1534. $data["apply_year"] = $batch["batch"];
  1535. $all_valid_keys = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type",
  1536. "position", "cur_entry_time", "labor_contract_rangetime",
  1537. "highest_degree", "graduate_school", "major", "study_abroad", "title", "pro_qua", "phone", "email",
  1538. "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition", "identifyGetTime",
  1539. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education", "parent_talent_level", "parent_talent_condition"];
  1540. foreach ($all_valid_keys as $key) {
  1541. $value = trim($param[$key]);
  1542. if ($value) {
  1543. $data[$key] = $value;
  1544. }
  1545. }
  1546. if ($data["study_abroad"] == 1) {
  1547. $data["abroad_school"] = $param["abroad_school"];
  1548. $data["abroad_major"] = $param["abroad_major"];
  1549. }
  1550. if ($data["study_abroad"] == 2) {
  1551. $data["abroad_school"] = null;
  1552. $data["abroad_major"] = null;
  1553. }
  1554. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1555. //真实状态11是驳回,需要判断什么字段可以提交
  1556. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1557. $tmp_data = $data;
  1558. $data = [];
  1559. foreach ($modify_fields as $field) {
  1560. $data[$field] = $tmp_data[$field];
  1561. }
  1562. }
  1563. $success_msg = "提交成功";
  1564. $error_msg = "提交失败";
  1565. if ($checkState == TalentState::SCND_SAVE) {
  1566. $data["checkState"] = $checkState;
  1567. $data["id"] = $id;
  1568. $success_msg = "保存成功";
  1569. if ($data["id"]) {
  1570. //编辑
  1571. $data["updateTime"] = date("Y-m-d H:i:s");
  1572. TalentModel::update($data);
  1573. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1574. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1575. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1576. } else {
  1577. if (!$last_log["companyId"]) {
  1578. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1579. }
  1580. }
  1581. } else {
  1582. //新增
  1583. $data["enterprise_id"] = $this->user["uid"];
  1584. $data["type"] = $this->user["type"];
  1585. $data["createTime"] = date("Y-m-d H:i:s");
  1586. $id = TalentModel::insertGetId($data);
  1587. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1588. $whr = [];
  1589. $whr[] = ["fileId", "in", $files];
  1590. $upd_checklog["mainId"] = $id;
  1591. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1592. }
  1593. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1594. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1595. exit();
  1596. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1597. unset($data);
  1598. $data["checkState"] = $checkState;
  1599. $data["id"] = $id;
  1600. if (!$info["first_submit_time"]) {
  1601. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1602. } else {
  1603. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1604. }
  1605. $data["updateTime"] = date("Y-m-d H:i:s");
  1606. TalentModel::update($data);
  1607. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1608. return json(["msg" => $success_msg, "code" => 200]);
  1609. } else {
  1610. throw new ValidateException($error_msg);
  1611. }
  1612. } catch (ValidateException $e) {
  1613. if ($checkState == TalentState::SCND_SAVE) {
  1614. $res = ["msg" => $e->getMessage()];
  1615. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1616. exit();
  1617. } else {
  1618. return json(["msg" => $e->getMessage()]);
  1619. }
  1620. } catch (\think\Exception $e) {
  1621. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1622. $logInfo = [
  1623. "enterprise_id" => $this->user["uid"],
  1624. "data" => $data,
  1625. "controller" => $this->request->controller(),
  1626. "action" => $this->request->action(),
  1627. "errCode" => $e->getCode(),
  1628. "errMsg" => $e->getMessage()
  1629. ];
  1630. Log::write($logInfo, "error");
  1631. if ($checkState == TalentState::SCND_SAVE) {
  1632. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1633. exit();
  1634. } else {
  1635. return json($res);
  1636. }
  1637. }
  1638. }
  1639. public function delete() {
  1640. $id = $this->request->param("talentInfoId");
  1641. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  1642. if (!$info) {
  1643. return json(["msg" => "操作失败"]);
  1644. }
  1645. $checkState = $info["checkState"];
  1646. if (in_array($checkState, [0, 1])) {
  1647. $log = TalentLogApi::getLastLog($id, 1);
  1648. if ($log["state"] > 1) {
  1649. //有提交审核记录
  1650. return json(["msg" => "该申报已提交审核,无法删除"]);
  1651. }
  1652. }
  1653. $data["id"] = $id;
  1654. $data["updateTime"] = date("Y-m-d H:i:s");
  1655. $data["delete"] = 1;
  1656. TalentModel::update($data);
  1657. return json(["msg" => "删除成功"]);
  1658. }
  1659. public function detail() {
  1660. $id = $this->request->param("id");
  1661. $info = $this->getInfoById($id);
  1662. return json($info);
  1663. }
  1664. public function getInfoById($id) {
  1665. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1666. if ($info["enterprise_id"] != $this->user["uid"]) {
  1667. return [];
  1668. }
  1669. return $info;
  1670. }
  1671. public function findTalentInfoInLibrary() {
  1672. $where = [];
  1673. $sList = [];
  1674. $type = $this->request->param('type');
  1675. if ($type == ProjectState::QUIT) {
  1676. $_where = [];
  1677. $_where[] = ["checkState", "not in", [3]];
  1678. $_where[] = ["delete", "<>", 1];
  1679. $idCards = Db::table("un_talent_quit")->where($_where)->column("idCard");
  1680. $sList = array_merge($sList, (array) $idCards);
  1681. $where[] = ["active", "=", 1];
  1682. }
  1683. if ($type == ProjectState::BANKCHANGE) {
  1684. $_where = [];
  1685. $_where[] = ["checkState", "not in", [3]];
  1686. $_where[] = ["delete", "<>", 1];
  1687. $idCards = Db::table("un_talent_bank_change")->where($_where)->column("idCard");
  1688. $sList = array_merge($sList, (array) $idCards);
  1689. }
  1690. if ($type == ProjectState::LEVELCHANGE) {
  1691. $_where = [];
  1692. $_where[] = ["checkState", "not in", [35, -1]];
  1693. $_where[] = ["isPublic", "<", 5];
  1694. $_where[] = ["delete", "<>", 1];
  1695. $_where[] = ["createTime", ">=", "2022-10-01 00:00:00"];
  1696. $idCards = Db::table("un_talent_type_change")->where($_where)->column("idCard");
  1697. $sList = array_merge($sList, (array) $idCards);
  1698. }
  1699. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1700. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1701. $where[] = ["isEffect", "<>", 4];
  1702. if ($sList) {
  1703. $where[] = ["card_number", "not in", $sList];
  1704. }
  1705. $result = TalentModel::where($where)->field("id,name,talent_arrange,card_number")->select()->toArray();
  1706. $list = [];
  1707. foreach ($result as $res) {
  1708. $_cardNumber = $res["card_number"];
  1709. if (!$list[$_cardNumber]) {
  1710. $list[$_cardNumber] = $res;
  1711. } else {
  1712. if ($res["talent_arrange"] < $list[$_cardNumber]["talent_arrange"]) {
  1713. $list[$_cardNumber] = $res;
  1714. }
  1715. }
  1716. }
  1717. sort($list);
  1718. return json($list);
  1719. }
  1720. public function findTalentInfoByChangeId() {
  1721. $where = [];
  1722. $id = $this->request->param('id');
  1723. $type = $this->request->param('type');
  1724. if ($type == ProjectState::QUIT) {
  1725. $info = Db::table("un_talent_quit")->where("id", $id)->find();
  1726. }
  1727. if ($type == ProjectState::LEVELCHANGE) {
  1728. $info = Db::table("un_talent_type_change")->where("id", $id)->find();
  1729. }
  1730. if ($type == ProjectState::BANKCHANGE) {
  1731. $info = Db::table("un_talent_bank_change")->where("id", $id)->find();
  1732. }
  1733. if (strlen($info["talentId"]) == 19) {
  1734. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1735. $where[] = ["card_number", "=", $info["idCard"]];
  1736. $where[] = ["delete", "=", 0];
  1737. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1738. } else {
  1739. $where[] = ["id", "=", $info["talentId"]];
  1740. }
  1741. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1742. return json($result);
  1743. }
  1744. public function getTalentBasicById() {
  1745. $id = $this->request["id"];
  1746. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  1747. /* if(FengStringUtil.isNotEmpAndNull(year)){
  1748. StringBuilder sb = new StringBuilder();
  1749. List<TalentAllowancecontractDetail> contractDetailList = new ArrayList<>(); //保存上一年度的工作单位
  1750. TalentAllowanceInfo info = new TalentAllowanceInfo();
  1751. info.setType(ti.getType());
  1752. info.setYear(year);
  1753. info.setFirstInJJTime(ti.getFirstInJJTime());
  1754. ApiTalentAllowanceController.getConcatList(ti,info,year,sb,contractDetailList);
  1755. int active = AllowanceSelectUtil.validMyqy(contractDetailList,ti,info);
  1756. ti.setActive(active);
  1757. } */
  1758. return $ti;
  1759. }
  1760. /**
  1761. *
  1762. */
  1763. public function getTalentInfoFromOldLibrary() {
  1764. $responseObj = new \stdClass();
  1765. $responseObj->code = 500;
  1766. $ep = EnterpriseApi::getOne($this->user["uid"]);
  1767. $pIdCard = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1768. $eIdCard = $ep->idCard;
  1769. $where = [];
  1770. $where[] = ["e.idCard", "=", $eIdCard];
  1771. $where[] = ["ti.idCard", "=", $pIdCard];
  1772. $old = Db::table("un_talent_info")->alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterpriseId")->field("ti.*")->where($where)->order("ti.createTime desc")->find();
  1773. if ($old) {
  1774. $responseObj->code = 200;
  1775. $responseObj->info = $old;
  1776. return $responseObj;
  1777. }
  1778. return $responseObj;
  1779. }
  1780. public function findTalentByEnterpriseInLibrary() {
  1781. $year = $this->request["year"];
  1782. $type = $this->request["type"];
  1783. $res = [];
  1784. $idCards = null;
  1785. $year = substr($year, 0, 4);
  1786. //根据申报年度查询当前企业已申报的人才
  1787. if ($type == 1) { //津补贴
  1788. $where = [];
  1789. $where[] = ["year", "like", $year . "%"];
  1790. $where[] = ["delete", "=", 0];
  1791. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  1792. $talentAllowances = \app\common\model\TalentAllowance::where($where)->select()->toArray();
  1793. $idCards = array_unique(array_column($talentAllowances, "idCard"));
  1794. } else if ($type == 2) { //购房补贴
  1795. $where = [];
  1796. $where[] = ["year", "like", $year . "%"];
  1797. $where[] = ["delete", "=", 0];
  1798. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  1799. $housePurchases = \app\common\model\HousePurchase::where($where)->select()->toArray();
  1800. $idCards = array_unique(array_column($housePurchases, "idCard"));
  1801. }
  1802. $whr = [];
  1803. $whr[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
  1804. $whr[] = ["ti.enterprise_id", "=", $this->user["uid"]];
  1805. $whr[] = ["e.type", "=", $this->user["type"]];
  1806. $whr[] = ["ti.card_number", "not in", $idCards];
  1807. $twiceIdentifyPersons = \app\common\api\VerifyApi::getTwiceIdentifyPersons();
  1808. if ($twiceIdentifyPersons) {
  1809. $_whr = $whr;
  1810. $whr[] = ["card_number", "not in", $twiceIdentifyPersons];
  1811. $_whr[] = ["card_number", "in", $twiceIdentifyPersons];
  1812. $tmpList = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.*,e.`type` as eType")->order("identifyMonth desc")->where($_whr)->select()->toArray();
  1813. $twiceIdentifyPersonList = [];
  1814. $otherTypeChangeList = [];
  1815. foreach ($tmpList as $person) {
  1816. if (!$twiceIdentifyPersonList[$person["card_number"]]) {
  1817. $twiceIdentifyPersonList[$person["card_number"]] = $person;
  1818. } else {
  1819. if ($person["talent_arrange"] < $twiceIdentifyPersonList[$person["card_number"]]["talent_arrange"]) {
  1820. $otherTypeChangeList[$person["card_number"]][] = ["oldIdentifyMonth" => $twiceIdentifyPersonList[$person["card_number"]]["identifyMonth"], "oldIdentifyGetTime" => $twiceIdentifyPersonList[$person["card_number"]]["identifyGetTime"]];
  1821. $twiceIdentifyPersonList[$person["card_number"]] = $person;
  1822. } else {
  1823. $otherTypeChangeList[$person["card_number"]][] = ["oldIdentifyMonth" => $person["identifyMonth"], "oldIdentifyGetTime" => $person["identifyGetTime"]];
  1824. }
  1825. }
  1826. }
  1827. sort($twiceIdentifyPersonList);
  1828. }
  1829. $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.*,e.`type` as eType")->order("identifyMonth desc")->where($whr)->select()->toArray();
  1830. if ($twiceIdentifyPersonList) {
  1831. $list = array_merge((array) $list, $twiceIdentifyPersonList);
  1832. $list = bubbleSort($list, "identifyMonth", "desc");
  1833. }
  1834. $specialPersonsBy2024 = \app\common\api\VerifyApi::getSpecialPersonsBy2024();
  1835. foreach ($list as $info) {
  1836. $info["enterpriseName"] = $this->user["name"];
  1837. $identifyTime = $info["identifyMonth"];
  1838. if ($info["eType"] == CommonConst::ENTERPRISE_JC) {
  1839. $identifyTime = $info["identifyGetTime"] ?: $info["identifyMonth"];
  1840. }
  1841. if (strtotime($year . "-12-31") >= strtotime($identifyTime) || in_array($info['card_number'],$specialPersonsBy2024)) {
  1842. $res[] = $info;
  1843. } else {
  1844. $whereTypeChange = [];
  1845. $whereTypeChange[] = ["talentId", "=", $info["id"]];
  1846. $whereTypeChange[] = ["checkState", "=", \app\common\state\MainState::PASS];
  1847. $whereTypeChange[] = ["isPublic", "=", 6];
  1848. $whereTypeChange[] = ["createTime", ">=", "2022-10-01 00:00:00"];
  1849. $typeChanges = \app\enterprise\model\TalentTypeChange::where($whereTypeChange)->select()->toArray();
  1850. if ($otherTypeChangeList[$info["card_number"]]) {
  1851. $typeChanges = array_merge($otherTypeChangeList[$info["card_number"]], (array) $typeChanges);
  1852. }
  1853. foreach ($typeChanges as $typeChange) {
  1854. $oldIdentifyTime = $typeChange["oldIdentifyMonth"];
  1855. if ($typeChange["type"] == CommonConst::ENTERPRISE_JC) {
  1856. $oldIdentifyTime = $typeChange["oldIdentifyGetTime"] ?: $typeChange["oldIdentifyMonth"];
  1857. }
  1858. if (strtotime($year . "-12-31") >= strtotime($oldIdentifyTime)) {
  1859. $res[] = $info;
  1860. break;
  1861. }
  1862. }
  1863. }
  1864. }
  1865. return $res;
  1866. }
  1867. /**
  1868. * 审核列表页
  1869. */
  1870. public function examineCenter() {
  1871. $tpl = "";
  1872. switch ($this->user["type"]) {
  1873. case CommonConst::ENTERPRISE_WJ:
  1874. $tpl = "/talent/hospital/examine_center"; //卫健医院
  1875. break;
  1876. }
  1877. return view($tpl);
  1878. }
  1879. /**
  1880. * 审核列表页
  1881. */
  1882. public function examineList() {
  1883. $res = TalentApi::getHospitalExamineList($this->request);
  1884. return json($res);
  1885. }
  1886. public function examinePage() {
  1887. $id = $this->request->param("id");
  1888. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1889. return view("/talent/hospital/view", ["row" => $info]);
  1890. }
  1891. /**
  1892. * 医院人才申报审核保存
  1893. * @return type
  1894. */
  1895. public function check() {
  1896. $request = $this->request;
  1897. $params = $request->param();
  1898. $check = $params["checkState"];
  1899. $check_msg = trim($params["checkMsg"]);
  1900. $files = $params["files"];
  1901. $fields = $params["fields"];
  1902. $id = $params["id"];
  1903. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1904. if (!$talent_info) {
  1905. return json(["msg" => "数据错误"]);
  1906. }
  1907. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1908. $checkState = $talent_info["checkState"];
  1909. if ($this->user["isGeneral"] != 1) {
  1910. return json(["msg" => "非总院账号,无法审核"]);
  1911. }
  1912. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1913. return json(["msg" => "不能审核其它非本医共体医院"]);
  1914. }
  1915. if (!$check) {
  1916. return json(["msg" => "请选择审核状态"]);
  1917. }
  1918. if (!$check_msg) {
  1919. return json(["msg" => "请填写审核说明"]);
  1920. }
  1921. if ($checkState == TalentState::FST_SUBMIT) {
  1922. if ($params["checkState"] == 3) {
  1923. //审核成功
  1924. $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
  1925. } else {
  1926. //审核驳回并记录需要修改的字段和上传文件
  1927. $checkState = TalentState::FST_SAVE; //退回材料编辑状态
  1928. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  1929. }
  1930. $log = TalentLogApi::getLastLog($id, 1);
  1931. if (!$log && !$talent_info["oldId"])
  1932. return json(["msg" => "日志数据异常,保存失败"]);
  1933. if ($log["active"] === 0) {
  1934. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1935. } else {
  1936. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1937. }
  1938. $data["id"] = $talent_info["id"];
  1939. $data["modify_files"] = $params["files"];
  1940. $data["modify_fields"] = $params["fields"];
  1941. TalentModel::update($data);
  1942. return json(["code" => 200, "msg" => "保存成功"]);
  1943. } else {
  1944. return json(["msg" => "不在审核范围内,保存失败"]);
  1945. }
  1946. }
  1947. /**
  1948. * 医院人才申报审核
  1949. * @return type
  1950. */
  1951. public function submitCheck() {
  1952. $id = $this->request->param("id");
  1953. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1954. if (!$talent_info) {
  1955. return json(["msg" => "数据错误"]);
  1956. }
  1957. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1958. $checkState = $talent_info["checkState"];
  1959. if ($this->user["isGeneral"] != 1) {
  1960. return json(["msg" => "非总院账号,无法审核"]);
  1961. }
  1962. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1963. return json(["msg" => "不能审核其它非本医共体医院"]);
  1964. }
  1965. if ($checkState == TalentState::FST_SUBMIT) {
  1966. $nowProcess = 1;
  1967. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1968. if (!$log || $log["active"] == 1)
  1969. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1970. if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
  1971. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1972. }
  1973. $data["id"] = $talent_info["id"];
  1974. $data["checkState"] = $log["new_state"];
  1975. TalentModel::update($data);
  1976. TalentLogApi::setActive($log["id"], 1);
  1977. if ($log["state"] == TalentState::BASE_REJECT) {
  1978. $this->sendMsg($enterprise["id"], $log["description"]);
  1979. }
  1980. return json(["code" => 200, "msg" => "审核成功"]);
  1981. } else {
  1982. return json(["msg" => "不在审核范围内,审核失败"]);
  1983. }
  1984. }
  1985. public function findFieldsAndFiles() {
  1986. $id = $this->request["id"];
  1987. $talentInfo = TalentApi::getOne($id);
  1988. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1989. $responseObj = new \stdClass();
  1990. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  1991. $fields = DictApi::getTalentFields_WJ();
  1992. $field_tmp = [];
  1993. if ($fields) {
  1994. foreach ($fields as $key => $field) {
  1995. $field_tmp[] = ["key" => $key, "value" => $field];
  1996. }
  1997. }
  1998. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  1999. $where = [];
  2000. $whr = [];
  2001. $where[] = ["project", "=", 1];
  2002. $where[] = ["active", "=", 1];
  2003. $where[] = ["type", "=", CommonConst::ENTERPRISE_WJ];
  2004. $where[] = ["isConditionFile", "<>", 1];
  2005. $where[] = ["delete", "=", 0];
  2006. if ($condition && $condition["bindFileTypes"]) {
  2007. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2008. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2009. } else {
  2010. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2011. }
  2012. $responseObj->code = 200;
  2013. $responseObj->id = $id;
  2014. $responseObj->fileList = $files;
  2015. $responseObj->fieldList = $field_tmp;
  2016. $responseObj->select = [
  2017. "files" => array_filter(explode(",", $talentInfo["modify_files"])),
  2018. "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
  2019. ];
  2020. } else {
  2021. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2022. }
  2023. return json($responseObj);
  2024. }
  2025. /**
  2026. * 初审-修改驳回字段
  2027. * @auth {{/talentInfo/updateFieldsAndFiles}}
  2028. */
  2029. public function updateFieldsAndFiles() {
  2030. $id = $this->request["id"];
  2031. $fields = array_filter(explode(",", $this->request["fields"]));
  2032. $files = array_filter(explode(",", $this->request["files"]));
  2033. $talentInfo = TalentApi::getOne($id);
  2034. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  2035. $responseObj = new \stdClass();
  2036. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  2037. if (!$fields && !$files) {
  2038. $responseObj->msg = "请选择可修改的字段或附件!";
  2039. return json($responseObj);
  2040. }
  2041. try {
  2042. $data["id"] = $id;
  2043. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  2044. $data["modify_files"] = $files ? implode(",", $files) : null;
  2045. TalentModel::update($data);
  2046. $responseObj->code = 200;
  2047. $responseObj->msg = "驳回字段修改成功";
  2048. return json($responseObj);
  2049. } catch (\think\db\exception\DbException $e) {
  2050. $responseObj->msg = $e->getMessage();
  2051. return json($responseObj);
  2052. }
  2053. } else {
  2054. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2055. return json($responseObj);
  2056. }
  2057. }
  2058. private function sendMsg($enterprise_id, $description = "") {
  2059. $ep = EnterpriseApi::getOne($enterprise_id);
  2060. if ($ep->agentPhone) {
  2061. $smsapi = new \app\common\api\ChuanglanSmsApi();
  2062. $result = $smsapi->sendSMS($phone, $template);
  2063. $result = json_decode($result, true);
  2064. $id = getStringId();
  2065. $record_data = [
  2066. 'id' => $id,
  2067. 'userId' => $ep->id,
  2068. 'bizId' => $result["msgId"],
  2069. 'type' => 2,
  2070. 'smsType' => 2,
  2071. 'name' => $ep->name,
  2072. 'phone' => $ep->agentPhone,
  2073. 'params' => "总院审核",
  2074. 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
  2075. 'state' => $result['code'] == 0 ? 2 : 3,
  2076. 'sendingDate' => date("Y-m-d H:i:s", time()),
  2077. 'createTime' => date("Y-m-d H:i:s", time()),
  2078. 'msg' => $result['errorMsg']
  2079. ];
  2080. \app\admin\model\MessageRecord::create($record_data);
  2081. }
  2082. }
  2083. public function validateIsCheck() {
  2084. $params = $this->request->param();
  2085. $id = $params["id"];
  2086. $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
  2087. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  2088. if ($talent_info) {
  2089. $checkState = $talent_info["checkState"];
  2090. if ($this->user["isGeneral"] != 1) {
  2091. return json(["msg" => "非总院账号,无法审核"]);
  2092. }
  2093. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  2094. return json(["msg" => "不能审核其它非本医共体医院"]);
  2095. }
  2096. if ($checkState != TalentState::FST_SUBMIT) {
  2097. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  2098. }
  2099. $fields = DictApi::getTalentFields_WJ();
  2100. $field_tmp = [];
  2101. if ($fields) {
  2102. foreach ($fields as $key => $field) {
  2103. $field_tmp[] = ["key" => $key, "value" => $field];
  2104. }
  2105. }
  2106. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  2107. $where = [];
  2108. $whr = [];
  2109. $where[] = ["project", "=", 1];
  2110. $where[] = ["active", "=", 1];
  2111. $where[] = ["type", "=", $enterprise["type"]];
  2112. $where[] = ["isConditionFile", "<>", 1];
  2113. $where[] = ["delete", "=", 0];
  2114. if ($condition && $condition["bindFileTypes"]) {
  2115. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2116. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2117. } else {
  2118. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2119. }
  2120. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  2121. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  2122. /* 保存的审核内容start */
  2123. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  2124. $check = ["msg" => $last_log["description"]];
  2125. if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
  2126. $check["checkState"] = 3;
  2127. }
  2128. if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
  2129. $check["checkState"] = 2;
  2130. }
  2131. /* 保存的审核内容end */
  2132. return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
  2133. }
  2134. }
  2135. // public function mixDelete() {
  2136. // $id = $this->request->param("talentInfoId");
  2137. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  2138. // if (!$info) {
  2139. // return json(["msg" => "操作失败"]);
  2140. // }
  2141. // $checkState = $info["checkState"];
  2142. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  2143. // $data["id"] = $id;
  2144. // $data["delete"] = 1;
  2145. // TalentModel::update($data);
  2146. // return json(["msg" => "删除成功"]);
  2147. // }
  2148. // return json(["msg" => "该申报已提交审核,无法删除"]);
  2149. // }
  2150. }