Talent.php 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236
  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["createTime"] = date("Y-m-d H:i:s");
  1118. $id = TalentModel::insertGetId($data);
  1119. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1120. $whr = [];
  1121. $whr[] = ["fileId", "in", $files];
  1122. $upd_checklog["mainId"] = $id;
  1123. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1124. }
  1125. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1126. if (!$info["first_submit_time"]) {
  1127. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1128. } else {
  1129. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1130. }
  1131. if ($data["id"]) {
  1132. $data["updateTime"] = date("Y-m-d H:i:s");
  1133. TalentModel::update($data);
  1134. } else {
  1135. //新增
  1136. $data["enterprise_id"] = $this->user["uid"];
  1137. $data["createTime"] = date("Y-m-d H:i:s");
  1138. $id = TalentModel::insertGetId($data);
  1139. $whr = [];
  1140. $whr[] = ["fileId", "in", $files];
  1141. $upd_checklog["mainId"] = $id;
  1142. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1143. }
  1144. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  1145. } else {
  1146. throw new ValidateException($error_msg);
  1147. }
  1148. if ($id) {
  1149. if ($deletes) {
  1150. //删除多余的附件,一般是选择人才类型留下来的
  1151. $whr = [];
  1152. $whr[] = ["typeId", "in", $deletes];
  1153. $whr[] = ["id", "in", $files];
  1154. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  1155. $_logfileIds[] = [];
  1156. foreach ($_wait_del_files as $_del_file) {
  1157. $_logfileIds[] = $_del_file["id"];
  1158. //@unlink("storage/" . $_del_file["url"]);
  1159. }
  1160. Db::table("new_talent_file")->where($whr)->delete();
  1161. if ($_logfileIds) {
  1162. $whr = [];
  1163. $whr[] = ["fileId", "in", $_logfileIds];
  1164. $_upd_checklog["description"] = "删除附件";
  1165. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  1166. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  1167. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  1168. }
  1169. }
  1170. $whr = [];
  1171. $whr[] = ["id", "in", $files];
  1172. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  1173. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1174. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1175. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1176. exit();
  1177. } else {
  1178. throw new ValidateException($error_msg);
  1179. }
  1180. } catch (ValidateException $e) {
  1181. $res = ["msg" => $e->getMessage()];
  1182. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1183. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1184. exit();
  1185. } catch (\think\Exception $e) {
  1186. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1187. $logInfo = [
  1188. "enterprise_id" => $this->user["uid"],
  1189. "data" => $data,
  1190. "controller" => $this->request->controller(),
  1191. "action" => $this->request->action(),
  1192. "errCode" => $e->getCode(),
  1193. "errMsg" => $e->getMessage()
  1194. ];
  1195. Log::write($logInfo, "error");
  1196. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1197. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1198. exit();
  1199. }
  1200. }
  1201. private function icSave($info, \think\Request $request, $checkState) {
  1202. try {
  1203. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1204. if ($batch["code"] != 200) {
  1205. throw new ValidateException($batch["msg"]);
  1206. }
  1207. $param = $request->param();
  1208. validate(TalentInfo::class)->check($param);
  1209. $id = $param["id"];
  1210. if ($id) {
  1211. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1212. throw new ValidateException("没有对应的人才认定申报信息");
  1213. }
  1214. }
  1215. $files = $param["uploadFiles"];
  1216. $data["headimgurl"] = $info["headimgurl"];
  1217. if ($request->file()) {
  1218. $headimg = $request->file("photo");
  1219. $upload = new \app\common\api\UploadApi();
  1220. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1221. if ($result->code == 500) {
  1222. throw new ValidateException($result->msg);
  1223. }
  1224. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1225. $width = imagesx($file);
  1226. $height = imagesy($file);
  1227. //免冠二寸照长宽413:579
  1228. if ($width * 579 != $height * 413) {
  1229. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1230. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1231. }
  1232. if ($info && $info["headimgurl"]) {
  1233. //如果新照片符合像素要求,则删除旧照片
  1234. $old_head_url = "storage/" . $info["headimgurl"];
  1235. //if (file_exists($old_head_url))
  1236. //@unlink($old_head_url);
  1237. }
  1238. $data["headimgurl"] = $result->filepath;
  1239. }
  1240. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1241. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1242. $data["apply_year"] = $batch["batch"];
  1243. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  1244. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  1245. "position", "cur_entry_time", "labor_contract_rangetime",
  1246. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  1247. "bank", "bank_branch_name", "bank_account", "description"];
  1248. foreach ($all_valid_keys as $key) {
  1249. $value = trim($param[$key]);
  1250. if ($value) {
  1251. $data[$key] = $value;
  1252. }
  1253. }
  1254. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1255. //真实状态11是驳回,需要判断什么字段可以提交
  1256. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1257. $tmp_data = $data;
  1258. $data = [];
  1259. foreach ($modify_fields as $field) {
  1260. $data[$field] = $tmp_data[$field];
  1261. }
  1262. }
  1263. $success_msg = "提交成功";
  1264. $error_msg = "提交失败";
  1265. if ($checkState == TalentState::SCND_SAVE) {
  1266. $data["checkState"] = $checkState;
  1267. $data["id"] = $id;
  1268. $success_msg = "保存成功";
  1269. if ($data["id"]) {
  1270. //编辑
  1271. $data["updateTime"] = date("Y-m-d H:i:s");
  1272. TalentModel::update($data);
  1273. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1274. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1275. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1276. } else {
  1277. if (!$last_log["companyId"]) {
  1278. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1279. }
  1280. }
  1281. } else {
  1282. //新增
  1283. $data["enterprise_id"] = $this->user["uid"];
  1284. $data["createTime"] = date("Y-m-d H:i:s");
  1285. $id = TalentModel::insertGetId($data);
  1286. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1287. $whr = [];
  1288. $whr[] = ["fileId", "in", $files];
  1289. $upd_checklog["mainId"] = $id;
  1290. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1291. }
  1292. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1293. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1294. exit();
  1295. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1296. unset($data);
  1297. $data["checkState"] = $checkState;
  1298. $data["id"] = $id;
  1299. if (!$info["first_submit_time"]) {
  1300. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1301. } else {
  1302. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1303. }
  1304. $data["updateTime"] = date("Y-m-d H:i:s");
  1305. TalentModel::update($data);
  1306. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1307. return json(["msg" => $success_msg, "code" => 200]);
  1308. } else {
  1309. throw new ValidateException($error_msg);
  1310. }
  1311. } catch (ValidateException $e) {
  1312. if ($checkState == TalentState::SCND_SAVE) {
  1313. $res = ["msg" => $e->getMessage()];
  1314. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1315. exit();
  1316. } else {
  1317. return json(["msg" => $e->getMessage()]);
  1318. }
  1319. } catch (\think\Exception $e) {
  1320. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1321. $logInfo = [
  1322. "enterprise_id" => $this->user["uid"],
  1323. "data" => $data,
  1324. "controller" => $this->request->controller(),
  1325. "action" => $this->request->action(),
  1326. "errCode" => $e->getCode(),
  1327. "errMsg" => $e->getMessage()
  1328. ];
  1329. Log::write($logInfo, "error");
  1330. if ($checkState == TalentState::SCND_SAVE) {
  1331. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1332. exit();
  1333. } else {
  1334. return json($res);
  1335. }
  1336. }
  1337. }
  1338. /**
  1339. * 卫健保存
  1340. * @param type $info
  1341. * @param \think\Request $request
  1342. * @param type $checkState
  1343. * @return type
  1344. * @throws ValidateException
  1345. */
  1346. private function wjSave($info, \think\Request $request, $checkState) {
  1347. $callback = "infoCallback";
  1348. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT])) {
  1349. $callback = "submitCallback";
  1350. }
  1351. try {
  1352. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1353. if ($batch["code"] != 200) {
  1354. throw new ValidateException($batch["msg"]);
  1355. }
  1356. $param = $request->param();
  1357. validate(TalentInfo::class)->check($param);
  1358. $id = $param["id"];
  1359. if ($id) {
  1360. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1361. throw new ValidateException("没有对应的人才认定申报信息");
  1362. }
  1363. }
  1364. $files = $param["uploadFiles"];
  1365. $data["headimgurl"] = $info["headimgurl"];
  1366. if ($request->file()) {
  1367. $headimg = $request->file("photo");
  1368. $upload = new \app\common\api\UploadApi();
  1369. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1370. if ($result->code == 500) {
  1371. throw new ValidateException($result->msg);
  1372. }
  1373. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1374. $width = imagesx($file);
  1375. $height = imagesy($file);
  1376. //免冠二寸照长宽413:579
  1377. if ($width * 579 != $height * 413) {
  1378. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1379. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1380. }
  1381. if ($info && $info["headimgurl"]) {
  1382. //如果新照片符合像素要求,则删除旧照片
  1383. $old_head_url = "storage/" . $info["headimgurl"];
  1384. //if (file_exists($old_head_url))
  1385. //@unlink($old_head_url);
  1386. }
  1387. $data["headimgurl"] = $result->filepath;
  1388. }
  1389. if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
  1390. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1391. $data["apply_year"] = $batch["batch"];
  1392. $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  1393. "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
  1394. "position", "cur_entry_time", "labor_contract_rangetime", "title", "fst_city_work_time",
  1395. "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition",
  1396. "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1397. foreach ($all_valid_keys as $key) {
  1398. $value = trim($param[$key]);
  1399. if ($value) {
  1400. $data[$key] = $value;
  1401. }
  1402. }
  1403. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
  1404. //真实状态11是驳回,需要判断什么字段可以提交
  1405. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1406. $tmp_data = $data;
  1407. $data = [];
  1408. foreach ($modify_fields as $field) {
  1409. $data[$field] = $tmp_data[$field];
  1410. }
  1411. }
  1412. $data["checkState"] = $checkState;
  1413. $data["id"] = $id;
  1414. $success_msg = "提交成功";
  1415. $error_msg = "提交失败";
  1416. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1417. $success_msg = "保存成功";
  1418. if ($data["id"]) {
  1419. //编辑
  1420. $data["updateTime"] = date("Y-m-d H:i:s");
  1421. TalentModel::update($data);
  1422. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1423. if ($last_log["new_state"] != TalentState::SCND_SAVE && $last_log["new_state"] != TalentState::FST_SAVE) {
  1424. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1425. } else {
  1426. if (!$last_log["companyId"]) {
  1427. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1428. }
  1429. }
  1430. } else {
  1431. //新增
  1432. $data["enterprise_id"] = $this->user["uid"];
  1433. $data["createTime"] = date("Y-m-d H:i:s");
  1434. $id = TalentModel::insertGetId($data);
  1435. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1436. $whr = [];
  1437. $whr[] = ["fileId", "in", $files];
  1438. $upd_checklog["mainId"] = $id;
  1439. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1440. }
  1441. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1442. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1443. //exit();
  1444. } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
  1445. if (!$info["first_submit_time"]) {
  1446. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1447. } else {
  1448. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1449. }
  1450. $data["updateTime"] = date("Y-m-d H:i:s");
  1451. TalentModel::update($data);
  1452. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1453. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1454. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1455. //exit();
  1456. } else {
  1457. throw new ValidateException($error_msg);
  1458. }
  1459. if ($id) {
  1460. $whr = [];
  1461. $whr[] = ["id", "in", $files];
  1462. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  1463. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1464. //$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1465. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1466. exit();
  1467. } else {
  1468. throw new ValidateException($error_msg);
  1469. }
  1470. } catch (ValidateException $e) {
  1471. $res = ["msg" => $e->getMessage()];
  1472. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1473. exit();
  1474. } catch (\think\Exception $e) {
  1475. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1476. $logInfo = [
  1477. "enterprise_id" => $this->user["uid"],
  1478. "data" => $data,
  1479. "controller" => $this->request->controller(),
  1480. "action" => $this->request->action(),
  1481. "errCode" => $e->getCode(),
  1482. "errMsg" => $e->getMessage()
  1483. ];
  1484. Log::write($logInfo, "error");
  1485. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1486. exit();
  1487. }
  1488. }
  1489. private function gjSave($info, \think\Request $request, $checkState) {
  1490. try {
  1491. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1492. if ($batch["code"] != 200) {
  1493. throw new ValidateException($batch["msg"]);
  1494. }
  1495. $param = $request->param();
  1496. validate(TalentInfo::class)->check($param);
  1497. $id = $param["id"];
  1498. if ($id) {
  1499. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1500. throw new ValidateException("没有对应的人才认定申报信息");
  1501. }
  1502. }
  1503. $files = $param["uploadFiles"];
  1504. $data["headimgurl"] = $info["headimgurl"];
  1505. if ($request->file()) {
  1506. $headimg = $request->file("photo");
  1507. $upload = new \app\common\api\UploadApi();
  1508. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1509. if ($result->code == 500) {
  1510. throw new ValidateException($result->msg);
  1511. }
  1512. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1513. $width = imagesx($file);
  1514. $height = imagesy($file);
  1515. //免冠二寸照长宽413:579
  1516. if ($width * 579 != $height * 413) {
  1517. //@unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1518. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1519. }
  1520. if ($info && $info["headimgurl"]) {
  1521. //如果新照片符合像素要求,则删除旧照片
  1522. $old_head_url = "storage/" . $info["headimgurl"];
  1523. //if (file_exists($old_head_url))
  1524. //@unlink($old_head_url);
  1525. }
  1526. $data["headimgurl"] = $result->filepath;
  1527. }
  1528. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1529. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1530. $data["apply_year"] = $batch["batch"];
  1531. $all_valid_keys = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type",
  1532. "position", "cur_entry_time", "labor_contract_rangetime",
  1533. "highest_degree", "graduate_school", "major", "study_abroad", "title", "pro_qua", "phone", "email",
  1534. "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition", "identifyGetTime",
  1535. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education", "parent_talent_level", "parent_talent_condition"];
  1536. foreach ($all_valid_keys as $key) {
  1537. $value = trim($param[$key]);
  1538. if ($value) {
  1539. $data[$key] = $value;
  1540. }
  1541. }
  1542. if ($data["study_abroad"] == 1) {
  1543. $data["abroad_school"] = $param["abroad_school"];
  1544. $data["abroad_major"] = $param["abroad_major"];
  1545. }
  1546. if ($data["study_abroad"] == 2) {
  1547. $data["abroad_school"] = null;
  1548. $data["abroad_major"] = null;
  1549. }
  1550. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1551. //真实状态11是驳回,需要判断什么字段可以提交
  1552. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1553. $tmp_data = $data;
  1554. $data = [];
  1555. foreach ($modify_fields as $field) {
  1556. $data[$field] = $tmp_data[$field];
  1557. }
  1558. }
  1559. $success_msg = "提交成功";
  1560. $error_msg = "提交失败";
  1561. if ($checkState == TalentState::SCND_SAVE) {
  1562. $data["checkState"] = $checkState;
  1563. $data["id"] = $id;
  1564. $success_msg = "保存成功";
  1565. if ($data["id"]) {
  1566. //编辑
  1567. $data["updateTime"] = date("Y-m-d H:i:s");
  1568. TalentModel::update($data);
  1569. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1570. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1571. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1572. } else {
  1573. if (!$last_log["companyId"]) {
  1574. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1575. }
  1576. }
  1577. } else {
  1578. //新增
  1579. $data["enterprise_id"] = $this->user["uid"];
  1580. $data["createTime"] = date("Y-m-d H:i:s");
  1581. $id = TalentModel::insertGetId($data);
  1582. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1583. $whr = [];
  1584. $whr[] = ["fileId", "in", $files];
  1585. $upd_checklog["mainId"] = $id;
  1586. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1587. }
  1588. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1589. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1590. exit();
  1591. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1592. unset($data);
  1593. $data["checkState"] = $checkState;
  1594. $data["id"] = $id;
  1595. if (!$info["first_submit_time"]) {
  1596. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1597. } else {
  1598. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1599. }
  1600. $data["updateTime"] = date("Y-m-d H:i:s");
  1601. TalentModel::update($data);
  1602. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1603. return json(["msg" => $success_msg, "code" => 200]);
  1604. } else {
  1605. throw new ValidateException($error_msg);
  1606. }
  1607. } catch (ValidateException $e) {
  1608. if ($checkState == TalentState::SCND_SAVE) {
  1609. $res = ["msg" => $e->getMessage()];
  1610. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1611. exit();
  1612. } else {
  1613. return json(["msg" => $e->getMessage()]);
  1614. }
  1615. } catch (\think\Exception $e) {
  1616. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1617. $logInfo = [
  1618. "enterprise_id" => $this->user["uid"],
  1619. "data" => $data,
  1620. "controller" => $this->request->controller(),
  1621. "action" => $this->request->action(),
  1622. "errCode" => $e->getCode(),
  1623. "errMsg" => $e->getMessage()
  1624. ];
  1625. Log::write($logInfo, "error");
  1626. if ($checkState == TalentState::SCND_SAVE) {
  1627. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1628. exit();
  1629. } else {
  1630. return json($res);
  1631. }
  1632. }
  1633. }
  1634. public function delete() {
  1635. $id = $this->request->param("talentInfoId");
  1636. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  1637. if (!$info) {
  1638. return json(["msg" => "操作失败"]);
  1639. }
  1640. $checkState = $info["checkState"];
  1641. if (in_array($checkState, [0, 1])) {
  1642. $log = TalentLogApi::getLastLog($id, 1);
  1643. if ($log["state"] > 1) {
  1644. //有提交审核记录
  1645. return json(["msg" => "该申报已提交审核,无法删除"]);
  1646. }
  1647. }
  1648. $data["id"] = $id;
  1649. $data["updateTime"] = date("Y-m-d H:i:s");
  1650. $data["delete"] = 1;
  1651. TalentModel::update($data);
  1652. return json(["msg" => "删除成功"]);
  1653. }
  1654. public function detail() {
  1655. $id = $this->request->param("id");
  1656. $info = $this->getInfoById($id);
  1657. return json($info);
  1658. }
  1659. public function getInfoById($id) {
  1660. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1661. if ($info["enterprise_id"] != $this->user["uid"]) {
  1662. return [];
  1663. }
  1664. return $info;
  1665. }
  1666. public function findTalentInfoInLibrary() {
  1667. $where = [];
  1668. $sList = [];
  1669. $type = $this->request->param('type');
  1670. if ($type == ProjectState::QUIT) {
  1671. $_where = [];
  1672. $_where[] = ["checkState", "not in", [3]];
  1673. $_where[] = ["delete", "<>", 1];
  1674. $idCards = Db::table("un_talent_quit")->where($_where)->column("idCard");
  1675. $sList = array_merge($sList, (array) $idCards);
  1676. $where[] = ["active", "=", 1];
  1677. }
  1678. if ($type == ProjectState::BANKCHANGE) {
  1679. $_where = [];
  1680. $_where[] = ["checkState", "not in", [3]];
  1681. $_where[] = ["delete", "<>", 1];
  1682. $idCards = Db::table("un_talent_bank_change")->where($_where)->column("idCard");
  1683. $sList = array_merge($sList, (array) $idCards);
  1684. }
  1685. if ($type == ProjectState::LEVELCHANGE) {
  1686. $_where = [];
  1687. $_where[] = ["checkState", "not in", [35, -1]];
  1688. $_where[] = ["isPublic", "<", 5];
  1689. $_where[] = ["delete", "<>", 1];
  1690. $_where[] = ["createTime", ">=", "2022-10-01 00:00:00"];
  1691. $idCards = Db::table("un_talent_type_change")->where($_where)->column("idCard");
  1692. $sList = array_merge($sList, (array) $idCards);
  1693. }
  1694. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1695. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1696. $where[] = ["isEffect", "<>", 4];
  1697. if ($sList) {
  1698. $where[] = ["card_number", "not in", $sList];
  1699. }
  1700. $result = TalentModel::where($where)->field("id,name,talent_arrange,card_number")->select()->toArray();
  1701. $list = [];
  1702. foreach ($result as $res) {
  1703. $_cardNumber = $res["card_number"];
  1704. if (!$list[$_cardNumber]) {
  1705. $list[$_cardNumber] = $res;
  1706. } else {
  1707. if ($res["talent_arrange"] < $list[$_cardNumber]["talent_arrange"]) {
  1708. $list[$_cardNumber] = $res;
  1709. }
  1710. }
  1711. }
  1712. sort($list);
  1713. return json($list);
  1714. }
  1715. public function findTalentInfoByChangeId() {
  1716. $where = [];
  1717. $id = $this->request->param('id');
  1718. $type = $this->request->param('type');
  1719. if ($type == ProjectState::QUIT) {
  1720. $info = Db::table("un_talent_quit")->where("id", $id)->find();
  1721. }
  1722. if ($type == ProjectState::LEVELCHANGE) {
  1723. $info = Db::table("un_talent_type_change")->where("id", $id)->find();
  1724. }
  1725. if ($type == ProjectState::BANKCHANGE) {
  1726. $info = Db::table("un_talent_bank_change")->where("id", $id)->find();
  1727. }
  1728. if (strlen($info["talentId"]) == 19) {
  1729. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1730. $where[] = ["card_number", "=", $info["idCard"]];
  1731. $where[] = ["delete", "=", 0];
  1732. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1733. } else {
  1734. $where[] = ["id", "=", $info["talentId"]];
  1735. }
  1736. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1737. return json($result);
  1738. }
  1739. public function getTalentBasicById() {
  1740. $id = $this->request["id"];
  1741. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  1742. /* if(FengStringUtil.isNotEmpAndNull(year)){
  1743. StringBuilder sb = new StringBuilder();
  1744. List<TalentAllowancecontractDetail> contractDetailList = new ArrayList<>(); //保存上一年度的工作单位
  1745. TalentAllowanceInfo info = new TalentAllowanceInfo();
  1746. info.setType(ti.getType());
  1747. info.setYear(year);
  1748. info.setFirstInJJTime(ti.getFirstInJJTime());
  1749. ApiTalentAllowanceController.getConcatList(ti,info,year,sb,contractDetailList);
  1750. int active = AllowanceSelectUtil.validMyqy(contractDetailList,ti,info);
  1751. ti.setActive(active);
  1752. } */
  1753. return $ti;
  1754. }
  1755. /**
  1756. *
  1757. */
  1758. public function getTalentInfoFromOldLibrary() {
  1759. $responseObj = new \stdClass();
  1760. $responseObj->code = 500;
  1761. $ep = EnterpriseApi::getOne($this->user["uid"]);
  1762. $pIdCard = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1763. $eIdCard = $ep->idCard;
  1764. $where = [];
  1765. $where[] = ["e.idCard", "=", $eIdCard];
  1766. $where[] = ["ti.idCard", "=", $pIdCard];
  1767. $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();
  1768. if ($old) {
  1769. $responseObj->code = 200;
  1770. $responseObj->info = $old;
  1771. return $responseObj;
  1772. }
  1773. return $responseObj;
  1774. }
  1775. public function findTalentByEnterpriseInLibrary() {
  1776. $year = $this->request["year"];
  1777. $type = $this->request["type"];
  1778. $res = [];
  1779. $idCards = null;
  1780. $year = substr($year, 0, 4);
  1781. //根据申报年度查询当前企业已申报的人才
  1782. if ($type == 1) { //津补贴
  1783. $where = [];
  1784. $where[] = ["year", "like", $year . "%"];
  1785. $where[] = ["delete", "=", 0];
  1786. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  1787. $talentAllowances = \app\common\model\TalentAllowance::where($where)->select()->toArray();
  1788. $idCards = array_unique(array_column($talentAllowances, "idCard"));
  1789. } else if ($type == 2) { //购房补贴
  1790. $where = [];
  1791. $where[] = ["year", "like", $year . "%"];
  1792. $where[] = ["delete", "=", 0];
  1793. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  1794. $housePurchases = \app\common\model\HousePurchase::where($where)->select()->toArray();
  1795. $idCards = array_unique(array_column($housePurchases, "idCard"));
  1796. }
  1797. $whr = [];
  1798. $whr[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
  1799. $whr[] = ["ti.enterprise_id", "=", $this->user["uid"]];
  1800. $whr[] = ["e.type", "=", $this->user["type"]];
  1801. $whr[] = ["ti.card_number", "not in", $idCards];
  1802. $twiceIdentifyPersons = \app\common\api\VerifyApi::getTwiceIdentifyPersons();
  1803. if ($twiceIdentifyPersons) {
  1804. $_whr = $whr;
  1805. $whr[] = ["card_number", "not in", $twiceIdentifyPersons];
  1806. $_whr[] = ["card_number", "in", $twiceIdentifyPersons];
  1807. $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();
  1808. $twiceIdentifyPersonList = [];
  1809. $otherTypeChangeList = [];
  1810. foreach ($tmpList as $person) {
  1811. if (!$twiceIdentifyPersonList[$person["card_number"]]) {
  1812. $twiceIdentifyPersonList[$person["card_number"]] = $person;
  1813. } else {
  1814. if ($person["talent_arrange"] < $twiceIdentifyPersonList[$person["card_number"]]["talent_arrange"]) {
  1815. $otherTypeChangeList[$person["card_number"]][] = ["oldIdentifyMonth" => $twiceIdentifyPersonList[$person["card_number"]]["identifyMonth"], "oldIdentifyGetTime" => $twiceIdentifyPersonList[$person["card_number"]]["identifyGetTime"]];
  1816. $twiceIdentifyPersonList[$person["card_number"]] = $person;
  1817. } else {
  1818. $otherTypeChangeList[$person["card_number"]][] = ["oldIdentifyMonth" => $person["identifyMonth"], "oldIdentifyGetTime" => $person["identifyGetTime"]];
  1819. }
  1820. }
  1821. }
  1822. sort($twiceIdentifyPersonList);
  1823. }
  1824. $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();
  1825. if ($twiceIdentifyPersonList) {
  1826. $list = array_merge((array) $list, $twiceIdentifyPersonList);
  1827. $list = bubbleSort($list, "identifyMonth", "desc");
  1828. }
  1829. foreach ($list as $info) {
  1830. $info["enterpriseName"] = $this->user["name"];
  1831. $identifyTime = $info["identifyMonth"];
  1832. if ($info["eType"] == CommonConst::ENTERPRISE_JC) {
  1833. $identifyTime = $info["identifyGetTime"] ?: $info["identifyMonth"];
  1834. }
  1835. if (strtotime($year . "-12-31") >= strtotime($identifyTime)) {
  1836. $res[] = $info;
  1837. } else {
  1838. $whereTypeChange = [];
  1839. $whereTypeChange[] = ["talentId", "=", $info["id"]];
  1840. $whereTypeChange[] = ["checkState", "=", \app\common\state\MainState::PASS];
  1841. $whereTypeChange[] = ["isPublic", "=", 6];
  1842. $whereTypeChange[] = ["createTime", ">=", "2022-10-01 00:00:00"];
  1843. $typeChanges = \app\enterprise\model\TalentTypeChange::where($whereTypeChange)->select()->toArray();
  1844. if ($otherTypeChangeList[$info["card_number"]]) {
  1845. $typeChanges = array_merge($otherTypeChangeList[$info["card_number"]], (array) $typeChanges);
  1846. }
  1847. foreach ($typeChanges as $typeChange) {
  1848. $oldIdentifyTime = $typeChange["oldIdentifyMonth"];
  1849. if ($typeChange["type"] == CommonConst::ENTERPRISE_JC) {
  1850. $oldIdentifyTime = $typeChange["oldIdentifyGetTime"] ?: $typeChange["oldIdentifyMonth"];
  1851. }
  1852. if (strtotime($year . "-12-31") >= strtotime($oldIdentifyTime)) {
  1853. $res[] = $info;
  1854. break;
  1855. }
  1856. }
  1857. }
  1858. }
  1859. return $res;
  1860. }
  1861. /**
  1862. * 审核列表页
  1863. */
  1864. public function examineCenter() {
  1865. $tpl = "";
  1866. switch ($this->user["type"]) {
  1867. case CommonConst::ENTERPRISE_WJ:
  1868. $tpl = "/talent/hospital/examine_center"; //卫健医院
  1869. break;
  1870. }
  1871. return view($tpl);
  1872. }
  1873. /**
  1874. * 审核列表页
  1875. */
  1876. public function examineList() {
  1877. $res = TalentApi::getHospitalExamineList($this->request);
  1878. return json($res);
  1879. }
  1880. public function examinePage() {
  1881. $id = $this->request->param("id");
  1882. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1883. return view("/talent/hospital/view", ["row" => $info]);
  1884. }
  1885. /**
  1886. * 医院人才申报审核保存
  1887. * @return type
  1888. */
  1889. public function check() {
  1890. $request = $this->request;
  1891. $params = $request->param();
  1892. $check = $params["checkState"];
  1893. $check_msg = trim($params["checkMsg"]);
  1894. $files = $params["files"];
  1895. $fields = $params["fields"];
  1896. $id = $params["id"];
  1897. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1898. if (!$talent_info) {
  1899. return json(["msg" => "数据错误"]);
  1900. }
  1901. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1902. $checkState = $talent_info["checkState"];
  1903. if ($this->user["isGeneral"] != 1) {
  1904. return json(["msg" => "非总院账号,无法审核"]);
  1905. }
  1906. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1907. return json(["msg" => "不能审核其它非本医共体医院"]);
  1908. }
  1909. if (!$check) {
  1910. return json(["msg" => "请选择审核状态"]);
  1911. }
  1912. if (!$check_msg) {
  1913. return json(["msg" => "请填写审核说明"]);
  1914. }
  1915. if ($checkState == TalentState::FST_SUBMIT) {
  1916. if ($params["checkState"] == 3) {
  1917. //审核成功
  1918. $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
  1919. } else {
  1920. //审核驳回并记录需要修改的字段和上传文件
  1921. $checkState = TalentState::FST_SAVE; //退回材料编辑状态
  1922. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  1923. }
  1924. $log = TalentLogApi::getLastLog($id, 1);
  1925. if (!$log && !$talent_info["oldId"])
  1926. return json(["msg" => "日志数据异常,保存失败"]);
  1927. if ($log["active"] === 0) {
  1928. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1929. } else {
  1930. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1931. }
  1932. $data["id"] = $talent_info["id"];
  1933. $data["modify_files"] = $params["files"];
  1934. $data["modify_fields"] = $params["fields"];
  1935. TalentModel::update($data);
  1936. return json(["code" => 200, "msg" => "保存成功"]);
  1937. } else {
  1938. return json(["msg" => "不在审核范围内,保存失败"]);
  1939. }
  1940. }
  1941. /**
  1942. * 医院人才申报审核
  1943. * @return type
  1944. */
  1945. public function submitCheck() {
  1946. $id = $this->request->param("id");
  1947. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1948. if (!$talent_info) {
  1949. return json(["msg" => "数据错误"]);
  1950. }
  1951. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1952. $checkState = $talent_info["checkState"];
  1953. if ($this->user["isGeneral"] != 1) {
  1954. return json(["msg" => "非总院账号,无法审核"]);
  1955. }
  1956. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1957. return json(["msg" => "不能审核其它非本医共体医院"]);
  1958. }
  1959. if ($checkState == TalentState::FST_SUBMIT) {
  1960. $nowProcess = 1;
  1961. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1962. if (!$log || $log["active"] == 1)
  1963. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1964. if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
  1965. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1966. }
  1967. $data["id"] = $talent_info["id"];
  1968. $data["checkState"] = $log["new_state"];
  1969. TalentModel::update($data);
  1970. TalentLogApi::setActive($log["id"], 1);
  1971. if ($log["state"] == TalentState::BASE_REJECT) {
  1972. $this->sendMsg($enterprise["id"], $log["description"]);
  1973. }
  1974. return json(["code" => 200, "msg" => "审核成功"]);
  1975. } else {
  1976. return json(["msg" => "不在审核范围内,审核失败"]);
  1977. }
  1978. }
  1979. public function findFieldsAndFiles() {
  1980. $id = $this->request["id"];
  1981. $talentInfo = TalentApi::getOne($id);
  1982. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1983. $responseObj = new \stdClass();
  1984. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  1985. $fields = DictApi::getTalentFields_WJ();
  1986. $field_tmp = [];
  1987. if ($fields) {
  1988. foreach ($fields as $key => $field) {
  1989. $field_tmp[] = ["key" => $key, "value" => $field];
  1990. }
  1991. }
  1992. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  1993. $where = [];
  1994. $whr = [];
  1995. $where[] = ["project", "=", 1];
  1996. $where[] = ["active", "=", 1];
  1997. $where[] = ["type", "=", CommonConst::ENTERPRISE_WJ];
  1998. $where[] = ["isConditionFile", "<>", 1];
  1999. $where[] = ["delete", "=", 0];
  2000. if ($condition && $condition["bindFileTypes"]) {
  2001. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2002. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2003. } else {
  2004. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2005. }
  2006. $responseObj->code = 200;
  2007. $responseObj->id = $id;
  2008. $responseObj->fileList = $files;
  2009. $responseObj->fieldList = $field_tmp;
  2010. $responseObj->select = [
  2011. "files" => array_filter(explode(",", $talentInfo["modify_files"])),
  2012. "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
  2013. ];
  2014. } else {
  2015. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2016. }
  2017. return json($responseObj);
  2018. }
  2019. /**
  2020. * 初审-修改驳回字段
  2021. * @auth {{/talentInfo/updateFieldsAndFiles}}
  2022. */
  2023. public function updateFieldsAndFiles() {
  2024. $id = $this->request["id"];
  2025. $fields = array_filter(explode(",", $this->request["fields"]));
  2026. $files = array_filter(explode(",", $this->request["files"]));
  2027. $talentInfo = TalentApi::getOne($id);
  2028. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  2029. $responseObj = new \stdClass();
  2030. if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
  2031. if (!$fields && !$files) {
  2032. $responseObj->msg = "请选择可修改的字段或附件!";
  2033. return json($responseObj);
  2034. }
  2035. try {
  2036. $data["id"] = $id;
  2037. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  2038. $data["modify_files"] = $files ? implode(",", $files) : null;
  2039. TalentModel::update($data);
  2040. $responseObj->code = 200;
  2041. $responseObj->msg = "驳回字段修改成功";
  2042. return json($responseObj);
  2043. } catch (\think\db\exception\DbException $e) {
  2044. $responseObj->msg = $e->getMessage();
  2045. return json($responseObj);
  2046. }
  2047. } else {
  2048. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  2049. return json($responseObj);
  2050. }
  2051. }
  2052. private function sendMsg($enterprise_id, $description = "") {
  2053. $ep = EnterpriseApi::getOne($enterprise_id);
  2054. if ($ep->agentPhone) {
  2055. $smsapi = new \app\common\api\ChuanglanSmsApi();
  2056. $result = $smsapi->sendSMS($phone, $template);
  2057. $result = json_decode($result, true);
  2058. $id = getStringId();
  2059. $record_data = [
  2060. 'id' => $id,
  2061. 'userId' => $ep->id,
  2062. 'bizId' => $result["msgId"],
  2063. 'type' => 2,
  2064. 'smsType' => 2,
  2065. 'name' => $ep->name,
  2066. 'phone' => $ep->agentPhone,
  2067. 'params' => "总院审核",
  2068. 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
  2069. 'state' => $result['code'] == 0 ? 2 : 3,
  2070. 'sendingDate' => date("Y-m-d H:i:s", time()),
  2071. 'createTime' => date("Y-m-d H:i:s", time()),
  2072. 'msg' => $result['errorMsg']
  2073. ];
  2074. \app\admin\model\MessageRecord::create($record_data);
  2075. }
  2076. }
  2077. public function validateIsCheck() {
  2078. $params = $this->request->param();
  2079. $id = $params["id"];
  2080. $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
  2081. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  2082. if ($talent_info) {
  2083. $checkState = $talent_info["checkState"];
  2084. if ($this->user["isGeneral"] != 1) {
  2085. return json(["msg" => "非总院账号,无法审核"]);
  2086. }
  2087. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  2088. return json(["msg" => "不能审核其它非本医共体医院"]);
  2089. }
  2090. if ($checkState != TalentState::FST_SUBMIT) {
  2091. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  2092. }
  2093. $fields = DictApi::getTalentFields_WJ();
  2094. $field_tmp = [];
  2095. if ($fields) {
  2096. foreach ($fields as $key => $field) {
  2097. $field_tmp[] = ["key" => $key, "value" => $field];
  2098. }
  2099. }
  2100. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  2101. $where = [];
  2102. $whr = [];
  2103. $where[] = ["project", "=", 1];
  2104. $where[] = ["active", "=", 1];
  2105. $where[] = ["type", "=", $enterprise["type"]];
  2106. $where[] = ["isConditionFile", "<>", 1];
  2107. $where[] = ["delete", "=", 0];
  2108. if ($condition && $condition["bindFileTypes"]) {
  2109. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  2110. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  2111. } else {
  2112. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  2113. }
  2114. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  2115. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  2116. /* 保存的审核内容start */
  2117. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  2118. $check = ["msg" => $last_log["description"]];
  2119. if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
  2120. $check["checkState"] = 3;
  2121. }
  2122. if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
  2123. $check["checkState"] = 2;
  2124. }
  2125. /* 保存的审核内容end */
  2126. return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
  2127. }
  2128. }
  2129. // public function mixDelete() {
  2130. // $id = $this->request->param("talentInfoId");
  2131. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  2132. // if (!$info) {
  2133. // return json(["msg" => "操作失败"]);
  2134. // }
  2135. // $checkState = $info["checkState"];
  2136. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  2137. // $data["id"] = $id;
  2138. // $data["delete"] = 1;
  2139. // TalentModel::update($data);
  2140. // return json(["msg" => "删除成功"]);
  2141. // }
  2142. // return json(["msg" => "该申报已提交审核,无法删除"]);
  2143. // }
  2144. }