Просмотр исходного кода

Merge branch 'dev' of ssh://10.10.100.21/source/smartschool-platform into dev

chenw 7 лет назад
Родитель
Сommit
1108071e4f
20 измененных файлов с 203 добавлено и 87 удалено
  1. 24 0
      applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/po/School.java
  2. 4 2
      applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/repository/SchoolRepository.java
  3. 3 1
      applications/device/device-client/src/main/resources/schema.sql
  4. 31 21
      applications/device/device-client/src/main/resources/static/iccard.html
  5. 2 0
      applications/device/device-client/src/main/resources/static/js/school.js
  6. 21 5
      applications/device/device-client/src/main/resources/static/school.html
  7. 3 4
      applications/device/device-server/src/test/java/com/usoftchina/smartschool/device/test/TestService.java
  8. 16 6
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java
  9. 1 2
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java
  10. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java
  11. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysStudentMapper.java
  12. 0 2
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java
  13. 5 0
      applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml
  14. 4 9
      applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml
  15. 1 1
      applications/wechat/wechat-server/src/main/resources/config/application-docker-cloud.yml
  16. 24 5
      applications/wechat/wechat-server/src/main/resources/config/application-docker-test.yml
  17. 24 7
      frontend/pc-web/app/view/Interaction/timetable/Detail.js
  18. 30 0
      frontend/pc-web/app/view/Interaction/timetable/DetailModel.js
  19. 0 16
      frontend/pc-web/app/view/core/form/FormPanel.js
  20. 6 6
      frontend/pc-web/app/view/core/form/FormPanelController.js

+ 24 - 0
applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/po/School.java

