TalentBasicChange.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. public function export() {
  134. $request = $this->request;
  135. $data["enterpriseName"] = \StrUtil::getRequestDecodeParam($request, "enterpriseName");
  136. $data["oldName"] = \StrUtil::getRequestDecodeParam($request, "oldName");
  137. $data["oldCardType"] = \StrUtil::getRequestDecodeParam($request, "oldCardType");
  138. $data["oldIdCard"] = \StrUtil::getRequestDecodeParam($request, "oldIdCard");
  139. $data["newName"] = \StrUtil::getRequestDecodeParam($request, "newName");
  140. $data["newCardType"] = \StrUtil::getRequestDecodeParam($request, "newCardType");
  141. $data["newIdCard"] = \StrUtil::getRequestDecodeParam($request, "newIdCard");
  142. $data["checkState"] = \StrUtil::getRequestDecodeParam($request, "checkState");
  143. $where = $this->setTalentBasic($data);
  144. $where[] = ["type", "=", $this->user["type"]];
  145. $where[] = ["delete", "=", 0];
  146. $list = TbcModel::where($where)->select()->toArray();
  147. $nationalityMap = DictApi::selectByParentCode("nationality");
  148. $nationMap = DictApi::selectByParentCode("nation");
  149. $politicalMap = DictApi::selectByParentCode("politics");
  150. $cardTypeMap = DictApi::selectByParentCode("card_type");
  151. $epMaps = \app\common\model\Enterprise::column("name", "id");
  152. $title = ["申报单位", "原姓名", "原出生日期", "原国家/地区", "原民族", "原政治面貌", "原证件类型", "原证件号码", "原电子邮箱",
  153. "现姓名", "现出生日期", "现国家/地区", "现民族", "现政治面貌", "现证件类型", "现证件号码", "现电子邮箱", "首次提交时间", "最新提交时间", "审核状态"];
  154. $keys = ["enterpriseName", "oldName", "oldBirthday", "oldNationalityName", "oldNationName", "oldPoliticsName", "oldCardTypeName", "oldIdCard", "oldEmail",
  155. "newName", "newBirthday", "newNationalityName", "newNationName", "newPoliticsName", "newCardTypeName", "newIdCard", "newEmail", "firstSubmitTime", "newSubmitTime", "checkStateName"];
  156. $rows = [];
  157. foreach ($list as &$item) {
  158. $item["oldNationalityName"] = $nationalityMap[$item["oldNationality"]];
  159. $item["oldNationName"] = $nationMap[$item["oldNation"]];
  160. $item["oldPoliticsName"] = $politicalMap[$item["oldPolitics"]];
  161. $item["oldCardTypeName"] = $cardTypeMap[$item["oldCardType"]];
  162. $item["newNationalityName"] = $nationalityMap[$item["newNationality"]];
  163. $item["newNationName"] = $nationMap[$item["newNation"]];
  164. $item["newPoliticsName"] = $politicalMap[$item["newPolitics"]];
  165. $item["newCardTypeName"] = $cardTypeMap[$item["newCardType"]];
  166. $item["enterpriseName"] = $epMaps[$item["enterpriseId"]];
  167. switch ($item["checkState"]) {
  168. case -1:
  169. $item["checkStateName"] = "待提交";
  170. break;
  171. case 1:
  172. $item["checkStateName"] = "待审核";
  173. break;
  174. case 2:
  175. $item["checkStateName"] = "审核驳回";
  176. break;
  177. case 3:
  178. $item["checkStateName"] = "已通过";
  179. break;
  180. case 9:
  181. $item["checkStateName"] = "重新提交";
  182. break;
  183. }
  184. $row = [];
  185. for ($i = 0; $i < count($keys); $i++) {
  186. $row[] = $item[$keys[$i]];
  187. }
  188. $rows[] = $row;
  189. }unset($item);
  190. if (!$rows) {
  191. return json(["msg" => "没有可导出的内容"]);
  192. }
  193. $fileName = "基础信息变更列表";
  194. export($title, $rows, $fileName);
  195. }
  196. private function setTalentBasic($talentBasicInfo) {
  197. $where = [];
  198. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["enterpriseName"])) {
  199. $whr = [];
  200. $whr[] = ["name", "like", "%{$talentBasicInfo["enterpriseName"]}%"];
  201. $ids = \app\common\model\Enterprise::where($whr)->column("id");
  202. $where[] = ["enterpriseName", "in", $ids];
  203. }
  204. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldName"])) {
  205. $where[] = ["oldName", "like", "%" . $talentBasicInfo["oldName"] . "%"];
  206. }
  207. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldCardType"])) {
  208. $where[] = ["oldCardType", "=", $talentBasicInfo["oldCardType"]];
  209. }
  210. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldIdCard"])) {
  211. $where[] = ["oldIdCard", "like", "%" . $talentBasicInfo["oldIdCard"] . "%"];
  212. }
  213. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newName"])) {
  214. $where[] = ["newName", "like", "%" . $talentBasicInfo["newName"] . "%"];
  215. }
  216. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newCardType"])) {
  217. $where[] = ["newCardType", "=", $talentBasicInfo["newCardType"]];
  218. }
  219. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newIdCard"])) {
  220. $where[] = ["newIdCard", "like", "%" . $talentBasicInfo["newIdCard"] . "%"];
  221. }
  222. if ($talentBasicInfo["checkState"] != null) {
  223. $where[] = ["checkState", "=", $talentBasicInfo["checkState"]];
  224. }
  225. return $where;
  226. }
  227. }