天马学航——智慧教务系统(移动端)开发日志五

天马学航——智慧教务系统(移动端)开发日志五

日志摘要:更新了增值服务模块:绩点查询以及学业预警,处理了高并发环境下的卡顿问题

1、学生端绩点查询

通过学生选课成绩,动态计算绩点,并提供智能分析以及提出智能化的建议

界面设计
image-20240620111914879
源代码
@Entry
@Component
struct GPA {
  @State gpa:number = 4.4

  aboutToAppear(){
    this.Info()
  }

  build() {
    Column({ space: 5 }) {
      Text(" ")
      Row({ space: 10 }) {
        Text(" ")
        Image($r('app.media.back'))
          .width(30)
          .height(30)
          .onClick(function () {
            //返回上一页
            router.back() //直接返回
          })
        Text("绩点查询")
          .fontSize(30)
          .fontWeight(FontWeight.Bolder)
      }
      .width('100%')
      Column({space:0}){
        Text("----------------------------------------------")
        Row(){
          Text("检测到您还不是VIP用户,试用仅剩3天")
        }
        .width('100%')
        .height(40)
        .backgroundColor("#fff6f6f6")
      }
      Text(" ")
      Stack(){
        if(this.gpa<2.5){
          Progress({ value: this.gpa, total: 5, type: ProgressType.Ring })
            .width(150)
            .height(200)
            .color(Color.Red)    // 进度条前景色为灰色
            .style({ strokeWidth: 15})    // 设置strokeWidth进度条宽度为15.0vp
        }
        else {
          Progress({ value: this.gpa, total: 5, type: ProgressType.Ring })
            .width(150)
            .height(200)
            .color(Color.Blue)    // 进度条前景色为灰色
            .style({ strokeWidth: 15})    // 设置strokeWidth进度条宽度为15.0vp
        }
        Text(this.gpa+"/5")
          .fontSize(30)
      }


      Text("当前绩点:"+this.gpa)
        .fontSize(30)

      Text(" ")
      Text(" ")

      Column({space:20}){
        Row(){
          Text("当前状态:")
            .fontSize(20)
          if(this.gpa<2.5){
            Text("危险!")
              .fontSize(20)
              .fontColor(Color.Red)
              .fontWeight(FontWeight.Bolder)
          }
          else {
            Text("正常")
              .fontSize(20)
              .fontColor(Color.Blue)
              .fontWeight(FontWeight.Bolder)
          }
        }
        .width('100%')
      }
        .width('95%')
        .padding(20)
        .backgroundColor(Color.White)
        .borderRadius(15)
        .shadow({ radius: 6, color: '#1F000000', offsetX: 2, offsetY: 4 })
      Column({space:20}){
        Row(){
          Text("智能分析:")
            .fontSize(20)
            .fontWeight(FontWeight.Bolder)
        }
        .width('100%')
        if(this.gpa<=2.5){
          Text("您的绩点过低,可能影响到您的毕业,详情请见学业预警界面")
            .fontSize(15)
          Button("跳转到学业预警")
            .onClick(()=>{
              router.pushUrl({
                url: "pages/view/Student/ACA"
              },
                router.RouterMode.Single,
                err => {
                  if (err) {
                    console.log("跳转失败")
                  }
                }
              )
            })
        }
        else if(this.gpa<=3){
          Text("您的绩点较低,处于及格线边缘,建议拉高绩点,以免无法毕业")
            .fontSize(15)
          Button("跳转到成绩查询")
            .onClick(()=>{
              router.pushUrl({
                url: "pages/view/Student/StudentGrades"
              },
                router.RouterMode.Single,
                err => {
                  if (err) {
                    console.log("跳转失败")
                  }
                }
              )
            })
        }
        else if(this.gpa<4){
          Text("您的绩点正常,还需多加努力,争取绩点达到4+")
            .fontSize(15)
          Button("跳转到成绩查询")
            .onClick(()=>{
              router.pushUrl({
                url:"pages/view/Student/StudentGrades"
              },
                router.RouterMode.Single,
                err => {
                  if (err) {
                    console.log("跳转失败")
                  }
                }
              )
            })
        }
        else if(this.gpa>=4){
          Text("您的绩点极高,可以申请保研")
            .fontSize(15)
          Button("跳转到升学/保研申请")
            .onClick(()=>{
              promptAction.showToast({
                message: '该功能正在加紧研发中~',
                duration: 2000,
                bottom: 50
              });
            })
        }
      }
        .width('95%')
        .padding(20)
        .backgroundColor(Color.White)
        .borderRadius(15)
        .shadow({ radius: 6, color: '#1F000000', offsetX: 2, offsetY: 4 })
    }
  }

