Sfoglia il codice sorgente

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

CrazyIter 4 anni fa
parent
commit
7faffeae17

+ 13 - 13
TEAMModelOS/ClientApp/src/common/CollapseMenuLayout.vue

@@ -142,20 +142,20 @@
                         role: 'teacher|admin',
                         role: 'teacher|admin',
                         permission:'',
                         permission:'',
                         child: [
                         child: [
-                            //{
-                            //    icon: '',
-                            //    name: '课程管理',
-                            //    router: '/home/NewAdminCourse',
-                            //    tag:'M',
-                            //    role:'teacher|admin',
-                            //    permission:'',
-                            //},
+                            {
+                                icon: '',
+                                name: '课程管理(废弃)',
+                                router: '/home/newAdminCourse',
+                                tag:'M',
+                                role:'admin',
+                                permission:'',
+                            },
                             {
                             {
                                 icon: '',
                                 icon: '',
                                 name: '课程管理',
                                 name: '课程管理',
-                                router: '/home/NewAdminCourse',
+                                router: '/home/ManageCourse',
                                 tag:'M',
                                 tag:'M',
-                                role:'teacher|admin',
+                                role:'admin',
                                 permission:'',
                                 permission:'',
                             },
                             },
                             {
                             {
@@ -163,15 +163,15 @@
                                 name: '课堂时间',
                                 name: '课堂时间',
                                 router: '/home/CourseTime',
                                 router: '/home/CourseTime',
                                 tag:'M',
                                 tag:'M',
-                                role:'teacher|admin',
+                                role:'admin',
                                 permission:'',
                                 permission:'',
                             },
                             },
                             {
                             {
                                 icon: '',
                                 icon: '',
                                 name: '排课管理',
                                 name: '排课管理',
-                                router: '/home/courseManage',
+                                router: '/home/CoursePlan',
                                 tag:'M',
                                 tag:'M',
-                                role:'teacher|admin',
+                                role:'admin',
                                 permission:'',
                                 permission:'',
                             },
                             },
                             {
                             {

+ 13 - 1
TEAMModelOS/ClientApp/src/router/routes.js

@@ -212,7 +212,7 @@ export const routes = [
                 name: 'courseManage',
                 name: 'courseManage',
                 component: resolve => require(['@/view/coursemgmt/CourseManage.vue'], resolve)
                 component: resolve => require(['@/view/coursemgmt/CourseManage.vue'], resolve)
             },
             },
-            //管理员课程管理
+            //管理员课程管理(废弃)
             //{
             //{
             //    path: 'adminCourse',
             //    path: 'adminCourse',
             //    name: 'adminCourse',
             //    name: 'adminCourse',
@@ -225,12 +225,24 @@ export const routes = [
                 name: 'newAdminCourse',
                 name: 'newAdminCourse',
                 component: resolve => require(['@/view/newcourse/NewAdminCourse.vue'], resolve)
                 component: resolve => require(['@/view/newcourse/NewAdminCourse.vue'], resolve)
             },
             },
+            //学校课程管理
+            {
+                path: 'ManageCourse',
+                name: 'ManageCourse',
+                component: resolve => require(['@/view/newcourse/ManageCourse.vue'], resolve)
+            },
             //课程时间管理
             //课程时间管理
             {
             {
                 path: 'CourseTime',
                 path: 'CourseTime',
                 name: 'CourseTime',
                 name: 'CourseTime',
                 component: resolve => require(['@/view/newcourse/CourseTime.vue'], resolve)
                 component: resolve => require(['@/view/newcourse/CourseTime.vue'], resolve)
             },
             },
+            //排课管理
+            {
+                path: 'CoursePlan',
+                name: 'CoursePlan',
+                component: resolve => require(['@/view/newcourse/CoursePlan.vue'], resolve)
+            },
             // 新课纲管理
             // 新课纲管理
             {
             {
                 path: 'syllabus',
                 path: 'syllabus',

+ 8 - 0
TEAMModelOS/ClientApp/src/view/newcourse/CoursePlan.less

@@ -0,0 +1,8 @@
+@first-bgColor: #141414;
+@second-bgColor: #1b1b1b;
+@third-bgColor: #222222;
+@borderColor: #424242;
+@primary-textColor: #fff; //文本主颜色
+@second-textColor: #a5a5a5; //文本副级颜色
+@primary-fontSize: 14px;
+@second-fontSize: 16px;

+ 28 - 0
TEAMModelOS/ClientApp/src/view/newcourse/CoursePlan.vue

@@ -0,0 +1,28 @@
+<template>
+    <div>
+
+    </div>
+</template>
+<script>
+    export default {
+        data() {
+            return {
+
+            }
+        },
+        methods: {
+
+        },
+        created() {
+
+        },
+        mounted() {
+
+        }
+    }
+</script>
+<style scoped lang="less">
+    @import "./CoursePlan.less";
+</style>
+<style>
+</style>

+ 25 - 9
TEAMModelOS/ClientApp/src/view/newcourse/CourseTime.less

@@ -47,7 +47,7 @@
     cursor: pointer;
     cursor: pointer;
     width:338px;
     width:338px;
     background:rgba(100,100,100,.5);
     background:rgba(100,100,100,.5);
-    padding:15px 10px;
+    padding:10px 10px;
     position:relative;
     position:relative;
     margin-left:5px;
     margin-left:5px;
     color:white;
     color:white;
@@ -106,14 +106,26 @@
     margin: 5px;
     margin: 5px;
 }
 }
 
 
-.week-day-cell{
-    height:76px;
-    position:relative;
-    display:flex;
-    align-items:center;
-    justify-content:center;
+.week-day-cell {
+    height: 76px;
+    position: relative;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    cursor:pointer;
+}
+.week-day-cell:hover{
+    background:#404040;
 }
 }
-.week-day-cell::before {
+.week-day-cell:hover{
+    .toggle-status-btn{
+        display:inline-block;
+    }
+}
+.vact-status {
+    background: linear-gradient( to top right, rgba(96,96,96, 0) 0%, rgba(96,96,96, 0) calc(50% - 1px), rgba(96,96,96, 1) 50%, rgba(96,96,96, 0) calc(50% + 1px), rgba(96,96,96, 0) 100% );
+}
+/*.week-day-cell::before {
     position: absolute;
     position: absolute;
     content: '';
     content: '';
     right: -13px;
     right: -13px;
@@ -122,7 +134,7 @@
     border-left: 16px solid transparent;
     border-left: 16px solid transparent;
     border-bottom: 16px solid rgba(100, 100, 100, 0.5);
     border-bottom: 16px solid rgba(100, 100, 100, 0.5);
     transform: rotate(135deg);
     transform: rotate(135deg);
-}
+}*/
 .cell-status{
 .cell-status{
     color:aqua;
     color:aqua;
     font-size:12px;
     font-size:12px;
@@ -131,3 +143,7 @@
     bottom:0px;
     bottom:0px;
     cursor:pointer;
     cursor:pointer;
 }
 }
+
+.toggle-status-btn{
+    display:none;
+}

+ 87 - 79
TEAMModelOS/ClientApp/src/view/newcourse/CourseTime.vue

@@ -10,8 +10,8 @@
             <div class="time-line-content">
             <div class="time-line-content">
                 <vuescroll>
                 <vuescroll>
                     <Timeline style="margin-top:5px;">
                     <Timeline style="margin-top:5px;">
-                        <TimelineItem :color="index > 5 ? 'green':'aqua'" v-for="(item,index) in schoolInfo.timetable">
-                            <Icon :type="index > 5 ? 'md-alarm':'ios-book'" slot="dot"></Icon>
+                        <TimelineItem :color="item.type == 1 ? 'aqua':'green'" v-for="(item,index) in schoolInfo.timetable">
+                            <Icon :type="item.type == 1 ? 'ios-book':'md-alarm'" slot="dot"></Icon>
                             <div :class="index == curTmIndex ? 'time-line-item time-line-item-active':'time-line-item'" @click="selectTimeNode(index)">
                             <div :class="index == curTmIndex ? 'time-line-item time-line-item-active':'time-line-item'" @click="selectTimeNode(index)">
                                 <div class="time-setting-item">
                                 <div class="time-setting-item">
                                     <span class="time">{{item.time}}</span>
                                     <span class="time">{{item.time}}</span>
@@ -26,7 +26,7 @@
         <div class="time-table-wrap dark-iview-table">
         <div class="time-table-wrap dark-iview-table">
             <vuescroll>
             <vuescroll>
                 <h1 class="sch-title">课程表预览</h1>
                 <h1 class="sch-title">课程表预览</h1>
-                <Table :columns="timeColumns" disabled-hover :data="schoolInfo.timetable" border :span-method="handleSpan" style="width:90%;margin:auto;margin-top:10px;">
+                <Table :columns="timeColumns" disabled-hover :data="tableData" border :span-method="handleSpan" style="width:90%;margin:auto;margin-top:10px;">
                     <!--上午/下午-->
                     <!--上午/下午-->
                     <template slot-scope="{ row, index }" slot="sub">
                     <template slot-scope="{ row, index }" slot="sub">
                         <p style="padding:10px 0px 4px 0px;font-size: 20px;">
                         <p style="padding:10px 0px 4px 0px;font-size: 20px;">
@@ -44,52 +44,45 @@
                     </template>
                     </template>
                     <!--星期一-->
                     <!--星期一-->
                     <template slot-scope="{ row, index }" slot="MON">
                     <template slot-scope="{ row, index }" slot="MON">
-                        <div class="week-day-cell">
-                            <!--<span v-if="index >= 5">- -</span>-->
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status"/>
-                            <Icon v-else type="md-close" color="red" class="cell-status"/>
+                        <div :class="row.weeklies.MON.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <!--<Icon type="md-checkmark" class="cell-status" title="上课"/>-->
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'MON')" ghost type="default">{{row.weeklies.MON.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期二-->
                     <!--星期二-->
                     <template slot-scope="{ row, index }" slot="TUE">
                     <template slot-scope="{ row, index }" slot="TUE">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.TUE.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'TUE')" ghost type="default">{{row.weeklies.TUE.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期三-->
                     <!--星期三-->
                     <template slot-scope="{ row, index }" slot="WED">
                     <template slot-scope="{ row, index }" slot="WED">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.WED.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'WED')" ghost type="default">{{row.weeklies.WED.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期四-->
                     <!--星期四-->
                     <template slot-scope="{ row, index }" slot="THU">
                     <template slot-scope="{ row, index }" slot="THU">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.THU.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'THU')" ghost type="default">{{row.weeklies.THU.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期五-->
                     <!--星期五-->
                     <template slot-scope="{ row, index }" slot="FRI">
                     <template slot-scope="{ row, index }" slot="FRI">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.FRI.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'FRI')" ghost type="default">{{row.weeklies.FRI.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期六-->
                     <!--星期六-->
                     <template slot-scope="{ row, index }" slot="SAT">
                     <template slot-scope="{ row, index }" slot="SAT">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.SAT.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'SAT')" ghost type="default">{{row.weeklies.SAT.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                     <!--星期日-->
                     <!--星期日-->
                     <template slot-scope="{ row, index }" slot="SUN">
                     <template slot-scope="{ row, index }" slot="SUN">
