TalentBasicChange.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\model\TalentBasicChange as TbcModel;
  5. use app\common\api\DictApi;
  6. use app\common\state\MainState;
  7. use app\common\model\TalentLog;
  8. use app\common\state\ProjectState;
  9. use think\facade\Db;
  10. /**
  11. * Description of TalentBasicChange
  12. *
  13. * @author sgq
  14. */
  15. class TalentBasicChange extends AdminController {
  16. public function index() {
  17. return view("", ["type" => $this->user["type"]]);
  18. }
  19. public function list() {
  20. $params = $this->request->param();
  21. $offset = $params["offset"] ?: 0;
  22. $order = $params["order"] ?: "desc";
  23. $limit = $params["limit"] ?: 10;
  24. $where = $this->setTalentBasic($params);
  25. $where[] = ["type", "=", $this->user["type"]];
  26. $where[] = ["delete", "=", 0];
  27. $count = TbcModel::where($where)->count();
  28. $list = TbcModel::where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
  29. $nationalityMap = DictApi::selectByParentCode("nationality");
  30. $nationMap = DictApi::selectByParentCode("nation");
  31. $politicalMap = DictApi::selectByParentCode("politics");
  32. $cardTypeMap = DictApi::selectByParentCode("card_type");
  33. $epMaps = \app\common\model\Enterprise::column("name", "id");
  34. foreach ($list as $key => $item) {
  35. $list[$key]["oldNationalityName"] = $nationalityMap[$item["oldNationality"]];
  36. $list[$key]["oldNationName"] = $nationMap[$item["oldNation"]];
  37. $list[$key]["oldPoliticsName"] = $politicalMap[$item["oldPolitics"]];
  38. $list[$key]["oldCardTypeName"] = $cardTypeMap[$item["oldCardType"]];
  39. $list[$key]["newNationalityName"] = $nationalityMap[$item["newNationality"]];
  40. $list[$key]["newNationName"] = $nationMap[$item["newNation"]];
  41. $list[$key]["newPoliticsName"] = $politicalMap[$item["newPolitics"]];
  42. $list[$key]["newCardTypeName"] = $cardTypeMap[$item["newCardType"]];
  43. $list[$key]["enterpriseName"] = $epMaps[$item["enterpriseId"]];
  44. if ($item["checkState"] == -1) {
  45. $list[$key]["checkStateName"] = "待提交";
  46. }
  47. if ($item["checkState"] == 1) {
  48. $list[$key]["checkStateName"] = "待审核";
  49. }
  50. if ($item["checkState"] == 2) {
  51. $list[$key]["checkStateName"] = "审核驳回";
  52. }
  53. if ($item["checkState"] == 3) {
  54. $list[$key]["checkStateName"] = "已通过";
  55. }
  56. if ($item["checkState"] == 9) {
  57. $list[$key]["checkStateName"] = "重新提交";
  58. }
  59. }
  60. return json(["rows" => $list, "total" => $count]);
  61. }
  62. public function check() {
  63. $id = $this->request["id"];
  64. $info = TbcModel::where("id", $id)->find();
  65. return view("check", ["type" => $this->user["type"], "row" => $info]);
  66. }
  67. public function submitToCheck() {
  68. $responseObj = new \stdClass();
  69. $responseObj->code = 500;
  70. $id = $this->request["id"];
  71. $checkState = $this->request["checkState"];
  72. $checkMsg = $this->request["checkMsg"];
  73. $info = TbcModel::where("id", $id)->find();
  74. if (!$info) {
  75. $responseObj->msg = "系统错误,请联系管理员";
  76. return $responseObj;
  77. }
  78. if (!$checkState) {
  79. $responseObj->msg = "请选择审核状态";
  80. return $responseObj;
  81. }
  82. Db::startTrans();
  83. try {
  84. //添加日志
  85. $user = $this->user;
  86. $log["id"] = getStringId();
  87. $log["active"] = 1;
  88. $log["state"] = $checkState;
  89. $log["step"] = 11;
  90. $log["stateChange"] = MainState::getStateName($info["checkState"]) . "->" . MainState::getStateName($checkState);
  91. $log["type"] = ProjectState::BASICCHANGE;
  92. $log["mainId"] = $id;
  93. $log["description"] = $checkMsg;
  94. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  95. $log["createTime"] = date("Y-m-d H:i:s");
  96. $updTalentBasic["id"] = $id;
  97. $updTalentBasic["checkState"] = $checkState;
  98. $updTalentBasic["checkMsg"] = $checkMsg;
  99. if ($checkState == 3) {
  100. //修改人才库信息
  101. $upd["id"] = $info["talentId"];
  102. $upd["name"] = $info["newName"];
  103. $upd["birthday"] = $info["newBirthday"];
  104. $upd["nationality"] = $info["newNationality"];
  105. $upd["nation"] = $info["newNation"];
  106. $upd["politics"] = $info["newPolitics"];
  107. $upd["card_type"] = $info["newCardType"];
  108. $upd["card_number"] = $info["newIdCard"];
  109. $upd["email"] = $info["newEmail"];
  110. Db::table("new_talent_info")->save($upd);
  111. $talentLog["id"] = getStringId();
  112. $talentLog["active"] = 1;
  113. $talentLog["step"] = 24;
  114. $talentLog["type"] = ProjectState::TALENT;
  115. $talentLog["mainId"] = $info["talentId"];
  116. $talentLog["description"] = "基础信息变更通过,同步到人才库";
  117. $talentLog["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  118. $talentLog["createTime"] = date("Y-m-d H:i:s");
  119. Db::table("new_talent_checklog")->insert($talentLog);
  120. }
  121. Db::table("new_talent_checklog")->insert($log);
  122. Db::table("un_talent_basic_change")->save($updTalentBasic);
  123. $responseObj->code = 200;
  124. $responseObj->msg = "审核成功";
  125. Db::commit();
  126. return $responseObj;
  127. } catch (\think\db\exception\DbException $e) {
  128. $responseObj->msg = $e->getMessage();
  129. Db::rollback();
  130. return $responseObj;
  131. }
  132. }
  133. private function setTalentBasic($talentBasicInfo) {
  134. $where = [];
  135. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["enterpriseName"])) {
  136. $whr = [];
  137. $whr[] = ["name", "like", "%{$talentBasicInfo["enterpriseName"]}%"];
  138. $ids = \app\common\model\Enterprise::where($whr)->column("id");
  139. $where[] = ["enterpriseName", "in", $ids];
  140. }
  141. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldName"])) {
  142. $where[] = ["oldName", "like", "%" . $talentBasicInfo["oldName"] . "%"];
  143. }
  144. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldCardType"])) {
  145. $where[] = ["oldCardType", "=", $talentBasicInfo["oldCardType"]];
  146. }
  147. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldIdCard"])) {
  148. $where[] = ["oldIdCard", "like", "%" . $talentBasicInfo["oldIdCard"] . "%"];
  149. }
  150. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newName"])) {
  151. $where[] = ["newName", "like", "%" . $talentBasicInfo["newName"] . "%"];
  152. }
  153. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newCardType"])) {
  154. $where[] = ["newCardType", "=", $talentBasicInfo["newCardType"]];
  155. }
  156. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newIdCard"])) {
  157. $where[] = ["newIdCard", "like", "%" . $talentBasicInfo["newIdCard"] . "%"];
  158. }
  159. if ($talentBasicInfo["checkState"] != null) {
  160. $where[] = ["checkState", "=", $talentBasicInfo["checkState"]];
  161. }
  162. return $where;
  163. }
  164. }