123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\model\TalentAllowance as TaModel;
- use think\facade\Db;
- use app\common\api\DictApi;
- use app\common\state\AllowanceStateEnum;
- use app\common\state\AllowanceProjectEnum;
- use app\common\api\TalentAllowanceApi;
- use app\common\model\TalentChecklog;
- /**
- * Description of TalentAllowance
- *
- * @author sgq
- */
- class TalentAllowance extends AdminController {
- public function index() {
- $process = $this->request["process"];
- $type = $this->user["type"];
- $assigns = ["process" => $process, "type" => $type];
- if ($process == 4) {
- if ($type == 1) {
- $msgBody["typeName"] = "晋江市优秀人才津补贴申报";
- $msgBody["address"] = "聚才网/人才晋江微信公众号";
- $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
- $msgBody["phone"] = "0595-85633128";
- $msgBody["email"] = "jjrc85661234@163.com";
- }
- if ($type == 2) {
- $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
- $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
- $msgBody["dep"] = "集成电路产业园区";
- $msgBody["phone"] = "0595-82250007、0595-82250001";
- $msgBody["email"] = "jjjcdr@163.com";
- }
- $assigns["message"] = $msgBody;
- }
- return view("", $assigns);
- }
- /**
- * 获取优秀人才津补贴列表
- */
- public function list() {
- $param = $this->request->param();
- $offset = $param["offset"] ?: 0;
- $limit = $param["limit"] ?: 10;
- $process = $param["process"];
- $where = [];
- $where[] = ["type", "=", $this->user["type"]];
- $order = "newSubmitTime desc";
- $where = $this->setTalentAllowanceInfo($where, $param, $process);
- switch ($process) {
- case 1:
- $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
- break;
- case 2:
- $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
- break;
- case 3:
- $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
- break;
- case 4:
- if ($param["publicState"]) {
- $where[] = ["publicState", "=", $param["publicState"]];
- }
- $where[] = ["checkState", "in", [-1, 30]];
- break;
- }
- $count = TaModel::where($where)->count();
- $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
- $list = $this->translateChinese($list);
- return json(["rows" => $list, "total" => $count]);
- }
- public function toCheckPage() {
- $id = $this->request["id"];
- $process = $this->request["process"];
- $obj = TalentAllowanceApi::getInfoById($id);
- $this->translateToChinese($obj);
- return view("info", ["row" => $obj, "process" => $process]);
- }
- /**
- * 校验是否在审核范围内
- */
- public function validateIsCheck() {
- $id = $this->request["id"];
- $type = $this->request["type"];
- $process = $this->request["process"];
- $response = new \stdClass();
- $response->code = 500;
- $info = null;
- switch ($type) {
- case 1: //编辑合同
- $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
- $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
- break;
- case 2: //编辑项目
- $project = \app\common\model\TalentAllowanceProject::find($id);
- $info = TalentAllowanceApi::getInfoById($project["mainId"]);
- break;
- case 3:
- $info = TalentAllowanceApi::getInfoById($id);
- break;
- }
- if (!$info) {
- $response->msg = "校验不通过,无法操作";
- return $response;
- }
- $where = [];
- $where[] = ["mainId", "=", $info["id"]];
- $where[] = ["step", "=", $process];
- $where[] = ["active", "=", 2];
- $log = null;
- switch ($process) {
- case 1:
- if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
- $response->msg = "不在审核范围内";
- return $response;
- }
- //$where[] = ["companyId","=",$this->user["companyId"]];
- $log = TalentChecklog::where($where)->order("createTime desc")->find();
- break;
- case 2:
- if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
- $response->msg = "不在审核范围内";
- return $response;
- }
- break;
- case 3:
- if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
- $response->msg = "不在审核范围内";
- return $response;
- }
- $log = TalentChecklog::where($where)->order("createTime desc")->find();
- break;
- }
- if ($log != null) {
- $info["checkState"] = $log["state"];
- $info["checkMsg"] = $log["description"];
- } else {
- $info["checkState"] = null;
- $info["checkMsg"] = "";
- }
- $res = [];
- $res["info"] = $info;
- if ($type == 3) {
- $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["isLock", "=", 1];
- $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
- $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
- $detailMap = array_reduce($detailList, function ($result, $item) {
- $key = $item["id"];
- $result[$key] = $item;
- return $result;
- }, []);
- foreach ($detailList as &$detail) {
- $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
- }unset($detail);
- foreach ($projectList as &$project) {
- $detail = $detailMap[$project["baseId"]];
- $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
- }
- $where = [];
- $where[] = ["type", "=", $info["type"]];
- $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
- $where[] = ["active", "=", 1];
- $where[] = ["delete", "=", 0];
- $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
- $res["files"] = $filetypes;
- $res["projects"] = $projectList;
- $res["concats"] = $detailList;
- $response->obj = $res;
- }
- $response->code = 200;
- return $response;
- return new ResponseObj(ResponseObj . SUCCESS, "", res);
- }
- /**
- * 查询工作单位
- */
- public function findAllowanceContractDetail() {
- $mainId = $this->request["mainId"];
- $offset = $this->request["offset"] ?: 0;
- $limit = $this->request["limit"] ?: 1000;
- $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
- $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
- $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
- foreach ($list as &$row) {
- $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
- }unset($row);
- return json(["rows" => $list, "total" => $count]);
- }
- /**
- * 查询核查项目情况
- */
- public function findAllowanceProject() {
- $mainId = $this->request["mainId"];
- $baseId = $this->request["baseId"];
- $offset = $this->request["offset"] ?: 0;
- $limit = $this->request["limit"] ?: 1000;
- $where = [];
- $where[] = ["mainId", "=", $mainId];
- $where[] = ["baseId", "=", $baseId];
- $count = \app\common\model\TalentAllowanceProject::where($where)->count();
- $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
- $info = TalentAllowanceApi::getInfoById($mainId);
- foreach ($list as &$project) {
- $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
- if ($info["checkState"] == 1) {
- $project["isEdit"] = in_array($project["project"], [
- AllowanceProjectEnum::PROJECT_CONTRACT,
- AllowanceProjectEnum::PROJECT_TAX,
- AllowanceProjectEnum::PROJECT_WAGES,
- AllowanceProjectEnum::PROJECT_ATTENDANCE,
- AllowanceProjectEnum::PROJECT_SB_PENSION,
- AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
- AllowanceProjectEnum::PROJECT_SB_MEDICA,
- AllowanceProjectEnum::PROJECT_WORKDAY
- ]) ? 1 : 2;
- } else if ($info["checkState"] == 10) {
- $projects = explode(",", $info["projects"]);
- if (in_array($project["id"], $projects)) {
- $project["isEdit"] = 1;
- } else {
- $project["isEdit"] = 2;
- }
- } else {
- $project["isEdit"] = 2;
- }
- }unset($project);
- return json(["rows" => $list, "total" => $count]);
- }
- /**
- * 查询人才层次变更记录
- */
- public function findAllowanceArrange() {
- $mainId = $this->request["mainId"];
- $offset = $this->request["offset"] ?: 0;
- $limit = $this->request["limit"] ?: 1000;
- $where = [];
- $where[] = ["mainId", "=", $mainId];
- $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
- $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
- foreach ($list as &$arrange) {
- $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
- $arrange["identifyConditionText"] = $condition["name"];
- $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
- }unset($arrange);
- return json(["rows" => $list, "total" => $count]);
- }
- private function setTalentAllowanceInfo($where, $query, $process) {
- if (\StrUtil::isNotEmpAndNull($query["year"])) {
- $where[] = ["year", "=", $query["year"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
- $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
- }
- if (\StrUtil::isNotEmpAndNull($query["name"])) {
- $where[] = ["name", "like", "%" . $query["name"] . "%"];
- }
- if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
- $where[] = ["talentType", "=", $query["talentType"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
- $where[] = ["talentArrange", "=", $query["talentArrange"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
- $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["address"])) {
- $where[] = ["address", "=", $query["address"]];
- }
- if ($query["recommendAllowanceType"]) {
- $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
- }
- if ($query["publicState"]) {
- $where[] = ["publicState", "=", $query["publicState"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
- $where[] = ["introductionMode", "=", $query["introductionMode"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
- $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
- }
- if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
- $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
- }
- if ($process == 4) {
- if ($query["isSupple"]) {
- $where[] = ["isSupple", "=", $query["isSupple"]];
- }
- if ($query["isPublicCheck"]) {
- $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
- }
- }
- if ($query["checkState"]) {
- if ($query["checkState"] == -1) {
- $where[] = ["checkState", "=", $query["checkState"]];
- } else {
- if ($process == 1) {
- switch ($query["checkState"]) {
- case 0: //保存未提交
- $where[] = ["checkState", "=", 1];
- break;
- case 1:
- $where[] = ["checkState", "=", 5];
- break;
- case 2: //驳回
- $where[] = ["checkState", "=", 10];
- break;
- case 3: //通过
- $where[] = ["checkState", "in", [15, 20, 30, 25]];
- break;
- case 4: //重新提交
- $where[] = ["checkState", "=", 5];
- $where[] = ["highProcess", ">=", $process];
- break;
- case 5: //上级驳回
- $where[] = ["checkState", "=", 13];
- break;
- }
- }
- if ($process == 2) {
- switch ($query["checkState"]) {
- case 1:
- $where[] = ["checkState", "=", 15];
- break;
- case 2: //驳回
- $where[] = ["checkState", "in", [1, 5, 10]];
- $where[] = ["highProcess", ">=", $process];
- break;
- case 3: //通过
- $where[] = ["checkState", "in", [20, 30]];
- break;
- case 9: //重新提交
- $where[] = ["checkState", "=", 15];
- $where[] = ["highProcess", ">=", $process];
- break;
- case 4: //上级驳回
- $where[] = ["checkState", "=", 25];
- break;
- case -1:
- $where[] = ["checkState", "=", -1];
- break;
- }
- }
- if ($process == 3) {
- switch ($query["checkState"]) {
- case -1:
- $where[] = ["checkState", "=", -1];
- break;
- case 1:
- $where[] = ["checkState", "=", 20];
- break;
- case 2: //驳回
- $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
- $where[] = ["highProcess", ">=", $process];
- break;
- case 3: //通过
- $where[] = ["checkState", "=", 30];
- break;
- case 9: //重新提交
- $where[] = ["checkState", "=", 20];
- $where[] = ["highProcess", ">=", $process];
- break;
- case 4: //上级驳回
- $where[] = ["checkState", "=", 35];
- break;
- }
- }
- if ($process == 4) {
- switch ($query["checkState"]) {
- case -1:
- $where[] = ["checkState", "=", -1];
- break;
- case 3: //通过
- $where[] = ["checkState", "=", 30];
- break;
- }
- }
- }
- }
- return $where;
- }
- private function translateToChinese(&$obj) {
- if (\StrUtil::isNotEmpAndNull($obj["address"])) {
- $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
- }
- if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
- $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
- }
- if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
- $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
- }
- if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
- $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
- }
- if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
- $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
- }
- }
- private function translateChinese($list) {
- //获取字典表
- $levelMap = DictApi::selectByParentCode("talent_arrange");
- $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
- $streetMap = DictApi::selectByParentCode("street");
- $cardTypeMap = DictApi::selectByParentCode("card_type");
- $modeMap = DictApi::selectByParentCode("import_way");
- $where = [];
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["id", "in", array_column($list, "identifyCondition")];
- $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
- foreach ($list as &$info) {
- if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
- $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
- }
- $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
- if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
- $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
- }
- $info["addressName"] = $streetMap[$info["address"]];
- $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
- $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
- $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
- $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
- $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
- $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
- $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
- $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
- $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
- $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
- }unset($info);
- return $list;
- }
- }
|