InstallController.class.php 20.3 KB
<?php
/**
 * 套件应用安装初始化数据
 * 头条
 * @author zhoutao
 * @date 2017-11-21 10:56:25
 */

namespace Rpc\Controller\Common;

use Common\Common\NewsHelper;
use Common\Service\ArticleService;
use Common\Service\ClassService;
use Common\Service\RightService;
use VcySDK\Attach;
use VcySDK\Service;

class InstallController extends AbstractController
{
    public function index()
    {
        // 写入默认分类
        $classServ = new ClassService();
        $classHad = $classServ->get_by_conds([]);
        if (empty($classHad)) {
            $classInsertArray = [];
            foreach ([
                '公司动态',
                '企业荣誉',
                '员工关怀',
                '培训通知',
            ] as $className) {
                $classInsertArray[] = [
                    'class_name' => $className,
                    'is_open' => 2
                ];
            }
            $classServ->insert_all($classInsertArray);
        }

        // 写入默认头条
        $articleServ = new ArticleService();
        $news = $articleServ->get_by_conds([]);
        if (empty($news)) {
            $class = $classServ->get_by_conds(['class_name' => '培训通知']);
            if (!empty($class)) {
                // 上传默认图片
                $attach = new Attach(Service::instance());
                $result = [];
                try {
                    $picFile = CODE_ROOT . DIRECTORY_SEPARATOR . "www/static/img/news/default_news.jpg";
                    $fileData = [
                        'file' => [
                            'name' => QY_DOMAIN . "_default_news.jpg",
                            'type' => mime_content_type($picFile),
                            'size' => filesize($picFile),
                            'tmp_name' => $picFile,
                        ],
                    ];
                    $result = $attach->upload([
                        'atMediatype' => Attach::TYPE_IMG,
                    ], $fileData);
                } catch (\Exception $e) {
                    \Think\Log::record('setDefaultMedal 方法内错误:::' . $e->getMessage());
                }

                $news = [
                    'title' => '员工培训体系如何建立?看这篇就够了',
                    'summary' => '只有选择合适的培训体系,才能为企业带来利益。',
                    'author' => '员圈小助手',
                    'class_id' => $class['class_id'],
                    'class_name' => $class['class_name'],
                    'cover_id' => $result['atId'],
                    'cover_url' => $result['atAttachment'],
                    'is_show_cover' => 1,
                    'is_notice' => 1,
                    'data_id' => $articleServ->buildDataID(),
                    'is_recommend' => 1,
                    'send_time' => MILLI_TIME,
                    'news_status' => 2,
                    'convert_status' => 2,
                    'content' => '<section style="background-color: rgb(255, 255, 255); box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="color: rgb(84, 141, 212); font-size: 16px;"><strong>企业要想建立完善的培训体系,应先明确培训目的。企业培训目的主要分为以下三个层次:</strong></span></p></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 10px 0%; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; width: 12%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 3px 0px; text-align: center; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; border: 1px solid rgb(253, 198, 32); background-color: rgb(253, 198, 32); width: 1.8em; height: 1.8em; line-height: 1.8em; border-radius: 100%; margin-left: auto; margin-right: auto; font-size: 18px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">01</p></section></section></section></section><section class="" style="display: inline-block; vertical-align: bottom; width: 88%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 5px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; border-bottom: 1px dashed rgb(175, 175, 175); margin-bottom: 0.25em; padding-left: 5px; padding-right: 5px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">岗位胜任为目的</p></section><section style="display: inline-block; vertical-align: bottom; width: 0.5em; height: 0.5em; border-radius: 50%; background-color: rgb(253, 198, 32); box-sizing: border-box;"></section></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">70%-80%企业对员工的培训是以此为培训目的的,重在通过培训使员工能够更好的适应岗位需要,胜任目前岗位。这样培训会更有针对性、实用性。但是以岗位胜任为目的培训往往会忽略员工的其他需求。</p><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 10px 0%; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; width: 12%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 3px 0px; text-align: center; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; border: 1px solid rgb(253, 198, 32); background-color: rgb(253, 198, 32); width: 1.8em; height: 1.8em; line-height: 1.8em; border-radius: 100%; margin-left: auto; margin-right: auto; font-size: 18px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">02</p></section></section></section></section><section class="" style="display: inline-block; vertical-align: bottom; width: 88%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 5px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; border-bottom: 1px dashed rgb(175, 175, 175); margin-bottom: 0.25em; padding-left: 5px; padding-right: 5px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">提升能力为目的</p></section><section style="display: inline-block; vertical-align: bottom; width: 0.5em; height: 0.5em; border-radius: 50%; background-color: rgb(253, 198, 32); box-sizing: border-box;"></section></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">企业为能提高组织的运作效率,希望员工能够一专多能,丰富员工工作内容,此时的培训是以提升员工能力为目的的。这对降低企业成本、提高组织工作效率很有帮助。但是这些技能的习得所花费的时间比较多,对企业来说是一种负担,对员工来说一方面增加了学习的成本和压力,另一方面,却也是对自己软实力的丰富和提高。</p><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 10px 0%; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; width: 12%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 3px 0px; text-align: center; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; border: 1px solid rgb(253, 198, 32); background-color: rgb(253, 198, 32); width: 1.8em; height: 1.8em; line-height: 1.8em; border-radius: 100%; margin-left: auto; margin-right: auto; font-size: 18px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">03</p></section></section></section></section><section class="" style="display: inline-block; vertical-align: bottom; width: 88%; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 5px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; box-sizing: border-box;"><section class="" style="display: inline-block; vertical-align: bottom; border-bottom: 1px dashed rgb(175, 175, 175); margin-bottom: 0.25em; padding-left: 5px; padding-right: 5px; box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">核心能力开发为目的</p></section><section style="display: inline-block; vertical-align: bottom; width: 0.5em; height: 0.5em; border-radius: 50%; background-color: rgb(253, 198, 32); box-sizing: border-box;"></section></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">职业核心能力是从事任何职业活动都需要的,能适应岗位不断变换和技术飞速发展的综合能力或基本能力。该类型的培训主要是结合企业自身战略发展需要,对核心骨干等进行分层分类培训,以提升骨干员工各方面创新意识为导向的培训。企业在培训的时候应明确什么是该岗位的核心能力,在请在这方面最有经验和见解的人或专业团队来进行培训。</p><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">我们对企业建立系统化的培训体系有这些建议:</p></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">企业应明确自身培训目的,目的不同课程设置、投入时间与精力都会有所不同,根据目的进行的设计,培训体系会更适合企业自身情况。</strong></p></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 10px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; width: 100%; vertical-align: top; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="padding: 0px 2px; font-size: 14px;  box-sizing: border-box;"><p style="clear: none; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">以岗位胜任为目的的培训,应尽量增加培训频次。</strong>公司的业绩要求员工能尽快为公司创造更多的价值,而初入职员工在信心和稳定性上都不足,增加培训频次可以让员工迅速提高技能,尽快了解公司并创造价值。</p></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 10px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; width: 100%; vertical-align: top; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="padding: 0px 2px; font-size: 14px;  box-sizing: border-box;"><p style="clear: none; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">以提升能力为目的的培训,则应建立配套的任职资格模型或能力模型。</strong>培训并非漫无目的,而是由极强针对性的,如果随意根据经验和直觉去培训,结果只能是浪费了大把的时间和金钱。</p></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="margin: 0px 0% 10px; position: static; box-sizing: border-box;"><section class="" style="display: inline-block; width: 100%; vertical-align: top; box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="padding: 0px 2px; font-size: 14px;  box-sizing: border-box;"><p style="clear: none; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">核心能力开发为导向的培训,则应注重高层意识的丰富与拓展。</strong>高层意识的人启用的是灵性思维,拥有一流的智慧和超凡的人格,知道的更多、看到的更深,在岗位上的贡献自然也就会更多。</p></section></section></section></section></section></section><section class="Powered-by-XIUMI V5" style="box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="font-size: 14px;  box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">一个适合企业发展的系统化的培训体系就好像企业的“换血再生系统”,关系到企业健康与否,关系到企业的未来,企业必须予以充分的重视。其中最要的是:<strong style="box-sizing: border-box;">只有选择合适的培训体系,才能为企业带来利益<strong style="font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box;">。</strong></strong></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;" powered-by="xiumi.us"><section class="" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"></section></section></section>',
                    'is_share' => 1,
                ];
                try {
                    $newsId = $articleServ->insert($news);
                } catch (\Exception $e) {
                    \Think\Log::record('写入头条出错:::' . var_export($e->getMessage(), true));
                }

                // 修改新闻未读人数
                $newsHelper = NewsHelper::instance();
                list($uids_all) = $newsHelper->getReadData($newsId);
                $articleServ->update($newsId, ['unread_total' => count($uids_all)]);

                // 保存阅读范围
                (new RightService())->saveData(['article_id' => $newsId], ['is_all' => 2]);

                if (isset($newsId)) {
                    // 写入推荐
                    $data_send = [
                        'app' => APP_DIR,
                        'dataCategoryId' => $class['class_id'],
                        'dataId' => $newsId,
                        'title' => $news['title'],
                        'attachId' => $result['atId'],
                        'pic' => $result['atAttachment'],
                        'url' => 'News/Frontend/Index/Detail?article_id=' . $newsId,
                        'right' => []
                    ];

                    \Com\Rpc::phprpc(rpcUrl('/Public/Rpc/Recommender/ArticleUpdate'))->invoke('Index', $data_send);
                }
            }
        }

        return true;
    }
}