TalentBasicChange.php 7.6 KB

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