TalentAllowance.php 21 KB

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