TalentBasicChange.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. //查看是否有上传旧附件
  66. $_where = [["mainId", "=", $id]];
  67. $old_list = Db::table("un_talent_common_file")->where($_where)->find();
  68. $showOldFile = 0;
  69. if ($old_list) {
  70. $showOldFile = 1;
  71. }
  72. return view("check", ["type" => $this->user["type"], "row" => $info, "showOldFile" => $showOldFile]);
  73. }
  74. public function submitToCheck() {
  75. $responseObj = new \stdClass();
  76. $responseObj->code = 500;
  77. $id = $this->request["id"];
  78. $checkState = $this->request["checkState"];
  79. $checkMsg = $this->request["checkMsg"];
  80. $info = TbcModel::where("id", $id)->find();
  81. if (!$info) {
  82. $responseObj->msg = "系统错误,请联系管理员";
  83. return $responseObj;
  84. }
  85. if (strlen($info["talentId"]) == 19) {
  86. //旧系统申请兼容处理
  87. unset($where);
  88. $where[] = ["enterprise_id", "=", $info["enterpriseId"]];
  89. $where[] = ["card_type", "=", $info["oldCardType"]];
  90. $where[] = ["card_number", "=", $info["oldIdCard"]];
  91. $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  92. $where[] = ["active", "=", 1];
  93. $where[] = ["delete", "=", 0];
  94. $ti = \app\enterprise\model\Talent::where($where)->order("createTime desc")->find();
  95. if (!$ti) {
  96. $responseObj->msg = "未匹配到人才数据";
  97. return $responseObj;
  98. }
  99. $info["talentId"] = $ti["id"];
  100. }
  101. if (!$checkState) {
  102. $responseObj->msg = "请选择审核状态";
  103. return $responseObj;
  104. }
  105. Db::startTrans();
  106. try {
  107. //添加日志
  108. $user = $this->user;
  109. $log["id"] = getStringId();
  110. $log["active"] = 1;
  111. $log["state"] = $checkState;
  112. $log["step"] = 11;
  113. $log["stateChange"] = MainState::getStateName($info["checkState"]) . "->" . MainState::getStateName($checkState);
  114. $log["type"] = ProjectState::BASICCHANGE;
  115. $log["mainId"] = $id;
  116. $log["description"] = $checkMsg;
  117. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  118. $log["createTime"] = date("Y-m-d H:i:s");
  119. $updTalentBasic["id"] = $id;
  120. $updTalentBasic["checkState"] = $checkState;
  121. $updTalentBasic["checkMsg"] = $checkMsg;
  122. if ($checkState == 3) {
  123. //修改人才库信息
  124. $upd["id"] = $info["talentId"];
  125. $upd["name"] = $info["newName"];
  126. $upd["birthday"] = $info["newBirthday"];
  127. $upd["nationality"] = $info["newNationality"];
  128. $upd["nation"] = $info["newNation"];
  129. $upd["politics"] = $info["newPolitics"];
  130. $upd["card_type"] = $info["newCardType"];
  131. $upd["card_number"] = $info["newIdCard"];
  132. $upd["email"] = $info["newEmail"];
  133. $upd["labor_contract_rangetime"] = $info["newContractStartTime"] . " - " . $info["newContractEndTime"];
  134. Db::table("new_talent_info")->save($upd);
  135. $talentLog["id"] = getStringId();
  136. $talentLog["active"] = 1;
  137. $talentLog["step"] = 24;
  138. $talentLog["type"] = ProjectState::TALENT;
  139. $talentLog["mainId"] = $info["talentId"];
  140. $talentLog["description"] = "基础信息变更通过,同步到人才库";
  141. $talentLog["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  142. $talentLog["createTime"] = date("Y-m-d H:i:s");
  143. Db::table("new_talent_checklog")->insert($talentLog);
  144. }
  145. Db::table("new_talent_checklog")->insert($log);
  146. Db::table("un_talent_basic_change")->save($updTalentBasic);
  147. $responseObj->code = 200;
  148. $responseObj->msg = "审核成功";
  149. Db::commit();
  150. return $responseObj;
  151. } catch (\think\db\exception\DbException $e) {
  152. $responseObj->msg = $e->getMessage();
  153. Db::rollback();
  154. return $responseObj;
  155. }
  156. }
  157. public function export() {
  158. $request = $this->request;
  159. $data["enterpriseName"] = \StrUtil::getRequestDecodeParam($request, "enterpriseName");
  160. $data["oldName"] = \StrUtil::getRequestDecodeParam($request, "oldName");
  161. $data["oldCardType"] = \StrUtil::getRequestDecodeParam($request, "oldCardType");
  162. $data["oldIdCard"] = \StrUtil::getRequestDecodeParam($request, "oldIdCard");
  163. $data["newName"] = \StrUtil::getRequestDecodeParam($request, "newName");
  164. $data["newCardType"] = \StrUtil::getRequestDecodeParam($request, "newCardType");
  165. $data["newIdCard"] = \StrUtil::getRequestDecodeParam($request, "newIdCard");
  166. $data["checkState"] = \StrUtil::getRequestDecodeParam($request, "checkState");
  167. $where = $this->setTalentBasic($data);
  168. $where[] = ["type", "=", $this->user["type"]];
  169. $where[] = ["delete", "=", 0];
  170. $list = TbcModel::where($where)->select()->toArray();
  171. $nationalityMap = DictApi::selectByParentCode("nationality");
  172. $nationMap = DictApi::selectByParentCode("nation");
  173. $politicalMap = DictApi::selectByParentCode("politics");
  174. $cardTypeMap = DictApi::selectByParentCode("card_type");
  175. $epMaps = \app\common\model\Enterprise::column("name", "id");
  176. $title = ["申报单位", "原姓名", "原出生日期", "原国家/地区", "原民族", "原政治面貌", "原证件类型", "原证件号码", "原电子邮箱", "原劳动合同起止时间",
  177. "现姓名", "现出生日期", "现国家/地区", "现民族", "现政治面貌", "现证件类型", "现证件号码", "现电子邮箱", "现劳动合同起止时间", "首次提交时间", "最新提交时间", "审核状态"];
  178. $keys = ["enterpriseName", "oldName", "oldBirthday", "oldNationalityName", "oldNationName", "oldPoliticsName", "oldCardTypeName", "oldIdCard", "oldEmail", "oldContractTime",
  179. "newName", "newBirthday", "newNationalityName", "newNationName", "newPoliticsName", "newCardTypeName", "newIdCard", "newEmail", "newContractTime", "firstSubmitTime", "newSubmitTime", "checkStateName"];
  180. $rows = [];
  181. foreach ($list as &$item) {
  182. $item["oldNationalityName"] = $nationalityMap[$item["oldNationality"]];
  183. $item["oldNationName"] = $nationMap[$item["oldNation"]];
  184. $item["oldPoliticsName"] = $politicalMap[$item["oldPolitics"]];
  185. $item["oldCardTypeName"] = $cardTypeMap[$item["oldCardType"]];
  186. $item["newNationalityName"] = $nationalityMap[$item["newNationality"]];
  187. $item["newNationName"] = $nationMap[$item["newNation"]];
  188. $item["newPoliticsName"] = $politicalMap[$item["newPolitics"]];
  189. $item["newCardTypeName"] = $cardTypeMap[$item["newCardType"]];
  190. $item["enterpriseName"] = $epMaps[$item["enterpriseId"]];
  191. switch ($item["checkState"]) {
  192. case -1:
  193. $item["checkStateName"] = "待提交";
  194. break;
  195. case 1:
  196. $item["checkStateName"] = "待审核";
  197. break;
  198. case 2:
  199. $item["checkStateName"] = "审核驳回";
  200. break;
  201. case 3:
  202. $item["checkStateName"] = "已通过";
  203. break;
  204. case 9:
  205. $item["checkStateName"] = "重新提交";
  206. break;
  207. }
  208. $row = [];
  209. for ($i = 0; $i < count($keys); $i++) {
  210. $row[] = $item[$keys[$i]];
  211. }
  212. $rows[] = $row;
  213. }unset($item);
  214. if (!$rows) {
  215. return json(["msg" => "没有可导出的内容"]);
  216. }
  217. $fileName = "基础信息变更列表";
  218. export($title, $rows, $fileName);
  219. }
  220. private function setTalentBasic($talentBasicInfo) {
  221. $where = [];
  222. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["enterpriseName"])) {
  223. $whr = [];
  224. $whr[] = ["name", "like", "%{$talentBasicInfo["enterpriseName"]}%"];
  225. $ids = \app\common\model\Enterprise::where($whr)->column("id");
  226. $where[] = ["enterpriseName", "in", $ids];
  227. }
  228. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldName"])) {
  229. $where[] = ["oldName", "like", "%" . $talentBasicInfo["oldName"] . "%"];
  230. }
  231. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldCardType"])) {
  232. $where[] = ["oldCardType", "=", $talentBasicInfo["oldCardType"]];
  233. }
  234. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["oldIdCard"])) {
  235. $where[] = ["oldIdCard", "like", "%" . $talentBasicInfo["oldIdCard"] . "%"];
  236. }
  237. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newName"])) {
  238. $where[] = ["newName", "like", "%" . $talentBasicInfo["newName"] . "%"];
  239. }
  240. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newCardType"])) {
  241. $where[] = ["newCardType", "=", $talentBasicInfo["newCardType"]];
  242. }
  243. if (\StrUtil::isNotEmpAndNull($talentBasicInfo["newIdCard"])) {
  244. $where[] = ["newIdCard", "like", "%" . $talentBasicInfo["newIdCard"] . "%"];
  245. }
  246. if ($talentBasicInfo["checkState"] != null) {
  247. $where[] = ["checkState", "=", $talentBasicInfo["checkState"]];
  248. }
  249. return $where;
  250. }
  251. }