TalentAllowance.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. use app\common\api\Response;
  6. use app\common\api\DictApi;
  7. use app\common\api\TalentAllowanceApi;
  8. use app\common\api\TalentLogApi;
  9. use app\common\model\TalentAllowance as TaModel;
  10. use app\common\model\TalentChecklog;
  11. use app\common\model\TalentAllowanceArrange;
  12. use app\common\state\ProjectState;
  13. use app\common\state\AllowanceStateEnum;
  14. use app\common\state\AllowanceProjectEnum;
  15. /**
  16. * Description of TalentAllowance
  17. *
  18. * @author sgq
  19. */
  20. class TalentAllowance extends AdminController {
  21. public function index() {
  22. $process = $this->request["process"];
  23. $type = $this->user["type"];
  24. $assigns = ["process" => $process, "type" => $type];
  25. if ($process == 4) {
  26. if ($type == 1) {
  27. $msgBody["typeName"] = "晋江市优秀人才津补贴申报";
  28. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  29. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  30. $msgBody["phone"] = "0595-85633128";
  31. $msgBody["email"] = "jjrc85661234@163.com";
  32. }
  33. if ($type == 2) {
  34. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  35. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  36. $msgBody["dep"] = "集成电路产业园区";
  37. $msgBody["phone"] = "0595-82250007、0595-82250001";
  38. $msgBody["email"] = "jjjcdr@163.com";
  39. }
  40. $assigns["message"] = $msgBody;
  41. }
  42. return view("", $assigns);
  43. }
  44. /**
  45. * 获取优秀人才津补贴列表
  46. */
  47. public function list() {
  48. $param = $this->request->param();
  49. $offset = $param["offset"] ?: 0;
  50. $limit = $param["limit"] ?: 10;
  51. $process = $param["process"];
  52. $where = [];
  53. $where[] = ["type", "=", $this->user["type"]];
  54. $order = "newSubmitTime desc";
  55. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  56. switch ($process) {
  57. case 1:
  58. $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  59. break;
  60. case 2:
  61. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  62. break;
  63. case 3:
  64. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  65. break;
  66. case 4:
  67. if ($param["publicState"]) {
  68. $where[] = ["publicState", "=", $param["publicState"]];
  69. }
  70. $where[] = ["checkState", "in", [-1, 30]];
  71. break;
  72. }
  73. $count = TaModel::where($where)->count();
  74. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  75. $list = $this->translateChinese($list);
  76. return json(["rows" => $list, "total" => $count]);
  77. }
  78. public function toCheckPage() {
  79. $id = $this->request["id"];
  80. $process = $this->request["process"];
  81. $obj = TalentAllowanceApi::getInfoById($id);
  82. $this->translateToChinese($obj);
  83. return view("info", ["row" => $obj, "process" => $process]);
  84. }
  85. /**
  86. * 审核
  87. */
  88. public function check() {
  89. $obj = $this->request->param();
  90. if (!$obj["checkState"]) {
  91. return new Response(Response::ERROR, "请选择审核状态");
  92. }
  93. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  94. if (!$oldObj) {
  95. return new Response(Response::ERROR, "审核对象不存在");
  96. }
  97. $newObj = [];
  98. $newObj["id"] = $obj["id"];
  99. $projectList = [];
  100. $fileList = [];
  101. if ($obj["process"] == 1) {
  102. if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
  103. $projectList = array_filter(explode(",", $obj["projects"]));
  104. $newObj["projects"] = implode(",", $projectList);
  105. }
  106. if (\StrUtil::isNotEmpAndNull($obj["files"])) {
  107. $fileList = array_filter(explode(",", $obj["files"]));
  108. $newObj["files"] = implode(",", $fileList);
  109. }
  110. //if (Const.RSJ.equals(checkCompany.getCode())) {
  111. $newObj["concats"] = $obj["concats"];
  112. $newObj["fields"] = $obj["fields"];
  113. //}
  114. }
  115. if ($obj["process"] == 3) {
  116. $newObj["toProcess"] = $obj["toProcess"];
  117. $newObj["toDep"] = $obj["toDep"];
  118. }
  119. TaModel::update($newObj);
  120. //添加日志
  121. TalentChecklog::create([
  122. 'id' => getStringId(),
  123. 'mainId' => $obj['id'],
  124. 'type' => intval(ProjectState::JBT),
  125. 'typeFileId' => null,
  126. 'active' => 2,
  127. 'state' => $obj["checkState"],
  128. 'step' => $obj["process"],
  129. 'stateChange' => null,
  130. 'description' => $obj["checkMsg"],
  131. 'createTime' => date("Y-m-d H:i:s", time()),
  132. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  133. ]);
  134. return new Response(Response::SUCCESS, "审核成功");
  135. }
  136. public function submitCheck() {
  137. $id = $this->request["id"];
  138. $process = $this->request["process"];
  139. $old = TalentAllowanceApi::getInfoById($id);
  140. if (!$old) {
  141. return new Response(Response::ERROR, "审核对象不存在");
  142. }
  143. $updCheck = [];
  144. $updCheck["id"] = $id;
  145. /* * 查询审核日志 */
  146. $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process);
  147. if (!$log) {
  148. return new Response(Response::ERROR, "请先审核后再提交");
  149. }
  150. $updCheck["checkMsg"] = $log["description"];
  151. /* * 判断到达的最高流程 */
  152. $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["process"];
  153. switch ($process) {
  154. case 1:
  155. switch ($log["state"]) {
  156. case 3:
  157. $updCheck["firstPassTime"] = $old["firstPassTime"];
  158. if (!$old["firstPassTime"]) {
  159. $updCheck["firstPassTime"] = date("Y-m-d H:i:s");
  160. }
  161. $updCheck["submitTime"] = date("Y-m-d H:i:s");
  162. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  163. break;
  164. case 2:
  165. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT;
  166. break;
  167. case -1:
  168. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  169. $updCheck["recommendAllowanceType"] = 3;
  170. $updCheck["recommendMoney"] = 0;
  171. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  172. break;
  173. default:
  174. return new Response(Response::ERROR, "未知的审核状态");
  175. }
  176. //添加日志
  177. TalentChecklog::create([
  178. 'id' => getStringId(),
  179. 'mainId' => $id,
  180. 'type' => intval(ProjectState::JBT),
  181. 'typeFileId' => null,
  182. 'active' => 1,
  183. 'state' => $log["state"],
  184. 'step' => $process,
  185. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  186. 'description' => $log["checkMsg"],
  187. 'createTime' => date("Y-m-d H:i:s", time()),
  188. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  189. ]);
  190. break;
  191. case 2:
  192. if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  193. return new Response(Response::ERROR, "不在审核范围内");
  194. }
  195. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  196. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  197. //添加日志
  198. TalentChecklog::create([
  199. 'id' => getStringId(),
  200. 'mainId' => $id,
  201. 'type' => intval(ProjectState::JBT),
  202. 'typeFileId' => null,
  203. 'active' => 1,
  204. 'state' => 3,
  205. 'step' => $process,
  206. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  207. 'description' => "走访核查提交审核",
  208. 'createTime' => date("Y-m-d H:i:s", time()),
  209. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  210. ]);
  211. break;
  212. case 3:
  213. switch ($log["state"]) {
  214. case 3:
  215. $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS;
  216. $updCheck["reviewPassTime"] = date("Y-m-d H:i:s");
  217. /* * * 在此处需要判断津补贴类型 */
  218. $arrangeList = $this->validateAllowanceType(&$updCheck);
  219. TalentAllowanceArrange::update($arrangeList);
  220. break;
  221. case 2:
  222. if ($old["toProcess"] == 1) {
  223. $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST;
  224. } else if ($old["toProcess"] == 2) {
  225. $updCheck["checkState"] = AllowanceStateEnum::REVIEW_REJECT;
  226. }
  227. $updCheck["toProcess"] = null;
  228. $updCheck["toDep"] = "";
  229. break;
  230. case -1:
  231. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  232. $updCheck["recommendAllowanceType"] = 3;
  233. $updCheck["recommendMoney"] = 0;
  234. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  235. break;
  236. default:
  237. return new Response(Response::ERROR, "未知的审核状态");
  238. }
  239. //添加日志
  240. TalentChecklog::create([
  241. 'id' => getStringId(),
  242. 'mainId' => $id,
  243. 'type' => intval(ProjectState::JBT),
  244. 'typeFileId' => null,
  245. 'active' => 1,
  246. 'state' => $log["state"],
  247. 'step' => $process,
  248. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  249. 'description' => $log["checkMsg"],
  250. 'createTime' => date("Y-m-d H:i:s", time()),
  251. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  252. ]);
  253. break;
  254. }
  255. TalentChecklog::delete($log["id"]);
  256. TaModel::update($updCheck);
  257. return new Response(Response::SUCCESS, "提交审核成功");
  258. }
  259. private function validateAllowanceType($info) {
  260. $old = TalentAllowanceApi::getInfoById($info["id"]);
  261. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  262. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  263. /* * 查询工作单位记录 */
  264. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  265. $detaiPdList = []; //用于判定类型
  266. $detailMonthList = []; //用于计算月份
  267. $recommendAllowanceMsg = [];
  268. foreach ($initDetailList as $detail) {
  269. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  270. $projectMap = [];
  271. foreach ($projectList as $project) {
  272. switch ($project["project"]) {
  273. case AllowanceProjectEnum::PROJECT_TAX:
  274. case AllowanceProjectEnum::PROJECT_WAGES:
  275. case AllowanceProjectEnum::PROJECT_SB_PENSION:
  276. case AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT:
  277. case AllowanceProjectEnum::PROJECT_SB_MEDICA:
  278. break;
  279. case AllowanceProjectEnum::PROJECT_ATTENDANCE:
  280. break;
  281. case AllowanceProjectEnum::PROJECT_WORKDAY:
  282. break;
  283. }
  284. $projectMap[$project["project"]] = $project;
  285. }
  286. $detail["list"] = $projectList;
  287. $detail["projectMap"] = $projectMap;
  288. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  289. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  290. /* * 筛选符合条件的人才标签 */
  291. $detaiPdList[] = $detail;
  292. $detailMonthList[] = $detail;
  293. }
  294. // /**查询人才标签字典表*/
  295. // Set<String> retainMonths = new TreeSet<>((o1, o2) -> {
  296. // int o1Int = Integer.parseInt(o1);
  297. // int o2Int = Integer.parseInt(o2);
  298. // return o1Int - o2Int;
  299. // });
  300. // /**集成电路优秀人才*/
  301. // if($this->user["type"] == 2) {
  302. // /**获取各个项目的综合月份*/
  303. // Map<Integer, Set<String>> monthMap = $this->mergeMonth($detailMonthList);
  304. // Map<Integer, Map<String, Integer>> monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList);
  305. // info.setRecommendAllowanceType(1);
  306. // info.setRecommendAllowanceMsg("");
  307. // TalentInfo talentInfo = this.talentInfoService.selectById(info.getTalentId());
  308. // List<TalentAllowanceProject> projectList = this.talentAllowanceProjectService.selectList(new EntityWrapper<TalentAllowanceProject>().eq("mainId", info.getId()));
  309. // Set<String> set = AllowanceICDecideUtil.valideAllowanceType(info, talentInfo, projectList, monthMap, monthAndDayMap);
  310. // info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "\n综合以上所有判断得到最终补贴类型为:");
  311. // if (info.getRecommendAllowanceType() == 1) {
  312. // info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "人才津贴;可享受月份为:" + set.stream().collect(Collectors.joining(",")) + "\n");
  313. // }
  314. // if (info.getRecommendAllowanceType() == 2)
  315. // info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "一次性交通补贴;");
  316. // if (info.getRecommendAllowanceType() == 3)
  317. // info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "不予兑现;");
  318. // retainMonths.addAll(set);
  319. // }
  320. // info.setRecommendMonths(StringUtils.join(retainMonths.toArray(), ","));
  321. // List<TalentAllowanceArrange> arrangeList = calculateAllowance(info, retainMonths, detailMonthList);
  322. // return arrangeList;
  323. }
  324. /**
  325. * 校验是否在审核范围内
  326. */
  327. public function validateIsCheck() {
  328. $id = $this->request["id"];
  329. $type = $this->request["type"];
  330. $process = $this->request["process"];
  331. $info = null;
  332. switch ($type) {
  333. case 1: //编辑合同
  334. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  335. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  336. break;
  337. case 2: //编辑项目
  338. $project = \app\common\model\TalentAllowanceProject::find($id);
  339. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  340. break;
  341. case 3:
  342. $info = TalentAllowanceApi::getInfoById($id);
  343. break;
  344. }
  345. if (!$info) {
  346. return new Response(Response::ERROR, "校验不通过,无法操作");
  347. }
  348. $where = [];
  349. $where[] = ["mainId", "=", $info["id"]];
  350. $where[] = ["step", "=", $process];
  351. $where[] = ["active", "=", 2];
  352. $log = null;
  353. switch ($process) {
  354. case 1:
  355. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  356. return new Response(Response::ERROR, "不在审核范围内");
  357. }
  358. //$where[] = ["companyId","=",$this->user["companyId"]];
  359. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  360. break;
  361. case 2:
  362. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  363. return new Response(Response::ERROR, "不在审核范围内");
  364. }
  365. break;
  366. case 3:
  367. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  368. return new Response(Response::ERROR, "不在审核范围内");
  369. }
  370. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  371. break;
  372. }
  373. if ($log != null) {
  374. $info["checkState"] = $log["state"];
  375. $info["checkMsg"] = $log["description"];
  376. } else {
  377. $info["checkState"] = null;
  378. $info["checkMsg"] = "";
  379. }
  380. $res = [];
  381. $res["info"] = $info;
  382. if ($type == 3) {
  383. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  384. $where = [];
  385. $where[] = ["mainId", "=", $id];
  386. $where[] = ["isLock", "=", 1];
  387. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  388. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  389. $detailMap = array_reduce($detailList, function ($result, $item) {
  390. $key = $item["id"];
  391. $result[$key] = $item;
  392. return $result;
  393. }, []);
  394. foreach ($detailList as &$detail) {
  395. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  396. }unset($detail);
  397. foreach ($projectList as &$project) {
  398. $detail = $detailMap[$project["baseId"]];
  399. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  400. }
  401. $where = [];
  402. $where[] = ["type", "=", $info["type"]];
  403. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  404. $where[] = ["active", "=", 1];
  405. $where[] = ["delete", "=", 0];
  406. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  407. $res["files"] = $filetypes;
  408. $res["projects"] = $projectList;
  409. $res["concats"] = $detailList;
  410. }
  411. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  412. }
  413. /**
  414. * 查询工作单位
  415. */
  416. public function findAllowanceContractDetail() {
  417. $mainId = $this->request["mainId"];
  418. $offset = $this->request["offset"] ?: 0;
  419. $limit = $this->request["limit"] ?: 1000;
  420. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  421. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  422. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  423. foreach ($list as &$row) {
  424. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  425. }unset($row);
  426. return json(["rows" => $list, "total" => $count]);
  427. }
  428. /**
  429. * 查询核查项目情况
  430. */
  431. public function findAllowanceProject() {
  432. $mainId = $this->request["mainId"];
  433. $baseId = $this->request["baseId"];
  434. $offset = $this->request["offset"] ?: 0;
  435. $limit = $this->request["limit"] ?: 1000;
  436. $where = [];
  437. $where[] = ["mainId", "=", $mainId];
  438. $where[] = ["baseId", "=", $baseId];
  439. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  440. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  441. $info = TalentAllowanceApi::getInfoById($mainId);
  442. foreach ($list as &$project) {
  443. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  444. if ($info["checkState"] == 1) {
  445. $project["isEdit"] = in_array($project["project"], [
  446. AllowanceProjectEnum::PROJECT_CONTRACT,
  447. AllowanceProjectEnum::PROJECT_TAX,
  448. AllowanceProjectEnum::PROJECT_WAGES,
  449. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  450. AllowanceProjectEnum::PROJECT_SB_PENSION,
  451. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  452. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  453. AllowanceProjectEnum::PROJECT_WORKDAY
  454. ]) ? 1 : 2;
  455. } else if ($info["checkState"] == 10) {
  456. $projects = explode(",", $info["projects"]);
  457. if (in_array($project["id"], $projects)) {
  458. $project["isEdit"] = 1;
  459. } else {
  460. $project["isEdit"] = 2;
  461. }
  462. } else {
  463. $project["isEdit"] = 2;
  464. }
  465. }unset($project);
  466. return json(["rows" => $list, "total" => $count]);
  467. }
  468. /**
  469. * 查询人才层次变更记录
  470. */
  471. public function findAllowanceArrange() {
  472. $mainId = $this->request["mainId"];
  473. $offset = $this->request["offset"] ?: 0;
  474. $limit = $this->request["limit"] ?: 1000;
  475. $where = [];
  476. $where[] = ["mainId", "=", $mainId];
  477. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  478. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  479. foreach ($list as &$arrange) {
  480. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  481. $arrange["identifyConditionText"] = $condition["name"];
  482. $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  483. }unset($arrange);
  484. return json(["rows" => $list, "total" => $count]);
  485. }
  486. private function setTalentAllowanceInfo($where, $query, $process) {
  487. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  488. $where[] = ["year", "=", $query["year"]];
  489. }
  490. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  491. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  492. }
  493. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  494. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  495. }
  496. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  497. $where[] = ["talentType", "=", $query["talentType"]];
  498. }
  499. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  500. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  501. }
  502. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  503. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  504. }
  505. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  506. $where[] = ["address", "=", $query["address"]];
  507. }
  508. if ($query["recommendAllowanceType"]) {
  509. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  510. }
  511. if ($query["publicState"]) {
  512. $where[] = ["publicState", "=", $query["publicState"]];
  513. }
  514. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  515. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  516. }
  517. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  518. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  519. }
  520. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  521. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  522. }
  523. if ($process == 4) {
  524. if ($query["isSupple"]) {
  525. $where[] = ["isSupple", "=", $query["isSupple"]];
  526. }
  527. if ($query["isPublicCheck"]) {
  528. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  529. }
  530. }
  531. if ($query["checkState"]) {
  532. if ($query["checkState"] == -1) {
  533. $where[] = ["checkState", "=", $query["checkState"]];
  534. } else {
  535. if ($process == 1) {
  536. switch ($query["checkState"]) {
  537. case 0: //保存未提交
  538. $where[] = ["checkState", "=", 1];
  539. break;
  540. case 1:
  541. $where[] = ["checkState", "=", 5];
  542. break;
  543. case 2: //驳回
  544. $where[] = ["checkState", "=", 10];
  545. break;
  546. case 3: //通过
  547. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  548. break;
  549. case 4: //重新提交
  550. $where[] = ["checkState", "=", 5];
  551. $where[] = ["highProcess", ">=", $process];
  552. break;
  553. case 5: //上级驳回
  554. $where[] = ["checkState", "=", 13];
  555. break;
  556. }
  557. }
  558. if ($process == 2) {
  559. switch ($query["checkState"]) {
  560. case 1:
  561. $where[] = ["checkState", "=", 15];
  562. break;
  563. case 2: //驳回
  564. $where[] = ["checkState", "in", [1, 5, 10]];
  565. $where[] = ["highProcess", ">=", $process];
  566. break;
  567. case 3: //通过
  568. $where[] = ["checkState", "in", [20, 30]];
  569. break;
  570. case 9: //重新提交
  571. $where[] = ["checkState", "=", 15];
  572. $where[] = ["highProcess", ">=", $process];
  573. break;
  574. case 4: //上级驳回
  575. $where[] = ["checkState", "=", 25];
  576. break;
  577. case -1:
  578. $where[] = ["checkState", "=", -1];
  579. break;
  580. }
  581. }
  582. if ($process == 3) {
  583. switch ($query["checkState"]) {
  584. case -1:
  585. $where[] = ["checkState", "=", -1];
  586. break;
  587. case 1:
  588. $where[] = ["checkState", "=", 20];
  589. break;
  590. case 2: //驳回
  591. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  592. $where[] = ["highProcess", ">=", $process];
  593. break;
  594. case 3: //通过
  595. $where[] = ["checkState", "=", 30];
  596. break;
  597. case 9: //重新提交
  598. $where[] = ["checkState", "=", 20];
  599. $where[] = ["highProcess", ">=", $process];
  600. break;
  601. case 4: //上级驳回
  602. $where[] = ["checkState", "=", 35];
  603. break;
  604. }
  605. }
  606. if ($process == 4) {
  607. switch ($query["checkState"]) {
  608. case -1:
  609. $where[] = ["checkState", "=", -1];
  610. break;
  611. case 3: //通过
  612. $where[] = ["checkState", "=", 30];
  613. break;
  614. }
  615. }
  616. }
  617. }
  618. return $where;
  619. }
  620. private function translateToChinese(&$obj) {
  621. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  622. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  623. }
  624. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  625. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  626. }
  627. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  628. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  629. }
  630. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  631. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  632. }
  633. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  634. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  635. }
  636. }
  637. private function translateChinese($list) {
  638. //获取字典表
  639. $levelMap = DictApi::selectByParentCode("talent_arrange");
  640. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  641. $streetMap = DictApi::selectByParentCode("street");
  642. $cardTypeMap = DictApi::selectByParentCode("card_type");
  643. $modeMap = DictApi::selectByParentCode("import_way");
  644. $where = [];
  645. $where[] = ["type", "=", $this->user["type"]];
  646. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  647. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  648. foreach ($list as &$info) {
  649. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  650. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  651. }
  652. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  653. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  654. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  655. }
  656. $info["addressName"] = $streetMap[$info["address"]];
  657. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  658. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  659. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  660. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  661. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  662. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  663. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  664. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  665. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  666. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  667. }unset($info);
  668. return $list;
  669. }
  670. }