123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use think\facade\Db;
- use app\common\api\Response;
- use app\common\api\DictApi;
- use app\common\api\TalentAllowanceApi;
- use app\common\api\TalentLogApi;
- use app\common\model\TalentAllowance as TaModel;
- use app\common\model\TalentChecklog;
- use app\common\model\TalentAllowanceArrange;
- use app\common\state\ProjectState;
- use app\common\state\AllowanceStateEnum;
- use app\common\state\AllowanceProjectEnum;
- /**
- * 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 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<TalentAllowanceArrange> arrangeList = this.talentAllowanceArrangeService.selectListAndAmount(new EntityWrapper<TalentAllowanceArrange>().eq("mainId", info.getId()).orderBy("talentArrange"));
- AmountStandard amountStandard = this.amountStandardService.selectOne(new EntityWrapper<AmountStandard>().eq("type", 1).eq("allowanceType", 1).eq("talentArrange", "4"));
- /*** 容器*/
- BigDecimal jobMoney = BigDecimal.ZERO; //计算所得工作津贴
- BigDecimal jtMoney = BigDecimal.ZERO; //计算所得一次性交通补贴
- Set<String> recommendMonths = new TreeSet<>(new Comparator<String>() {
- @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<String> totalArrangeMonth = new HashSet<>();
- for (TalentAllowanceArrange arrange : arrangeList) {
- List<String> 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<String> 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<String> 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<String> 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;
- }
- }
|