@@ -11,6 +11,14 @@ public class School implements Serializable {
      * 学校名称
      */
     private String name;
+    /**
+     * ID
+     */
+    private String id;
+    /**
+     * 私钥
+     */
+    private String secret;
 
     public String getName() {
         return name;
@@ -19,4 +27,20 @@ public class School implements Serializable {
     public void setName(String name) {
         this.name = name;
     }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
 }

+ 4 - 2
applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/repository/SchoolRepository.java

@@ -27,10 +27,12 @@ public class SchoolRepository{
     }
 
     public void save(School school) {
-        jdbcTemplate.update("insert into school (name) values (?)", school.getName());
+        jdbcTemplate.update("insert into school (name,id,secret) values (?,?,?)", school.getName(),
+                school.getId(), school.getSecret());
     }
 
     public void update(School school) {
-        jdbcTemplate.update("update school set name=?", school.getName());
+        jdbcTemplate.update("update school set name=?,id=?,secret=?",
+                school.getName(), school.getId(), school.getSecret());
     }
 }

+ 3 - 1
applications/device/device-client/src/main/resources/schema.sql

@@ -10,7 +10,9 @@ password varchar(50) not null
 
 create table if not exists school
 (
-name varchar(500) primary key not null
+name varchar(500) not null,
+id varchar(32) not null,
+secret varchar(100) not null
 );
 
 create table if not exists iccard

+ 31 - 21
applications/device/device-client/src/main/resources/static/iccard.html

@@ -26,32 +26,42 @@
 </nav>
 <div class="container">
     <div class="row justify-content-md-center">
-        <div class="col-lg-auto" style="width: 500px">
+        <div class="col-lg-auto" style="width: 500px;padding: 20px">
             <form id="form">
-                <div class="form-group">
-                    <label for="ipInput">IP</label>
-                    <input type="text" class="form-control" id="ipInput" name="ip" required
-                           aria-describedby="ipHelp" placeholder="ip地址,例如192.168.1.100">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="ipInput">IP</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="ipInput" name="ip" required
+                               placeholder="ip地址,例如192.168.1.100">
+                    </div>
                 </div>
-                <div class="form-group">
-                    <label for="portInput">端口</label>
-                    <input type="text" class="form-control" id="portInput" name="port" required
-                           aria-describedby="portHelp" placeholder="tcp端口,例如37777">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="portInput">端口</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="portInput" name="port" required
+                               placeholder="tcp端口,例如1433">
+                    </div>
                 </div>
-                <div class="form-group">
-                    <label for="usernameInput">账号</label>
-                    <input type="text" class="form-control" id="usernameInput" name="username"
-                           value="admin" required aria-describedby="usernameHelp" placeholder="数据库账号,例如sa">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="usernameInput">账号</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="usernameInput" name="username"
+                               value="admin" required placeholder="数据库账号,例如sa">
+                    </div>
                 </div>
-                <div class="form-group">
-                    <label for="passwordInput">密码</label>
-                    <input type="password" class="form-control" id="passwordInput" name="password"
-                           required aria-describedby="passwordHelp" placeholder="数据库密码">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="passwordInput">密码</label>
+                    <div class="col-sm-10">
+                        <input type="password" class="form-control" id="passwordInput" name="password"
+                               required placeholder="数据库密码">
+                    </div>
                 </div>
-                <div class="form-group">
-                    <label for="databaseNameInput">数据库</label>
-                    <input type="text" class="form-control" id="databaseNameInput" name="databaseName"
-                           required aria-describedby="databaseNameHelp" placeholder="数据库名称">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="databaseNameInput">数据库</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="databaseNameInput" name="databaseName"
+                               required placeholder="数据库名称">
+                    </div>
                 </div>
                 <button type="button" class="btn btn-primary btn-save">保存</button>
             </form>

+ 2 - 0
applications/device/device-client/src/main/resources/static/js/school.js

@@ -8,6 +8,8 @@ $(document).ready(function () {
                     success: function (content) {
                         if (content.success) {
                             $('#nameInput').val(content.data.name);
+                            $('#idInput').val(content.data.id);
+                            $('#secretInput').val(content.data.secret);
                         } else {
                             alert(content.message);
                         }

+ 21 - 5
applications/device/device-client/src/main/resources/static/school.html

@@ -26,12 +26,28 @@
 </nav>
 <div class="container">
     <div class="row justify-content-md-center">
-        <div class="col-lg-auto" style="width: 500px">
+        <div class="col-lg-auto" style="width: 500px;padding: 20px">
             <form id="form">
-                <div class="form-group">
-                    <label for="nameInput">名称</label>
-                    <input type="text" class="form-control" id="nameInput" name="name" required
-                           aria-describedby="nameHelp" placeholder="学校名称">
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="nameInput">名称</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="nameInput" name="name" required
+                               placeholder="学校名称">
+                    </div>
+                </div>
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="idInput">ID</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="idInput" name="id" required
+                               placeholder="学校唯一标志">
+                    </div>
+                </div>
+                <div class="form-group row">
+                    <label class="col-sm-2 col-form-label" for="secretInput">私钥</label>
+                    <div class="col-sm-10">
+                        <input type="text" class="form-control" id="secretInput" name="secret" required
+                               placeholder="学校数据传输私钥">
+                    </div>
                 </div>
                 <button type="button" class="btn btn-primary btn-save">保存</button>
             </form>

+ 3 - 4
applications/device/device-server/src/test/java/com/usoftchina/smartschool/device/test/TestService.java

@@ -2,7 +2,6 @@ package com.usoftchina.smartschool.device.test;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.usoftchina.smartschool.device.dto.AccessControlInfo;
-import com.usoftchina.smartschool.device.service.AccessService;
 import com.usoftchina.smartschool.utils.DateUtils;
 import com.usoftchina.smartschool.wechat.api.WechatApi;
 import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
@@ -20,8 +19,8 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 public class TestService {
 
-    @Autowired
-    AccessService accessService;
+  /*  @Autowired
+    AccessService accessService;*/
     @Autowired
     WechatApi wechatApi;
 
@@ -30,7 +29,7 @@ public class TestService {
         AccessControlInfo info = new AccessControlInfo();
         info.setCardNo("school");
         info.setEventType(1);
-        accessService.accessEvent(info);
+        //accessService.accessEvent(info);
     }
 
     @Test

+ 16 - 6
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java

@@ -212,15 +212,25 @@ public class GradeServiceImpl implements GradeService{
             throw new BizException(BizExceptionCode.USELESS_DATA);
         }
         Integer check = 0;
-        //检测学生
-        check = sysStudentMapper.countStudent(id);
-        if(check > 0){
-            throw new BizException(BizExceptionCode.EFFECTIVE_CLASS_DATA);
+        //学生检测
+        check = sysStudentMapper.checkStu(id);
+        if (check > 0) {
+            throw new BizException(BizExceptionCode.EXISTS_STU);
+        }
+        //教师检测
+        check = sysStudentMapper.checkTeacher(id);
+        if (check > 0) {
+            throw new BizException(BizExceptionCode.EXISTS_TEACHER);
+        }
+        //课表检测
+        check = sysStudentMapper.repeatCurriculum(id);
+        if (check > 0) {
+            throw new BizException(BizExceptionCode.EXISTS_CURRICULUM);
         }
         //检测科目
-        check = sysTeacherMapper.checkTeacherSubjects(id);
+        check = homeWorkMapper.homeWorkRelease(id);
         if(check > 0){
-            throw new BizException(BizExceptionCode.EXISTS_TEACHER_SUBJECTS);
+            throw new BizException(BizExceptionCode.HOMEWORK_RELEASE);
         }
         sysClazzMapper.deleteByPrimaryKey(id);
     }

+ 1 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java

@@ -24,12 +24,11 @@ public enum BizExceptionCode implements BaseExceptionCode {
     EXISTS_SUBJECT_TEACHER(5000012, "该课程存在班级与任课教师,禁止删除"),
     EXISTS_SCORE_PUBLISH(5000013, "存在已发布成绩,禁止删除"),
     EXISTS_CLASS(500011, "存在班级,无法删除"),
-    EXISTS_TEACHER_SUBJECTS(500012, "存在学科信息,无法删除"),
+    HOMEWORK_RELEASE(500012, "存在发布作业,无法删除"),
     REPEAT_SUBJECTS(600001, "老师已在这个班任教"),
     REPEAT_GRADE_NAME(600001, "年级名称重复"),
     REPEAT_CLASS_NAME(600002, "班级名称重复"),
     REPEAT_STUDENT_NUMBER(600003, "学生学号不可重复"),
-    EFFECTIVE_CLASS_DATA(600004, "无法删除有学生的班级"),
     TASK_RELEASE_STATUS(600005, "作业已发布无法更改"),
     COURSE_RELEASE_STATUS(600006, "课程表已生效,无法删除"),
     NOTICE_RELEASE_STATUS(600007, "学校发布已生效,无法删除"),

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java

@@ -32,4 +32,6 @@ public interface HomeWorkMapper {
      * @return
      */
     int taskStatus(@Param("task_status") String task_status,@Param("task_id") Long task_id);
+
+    Integer homeWorkRelease(Long id);
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysStudentMapper.java

@@ -57,6 +57,8 @@ public interface SysStudentMapper {
 
     Integer checkCurriculum(Long id);
 
+    Integer repeatCurriculum(Long id);
+
     /**
      * 学生信息:学号重复
      * @return

+ 0 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java

@@ -41,7 +41,5 @@ public interface SysTeacherMapper {
 
     int checkTeacher(@Param("teacher_id") Long teacher_id);
 
-    Integer checkTeacherSubjects(@Param("clazz_id") Long clazz_id);
-
     void deleteDetail(@Param("teacher_clazz_id") Long teacher_clazz_id);
 }

+ 5 - 0
applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml

@@ -258,4 +258,9 @@
             </if>
         </where>
     </select>
+
+    <select id="homeWorkRelease" parameterType="long" resultType="integer">
+      select count(1) from sys_clazz left join task_notify on sys_clazz.clazz_name=task_notify.classz_name
+      where sys_clazz.clazz_id = #{id} and task_notify.task_status=1
+  </select>
 </mapper>

+ 4 - 9
applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml

@@ -458,6 +458,10 @@
     select count(1) from clazz_curriculum where clazz_id = #{id}
   </select>
 
+  <select id="repeatCurriculum" parameterType="long" resultType="integer">
+    select count(1) from clazz_curriculum where clazz_id = #{id} and clazz_curriculum.cur_status=1
+  </select>
+
   <select id="count" resultType="int">
     select count(*) from sys_student
     <where>
@@ -476,15 +480,6 @@
     where stu_number = #{stu_number,jdbcType=VARCHAR}
   </select>
 
-  <select id="countStudent" resultType="Integer">
-    select count(*) from sys_student
-    <where>
-      <if test="clazz_id != null">
-         clazz_id=#{clazz_id}
-      </if>
-    </where>
-  </select>
-
   <select id="selectIdByClazzId" resultType="string" parameterType="long">
     SELECT stu_id FROM sys_student WHERE clazz_id = #{clazzId}
   </select>

+ 1 - 1
applications/wechat/wechat-server/src/main/resources/config/application-docker-cloud.yml

@@ -22,7 +22,7 @@ spring:
         max-lifetime: 1800000
         connection-timeout: 30000
   rabbitmq:
-      host: 127.0.0.1
+      host: 132.232.174.14
       port: 5672
       virtual-host: school
       username: saas

+ 24 - 5
applications/wechat/wechat-server/src/main/resources/config/application-docker-test.yml

@@ -1,12 +1,31 @@
 eureka:
   instance:
-    hostname: saas-sale-server-test
+    hostname: smartschool-wechat-server
     prefer-ip-address: false
   client:
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@smartschool-eureka-server:9500/eureka/
 spring:
+  redis:
+    host: 172.27.0.13
+    port: 6379
+    password: select111***
+  datasource:
+      driver-class-name: com.mysql.jdbc.Driver
+      url: jdbc:mysql://172.27.0.15:3306/smart_campus?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
+      username: root
+      password: select111***
+      hikari:
+        minimum-idle: 5
+        maximum-pool-size: 50
+        idle-timeout: 30000
+        max-lifetime: 1800000
+        connection-timeout: 30000
   rabbitmq:
-    virtual-host: test
-server:
-  port: 8835
+      host: 127.0.0.1
+      port: 5672
+      virtual-host: school
+      username: saas
+      password: select123***
+      publisher-returns: true
+      publisher-confirms: true

+ 24 - 7
frontend/pc-web/app/view/Interaction/timetable/Detail.js

@@ -3,6 +3,7 @@ Ext.define('school.view.interaction.timetable.Detail', {
     xtype: 'interaction-timetable-detail',
 
     controller: 'interaction-timetable-detail',
+    viewModel: 'interaction-timetable-detail',
 
     _title: '课程表',
     _idField: 'id',
@@ -33,7 +34,11 @@ Ext.define('school.view.interaction.timetable.Detail', {
             }, {
                 xtype: 'textfield',
                 name: 'name',
-                fieldLabel: '课表名称'
+                fieldLabel: '课表名称',
+                emptyText: '请选择年级',
+                bind: {
+                    emptyText: '{name_emptyText}'
+                }
             }, {
                 xtype: 'numberfield',
                 name: 'gradeId',
@@ -46,9 +51,10 @@ Ext.define('school.view.interaction.timetable.Detail', {
                 allowBlank: false,
                 listeners: {
                     select: function (combo, record, eOpts) {
-                        combo.up('form').getForm().findField('gradeId').setValue(record.get('grade_id'));
-                        combo.up('form').getForm().findField('clazzId').setValue(null);
-                        combo.up('form').getForm().findField('clazzName').setValue(null);
+                        let viewModel = me.getViewModel();
+                        viewModel.set('gradeId', record.get('grade_id'));
+                        viewModel.set('clazzId', null);
+                        viewModel.set('clazzName', null);
                     }
                 }
             }, {
@@ -78,9 +84,10 @@ Ext.define('school.view.interaction.timetable.Detail', {
                         }
                     },
                     select: function (combo, record, eOpts) {
-                        combo.up('form').getForm().findField('clazzId').setValue(record.get('clazz_id'));
-                        combo.up('form').getForm().findField('gradeId').setValue(record.get('grade_id'));
-                        combo.up('form').getForm().findField('gradeName').setValue(record.get('clazz_grade'));
+                        let viewModel = me.getViewModel();
+                        viewModel.set('clazzId', record.get('clazz_id'));
+                        viewModel.set('gradeId', record.get('grade_id'));
+                        viewModel.set('gradeName', record.get('clazz_grade'));
                     }
                 }
             }, {
@@ -371,6 +378,16 @@ Ext.define('school.view.interaction.timetable.Detail', {
         this.callParent();
     },
 
+    listeners: {
+        beforeSave: function(form) {
+            let nameField = form.getForm().findField('name');
+            if(!nameField.value) {
+                nameField.setValue(nameField.emptyText);
+            }
+            return true;
+        }
+    },
+
     onSelectPeriod0: function(picker, menu, record) {
         let me = this;
         let cRecord = me.currentRecord;

+ 30 - 0
frontend/pc-web/app/view/Interaction/timetable/DetailModel.js

@@ -0,0 +1,30 @@
+Ext.define('school.view.interaction.timetable.DetailModel', {
+    extend: 'school.view.core.form.FormPanelModel',
+    alias: 'viewmodel.interaction-timetable-detail',
+
+    formulas: {
+        name_emptyText: function(get) {
+            let gradeName = get('gradeName'),
+            clazzName = get('clazzName'),
+            termPart = get('termPart'),
+            termName = get('termName'),
+            text;
+
+            if(!!gradeName && !!clazzName && !!termPart && !!termName) {
+                text =  gradeName + clazzName + termPart.split('-')[0].substring(2, 4) + '年' + termName + '课表';
+                this.set('name', text);
+            }else if(!gradeName) {
+                text = '请选择年级';
+            }else if(!clazzName) {
+                text = '请选择班级';
+            }else if(!termPart) {
+                text = '请选择学年';
+            }else if(!termName) {
+                text = '请选择学期';
+            }
+
+            return text;
+        }
+    }
+
+});

+ 0 - 16
frontend/pc-web/app/view/core/form/FormPanel.js

@@ -489,22 +489,6 @@ Ext.define('school.view.core.form.FormPanel', {
         return dirtyData;
     },
 
-    beforeSave: function() {
-        return true;
-    },
-
-    beforeDelete: function() {
-        return true;
-    },
-
-    beforeAudit: function() {
-        return true;
-    },
-
-    beforeUnAudit: function() {
-        return true;
-    },
-
     promiseCloseTab: function() {
         let me = this,
         controller = me.getController();

+ 6 - 6
frontend/pc-web/app/view/core/form/FormPanelController.js

@@ -116,7 +116,7 @@ Ext.define('school.view.core.form.FormPanelController', {
         var code = viewModel.get(form._codeField);
         if(id&&id.value!=0){
 
-            if(!form.beforeDelete()) {
+            if(form.fireEvent('beforeDelete', form) == false) {
                 return false;
             }
 
@@ -157,7 +157,7 @@ Ext.define('school.view.core.form.FormPanelController', {
             return false;
         }
 
-        if(!form.beforeSave()) {
+        if(form.fireEvent('beforeSave', form) == false) {
             return false;
         }
 
@@ -254,7 +254,7 @@ Ext.define('school.view.core.form.FormPanelController', {
             return false;
         }
 
-        if(!form.beforeAudit()) {
+        if(form.fireEvent('beforeAudit', form) == false) {
             return false;
         }
 
@@ -342,7 +342,7 @@ Ext.define('school.view.core.form.FormPanelController', {
         var code = viewModel.get(form._codeField);
         if(id&&id.value!=0){
 
-            if(!form.beforeUnAudit()) {
+            if(form.fireEvent('beforeUnAudit', form)) {
                 return false;
             }
 
@@ -447,7 +447,7 @@ Ext.define('school.view.core.form.FormPanelController', {
         id = viewModel.get(form._idField),
         code = viewModel.get(form._codeField);
 
-        me.beforePrint(caller).then(function(flag) {
+        me.checkPrintAccess(caller).then(function(flag) {
             if(!flag) {
                 return false;
             }
@@ -484,7 +484,7 @@ Ext.define('school.view.core.form.FormPanelController', {
     /**
      * 判断权限
      */
-    beforePrint: function(caller) {
+    checkPrintAccess: function(caller) {
         return school.util.BaseUtil.request({
             url: '/api/commons/' + caller + '/print',
             method: 'GET',