  aa(sum:number):string{
    let sum1 = sum.toFixed(1)
    return sum1
  }

  Info(){
    GetSTGrade.GSTG()
      .then(resp=>{
        let sum = 0
        let num = 0
        //计算学分绩点之和
        //这里定义学分为3
        resp.forEach(sc=>{
          let n
          if(sc.grade<50) n = sc.grade
          else n = sc.grade-50
          n = n/10*3
          sum+=n
          num++
        })
        let s1
        s1 = (1.0)*sum/(num*3)
        let s2 = this.aa(s1)
        this.gpa = parseFloat(s2)
      })
  }
}

2、学业预警

根据挂科情况动态分析学业预警情况,并列出所有挂科的科目

界面设计
image-20240620111914879
源代码
@Entry
@Component
struct ACA {
  @State gardess:SGpojo[] = []
  @State FC:number = 1
  @State Course:number = 5

  aboutToAppear(){
    this.info()
  }

  build() {
    Column({ space: 5 }) {
      Text(" ")
      Row({ space: 10 }) {
        Text(" ")
        Image($r('app.media.back'))
          .width(30)
          .height(30)
          .onClick(function () {
            //返回上一页
            router.back() //直接返回
          })
        Text("学业预警")
          .fontSize(30)
          .fontWeight(FontWeight.Bolder)
      }
      .width('100%')

      Column({ space: 0 }) {
        Text("----------------------------------------------")
        Row() {
          Text("检测到您还不是VIP用户,试用仅剩3天")
        }
        .width('100%')
        .height(40)
        .backgroundColor("#fff6f6f6")
      }

      Text(" ")

      Text("挂科情况")
        .fontSize(30)

      Stack(){
        Progress({ value: this.FC, total: this.Course, type: ProgressType.Ring })
          .width(150)
          .height(200)
          .color(Color.Red)    // 进度条前景色为灰色
          .style({ strokeWidth: 15})    // 设置strokeWidth进度条宽度为15.0vp

        Text(this.FC+"/"+this.Course)
          .fontSize(30)
          .fontColor(Color.Red)
      }

      Row(){
        Text("待处理的学业预警")
          .fontSize(20)
          .fontWeight(FontWeight.Bolder)
      }
      .width('100%')

      List({space:20}){
        ForEach(
          this.gardess,
          gardes=>{
            ListItem(){
                Row({space:30}){
                  Text(" ")
                  Column({space:20}){
                    Text(gardes.cname)
                      .fontColor(Color.Green)
                      .fontSize(20)
                      .fontWeight(FontWeight.Bolder)
                      .fontFamily("楷体")
                    if(gardes.grade<60){
                      Text("状态:不及格")
                        .fontSize(15)
                        .fontColor(Color.Red)
                    }
                    else {
                      Text("状态:及格")
                        .fontSize(15)
                        .fontColor(Color.Green)
                    }
                  }
                  .justifyContent(FlexAlign.Start)
                  .alignItems(HorizontalAlign.Start)
                  Blank()
                  if(gardes.grade<60){
                    Text(gardes.grade+"")
                      .fontWeight(FontWeight.Bolder)
                      .fontSize(30)
                      .fontColor(Color.Red)
                  }
                  else {
                    Text(gardes.grade+"")
                      .fontWeight(FontWeight.Bolder)
                      .fontSize(30)
                      .fontColor(Color.Green)
                  }
                }
                .width('95%')
                .padding(20)
                .backgroundColor(Color.White)
                .borderRadius(15)
                .shadow({ radius: 6, color: '#1F000000', offsetX: 2, offsetY: 4 })
            }
          }
        )
      }
    }
    .width('100%')
  }
  info(){
    GetSTGrade.GSTG()
      .then(resp=>{
        let sum1 = 0
        let sum2 = 0
        resp.forEach(sc=>{
          if(sc.grade<60){
            sum2++;
          }
          sum1++;
        })
        this.Course = sum1
        this.FC = sum2

        resp.forEach(sc=>{
          if(sc.grade<60){
            this.gardess.push(sc)
          }
        })
      })
  }
}

3、BUG修复

修复了多人访问线程死锁的问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值