Talent.php 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241
  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. foreach ($list as $info) {
  1835. $info["enterpriseName"] = $this->user["name"];
  1836. $identifyTime = $info["identifyMonth"];
  1837. if ($info["eType"] == CommonConst::ENTERPRISE_JC) {
  1838. $identifyTime = $info["identifyGetTime"] ?: $info["identifyMonth"];
  1839. }
  1840. if (strtotime($year . "-12-31") >= strtotime($identifyTime)) {
  1841. $res[] = $info;
  1842. } else {
  1843. $whereTypeChange = [];
  1844. $whereTypeChange[] = ["talentId", "=", $info["id"]];
  1845. $whereTypeChange[] = ["checkState", "=", \app\common\state\MainState::PASS];
  1846. $whereTypeChange[] = ["isPublic", "=", 6];
  1847. $whereTypeChange[] = ["createTime", ">=", "2022-10-01 00:00:00"];
  1848. $typeChanges = \app\enterprise\model\TalentTypeChange::where($whereTypeChange)->select()->toArray();
  1849. if ($otherTypeChangeList[$info["card_number"]]) {
  1850. $typeChanges = array_merge($otherTypeChangeList[$info["card_number"]], (array) $typeChanges);
  1851. }
  1852. foreach ($typeChanges as $typeChange) {
  1853. $oldIdentifyTime = $typeChange["oldIdentifyMonth"];
  1854. if ($typeChange["type"] == CommonConst::ENTERPRISE_JC) {
  1855. $oldIdentifyTime = $typeChange["oldIdentifyGetTime"] ?: $typeChange["oldIdentifyMonth"];
  1856. }
  1857. if (strtotime($year . "-12-31") >= strtotime($oldIdentifyTime)) {
  1858. $res[] = $info;
  1859. break;
  1860. }
  1861. }
  1862. }
  1863. }
  1864. return $res;
  1865. }
  1866. /**
  1867. * 审核列表页
  1868. */
  1869. public function examineCenter() {
  1870. $tpl = "";
  1871. switch ($this->user["type"]) {
  1872. case CommonConst::ENTERPRISE_WJ:
  1873. $tpl = "/talent/hospital/examine_center"; //卫健医院
  1874. break;
  1875. }
  1876. return view($tpl);
  1877. }
  1878. /**
  1879. * 审核列表页
  1880. */
  1881. public function examineList() {
  1882. $res = TalentApi::getHospitalExamineList($this->request);
  1883. return json($res);
  1884. }
  1885. public function examinePage() {
  1886. $id = $this->request->param("id");
  1887. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1888. return view("/talent/hospital/view", ["row" => $info]);
  1889. }
  1890. /**
  1891. * 医院人才申报审核保存
  1892. * @return type
  1893. */
  1894. public function check() {
  1895. $request = $this->request;
  1896. $params = $request->param();
  1897. $check = $params["checkState"];
  1898. $check_msg = trim($params["checkMsg"]);
  1899. $files = $params["files"];
  1900. $fields = $params["fields"];
  1901. $id = $params["id"];
  1902. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1903. if (!$talent_info) {
  1904. return json(["msg" => "数据错误"]);
  1905. }
  1906. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1907. $checkState = $talent_info["checkState"];
  1908. if ($this->user["isGeneral"] != 1) {
  1909. return json(["msg" => "非总院账号,无法审核"]);
  1910. }
  1911. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1912. return json(["msg" => "不能审核其它非本医共体医院"]);
  1913. }
  1914. if (!$check) {
  1915. return json(["msg" => "请选择审核状态"]);
  1916. }
  1917. if (!$check_msg) {
  1918. return json(["msg" => "请填写审核说明"]);
  1919. }
  1920. if ($checkState == TalentState::FST_SUBMIT) {
  1921. if ($params["checkState"] == 3) {
  1922. //审核成功
  1923. $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
  1924. } else {
  1925. //审核驳回并记录需要修改的字段和上传文件
  1926. $checkState = TalentState::FST_SAVE; //退回材料编辑状态
  1927. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  1928. }
  1929. $log = TalentLogApi::getLastLog($id, 1);
  1930. if (!$log && !$talent_info["oldId"])
  1931. return json(["msg" => "日志数据异常,保存失败"]);
  1932. if ($log["active"] === 0) {
  1933. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1934. } else {
  1935. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1936. }
  1937. $data["id"] = $talent_info["id"];
  1938. $data["modify_files"] = $params["files"];
  1939. $data["modify_fields"] = $params["fields"];
  1940. TalentModel::update($data);
  1941. return json(["code" => 200, "msg" => "保存成功"]);
  1942. } else {
  1943. return json(["msg" => "不在审核范围内,保存失败"]);
  1944. }
  1945. }
  1946. /**
  1947. * 医院人才申报审核
  1948. * @return type
  1949. */
  1950. public function submitCheck() {
  1951. $id = $this->request->param("id");
  1952. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1953. if (!$talent_info) {
  1954. return json(["msg" => "数据错误"]);
  1955. }
  1956. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1957. $checkState = $talent_info["checkState"];
  1958. if ($this->user["isGeneral"] != 1) {
  1959. return json(["msg" => "非总院账号,无法审核"]);
  1960. }
  1961. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1962. return json(["msg" => "不能审核其它非本医共体医院"]);
  1963. }
  1964. if ($checkState == TalentState::FST_SUBMIT) {
  1965. $nowProcess = 1;
  1966. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1967. if (!$log || $log["active"] == 1)
  1968. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1969. if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
  1970. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1971. }
  1972. $data["id"] = $talent_info["id"];
  1973. $data["checkState"] = $log["new_state"];
  1974. TalentModel::update($data);
  1975. TalentLogApi::setActive($log["id"], 1);
  1976. if ($log["state"] == TalentState::BASE_REJECT) {
  1977. $this->sendMsg($enterprise["id"], $log["description"]);
  1978. }
  1979. return json(["code" => 200, "msg" => "审核成功"]);
  1980. } else {
  1981. return json(["msg" => "不在审核范围内,审核失败"]);
  1982. }
  1983. }
  1984. public function findFieldsAndFiles() {
  1985. $id = $this->request["id"];
  1986. $talentInfo = TalentApi::getOne($id);
  1987. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1988. $responseObj = new \stdClass();
  1989. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  1990. $fields = DictApi::getTalentFields_WJ();
  1991. $field_tmp = [];
  1992. if ($fields) {
  1993. foreach ($fields as $key => $field) {
  1994. $field_tmp[] = ["key" => $key, "value" => $field];
  1995. }
  1996. }
  1997. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  1998. $where = [];
  1999. $whr = [];
  2000. $where[] = ["project", "=", 1];
  2001. $where[] = ["active", "=", 1];
  2002. $where[] = ["type", "=", CommonConst::ENTERPRISE_WJ];
  2003. $where[] = ["isConditionFile", "<>", 1];
  2004. $where[] = ["delete", "=", 0];
  2005. if ($condition && $condition["bindFileTypes"]) {
  2006. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2007. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2008. } else {
  2009. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2010. }
  2011. $responseObj->code = 200;
  2012. $responseObj->id = $id;
  2013. $responseObj->fileList = $files;
  2014. $responseObj->fieldList = $field_tmp;
  2015. $responseObj->select = [
  2016. "files" => array_filter(explode(",", $talentInfo["modify_files"])),
  2017. "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
  2018. ];
  2019. } else {
  2020. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2021. }
  2022. return json($responseObj);
  2023. }
  2024. /**
  2025. * 初审-修改驳回字段
  2026. * @auth {{/talentInfo/updateFieldsAndFiles}}
  2027. */
  2028. public function updateFieldsAndFiles() {
  2029. $id = $this->request["id"];
  2030. $fields = array_filter(explode(",", $this->request["fields"]));
  2031. $files = array_filter(explode(",", $this->request["files"]));
  2032. $talentInfo = TalentApi::getOne($id);
  2033. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  2034. $responseObj = new \stdClass();
  2035. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  2036. if (!$fields && !$files) {
  2037. $responseObj->msg = "请选择可修改的字段或附件!";
  2038. return json($responseObj);
  2039. }
  2040. try {
  2041. $data["id"] = $id;
  2042. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  2043. $data["modify_files"] = $files ? implode(",", $files) : null;
  2044. TalentModel::update($data);
  2045. $responseObj->code = 200;
  2046. $responseObj->msg = "驳回字段修改成功";
  2047. return json($responseObj);
  2048. } catch (\think\db\exception\DbException $e) {
  2049. $responseObj->msg = $e->getMessage();
  2050. return json($responseObj);
  2051. }
  2052. } else {
  2053. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2054. return json($responseObj);
  2055. }
  2056. }
  2057. private function sendMsg($enterprise_id, $description = "") {
  2058. $ep = EnterpriseApi::getOne($enterprise_id);
  2059. if ($ep->agentPhone) {
  2060. $smsapi = new \app\common\api\ChuanglanSmsApi();
  2061. $result = $smsapi->sendSMS($phone, $template);
  2062. $result = json_decode($result, true);
  2063. $id = getStringId();
  2064. $record_data = [
  2065. 'id' => $id,
  2066. 'userId' => $ep->id,
  2067. 'bizId' => $result["msgId"],
  2068. 'type' => 2,
  2069. 'smsType' => 2,
  2070. 'name' => $ep->name,
  2071. 'phone' => $ep->agentPhone,
  2072. 'params' => "总院审核",
  2073. 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
  2074. 'state' => $result['code'] == 0 ? 2 : 3,
  2075. 'sendingDate' => date("Y-m-d H:i:s", time()),
  2076. 'createTime' => date("Y-m-d H:i:s", time()),
  2077. 'msg' => $result['errorMsg']
  2078. ];
  2079. \app\admin\model\MessageRecord::create($record_data);
  2080. }
  2081. }
  2082. public function validateIsCheck() {
  2083. $params = $this->request->param();
  2084. $id = $params["id"];
  2085. $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
  2086. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  2087. if ($talent_info) {
  2088. $checkState = $talent_info["checkState"];
  2089. if ($this->user["isGeneral"] != 1) {
  2090. return json(["msg" => "非总院账号,无法审核"]);
  2091. }
  2092. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  2093. return json(["msg" => "不能审核其它非本医共体医院"]);
  2094. }
  2095. if ($checkState != TalentState::FST_SUBMIT) {
  2096. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  2097. }
  2098. $fields = DictApi::getTalentFields_WJ();
  2099. $field_tmp = [];
  2100. if ($fields) {
  2101. foreach ($fields as $key => $field) {
  2102. $field_tmp[] = ["key" => $key, "value" => $field];
  2103. }
  2104. }
  2105. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  2106. $where = [];
  2107. $whr = [];
  2108. $where[] = ["project", "=", 1];
  2109. $where[] = ["active", "=", 1];
  2110. $where[] = ["type", "=", $enterprise["type"]];
  2111. $where[] = ["isConditionFile", "<>", 1];
  2112. $where[] = ["delete", "=", 0];
  2113. if ($condition && $condition["bindFileTypes"]) {
  2114. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2115. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2116. } else {
  2117. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2118. }
  2119. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  2120. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  2121. /* 保存的审核内容start */
  2122. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  2123. $check = ["msg" => $last_log["description"]];
  2124. if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
  2125. $check["checkState"] = 3;
  2126. }
  2127. if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
  2128. $check["checkState"] = 2;
  2129. }
  2130. /* 保存的审核内容end */
  2131. return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
  2132. }
  2133. }
  2134. // public function mixDelete() {
  2135. // $id = $this->request->param("talentInfoId");
  2136. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  2137. // if (!$info) {
  2138. // return json(["msg" => "操作失败"]);
  2139. // }
  2140. // $checkState = $info["checkState"];
  2141. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  2142. // $data["id"] = $id;
  2143. // $data["delete"] = 1;
  2144. // TalentModel::update($data);
  2145. // return json(["msg" => "删除成功"]);
  2146. // }
  2147. // return json(["msg" => "该申报已提交审核,无法删除"]);
  2148. // }
  2149. }