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 check() { $obj = $this->request->param(); if (!$obj["checkState"]) { return new Response(Response::ERROR, "请选择审核状态"); } $oldObj = TalentAllowanceApi::getInfoById($obj["id"]); if (!$oldObj) { return new Response(Response::ERROR, "审核对象不存在"); } $newObj = []; $newObj["id"] = $obj["id"]; $projectList = []; $fileList = []; if ($obj["process"] == 1) { if (\StrUtil::isNotEmpAndNull($obj["projects"])) { $projectList = array_filter(explode(",", $obj["projects"])); $newObj["projects"] = implode(",", $projectList); } if (\StrUtil::isNotEmpAndNull($obj["files"])) { $fileList = array_filter(explode(",", $obj["files"])); $newObj["files"] = implode(",", $fileList); } //if (Const.RSJ.equals(checkCompany.getCode())) { $newObj["concats"] = $obj["concats"]; $newObj["fields"] = $obj["fields"]; //} } if ($obj["process"] == 3) { $newObj["toProcess"] = $obj["toProcess"]; $newObj["toDep"] = $obj["toDep"]; } TaModel::update($newObj); //添加日志 TalentChecklog::create([ 'id' => getStringId(), 'mainId' => $obj['id'], 'type' => intval(ProjectState::JBT), 'typeFileId' => null, 'active' => 2, 'state' => $obj["checkState"], 'step' => $obj["process"], 'stateChange' => null, 'description' => $obj["checkMsg"], 'createTime' => date("Y-m-d H:i:s", time()), 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]) ]); return new Response(Response::SUCCESS, "审核成功"); } public function submitCheck() { $id = $this->request["id"]; $process = $this->request["process"]; $old = TalentAllowanceApi::getInfoById($id); if (!$old) { return new Response(Response::ERROR, "审核对象不存在"); } $updCheck = []; $updCheck["id"] = $id; /* * 查询审核日志 */ $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process); if (!$log) { return new Response(Response::ERROR, "请先审核后再提交"); } $updCheck["checkMsg"] = $log["description"]; /* * 判断到达的最高流程 */ $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["process"]; switch ($process) { case 1: switch ($log["state"]) { case 3: $updCheck["firstPassTime"] = $old["firstPassTime"]; if (!$old["firstPassTime"]) { $updCheck["firstPassTime"] = date("Y-m-d H:i:s"); } $updCheck["submitTime"] = date("Y-m-d H:i:s"); $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW; break; case 2: $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT; break; case -1: $updCheck["checkState"] = AllowanceStateEnum::NOTPASS; $updCheck["recommendAllowanceType"] = 3; $updCheck["recommendMoney"] = 0; $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现"; break; default: return new Response(Response::ERROR, "未知的审核状态"); } //添加日志 TalentChecklog::create([ 'id' => getStringId(), 'mainId' => $id, 'type' => intval(ProjectState::JBT), 'typeFileId' => null, 'active' => 1, 'state' => $log["state"], 'step' => $process, 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]), 'description' => $log["checkMsg"], 'createTime' => date("Y-m-d H:i:s", time()), 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]) ]); break; case 2: if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) { return new Response(Response::ERROR, "不在审核范围内"); } $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW; $updCheck["visitPassTime"] = date("Y-m-d H:i:s"); //添加日志 TalentChecklog::create([ 'id' => getStringId(), 'mainId' => $id, 'type' => intval(ProjectState::JBT), 'typeFileId' => null, 'active' => 1, 'state' => 3, 'step' => $process, 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]), 'description' => "走访核查提交审核", 'createTime' => date("Y-m-d H:i:s", time()), 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]) ]); break; case 3: switch ($log["state"]) { case 3: $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS; $updCheck["reviewPassTime"] = date("Y-m-d H:i:s"); /* * * 在此处需要判断津补贴类型 */ $arrangeList = $this->validateAllowanceType($updCheck); TalentAllowanceArrange::update($arrangeList); break; case 2: if ($old["toProcess"] == 1) { $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST; } else if ($old["toProcess"] == 2) { $updCheck["checkState"] = AllowanceStateEnum::REVIEW_REJECT; } $updCheck["toProcess"] = null; $updCheck["toDep"] = ""; break; case -1: $updCheck["checkState"] = AllowanceStateEnum::NOTPASS; $updCheck["recommendAllowanceType"] = 3; $updCheck["recommendMoney"] = 0; $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现"; break; default: return new Response(Response::ERROR, "未知的审核状态"); } //添加日志 TalentChecklog::create([ 'id' => getStringId(), 'mainId' => $id, 'type' => intval(ProjectState::JBT), 'typeFileId' => null, 'active' => 1, 'state' => $log["state"], 'step' => $process, 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]), 'description' => $log["checkMsg"], 'createTime' => date("Y-m-d H:i:s", time()), 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]) ]); break; } TalentChecklog::delete($log["id"]); TaModel::update($updCheck); return new Response(Response::SUCCESS, "提交审核成功"); } private function validateAllowanceType(&$info) { $old = TalentAllowanceApi::getInfoById($info["id"]); $talentTypeMap = DictApi::selectByParentCode("enterprise_tag"); $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id"); /* * 查询工作单位记录 */ $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray(); $detaiPdList = []; //用于判定类型 $detailMonthList = []; //用于计算月份 $recommendAllowanceMsg = []; foreach ($initDetailList as $detail) { $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray(); $projectMap = []; foreach ($projectList as $project) { $projectMap[$project["project"]] = $project; } $detail["list"] = $projectList; $detail["projectMap"] = $projectMap; $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]]; $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]]; /* * 筛选符合条件的人才标签 */ $detaiPdList[] = $detail; $detailMonthList[] = $detail; } /* * 集成电路优秀人才 */ if ($this->user["type"] == 2) { /* * 获取各个项目的综合月份 */ $monthMap = $this->mergeMonth($detailMonthList); $monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList); $info["recommendAllowanceType"] = 1; $info["recommendAllowanceMsg"] = ""; $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $info["id"])->select()->toArray(); $set = $this->valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap); $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n综合以上所有判断得到最终补贴类型为:"; if ($info["recommendAllowanceType"] == 1) { $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "工作津贴;可享受月份为:" . implode(",", $set) . "\n"; } if ($info["recommendAllowanceType"] == 2) $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "一次性交通补贴;"; if ($info["recommendAllowanceType"] == 3) $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "不予兑现;"; usort($set, function($a, $b) { return (int) $a - (int) $b; }); } $info["recommendMonths"] = implode(",", $set); $arrangeList = $this->calculateAllowance($info, $set, $detailMonthList); return $arrangeList; } /** * 集成电路津补贴总校验 * */ private function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) { $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]; /* * 2.判定工作月份、五险和个税是否满足重叠6个月要求* */ $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WORKDAY], $info, "上年度工作月份", "①"); $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "②"); $injurySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_INJURY], $info, "工伤保险", "③"); $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "④"); $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑤"); $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑥"); $set = array_intersect($set, $workdaySet); $set = array_intersect($set, $pensionSet); $set = array_intersect($set, $injurySet); $set = array_intersect($set, $unemploymentSet); $set = array_intersect($set, $medicaSet); $set = array_intersect($set, $taxSet); if ($info["recommendAllowanceType"] == 1 && count($set) < 6) { //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求 $info["recommendAllowanceType"] == 2; } if ($info["recommendAllowanceType"] == 2) { //判断境内工作时间是否大于30天 $totalDays = 0; $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_WORKDAY]; foreach ($workmonths as $days) { $totalDays += $days; } if ($totalDays < 30) { $info["recommendAllowanceType"] == 3; $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)"; } } return $set; } /** * 计算津补贴 */ private function calculateAllowance(&$info, $retainMonths, $detailMonthList) { /**查询人才层次变更记录*/ List arrangeList = this.talentAllowanceArrangeService.selectListAndAmount(new EntityWrapper().eq("mainId", info.getId()).orderBy("talentArrange")); AmountStandard amountStandard = this.amountStandardService.selectOne(new EntityWrapper().eq("type", 1).eq("allowanceType", 1).eq("talentArrange", "4")); /*** 容器*/ BigDecimal jobMoney = BigDecimal.ZERO; //计算所得工作津贴 BigDecimal jtMoney = BigDecimal.ZERO; //计算所得一次性交通补贴 Set recommendMonths = new TreeSet<>(new Comparator() { @Override public int compare(String o1, String o2) { int o1Int = Integer.parseInt(o1); int o2Int = Integer.parseInt(o2); return o1Int - o2Int; } }); //推荐月份 String talentArrange = null; /***********计算**************/ StringBuilder msgBulider = new StringBuilder(); switch (info.getRecommendAllowanceType()) { case 1: if (info.getType() == 1) { //晋江市优秀人才 /**判断判定最终月份和人才层次有效月份是否存在共同月份,不存在则为一次性交通补贴*/ Set totalArrangeMonth = new HashSet<>(); for (TalentAllowanceArrange arrange : arrangeList) { List levelList = new ArrayList<>(Arrays.asList(arrange.getPrepareMonths().split(","))); //对于2019年度的津补贴申报人才层次可享受月份均在07-12月 if ("2019".equals(info.getYear())) { levelList.retainAll(new ArrayList<>(Arrays.asList("07", "08", "09", "10", "11", "12"))); } totalArrangeMonth.addAll(levelList); } totalArrangeMonth.retainAll(retainMonths); /**对于人才标签中存在在站博士后的需要去除在站博士后计算,在站博士后不考虑人才层次(不予人才层次取交集),默认第四层次*/ for (TalentAllowancecontractDetail detail : detailMonthList) { if (DictValueConst.TALENTTYPE_ZZBSH.equals(detail.getTalentType())) { String months = detail.getMonths(); if (FengStringUtil.isNotEmpAndNull(months)) { List monthsList = new ArrayList<>(Arrays.asList(months.split(","))); BigDecimal total = amountStandard.getMoney().multiply(new BigDecimal(monthsList.size())).setScale(2, BigDecimal.ROUND_HALF_UP); jobMoney = jobMoney.add(total); msgBulider.append(monthsList.size() + "(" + StringUtils.join(monthsList.toArray(), ",") + ")x" + amountStandard.getMoney() + "(第" + amountStandard.getTalentArrange() + "层次)+"); recommendMonths.addAll(monthsList); retainMonths.removeAll(monthsList); //去除在站博士后已计算月份 /**当存在在站博士后时无需计算月份和人才层次的交集,此处在交集内加入月份 数据,防止下面if判断导致津贴类型变更*/ totalArrangeMonth.addAll(monthsList); } } } if (totalArrangeMonth.size() == 0) { int tempArrange = Integer.parseInt(arrangeList.get(0).getTalentArrange()); if (tempArrange < 6) { info.setRecommendAllowanceType(2); info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "\n由于判定结果月份与人才层次有效月份无交集,因此津贴类型为:一次性交通补贴"); } else { info.setRecommendAllowanceType(3); info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "\n由于判定结果月份与人才层次有效月份无交集且为第" + tempArrange + "层次,因此津贴类型为:不予兑现"); } return calculateAllowance(info, retainMonths, detailMonthList); } if (retainMonths.size() > 0) { for (TalentAllowanceArrange arrange : arrangeList) { if (FengStringUtil.isNotEmpAndNull(arrange.getPrepareMonths())) { List levelList = new ArrayList<>(Arrays.asList(arrange.getPrepareMonths().split(","))); //对于2019年度的津补贴申报人才层次可享受月份均在07-12月 if ("2019".equals(info.getYear())) { levelList.retainAll(new ArrayList<>(Arrays.asList("07", "08", "09", "10", "11", "12"))); } levelList.retainAll(retainMonths); BigDecimal total = arrange.getJobMoney().multiply(new BigDecimal(levelList.size())).setScale(2, BigDecimal.ROUND_HALF_UP); jobMoney = jobMoney.add(total); msgBulider.append(levelList.size() + "(" + StringUtils.join(levelList.toArray(), ",") + ")x" + arrange.getJobMoney() + "(第" + arrange.getTalentArrange() + "层次)+"); recommendMonths.addAll(levelList); arrange.setMonths(StringUtils.join(levelList.toArray(), ",")); arrange.setCount(levelList.size()); arrange.setTotal(total); } else { msgBulider.append("0()x" + arrange.getJobMoney() + "(第" + arrange.getTalentArrange() + "层次)+"); arrange.setCount(0); arrange.setTotal(new BigDecimal(0.00)); } } } info.setRecommendMonths(StringUtils.join(recommendMonths.toArray(), ",")); info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "通过与人才证书有效期取交集得到最终可享受月份:" + StringUtils.join(recommendMonths.toArray(), ",") + "\n经过计算:人才津贴为" + jobMoney + ";"); info.setRecommendMoney(jobMoney); info.setRecommendMoneyDesc(msgBulider.substring(0, msgBulider.length() - 1)); info.setWorkAllowanceMoney(jobMoney.multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_HALF_UP)); info.setDevelopAllowanceMoney(jobMoney.multiply(new BigDecimal(0.2)).setScale(2, BigDecimal.ROUND_HALF_UP)); info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "工作津贴为" + info.getWorkAllowanceMoney() + ";发展津贴为:" + info.getDevelopAllowanceMoney()); this.talentAllowancecontractDetailService.updateBatchById(detailMonthList); } else if (info.getType() == 2) { //集成电路优秀人才 for (TalentAllowanceArrange arrange : arrangeList) { if (FengStringUtil.isNotEmpAndNull(arrange.getPrepareMonths())) { List levelList = new ArrayList<>(Arrays.asList(arrange.getPrepareMonths().split(","))); levelList.retainAll(retainMonths); BigDecimal total = arrange.getJobMoney().multiply(new BigDecimal(levelList.size())).setScale(2, BigDecimal.ROUND_HALF_UP); jobMoney = jobMoney.add(total); msgBulider.append(levelList.size() + "(" + StringUtils.join(levelList.toArray(), ",") + ")x" + arrange.getJobMoney() + "(第" + arrange.getTalentArrange() + "层次)+"); recommendMonths.addAll(levelList); arrange.setMonths(StringUtils.join(levelList.toArray(), ",")); arrange.setCount(levelList.size()); arrange.setTotal(total); } else { msgBulider.append("0()x" + arrange.getJobMoney() + "(第" + arrange.getTalentArrange() + "层次)+"); arrange.setCount(0); arrange.setTotal(new BigDecimal(0.00)); } } info.setRecommendMonths(StringUtils.join(recommendMonths.toArray(), ",")); info.setRecommendAllowanceMsg(info.getRecommendAllowanceMsg() + "通过与人才证书有效期取交集得到最终可享受月份:" + StringUtils.join(recommendMonths.toArray(), ",") + "\n经过计算:人才津贴为" + jobMoney + ";"); info.setRecommendMoney(jobMoney); info.setRecommendMoneyDesc(msgBulider.substring(0, msgBulider.length() - 1)); } break; case 2: for (TalentAllowanceArrange arrange : arrangeList) { Integer intArragnge = Integer.parseInt(arrange.getTalentArrange()); if (FengStringUtil.isNotEmpAndNull(arrange.getPrepareMonths()) && intArragnge <=5) { if (jtMoney.compareTo(BigDecimal.ZERO) == 0 || arrange.getJtMoney().compareTo(jtMoney) == 1) { jtMoney = arrange.getJtMoney(); talentArrange = arrange.getTalentArrange(); } } } info.setRecommendMoney(jtMoney); info.setRecommendMonths(""); info.setRecommendMoneyDesc("一次性交通补贴"); info.setWorkAllowanceMoney(new BigDecimal(0.00)); info.setDevelopAllowanceMoney(new BigDecimal(0.00)); info.setRecommendTalentArrange(talentArrange); break; case 3: info.setRecommendMoney(new BigDecimal(0.00)); info.setRecommendMoneyDesc("不予兑现"); info.setRecommendMonths(""); info.setWorkAllowanceMoney(new BigDecimal(0.00)); info.setDevelopAllowanceMoney(new BigDecimal(0.00)); break; } // this.talentAllowanceArrangeService.updateBatchById(arrangeList); return arrangeList; } /** * 判定是否交足6个月(集成电路) * @param set * @param info * @param name */ private function chkMonths($set, &$info, $name, $sort) { if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6)) { $info["recommendAllowanceType"] = 2; $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)"; } return set; } //合并所有项目的月份 private function mergeMonth($detailList) { $taxList = []; $wagesList = []; $pensionList = []; $unemploymentList = []; $medicaList = []; $attendanceList = []; $workdayList = []; foreach ($detailList as $detail) { $projectMap = $detail["projectMap"]; if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])); $taxList = array_merge($taxList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])); $wagesList = array_merge($wagesList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])); $pensionList = array_merge($pensionList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])); $unemploymentList = array_merge($unemploymentList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])); $medicaList = array_merge($medicaList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])); $attendanceList = array_merge($attendanceList, $tmp); } if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) { $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])); $workdayList = array_merge($workdayList, $tmp); } } $map = [ AllowanceProjectEnum::PROJECT_TAX => $taxList, AllowanceProjectEnum::PROJECT_WAGES => $wagesList, AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList, AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList, AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList, AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList, AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList, ]; return $map; } /** * 合并多个单位带有天数的项目的月份如考勤1月30天, * */ private function mergeMonthNeedDay($detailList) { $attendMap = []; $workDayMap = []; foreach ($detailList as $detail) { $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap); $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap); } $res = [ AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap, AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap ]; return $res; } private function getMergeMonthNeedDayMap($project, $map) { if (\StrUtil::isNotEmpAndNull($project["months"])) { $monthAndDayList = array_filter(explode(",", $project["months"])); for ($i = 0; $i < count($monthAndDayList); $i++) { $obj = explode("=", $monthAndDayList[$i]); $month = $obj[0]; $day = $obj[1]; $count = $map[$month]; if ($count == 0) { $map[$month] = $day; } else { $map[$month] = $day + $count; } } } return $map; } /** * 校验是否在审核范围内 */ public function validateIsCheck() { $id = $this->request["id"]; $type = $this->request["type"]; $process = $this->request["process"]; $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) { return new Response(Response::ERROR, "校验不通过,无法操作"); } $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) { return new Response(Response::ERROR, "不在审核范围内"); } //$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) { return new Response(Response::ERROR, "不在审核范围内"); } break; case 3: if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) { return new Response(Response::ERROR, "不在审核范围内"); } $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; } return new Response(Response::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; } }