TalentAllowance.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\Response;
  5. use app\common\model\TalentAllowance as TaModel;
  6. use think\facade\Db;
  7. use app\common\api\DictApi;
  8. use app\common\state\AllowanceStateEnum;
  9. use app\common\state\AllowanceProjectEnum;
  10. use app\common\api\TalentAllowanceApi;
  11. use app\common\model\TalentChecklog;
  12. /**
  13. * Description of TalentAllowance
  14. *
  15. * @author sgq
  16. */
  17. class TalentAllowance extends AdminController {
  18. public function index() {
  19. $process = $this->request["process"];
  20. $type = $this->user["type"];
  21. $assigns = ["process" => $process, "type" => $type];
  22. if ($process == 4) {
  23. if ($type == 1) {
  24. $msgBody["typeName"] = "晋江市优秀人才津补贴申报";
  25. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  26. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  27. $msgBody["phone"] = "0595-85633128";
  28. $msgBody["email"] = "jjrc85661234@163.com";
  29. }
  30. if ($type == 2) {
  31. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  32. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  33. $msgBody["dep"] = "集成电路产业园区";
  34. $msgBody["phone"] = "0595-82250007、0595-82250001";
  35. $msgBody["email"] = "jjjcdr@163.com";
  36. }
  37. $assigns["message"] = $msgBody;
  38. }
  39. return view("", $assigns);
  40. }
  41. /**
  42. * 获取优秀人才津补贴列表
  43. */
  44. public function list() {
  45. $param = $this->request->param();
  46. $offset = $param["offset"] ?: 0;
  47. $limit = $param["limit"] ?: 10;
  48. $process = $param["process"];
  49. $where = [];
  50. $where[] = ["type", "=", $this->user["type"]];
  51. $order = "newSubmitTime desc";
  52. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  53. switch ($process) {
  54. case 1:
  55. $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  56. break;
  57. case 2:
  58. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  59. break;
  60. case 3:
  61. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  62. break;
  63. case 4:
  64. if ($param["publicState"]) {
  65. $where[] = ["publicState", "=", $param["publicState"]];
  66. }
  67. $where[] = ["checkState", "in", [-1, 30]];
  68. break;
  69. }
  70. $count = TaModel::where($where)->count();
  71. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  72. $list = $this->translateChinese($list);
  73. return json(["rows" => $list, "total" => $count]);
  74. }
  75. public function toCheckPage() {
  76. $id = $this->request["id"];
  77. $process = $this->request["process"];
  78. $obj = TalentAllowanceApi::getInfoById($id);
  79. $this->translateToChinese($obj);
  80. return view("info", ["row" => $obj, "process" => $process]);
  81. }
  82. /**
  83. * 审核
  84. */
  85. public function check() {
  86. $obj = $this->request->param();
  87. if (!$obj["checkState"]) {
  88. return new Response(Response::ERROR, "请选择审核状态");
  89. }
  90. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  91. $newObj = [];
  92. $newObj["id"] = $obj["id"];
  93. if ($obj["process"] == 1) {
  94. List<String> projectList = FengStringUtil.isEmpOrNull(oldObj.getProjects()) ? new ArrayList<>() : new ArrayList<>(Arrays.asList(oldObj.getProjects().split(",")));
  95. List<String> fileList = FengStringUtil.isEmpOrNull(oldObj.getFiles()) ? new ArrayList<>() : new ArrayList<>(Arrays.asList(oldObj.getFiles().split(",")));
  96. if (FengStringUtil.isNotEmpAndNull(obj.getProjects())) {
  97. List<String> newList = new ArrayList<>(Arrays.asList(obj.getProjects().split(",")));
  98. projectList.removeAll(newList);
  99. projectList.addAll(newList);
  100. }
  101. if (FengStringUtil.isNotEmpAndNull(obj.getFiles())) {
  102. List<String> newList = new ArrayList<>(Arrays.asList(obj.getFiles().split(",")));
  103. fileList.removeAll(newList);
  104. fileList.addAll(newList);
  105. }
  106. newObj.setProjects(projectList.stream().collect(Collectors.joining(",")));
  107. newObj.setFiles(fileList.stream().collect(Collectors.joining(",")));
  108. if (Const.RSJ.equals(checkCompany.getCode())) {
  109. newObj.setConcats(obj.getConcats());
  110. newObj.setFields(obj.getFields());
  111. }
  112. }
  113. if ($obj["process"] == 3) {
  114. $newObj["toProcess"] = $obj["toProcess"];
  115. $newObj["toDep"] = $obj["toDep"];
  116. }
  117. this.talentAllowanceInfoService.updateById(newObj);
  118. TalentChecklog log = new TalentChecklog(ProjectEnum.JBT.getCode(), obj.getId(), null,
  119. StateConst.ACTIVE_NO, checkState, obj.getProcess(), null, obj.getCheckMsg(),
  120. DateUtil.getTime(), ShiroKit.getUser().getAccount() + "(" + company.getName() + ")");
  121. if (obj.getProcess() == AllowanceStepEnum.JBT_STEP_FIRST.getCode()) {
  122. log.setCompanyId(obj.getCompanyId());
  123. }
  124. this.talentChecklogService.insert(log);
  125. return new ResponseObj(ResponseObj.SUCCESS, "审核成功");
  126. }
  127. /**
  128. * 校验是否在审核范围内
  129. */
  130. public function validateIsCheck() {
  131. $id = $this->request["id"];
  132. $type = $this->request["type"];
  133. $process = $this->request["process"];
  134. $info = null;
  135. switch ($type) {
  136. case 1: //编辑合同
  137. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  138. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  139. break;
  140. case 2: //编辑项目
  141. $project = \app\common\model\TalentAllowanceProject::find($id);
  142. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  143. break;
  144. case 3:
  145. $info = TalentAllowanceApi::getInfoById($id);
  146. break;
  147. }
  148. if (!$info) {
  149. return new Response(Response::ERROR, "校验不通过,无法操作");
  150. }
  151. $where = [];
  152. $where[] = ["mainId", "=", $info["id"]];
  153. $where[] = ["step", "=", $process];
  154. $where[] = ["active", "=", 2];
  155. $log = null;
  156. switch ($process) {
  157. case 1:
  158. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  159. return new Response(Response::ERROR, "不在审核范围内");
  160. }
  161. //$where[] = ["companyId","=",$this->user["companyId"]];
  162. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  163. break;
  164. case 2:
  165. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  166. return new Response(Response::ERROR, "不在审核范围内");
  167. }
  168. break;
  169. case 3:
  170. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  171. return new Response(Response::ERROR, "不在审核范围内");
  172. }
  173. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  174. break;
  175. }
  176. if ($log != null) {
  177. $info["checkState"] = $log["state"];
  178. $info["checkMsg"] = $log["description"];
  179. } else {
  180. $info["checkState"] = null;
  181. $info["checkMsg"] = "";
  182. }
  183. $res = [];
  184. $res["info"] = $info;
  185. if ($type == 3) {
  186. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  187. $where = [];
  188. $where[] = ["mainId", "=", $id];
  189. $where[] = ["isLock", "=", 1];
  190. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  191. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  192. $detailMap = array_reduce($detailList, function ($result, $item) {
  193. $key = $item["id"];
  194. $result[$key] = $item;
  195. return $result;
  196. }, []);
  197. foreach ($detailList as &$detail) {
  198. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  199. }unset($detail);
  200. foreach ($projectList as &$project) {
  201. $detail = $detailMap[$project["baseId"]];
  202. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  203. }
  204. $where = [];
  205. $where[] = ["type", "=", $info["type"]];
  206. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  207. $where[] = ["active", "=", 1];
  208. $where[] = ["delete", "=", 0];
  209. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  210. $res["files"] = $filetypes;
  211. $res["projects"] = $projectList;
  212. $res["concats"] = $detailList;
  213. }
  214. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  215. }
  216. /**
  217. * 查询工作单位
  218. */
  219. public function findAllowanceContractDetail() {
  220. $mainId = $this->request["mainId"];
  221. $offset = $this->request["offset"] ?: 0;
  222. $limit = $this->request["limit"] ?: 1000;
  223. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  224. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  225. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  226. foreach ($list as &$row) {
  227. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  228. }unset($row);
  229. return json(["rows" => $list, "total" => $count]);
  230. }
  231. /**
  232. * 查询核查项目情况
  233. */
  234. public function findAllowanceProject() {
  235. $mainId = $this->request["mainId"];
  236. $baseId = $this->request["baseId"];
  237. $offset = $this->request["offset"] ?: 0;
  238. $limit = $this->request["limit"] ?: 1000;
  239. $where = [];
  240. $where[] = ["mainId", "=", $mainId];
  241. $where[] = ["baseId", "=", $baseId];
  242. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  243. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  244. $info = TalentAllowanceApi::getInfoById($mainId);
  245. foreach ($list as &$project) {
  246. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  247. if ($info["checkState"] == 1) {
  248. $project["isEdit"] = in_array($project["project"], [
  249. AllowanceProjectEnum::PROJECT_CONTRACT,
  250. AllowanceProjectEnum::PROJECT_TAX,
  251. AllowanceProjectEnum::PROJECT_WAGES,
  252. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  253. AllowanceProjectEnum::PROJECT_SB_PENSION,
  254. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  255. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  256. AllowanceProjectEnum::PROJECT_WORKDAY
  257. ]) ? 1 : 2;
  258. } else if ($info["checkState"] == 10) {
  259. $projects = explode(",", $info["projects"]);
  260. if (in_array($project["id"], $projects)) {
  261. $project["isEdit"] = 1;
  262. } else {
  263. $project["isEdit"] = 2;
  264. }
  265. } else {
  266. $project["isEdit"] = 2;
  267. }
  268. }unset($project);
  269. return json(["rows" => $list, "total" => $count]);
  270. }
  271. /**
  272. * 查询人才层次变更记录
  273. */
  274. public function findAllowanceArrange() {
  275. $mainId = $this->request["mainId"];
  276. $offset = $this->request["offset"] ?: 0;
  277. $limit = $this->request["limit"] ?: 1000;
  278. $where = [];
  279. $where[] = ["mainId", "=", $mainId];
  280. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  281. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  282. foreach ($list as &$arrange) {
  283. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  284. $arrange["identifyConditionText"] = $condition["name"];
  285. $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  286. }unset($arrange);
  287. return json(["rows" => $list, "total" => $count]);
  288. }
  289. private function setTalentAllowanceInfo($where, $query, $process) {
  290. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  291. $where[] = ["year", "=", $query["year"]];
  292. }
  293. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  294. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  295. }
  296. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  297. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  298. }
  299. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  300. $where[] = ["talentType", "=", $query["talentType"]];
  301. }
  302. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  303. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  304. }
  305. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  306. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  307. }
  308. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  309. $where[] = ["address", "=", $query["address"]];
  310. }
  311. if ($query["recommendAllowanceType"]) {
  312. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  313. }
  314. if ($query["publicState"]) {
  315. $where[] = ["publicState", "=", $query["publicState"]];
  316. }
  317. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  318. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  319. }
  320. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  321. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  322. }
  323. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  324. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  325. }
  326. if ($process == 4) {
  327. if ($query["isSupple"]) {
  328. $where[] = ["isSupple", "=", $query["isSupple"]];
  329. }
  330. if ($query["isPublicCheck"]) {
  331. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  332. }
  333. }
  334. if ($query["checkState"]) {
  335. if ($query["checkState"] == -1) {
  336. $where[] = ["checkState", "=", $query["checkState"]];
  337. } else {
  338. if ($process == 1) {
  339. switch ($query["checkState"]) {
  340. case 0: //保存未提交
  341. $where[] = ["checkState", "=", 1];
  342. break;
  343. case 1:
  344. $where[] = ["checkState", "=", 5];
  345. break;
  346. case 2: //驳回
  347. $where[] = ["checkState", "=", 10];
  348. break;
  349. case 3: //通过
  350. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  351. break;
  352. case 4: //重新提交
  353. $where[] = ["checkState", "=", 5];
  354. $where[] = ["highProcess", ">=", $process];
  355. break;
  356. case 5: //上级驳回
  357. $where[] = ["checkState", "=", 13];
  358. break;
  359. }
  360. }
  361. if ($process == 2) {
  362. switch ($query["checkState"]) {
  363. case 1:
  364. $where[] = ["checkState", "=", 15];
  365. break;
  366. case 2: //驳回
  367. $where[] = ["checkState", "in", [1, 5, 10]];
  368. $where[] = ["highProcess", ">=", $process];
  369. break;
  370. case 3: //通过
  371. $where[] = ["checkState", "in", [20, 30]];
  372. break;
  373. case 9: //重新提交
  374. $where[] = ["checkState", "=", 15];
  375. $where[] = ["highProcess", ">=", $process];
  376. break;
  377. case 4: //上级驳回
  378. $where[] = ["checkState", "=", 25];
  379. break;
  380. case -1:
  381. $where[] = ["checkState", "=", -1];
  382. break;
  383. }
  384. }
  385. if ($process == 3) {
  386. switch ($query["checkState"]) {
  387. case -1:
  388. $where[] = ["checkState", "=", -1];
  389. break;
  390. case 1:
  391. $where[] = ["checkState", "=", 20];
  392. break;
  393. case 2: //驳回
  394. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  395. $where[] = ["highProcess", ">=", $process];
  396. break;
  397. case 3: //通过
  398. $where[] = ["checkState", "=", 30];
  399. break;
  400. case 9: //重新提交
  401. $where[] = ["checkState", "=", 20];
  402. $where[] = ["highProcess", ">=", $process];
  403. break;
  404. case 4: //上级驳回
  405. $where[] = ["checkState", "=", 35];
  406. break;
  407. }
  408. }
  409. if ($process == 4) {
  410. switch ($query["checkState"]) {
  411. case -1:
  412. $where[] = ["checkState", "=", -1];
  413. break;
  414. case 3: //通过
  415. $where[] = ["checkState", "=", 30];
  416. break;
  417. }
  418. }
  419. }
  420. }
  421. return $where;
  422. }
  423. private function translateToChinese(&$obj) {
  424. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  425. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  426. }
  427. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  428. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  429. }
  430. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  431. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  432. }
  433. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  434. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  435. }
  436. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  437. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  438. }
  439. }
  440. private function translateChinese($list) {
  441. //获取字典表
  442. $levelMap = DictApi::selectByParentCode("talent_arrange");
  443. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  444. $streetMap = DictApi::selectByParentCode("street");
  445. $cardTypeMap = DictApi::selectByParentCode("card_type");
  446. $modeMap = DictApi::selectByParentCode("import_way");
  447. $where = [];
  448. $where[] = ["type", "=", $this->user["type"]];
  449. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  450. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  451. foreach ($list as &$info) {
  452. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  453. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  454. }
  455. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  456. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  457. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  458. }
  459. $info["addressName"] = $streetMap[$info["address"]];
  460. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  461. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  462. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  463. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  464. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  465. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  466. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  467. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  468. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  469. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  470. }unset($info);
  471. return $list;
  472. }
  473. }