Ver Fonte

人才层次变更兼容旧数据

sugangqiang há 1 ano atrás
pai
commit
55358d844c

+ 119 - 34
app/admin/controller/TalentTypeChange.php

@@ -12,6 +12,7 @@ use app\common\state\CommonConst;
 use app\common\state\ProjectState;
 use app\common\api\TalentLogApi;
 use app\common\model\TalentChecklog;
+use app\common\api\TalentTypeChangeApi as ttcApi;
 
 class TalentTypeChange extends AdminController {
 
@@ -71,7 +72,7 @@ class TalentTypeChange extends AdminController {
         $where = [];
         $this->setTalentTypeChange($where, $params);
         $this->setTypeChangeCheckStateCondition($where, $params, $process);
-        $whereRaw = "length(talentId) <> 19";
+        //$whereRaw = "length(talentId) <> 19";
         if (in_array($this->user["type"], [1, 2, 5, 6])) {
             $where[] = ["type", "=", $this->user["type"]];
         }
@@ -104,8 +105,8 @@ class TalentTypeChange extends AdminController {
         }
 
         $levelMap = DictApi::selectByParentCode("talent_arrange");
-        $count = ttcModel::whereRaw($whereRaw)->where($where)->count();
-        $list = ttcModel::whereRaw($whereRaw)->where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
+        $count = ttcModel::where($where)->count();
+        $list = ttcModel::where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
         foreach ($list as $key => $item) {
             if ($item["beforeCheckCompany"]) {
                 $list[$key]["beforeCheckCompanyName"] = getCacheById("Company", $item["beforeCheckCompany"]);
@@ -135,7 +136,7 @@ class TalentTypeChange extends AdminController {
     }
 
     public function toCommonCheck($id, $process) {
-        $info = ttcModel::find($id);
+        $info = ttcApi::getOne($id);
         $arrangeMap = DictApi::selectByParentCode("talent_arrange");
         $importMap = DictApi::selectByParentCode("import_way");
         $info["oldTalentArrangeName"] = $arrangeMap[$info["oldTalentArrange"]];
@@ -177,7 +178,7 @@ class TalentTypeChange extends AdminController {
         $response->code = 500;
         $params = $this->request->param();
         $id = $params["id"];
-        $info = ttcModel::find($id);
+        $info = ttcApi::getOne($id);
         if (!$info) {
             $response->msg = "请选择需要修改的对象";
             return $response;
@@ -261,15 +262,19 @@ class TalentTypeChange extends AdminController {
         $process = $this->request->param("process");
         $response = new \stdClass();
         $response->code = 500;
-        $whr = [];
-        $whr[] = ["id", "=", $id];
-        $whr[] = ["type", "=", $this->user["type"]];
-        $whr[] = ["delete", "=", 0];
-        $info = ttcModel::where($whr)->find();
-        if (!$info || strlen($info["talentId"]) == 19) {
+        $info = ttcApi::getOne($id);
+        if (!$info || $info["delete"] == 1 || $info["type"] != $this->user["type"]) {
             $response->msg = "没有对应的人才变更记录";
             return $response;
         }
+        if (!$info["talentId"]) {
+            $response->msg = "没有对应的人才信息";
+            return $response;
+        }
+        if (!$info["newIdentifyCondition"]) {
+            $response->msg = "没有对应的认定条件";
+            return $response;
+        }
         $where = [];
         $where[] = ["step", "=", $process];
         $where[] = ["active", "=", 0];
@@ -437,7 +442,7 @@ class TalentTypeChange extends AdminController {
                     $log["id"] = $lastLog["id"];
                     $log["active"] = 1;
                     $log["state"] = 8;
-                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($checkState);
+                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($data["checkState"]);
                     $log["updateUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
                     $log["updateTime"] = date("Y-m-d H:i:s");
                     Db::table("new_talent_checklog")->update($log);
@@ -465,7 +470,7 @@ class TalentTypeChange extends AdminController {
                     $log["id"] = $lastLog["id"];
                     $log["active"] = 1;
                     $log["state"] = 8;
-                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($checkState);
+                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($data["checkState"]);
                     $log["updateUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
                     $log["updateTime"] = date("Y-m-d H:i:s");
                     Db::table("new_talent_checklog")->update($log);
@@ -518,7 +523,7 @@ class TalentTypeChange extends AdminController {
                     $log["id"] = $lastLog["id"];
                     $log["active"] = 1;
                     $log["state"] = 8;
-                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($checkState);
+                    $log["stateChange"] = MainState::getStateDesc($old["checkState"]) . "->" . MainState::getStateDesc($data["checkState"]);
                     $log["updateUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
                     $log["updateTime"] = date("Y-m-d H:i:s");
                     Db::table("new_talent_checklog")->update($log);
@@ -579,8 +584,8 @@ class TalentTypeChange extends AdminController {
                 $where[] = ["checkState", "in", [35]];
                 break;
         }
-        $whereRaw = "length(talentId)<>19";
-        $list = ttcModel::where($where)->whereRaw($whereRaw)->field("id,idCard,talentName,enterpriseId,checkState")->select()->toArray();
+        //$whereRaw = "length(talentId)<>19";
+        $list = ttcModel::where($where)->field("id,idCard,talentName,enterpriseId,checkState")->select()->toArray();
         //查询企业信息
         $enterprises = \app\common\model\Enterprise::column("name", "id");
         foreach ($list as $key => $item) {
@@ -739,8 +744,12 @@ class TalentTypeChange extends AdminController {
         $ids_arr = array_filter(explode(",", $params["ids"]));
         $columns = ["序号", "姓名", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
         if ($ids_arr) {
-            $where[] = ["ttc.id", "in", $ids_arr];
-            $list = ttcModel::alias("ttc")->leftJoin("new_talent_condition tc", "ttc.newIdentifyCondition=tc.id")->field("ttc.*,tc.name as identifyConditionZH")->where($where)->select()->toArray();
+            $where[] = ["id", "in", $ids_arr];
+            $list = ttcModel::where($where)->select()->toArray();
+
+            $oldIdentifyConditions = [];
+            $newIdentifyConditions = [];
+
             $rows = [];
             $talentArranges = DictApi::selectByParentCode("talent_arrange");
             for ($i = 0; $i < count($list); $i++) {
@@ -763,8 +772,20 @@ class TalentTypeChange extends AdminController {
                 if ($item["checkState"] == MainState::PASS) {
                     $stateName = "审核通过";
                 }
+                $identifyConditionZH = "";
+                if (strlen($item["newIdentifyCondition"]) == 19) {
+                    if (!$oldIdentifyConditions) {
+                        $oldIdentifyConditions = Db::table("un_identify_condition")->where("type", $this->user["type"])->column("name", "id");
+                    }
+                    $identifyConditionZH = $oldIdentifyConditions[$item["newIdentifyCondition"]];
+                } else {
+                    if (!$newIdentifyConditions) {
+                        $newIdentifyConditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+                    }
+                    $identifyConditionZH = $newIdentifyConditions[$item["newIdentifyCondition"]];
+                }
                 $row = [
-                    $i + 1, $item["talentName"], $item["enterpriseName"], $item["identifyConditionZH"], $talentArranges[$item["newTalentArrange"]], $stateName, $description
+                    $i + 1, $item["talentName"], $item["enterpriseName"], $identifyConditionZH, $talentArranges[$item["newTalentArrange"]], $stateName, $description
                 ];
                 $rows[] = $row;
             }
@@ -861,13 +882,17 @@ class TalentTypeChange extends AdminController {
         if (!strtotime($startTime) || !strtotime($endTime))
             return json(["msg" => "时间格式错误"]);
         $where = [];
-        $where[] = ["ttc.type", "=", $this->user["type"]];
+        $where[] = ["type", "=", $this->user["type"]];
         $where[] = ["publicBatch", "between", [$startTime, $endTime]];
-        $list = ttcModel::alias("ttc")->leftJoin("new_talent_condition tc", "ttc.newIdentifyCondition=tc.id")->field("ttc.*,tc.name as identifyConditionZH")->where($where)->order("publicBatch")->select()->toArray();
+        $list = ttcModel::where($where)->order("publicBatch")->select()->toArray();
         if (!$list) {
             $response->msg = "所选时间段内无公示数据";
             return \StrUtil::back($response, "TalentTypeChange.callBack");
         }
+
+        $oldIdentifyConditions = [];
+        $newIdentifyConditions = [];
+
         $rows = [];
         $i = 1;
         $talentArranges = DictApi::selectByParentCode("talent_arrange");
@@ -891,8 +916,20 @@ class TalentTypeChange extends AdminController {
             if ($item["checkState"] == MainState::PASS) {
                 $stateName = "审核通过";
             }
+            $identifyConditionZH = "";
+            if (strlen($item["newIdentifyCondition"]) == 19) {
+                if (!$oldIdentifyConditions) {
+                    $oldIdentifyConditions = Db::table("un_identify_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $oldIdentifyConditions[$item["newIdentifyCondition"]];
+            } else {
+                if (!$newIdentifyConditions) {
+                    $newIdentifyConditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $newIdentifyConditions[$item["newIdentifyCondition"]];
+            }
             $row = [
-                $i + 1, $item["publicBatch"], $item["talentName"], $item["enterpriseName"], $item["newIdentifyMonth"], $item["identifyConditionZH"], $talentArranges[$item["newTalentArrange"]], $stateName, $description
+                $i + 1, $item["publicBatch"], $item["talentName"], $item["enterpriseName"], $item["newIdentifyMonth"], $identifyConditionZH, $talentArranges[$item["newTalentArrange"]], $stateName, $description
             ];
             $rows[] = $row;
         }
@@ -1091,12 +1128,15 @@ class TalentTypeChange extends AdminController {
      */
     public function publishExportBefore($ids) {
         $where = [];
-        $where[] = ["ttc.id", "in", explode(",", $ids)];
-        $list = ttcModel::alias("ttc")->leftJoin("new_talent_condition tc", "ttc.newIdentifyCondition=tc.id")->field("ttc.*,tc.name as identifyConditionZH")->where($where)->select()->toArray();
+        $where[] = ["id", "in", explode(",", $ids)];
+        $list = ttcModel::where($where)->select()->toArray();
         if (!$list) {
             $response->msg = "系统错误,请联系管理员";
             return $response;
         }
+        $oldIdentifyConditions = [];
+        $newIdentifyConditions = [];
+
         $columns = ["序号", "批次", "姓名", "工作单位", "申请认定时间", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
         $rows = [];
         $levelMap = DictApi::selectByParentCode("talent_arrange");
@@ -1121,8 +1161,21 @@ class TalentTypeChange extends AdminController {
                 $stateName = "审核通过";
             }
 
+            $identifyConditionZH = "";
+            if (strlen($obj["newIdentifyCondition"]) == 19) {
+                if (!$oldIdentifyConditions) {
+                    $oldIdentifyConditions = Db::table("un_identify_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $oldIdentifyConditions[$obj["newIdentifyCondition"]];
+            } else {
+                if (!$newIdentifyConditions) {
+                    $newIdentifyConditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $newIdentifyConditions[$obj["newIdentifyCondition"]];
+            }
+
             $rows[] = [
-                $i + 1, $obj["publicBatch"], $obj["talentName"], $obj["enterpriseName"], $obj["newIdentifyMonth"], $obj["identifyConditionZH"], $levelMap[$obj["newTalentArrange"]], $stateName, $description
+                $i + 1, $obj["publicBatch"], $obj["talentName"], $obj["enterpriseName"], $obj["newIdentifyMonth"], $identifyConditionZH, $levelMap[$obj["newTalentArrange"]], $stateName, $description
             ];
         }
         $filename = "人才层次变更公布名单导出";
@@ -1144,13 +1197,17 @@ class TalentTypeChange extends AdminController {
         if (!strtotime($startTime) || !strtotime($endTime))
             return json(["msg" => "时间格式错误"]);
         $where = [];
-        $where[] = ["ttc.type", "=", $this->user["type"]];
+        $where[] = ["type", "=", $this->user["type"]];
         $where[] = ["newIdentifyMonth", "between", [$startTime, $endTime]];
-        $list = ttcModel::alias("ttc")->leftJoin("new_talent_condition tc", "ttc.newIdentifyCondition=tc.id")->field("ttc.*,tc.name as identifyConditionZH")->where($where)->order("newIdentifyMonth")->select()->toArray();
+        $list = ttcModel::where($where)->order("newIdentifyMonth")->select()->toArray();
         if (!$list) {
             $response->msg = "所选时间段内无公布数据";
             return \StrUtil::back($response, "TalentTypeChange.callBack");
         }
+
+        $oldIdentifyConditions = [];
+        $newIdentifyConditions = [];
+
         $rows = [];
         $i = 1;
         $talentArranges = DictApi::selectByParentCode("talent_arrange");
@@ -1174,8 +1231,22 @@ class TalentTypeChange extends AdminController {
             if ($item["checkState"] == MainState::PASS) {
                 $stateName = "审核通过";
             }
+
+            $identifyConditionZH = "";
+            if (strlen($item["newIdentifyCondition"]) == 19) {
+                if (!$oldIdentifyConditions) {
+                    $oldIdentifyConditions = Db::table("un_identify_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $oldIdentifyConditions[$item["newIdentifyCondition"]];
+            } else {
+                if (!$newIdentifyConditions) {
+                    $newIdentifyConditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+                }
+                $identifyConditionZH = $newIdentifyConditions[$item["newIdentifyCondition"]];
+            }
+
             $row = [
-                $i + 1, $item["talentName"], $item["enterpriseName"], $item["newIdentifyMonth"], $item["identifyConditionZH"], $talentArranges[$item["newTalentArrange"]], $stateName, $description
+                $i + 1, $item["talentName"], $item["enterpriseName"], $item["newIdentifyMonth"], $identifyConditionZH, $talentArranges[$item["newTalentArrange"]], $stateName, $description
             ];
             $rows[] = $row;
         }
@@ -1268,6 +1339,7 @@ class TalentTypeChange extends AdminController {
                 $where[] = ["id", "in", $ids];
                 $changeList = ttcModel::where($where)->select()->toArray();
                 $year = date("Y");
+                $translateOldAndNewIdentifyConditionMap = Db::table("un_identify_condition")->alias("o")->leftJoin("new_talent_condition n", "n.name=o.name and n.type=o.type")->where("o.type", $this->user["type"])->column("n.id", "o.id");
                 foreach ($changeList as $change) {
                     if ($change["checkState"] != MainState::PASS || $change["isPublic"] != 5) {
                         Db::rollback();
@@ -1285,7 +1357,11 @@ class TalentTypeChange extends AdminController {
                     }
                     $data["id"] = $change["talentId"];
                     $data["talent_arrange"] = $change["newTalentArrange"];
-                    $data["talent_condition"] = $change["newIdentifyCondition"];
+                    $identifyCondition = $change["newIdentifyCondition"];
+                    if (strlen($identifyCondition) == 19) {
+                        $identifyCondition = $translateOldAndNewIdentifyConditionMap[$identifyCondition];
+                    }
+                    $data["talent_condition"] = $identifyCondition;
                     $data["identifyConditionName"] = $change["newIdentifyConditionName"];
                     $data["source"] = $change["newSource"];
                     $data["source_city"] = $change["newFromCity"];
@@ -1357,7 +1433,7 @@ class TalentTypeChange extends AdminController {
         $response->code = 500;
         $where = [];
         $where[] = ["type", "=", $this->user["type"]];
-        $whereRaw = "length(talentId) <> 19";
+        //$whereRaw = "length(talentId) <> 19";
         $request = $this->request;
         $talentName = \StrUtil::getRequestDecodeParam($request, "talentName");
         $idCard = \StrUtil::getRequestDecodeParam($request, "idCard");
@@ -1425,7 +1501,7 @@ class TalentTypeChange extends AdminController {
                 $where[] = ["isPublic", "=", 6];
                 break;
         }
-        $list = ttcModel::where($where)->whereRaw($whereRaw)->select()->toArray();
+        $list = ttcModel::where($where)->select()->toArray();
         $list = $this->translateToChinese($list, $process);
         $columns = [
             "姓名", "证件号码", "工作单位", "所属街道", "原申报年度", "原申报来源", "原入选来源地级市", "原入选来源县市区", "原人才层次", "原认定条件", "原认定条件证书取得时间", "原认定条件过期时间", "原认定条件名称",
@@ -1552,7 +1628,8 @@ class TalentTypeChange extends AdminController {
         $levelMap = DictApi::selectByParentCode("talent_arrange");
         $importWayMap = DictApi::selectByParentCode("import_way");
         $streetMap = DictApi::selectByParentCode("street");
-        $conditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+        $newIdentifyConditions = Db::table("new_talent_condition")->where("type", $this->user["type"])->column("name", "id");
+        $oldIdentifyConditions = Db::table("un_identify_condition")->where("type", $this->user["type"])->column("name", "id");
         $whereEp = [];
         $whereEp[] = ["id", "in", array_column($list, "enterpriseId")];
         $enterpriseList = \app\common\model\Enterprise::where($whereEp)->column("street", "id");
@@ -1563,8 +1640,16 @@ class TalentTypeChange extends AdminController {
             $talentTypeChange["newTalentArrangeName"] = $levelMap[$talentTypeChange["newTalentArrange"]];
             $talentTypeChange["oldIntroductionModeName"] = $importWayMap[$talentTypeChange["oldIntroductionMode"]];
             $talentTypeChange["newIntroductionModeName"] = $importWayMap[$talentTypeChange["newIntroductionMode"]];
-            $talentTypeChange["oldIdentifyConditionCH"] = $conditions[$talentTypeChange["oldIdentifyCondition"]];
-            $talentTypeChange["newIdentifyConditionCH"] = $conditions[$talentTypeChange["newIdentifyCondition"]];
+            if (strlen($talentTypeChange["oldIdentifyCondition"]) == 19) {
+                $talentTypeChange["oldIdentifyConditionCH"] = $oldIdentifyConditions[$talentTypeChange["oldIdentifyCondition"]];
+            } else {
+                $talentTypeChange["oldIdentifyConditionCH"] = $newIdentifyConditions[$talentTypeChange["oldIdentifyCondition"]];
+            }
+            if (strlen($talentTypeChange["newIdentifyCondition"]) == 19) {
+                $talentTypeChange["newIdentifyConditionCH"] = $oldIdentifyConditions[$talentTypeChange["newIdentifyCondition"]];
+            } else {
+                $talentTypeChange["newIdentifyConditionCH"] = $newIdentifyConditions[$talentTypeChange["newIdentifyCondition"]];
+            }
             switch ($talentTypeChange["isPublic"]) {
                 case 1:
                     $talentTypeChange["isPublicName"] = "待核查征信";

+ 47 - 0
app/common/api/TalentTypeChangeApi.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace app\common\api;
+
+use app\enterprise\model\TalentTypeChange as ttcModel;
+use app\enterprise\model\Talent;
+use app\common\api\TalentState;
+use think\facade\Db;
+
+/**
+ * Description of TalentTypeChangeApi
+ *
+ * @author sgq
+ */
+class TalentTypeChangeApi {
+
+    public static function getOne($id) {
+        $info = ttcModel::find($id);
+        if (strlen($info["talentId"]) == 19) {
+            $where = [];
+            $where[] = ["card_number", "=", $info["idCard"]];
+            $where[] = ["delete", "=", 0];
+            $where[] = ["checkState", "=", TalentState::CERTIFICATED];
+            $talentInfo = Talent::where($where)->find();
+            $info["talentId"] = $talentInfo["id"];
+        }
+        if (strlen($info["oldIdentifyCondition"]) == 19) {
+            $newIdentifyCondition = self::getNewIdentifyConditionIdFromOldId($info["oldIdentifyCondition"]);
+            $info["oldIdentifyCondition"] = $newIdentifyCondition["id"];
+        }
+        if (strlen($info["newIdentifyCondition"]) == 19) {
+            $newIdentifyCondition = self::getNewIdentifyConditionIdFromOldId($info["newIdentifyCondition"]);
+            $info["newIdentifyCondition"] = $newIdentifyCondition["id"];
+        }
+        return $info;
+    }
+
+    public static function getNewIdentifyConditionIdFromOldId($oldIdentifyConditionId) {
+        $oldIdentifyCondition = Db::table("un_identify_condition")->find($oldIdentifyConditionId);
+        $where = [];
+        $where[] = ["type", "=", $oldIdentifyCondition["type"]];
+        $where[] = ["name", "=", $oldIdentifyCondition["name"]];
+        $newIdentifyCondtion = Db::table("new_talent_condition")->where($where)->find();
+        return $newIdentifyCondtion;
+    }
+
+}

+ 18 - 1
app/common/controller/Api.php

@@ -324,6 +324,23 @@ class Api extends BaseController {
                 }
             }
         }
+
+        if ($type == ProjectState::LEVELCHANGE) {
+            $where = [];
+            $where[] = ["mainId", "=", $mainId];
+            $where[] = ["type", "=", ProjectState::LEVELCHANGE];
+            $before_list = Db::table("un_talent_checklog")->where($where)->order("createTime desc")->select();
+            foreach ($before_list as $before_item) {
+                $new_list[] = [
+                    "stepName" => DictApi::getOldStepNameByStep($before_item["step"]),
+                    "stateName" => DictApi::getOldStateNameByState($before_item["state"]),
+                    "stateChange" => $before_item["stateChange"],
+                    "description" => $before_item["description"],
+                    "createUser" => $before_item["createUser"],
+                    "createTime" => $before_item["createTime"]
+                ];
+            }
+        }
         return json(["rows" => $new_list]);
     }
 
@@ -708,7 +725,7 @@ class Api extends BaseController {
         $where[] = ["mainId", "=", $id];
         if (!$files)
             $files = Db::table($table)->where($where)->select()->toArray();
-        if (!$files){
+        if (!$files) {
             //die("没有附件不能打包下载");
             echo "<script>parent.layer.alert('没有附件不能打包下载');window.history.go(-1);</script>";
         }

+ 3 - 3
app/enterprise/api/TalentApi.php

@@ -159,7 +159,7 @@ class TalentApi {
         $where = [];
         $where[] = ["enterpriseId", "=", session("user")["uid"]];
         $where[] = ["delete", "=", 0];
-        $whereRaw = "length(talentId) <> 19";
+        //$whereRaw = "length(talentId) <> 19";
         if ($talentName) {
             $where[] = ["talentName", "like", "%" . $talentName . "%"];
         }
@@ -178,8 +178,8 @@ class TalentApi {
         if ($newIdentifyCondition) {
             $where[] = ["newIdentifyCondition", "=", $newIdentifyCondition];
         }
-        $count = TalentTypeChange::where($where)->whereRaw($whereRaw)->count();
-        $list = TalentTypeChange::where($where)->whereRaw($whereRaw)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
+        $count = TalentTypeChange::where($where)->count();
+        $list = TalentTypeChange::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
         $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
 
         foreach ($list as $k => $v) {

+ 20 - 7
app/enterprise/controller/TalentTypeChange.php

@@ -14,6 +14,7 @@ use app\common\api\DictApi;
 use app\common\api\VerifyApi;
 use app\Request;
 use app\enterprise\model\TalentTypeChange as TalentTypeChangeModel;
+use app\common\api\TalentTypeChangeApi as ttcApi;
 use think\facade\Db;
 
 /**
@@ -36,7 +37,7 @@ class TalentTypeChange extends EnterpriseController {
         $enterprise = EnterpriseApi::getOne($this->user["uid"]);
         $params = $this->request->param();
         if ($params["id"]) {
-            $info = TalentTypeChangeModel::find($params["id"]);
+            $info = ttcApi::getOne($params["id"]);
         }
         $year = $info["newYear"] ?: $params["year"];
         return view("apply", ['enterprise' => $enterprise, "info" => $info, 'year' => $year]);
@@ -45,7 +46,7 @@ class TalentTypeChange extends EnterpriseController {
     public function view() {
         $params = $this->request->param();
         if ($params["id"]) {
-            $info = TalentTypeChangeModel::find($params["id"]);
+            $info = ttcApi::getOne($params["id"]);
         }
         if ($info["enterpriseId"] != $this->user["uid"])
             $info = null;
@@ -58,7 +59,15 @@ class TalentTypeChange extends EnterpriseController {
             return $res;
         }
         $data = $this->request->param();
-        $talentInfo = TalentApi::getOne($data["talentId"]);
+        if (strlen($data["talentId"]) == 19) {
+            $where = [];
+            $where[] = ["card_number", "=", $data["idCard"]];
+            $where[] = ["checkState", "=", TalentState::CERTIFICATED];
+            $where[] = ["delete", "=", 0];
+            $talentInfo = Db::table("new_talent_info")->where($where)->find();
+        } else {
+            $talentInfo = TalentApi::getOne($data["talentId"]);
+        }
         if (!$talentInfo || $talentInfo["checkState"] != TalentState::CERTIFICATED || $talentInfo["delete"] == 1) {
             return json(["msg" => "人才库中匹配不到该人才", "code" => 500]);
         }
@@ -105,13 +114,17 @@ class TalentTypeChange extends EnterpriseController {
         $response = new \stdClass();
         $response->code = 500;
         $id = $this->request["id"];
-        $info = TalentTypeChangeModel::where("id", $id)->find();
+        $info = ttcApi::getOne($id);
         if (!$info) {
             $response->msg = "提交审核失败,请先填写基础信息";
             return $response;
         }
-        if (strlen($info["talentId"]) == 19) {
-            $response->msg = "该记录已经过期,请重新提交人才层次变更申请";
+        if (!$info["talentId"]) {
+            $response->msg = "没有对应的人才信息";
+            return $response;
+        }
+        if (!$info["newIdentifyCondition"]) {
+            $response->msg = "没有对应的认定条件";
             return $response;
         }
         if ($info["checkState"] != MainState::SAVE && $info["checkState"] != MainState::FIRST_REJECT && $info["checkState"] != MainState::BEFORE_REJECT) {
@@ -216,7 +229,7 @@ class TalentTypeChange extends EnterpriseController {
         if (\StrUtil::isEmpOrNull($data->param('newIdentifyGetTime'))) {
             return json(["msg" => "新认定条件证书取得时间不能为空", "code" => 500]);
         }
-        $res = TalentTypeChangeModel::where('idCard', $data->param('idCard'))->where('id', '<>', $data->param('id'))->whereRaw('isPublic <> 6 and (isPublic <> 5 or checkState <> -1) and length(talentId) <> 19')->find();
+        $res = TalentTypeChangeModel::where('idCard', $data->param('idCard'))->where('id', '<>', $data->param('id'))->whereRaw('isPublic <> 6 and (isPublic <> 5 or checkState <> -1)')->find();
 
         if ($res) {
             return json(["msg" => "添加失败,该证件号码已申报", "code" => 500]);