-                        <div class="week-day-cell">
-                            <Icon v-if="index < 5" type="md-checkmark" class="cell-status" />
-                            <Icon v-else type="md-close" color="red" class="cell-status" />
+                        <div :class="row.weeklies.SUN.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
+                            <Button class="toggle-status-btn" @click="confirmSetVact(row,'SUN')" ghost type="default">{{row.weeklies.SUN.status == 1 ? '设为休假':'设为上课'}}</Button>
                         </div>
                         </div>
                     </template>
                     </template>
                 </Table>
                 </Table>
@@ -116,7 +109,7 @@
                             <span>上课时间</span>
                             <span>上课时间</span>
                         </Radio>
                         </Radio>
                         <Radio label="0" style="margin-left:20px;">
                         <Radio label="0" style="margin-left:20px;">
-                            <span>其他时间</span>
+                            <span>休息/其他时间</span>
                         </Radio>
                         </Radio>
                     </RadioGroup>
                     </RadioGroup>
                 </FormItem>
                 </FormItem>
@@ -146,12 +139,35 @@
         data() {
         data() {
             return {
             return {
                 subIndex: undefined,
                 subIndex: undefined,
-                weekDay:'',
+                weekDay: '',
                 curTmIndex: 0,
                 curTmIndex: 0,
                 isVact: undefined,
                 isVact: undefined,
                 addTimeStatus: false,
                 addTimeStatus: false,
                 setVactStatus: false,
                 setVactStatus: false,
                 schoolInfo: {},
                 schoolInfo: {},
+                defVact: {
+                    'MON': {
+                        status:1
+                    },
+                    'TUE': {
+                        status:1
+                    },
+                    'WED': {
+                        status:1
+                    },
+                    'THU': {
+                        status:1
+                    },
+                    'FRI': {
+                        status:1
+                    },
+                    'SAT': {
+                        status:0
+                    },
+                    'SUN':{
+                        status:0
+                    }
+                },
                 timeColumns: [
                 timeColumns: [
                     {
                     {
                         title: ' ',
                         title: ' ',
@@ -194,34 +210,7 @@
                     {
                     {
                         title:'星期六',
                         title:'星期六',
                         slot: 'SAT',
                         slot: 'SAT',
-                        align:'center',
-                        //renderHeader: (h,obj) => {
-                        //    return h(
-                        //        'span',
-                        //        [
-                        //            '星期六',
-                        //            h(
-                        //                'Icon',
-                        //                {
-                        //                    props: {
-                        //                        type: 'ios-settings'
-                        //                    },
-                        //                    style: {
-                        //                        fontSize: '18px', // 改变icon的样式
-                        //                        color: '#559DF9',
-                        //                        cursor: 'pointer'
-                        //                    },
-                        //                    on: {
-                        //                        click: () => {
-                        //                            this.setVactStatus = true
-                        //                            this.weekDay = 'SAT'
-                        //                        }
-                        //                    }
-                        //                }
-                        //            )
-                        //        ]
-                        //    )
-                        //}
+                        align:'center'
                     },
                     },
                     {
                     {
                         title:'星期日',
                         title:'星期日',
@@ -259,7 +248,9 @@
                 timeNode: {
                 timeNode: {
                     label: '',
                     label: '',
                     start: '',
                     start: '',
-                    end:''
+                    end: '',
+                    type: '',
+                    weeklies: {}
                 },
                 },
                 ruleValidate: {
                 ruleValidate: {
                     label: [
                     label: [
@@ -277,6 +268,10 @@
             }
             }
         },
         },
         methods: {
         methods: {
+            //显示设置休假
+            showSetVact(row,index,weekDay) {
+
+            },
             //根据上下午合并单元格
             //根据上下午合并单元格
             handleSpan({ row, column, rowIndex, columnIndex }) {
             handleSpan({ row, column, rowIndex, columnIndex }) {
                 this.getSubIndex()
                 this.getSubIndex()
@@ -294,33 +289,29 @@
 
 
             getSubIndex() {
             getSubIndex() {
                 for (let index in this.schoolInfo.timetable) {
                 for (let index in this.schoolInfo.timetable) {
-                    if (parseInt(this.schoolInfo.timetable[index].time.substr(0, 2)) > 12) {
+                    if (parseInt(this.tableData[index].time.substr(0, 2)) > 12) {
                         this.subIndex = parseInt(index)
                         this.subIndex = parseInt(index)
                         break
                         break
                     }
                     }
                 }
                 }
             },
             },
-            //设置周六周日休假
-            confirmSetVact() {
-                if (this.isVact == 1) {
-                    if (this.weekDay == 'SUN') {
-                        for (let index in this.schoolInfo.timetable) {
-                            this.$set(this.schoolInfo.timetable[index], 'SUN', '- -')
-                        }
-                    } else if (this.weekDay == 'SAT') {
-                        for (let index in this.schoolInfo.timetable) {
-                            this.$set(this.schoolInfo.timetable[index], 'SAT', '- -')
-                        }
-                    }
-                } else if (this.isVact == 0) {
-                    if (this.weekDay == 'SUN') {
-                        for (let index in this.schoolInfo.timetable) {
-                            this.$set(this.schoolInfo.timetable[index], 'SUN', '')
-                        }
-                    } else if (this.weekDay == 'SAT') {
-                        for (let index in this.schoolInfo.timetable) {
-                            this.$set(this.schoolInfo.timetable[index], 'SAT', '')
-                        }
+            //设置休假/上课
+            confirmSetVact(row, key) {
+                console.log(row)
+                for (let index in this.schoolInfo.timetable) {
+                    if (this.schoolInfo.timetable[index].time == row.time) {
+                        this.schoolInfo.timetable[index].weeklies[key].status = 1 - parseInt(this.schoolInfo.timetable[index].weeklies[key].status)
+                        this.$api.schoolSetting.schoolSettingSaveOrUpdate(this.schoolInfo).then(
+                            (res) => {
+                                if (res.error == null) {
+                                    this.$Message.success(this.$t('schoolBaseInfo.ssTips3'))
+                                }
+                            },
+                            (err) => {
+                                this.$Message.error("设置失败!")
+                            }
+                        )
+                        break
                     }
                     }
                 }
                 }
             },
             },
@@ -336,6 +327,8 @@
                 this.timeNode.label = ''
                 this.timeNode.label = ''
                 this.timeNode.start = ''
                 this.timeNode.start = ''
                 this.timeNode.end = ''
                 this.timeNode.end = ''
+                this.timeNode.type = ''
+                this.timeNode.weeklies = []
             },
             },
             //编辑时间节点
             //编辑时间节点
             editTimeNode(index) {
             editTimeNode(index) {
@@ -343,6 +336,7 @@
                 this.timeNodeIndex = index
                 this.timeNodeIndex = index
                 let times = this.schoolInfo.timetable[index].time.split(' - ')
                 let times = this.schoolInfo.timetable[index].time.split(' - ')
                 this.timeNode.label = this.schoolInfo.timetable[index].label
                 this.timeNode.label = this.schoolInfo.timetable[index].label
+                this.timeNode.type = this.schoolInfo.timetable[index].type
                 this.timeNode.start = times[0]
                 this.timeNode.start = times[0]
                 if (times.length > 1) {
                 if (times.length > 1) {
                     this.timeNode.end = times[1]
                     this.timeNode.end = times[1]
@@ -380,7 +374,9 @@
                             }
                             }
                             this.schoolInfo.timetable.splice(this.timeNodeIndex + 1, 0, {
                             this.schoolInfo.timetable.splice(this.timeNodeIndex + 1, 0, {
                                 label: this.timeNode.label,
                                 label: this.timeNode.label,
-                                time: time
+                                time: time,
+                                type: this.timeNode.type,
+                                weeklies: {...this.defVact}
                             })
                             })
                         } else {
                         } else {
                             let time = this.timeNode.start
                             let time = this.timeNode.start
@@ -389,6 +385,10 @@
                             }
                             }
                             this.schoolInfo.timetable[this.timeNodeIndex].label = this.timeNode.label
                             this.schoolInfo.timetable[this.timeNodeIndex].label = this.timeNode.label
                             this.schoolInfo.timetable[this.timeNodeIndex].time = time
                             this.schoolInfo.timetable[this.timeNodeIndex].time = time
+                            this.schoolInfo.timetable[this.timeNodeIndex].type = this.timeNode.type
+                            if (!this.schoolInfo.timetable[this.timeNodeIndex].weeklies) {
+                                this.schoolInfo.timetable[this.timeNodeIndex].weeklies = {...this.defVact}
+                            }
                         }
                         }
                         this.$api.schoolSetting.schoolSettingSaveOrUpdate(this.schoolInfo).then(
                         this.$api.schoolSetting.schoolSettingSaveOrUpdate(this.schoolInfo).then(
                             (res) => {
                             (res) => {
@@ -409,6 +409,14 @@
         },
         },
         created() {
         created() {
             this.schoolInfo = this.$store.state.schoolBaseInfo.schoolBaseInfo
             this.schoolInfo = this.$store.state.schoolBaseInfo.schoolBaseInfo
+        },
+        computed: {
+            tableData(){
+                let arr = this.schoolInfo.timetable.filter((item, index) => {
+                    return item.type == 1
+                })
+                return arr
+            }
         }
         }
     }
     }
 </script>
 </script>

+ 8 - 0
TEAMModelOS/ClientApp/src/view/newcourse/ManageCourse.less

@@ -0,0 +1,8 @@
+@first-bgColor: #141414;
+@second-bgColor: #1b1b1b;
+@third-bgColor: #222222;
+@borderColor: #424242;
+@primary-textColor: #fff; //文本主颜色
+@second-textColor: #a5a5a5; //文本副级颜色
+@primary-fontSize: 14px;
+@second-fontSize: 16px;

+ 29 - 0
TEAMModelOS/ClientApp/src/view/newcourse/ManageCourse.vue

@@ -0,0 +1,29 @@
+<template>
+    <div>
+
+    </div>
+</template>
+<script>
+    export default {
+        data() {
+            return {
+
+            }
+        },
+        methods: {
+
+        },
+        created() {
+
+        },
+        mounted() {
+
+        }
+    }
+</script>
+<style scoped lang="less">
+    @import "./ManageCourse.less";
+</style>
+<style>
+
+</style>

+ 24 - 2
TEAMModelOS/Controllers/Task/HomeworkController.cs

@@ -1,15 +1,21 @@
-using Grpc.Extension.Common;
+
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Azure.ServiceBus;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Configuration;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
+using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.Models;
 using TEAMModelOS.Models;
+using TEAMModelOS.SDK.Context.Configuration;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Services.Learn;
 using TEAMModelOS.Service.Services.Learn;
@@ -26,6 +32,8 @@ namespace TEAMModelOS.Controllers.Learn
     {
     {
         private readonly IAzureCosmosDBV3Repository _cosmos;
         private readonly IAzureCosmosDBV3Repository _cosmos;
         private readonly ITimerWorkService _timerWorkService;
         private readonly ITimerWorkService _timerWorkService;
+        private static ITopicClient topicClient;
+        readonly string ServiceBusConnectionString = BaseConfigModel.Configuration["HaBookAuth:ServiceBus"];
 
 
         public HomeworkController(IAzureCosmosDBV3Repository cosmos, ITimerWorkService timerWorkService)
         public HomeworkController(IAzureCosmosDBV3Repository cosmos, ITimerWorkService timerWorkService)
         {
         {
@@ -88,9 +96,11 @@ namespace TEAMModelOS.Controllers.Learn
         [HttpPost("upsert")]
         [HttpPost("upsert")]
         public async Task<BaseJosnRPCResponse> Upsert(JosnRPCRequest<HomeworkDto> request)
         public async Task<BaseJosnRPCResponse> Upsert(JosnRPCRequest<HomeworkDto> request)
         {
         {
-            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();           
+            topicClient = new TopicClient(ServiceBusConnectionString, Constants.TopicName);
             //新增
             //新增
             if (string.IsNullOrEmpty(request.@params.homeWork.id))
             if (string.IsNullOrEmpty(request.@params.homeWork.id))
+
             {
             {
                 request.@params.homeWork.id = Guid.NewGuid().ToString();
                 request.@params.homeWork.id = Guid.NewGuid().ToString();
                 request.@params.homeWork.state = 100;
                 request.@params.homeWork.state = 100;
@@ -108,6 +118,18 @@ namespace TEAMModelOS.Controllers.Learn
             {
             {
                 //TimerWork<HomeWork>(request.@params.homeWork.startTime,new Dictionary<string, object> { { "id", request.@params.homeWork.id } });
                 //TimerWork<HomeWork>(request.@params.homeWork.startTime,new Dictionary<string, object> { { "id", request.@params.homeWork.id } });
                 //设定开始时间
                 //设定开始时间
+                Dictionary<string, object> dict = new Dictionary<string, object>() {
+                    { "name",typeof(Homework).Name},
+                    { "id",request.@params.homeWork.id},
+                    { "status",200}
+                };
+                var message = new Message(Encoding.UTF8.GetBytes(dict.ToApiJson()));
+                long time = request.@params.homeWork.startTime - new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
+                if (time <= 0) {
+                    return builder.Data("请重新设置时间").build();
+                }
+                await topicClient.ScheduleMessageAsync(message, new DateTimeOffset(DateTimeHelper.ConvertToDateTime(request.@params.homeWork.startTime)));
+                await topicClient.SendAsync(message);
                 _timerWorkService.TimerWork<Homework>(request.@params.homeWork.startTime,200, new Dictionary<string, object> { { "id", request.@params.homeWork.id } });
                 _timerWorkService.TimerWork<Homework>(request.@params.homeWork.startTime,200, new Dictionary<string, object> { { "id", request.@params.homeWork.id } });
             }
             }
 
 

+ 12 - 0
TEAMModelOS/Models/Constants.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Models
+{
+    public static class Constants
+    {
+        public const string TopicName = "test_topic_ActiveTask";
+    }
+}

+ 1 - 0
TEAMModelOS/TEAMModelOS.csproj

@@ -15,6 +15,7 @@
     <PackageReference Include="Caching.CSRedis" Version="3.5.5" />
     <PackageReference Include="Caching.CSRedis" Version="3.5.5" />
     <PackageReference Include="CSRedisCore" Version="3.5.5" />
     <PackageReference Include="CSRedisCore" Version="3.5.5" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
+    <PackageReference Include="Microsoft.Azure.ServiceBus" Version="4.1.3" />
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.3" />
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.3" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
     <PackageReference Include="VueCliMiddleware" Version="3.0.0" />
     <PackageReference Include="VueCliMiddleware" Version="3.0.0" />

+ 1 - 0
TEAMModelOS/appsettings.Development.json

@@ -31,6 +31,7 @@
     "TeamModelLoginUrl": "https://account.habookaclass.biz/?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsb2dpbiIsImF1ZCI6ImNoZW5nZHVMb2dpbiIsImlzcyI6Imh0dHBzOi8vYXBpLmhhYm9va2FjbGFzcy5iaXoiLCJpYXQiOjE1MzYxMzUwNDcsIm5iZiI6MTUzNjEzNTA0NywiZXhwIjoxNTY3NTU1MjAwLCJpZHAiOiJIYWJvb2sgQ29yZVNlcnZpY2UifQ.F4AnkbJrMRoZvJ6SC-lqZEYIYSoq5x8lvX6_a3YqSgM&callback=",
     "TeamModelLoginUrl": "https://account.habookaclass.biz/?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsb2dpbiIsImF1ZCI6ImNoZW5nZHVMb2dpbiIsImlzcyI6Imh0dHBzOi8vYXBpLmhhYm9va2FjbGFzcy5iaXoiLCJpYXQiOjE1MzYxMzUwNDcsIm5iZiI6MTUzNjEzNTA0NywiZXhwIjoxNTY3NTU1MjAwLCJpZHAiOiJIYWJvb2sgQ29yZVNlcnZpY2UifQ.F4AnkbJrMRoZvJ6SC-lqZEYIYSoq5x8lvX6_a3YqSgM&callback=",
     "AccountUrl": "https://api.habookaclass.biz/account",
     "AccountUrl": "https://api.habookaclass.biz/account",
     "ServiceUrl": "https://api.habookaclass.biz/service",
     "ServiceUrl": "https://api.habookaclass.biz/service",
+    "ServiceBus": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
     "UserInfoKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJpZCIsImF1ZCI6ImNoZW5nZHVJZCIsImlzcyI6Imh0dHBzOi8vYXBpLmhhYm9va2FjbGFzcy5iaXoiLCJpYXQiOjE1MzYwNTIzNjcsIm5iZiI6MTUzNjA1MjM2NywiZXhwIjoxNTY3NTU1MjAwLCJpZHAiOiJIYWJvb2sgQ29yZVNlcnZpY2UifQ.RGKDVtwFEp4OBctlHOuF6yqyI21fTz4cinCxjFCxkSQ",
     "UserInfoKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJpZCIsImF1ZCI6ImNoZW5nZHVJZCIsImlzcyI6Imh0dHBzOi8vYXBpLmhhYm9va2FjbGFzcy5iaXoiLCJpYXQiOjE1MzYwNTIzNjcsIm5iZiI6MTUzNjA1MjM2NywiZXhwIjoxNTY3NTU1MjAwLCJpZHAiOiJIYWJvb2sgQ29yZVNlcnZpY2UifQ.RGKDVtwFEp4OBctlHOuF6yqyI21fTz4cinCxjFCxkSQ",
     "SchoolCodeKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzY2hvb2xDb2RlIiwiYXVkIjoiY2hlbmdkdVNjaG9vbENvZGUiLCJpc3MiOiJodHRwczovL2FwaS5oYWJvb2thY2xhc3MuYml6IiwiaWF0IjoxNTM2MDUyNDI3LCJuYmYiOjE1MzYwNTI0MjcsImV4cCI6MTU2NzU1NTIwMCwiaWRwIjoiSGFib29rIENvcmVTZXJ2aWNlIn0.8m5VH3Nz4N9EdMz8AexTOEuDVitcJZFKy9DfW_UQkSY",
     "SchoolCodeKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzY2hvb2xDb2RlIiwiYXVkIjoiY2hlbmdkdVNjaG9vbENvZGUiLCJpc3MiOiJodHRwczovL2FwaS5oYWJvb2thY2xhc3MuYml6IiwiaWF0IjoxNTM2MDUyNDI3LCJuYmYiOjE1MzYwNTI0MjcsImV4cCI6MTU2NzU1NTIwMCwiaWRwIjoiSGFib29rIENvcmVTZXJ2aWNlIn0.8m5VH3Nz4N9EdMz8AexTOEuDVitcJZFKy9DfW_UQkSY",
     "SmsKey": "Basic ZmYwMWM0YTJjODdmZmNkYTUyNjhmMDEwOmE0YTE5YTVjNTU2ZWVhZTNjZmZhNTI0Mg==",
     "SmsKey": "Basic ZmYwMWM0YTJjODdmZmNkYTUyNjhmMDEwOmE0YTE5YTVjNTU2ZWVhZTNjZmZhNTI0Mg==",