Переглянути джерело

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

guq 6 роки тому
батько
коміт
394b0d99e4

+ 3 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/NoticeServiceImpl.java

@@ -148,6 +148,7 @@ public class NoticeServiceImpl implements NoticeService{
         if (StringUtils.isEmpty(template) || StringUtils.isEmpty(template.getSt_templateid())) {
             throw new BizException(BizExceptionCode.NULL_TEMPLATE);
         }
+        List<SchoolNoticer> noticerList = new ArrayList<>();
         noticers.forEach(noticer -> {
             MessageInfoDTO msg = new MessageInfoDTO();
             String endUrl = null;
@@ -161,6 +162,7 @@ public class NoticeServiceImpl implements NoticeService{
                     noticer.setType("0");
                     noticer.setPersonId(noticer.getPersonId().split(",")[0]);
                 }
+                noticerList.add(noticer);
                 String url = baseWechatUrl + "/notifyDetail" + endUrl;
                 msg.setUrl(url);
                 msg.setTitle(data.getNotify_title());
@@ -176,7 +178,7 @@ public class NoticeServiceImpl implements NoticeService{
                 msgs.add(msg);
             }
         });
-        noticeMapper.insertDetailBySelective(noticers, id);
+        noticeMapper.insertDetailBySelective(noticerList, id);
         if (msgs.size() > 0) {
             TransferDTO transferDTO = new TransferDTO();
             transferDTO.setData(msgs);

+ 10 - 3
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/ScoreServiceImpl.java

@@ -112,6 +112,7 @@ public class ScoreServiceImpl implements ScoreService{
             throw new BizException(BizExceptionCode.EXISTS_TEACHER_CLASS);
         }
         scoreMapper.deleteByPrimaryKey(id);
+        scoreMapper.deleteByPrimaryDetailKey(id);
         messageLogService.delete(new DocBaseDTO(id, CODE, NAME));
     }
 
@@ -313,6 +314,7 @@ public class ScoreServiceImpl implements ScoreService{
     }
 
     @Override
+    @Transactional
     public DocBaseDTO save(ScoreForm data) {
         if (ObjectUtils.isEmpty(data)){
             throw new BizException(BizExceptionCode.EMPTY_DATA);
@@ -329,7 +331,6 @@ public class ScoreServiceImpl implements ScoreService{
             classId = sysClazz.getClazz_id();
             gradeId = sysClazz.getGrade_id();
         }
-        Long mId = main.getSi_id();
         if (null == main.getSi_id() || 0 == main.getSi_id()){
             main.setSi_date(new Date());
             main.setSi_creator(BaseContextHolder.getUserName());
@@ -353,11 +354,14 @@ public class ScoreServiceImpl implements ScoreService{
                             throw new BizException(BizExceptionCode.NONSTU);
                         }
                         SysStudent sysStudent = sysStudentMapper.selectByStudent(item.getSd_stu() ,classId,schoolId);
+                        if(sysStudent == null){
+                            throw new BizException(BizExceptionCode.NONSTUS);
+                        }
                         Long stuId = sysStudent.getStu_id();
                         item.setSd_stuid(stuId);
                     }
                     item.setSchool_id(schoolId);
-                    item.setSd_siid(mId);
+                    item.setSd_siid(main.getSi_id());
                     //插入从表
                     scoreMapper.insertScoreImportDetail(item);
                 }
@@ -382,11 +386,14 @@ public class ScoreServiceImpl implements ScoreService{
                             throw new BizException(BizExceptionCode.NONSTU);
                         }
                         SysStudent sysStudent = sysStudentMapper.selectByStudent(item.getSd_stu() ,classId,schoolId);
+                        if(sysStudent == null){
+                            throw new BizException(BizExceptionCode.NONSTUS);
+                        }
                         Long stuId = sysStudent.getStu_id();
                         item.setSd_stuid(stuId);
                     }
                     item.setSchool_id(schoolId);
-                    item.setSd_siid(mId);
+                    item.setSd_siid(main.getSi_id());
 
                     if(item.getSd_id() != null && 0 != item.getSd_id()) {
                         updateList.add(item);

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

@@ -17,7 +17,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     NONCLAZZ(500005, "班级名称不存在"),
     EXAM_SCOPE(5000014, "考试范围只有全年级和班级"),
     REPEAT_TEACHER_NUMBER(500006, "教师工号重复"),
-    NONSTU(500006, "学生不存在"),
+    NONSTU(500007, "学生不存在"),
+    NONSTUS(500008, "这个班没有这个学生"),
     EXISTS_TEACHER(500004,"存在任课教师,无法删除"),
     EXISTS_CURRICULUM(500005,"存在课表,无法删除"),
     EXISTS_TEACHER_CLASS(500006,"存在任课班级,无法删除"),

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

@@ -10,6 +10,8 @@ import java.util.List;
 public interface ScoreMapper {
     int deleteByPrimaryKey(Long score_id);
 
+    int deleteByPrimaryDetailKey(Long sd_siid);
+
     int insert(StuScoreDO record);
 
     int insertSelective(StuScoreDO record);

+ 11 - 8
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxNotifyServiceImpl.java

@@ -7,6 +7,7 @@ import com.usoftchina.smartschool.school.wxschool.basic.service.WxNotifyService;
 import com.usoftchina.smartschool.school.wxschool.mapper.*;
 import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
 import com.usoftchina.smartschool.wechat.api.WxPushApi;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -231,10 +232,11 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 	 */
 	public NotifyDO getNotifyDetails(Long stuId,Long notifyId) throws Exception {
 		NotifyDO notifyDO = notifyMapper.get(notifyId);
-		NotifyrecordsDO byStu = notifyrecordsMapper.getByStu(stuId, notifyId);
-		if (ObjectUtils.isNotEmpty(byStu)){
-			byStu.setIsRead(2);
-			int update = notifyrecordsMapper.update(byStu);
+		List<NotifyrecordsDO> byStu = notifyrecordsMapper.getByStu(stuId, notifyId);
+		if (CollectionUtils.isNotEmpty(byStu)){
+		    NotifyrecordsDO notifyrecordsDO = byStu.get(0);
+            notifyrecordsDO.setIsRead(2);
+			int update = notifyrecordsMapper.update(notifyrecordsDO);
 			if (update>0){
 				return getNotifyDetail(stuId,0L,notifyDO);
 			}else {
@@ -252,10 +254,11 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 	 */
 	public NotifyDO getNotifyDetailsByTeacher(Long notifyId, Long teacherId) throws Exception {
 		NotifyDO notifyDO = notifyMapper.get(notifyId);
-		NotifyrecordsDO byTeacher = notifyrecordsMapper.getByTeacher(notifyId, teacherId);
-		if (ObjectUtils.isNotEmpty(byTeacher)){
-			byTeacher.setIsRead(2);
-			int update = notifyrecordsMapper.update(byTeacher);
+        List<NotifyrecordsDO> byTeacher = notifyrecordsMapper.getByTeacher(notifyId, teacherId);
+		if (CollectionUtils.isNotEmpty(byTeacher)){
+            NotifyrecordsDO notifyrecordsDO = byTeacher.get(0);
+            notifyrecordsDO.setIsRead(2);
+			int update = notifyrecordsMapper.update(notifyrecordsDO);
 			if (update>0){
 				return getNotifyDetail(0L,teacherId,notifyDO);
 			}else {

+ 2 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/mapper/WxNotifyrecordsMapper.java

@@ -30,7 +30,7 @@ public interface WxNotifyrecordsMapper {
 	
 	int batchRemove(Long[] reIds);
 
-	NotifyrecordsDO getByStu(@Param("stuId") Long stuId, @Param("notifyId") Long notifyId);
+	List<NotifyrecordsDO> getByStu(@Param("stuId") Long stuId, @Param("notifyId") Long notifyId);
 
-	NotifyrecordsDO getByTeacher(@Param("notifyId") Long notifyId, @Param("teacherId") Long teacherId);
+	List<NotifyrecordsDO> getByTeacher(@Param("notifyId") Long notifyId, @Param("teacherId") Long teacherId);
 }

+ 2 - 2
applications/school/school-server/src/main/resources/mapper/NotifyMapper.xml

@@ -238,7 +238,7 @@
       (
       #{notice_id,jdbcType=VARCHAR},
       <choose>
-        <when test="item.type == 1">
+        <when test='item.type == "1"'>
           #{item.personId,jdbcType=VARCHAR},
         </when>
         <otherwise>
@@ -246,7 +246,7 @@
         </otherwise>
       </choose>
       <choose>
-        <when test="item.type == 0">
+        <when test='item.type == "0"'>
           #{item.personId,jdbcType=VARCHAR},
         </when>
         <otherwise>

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/ScoreMapper.xml

@@ -31,6 +31,10 @@
     delete from Score_Import
     where si_id = #{si_id,jdbcType=BIGINT}
   </delete>
+  <delete id="deleteByPrimaryDetailKey" parameterType="java.lang.Long" >
+    delete from score_importdetail
+    where sd_siid = #{sd_siid,jdbcType=BIGINT}
+  </delete>
   <insert id="insert" parameterType="com.usoftchina.smartschool.school.po.StuScore" >
     insert into stu_score (score_id, score_type, score_name,
     stu_id, score_total, score_num,

+ 50 - 42
frontend/pc-web/app/view/Interaction/score/Detail.js

@@ -31,19 +31,61 @@ Ext.define('school.view.interaction.score.Detail', {
             }, {
                 xtype: 'datefield',
                 name: 'si_examdate',
-                fieldLabel: '考试时间'
+                fieldLabel: '考试时间',
+                allowBlank: false
             }, {
                 xtype: 'textfield',
                 name: 'si_examscope',
                 fieldLabel: '考试范围'
             }, {
+            //     xtype: 'hidden',
+            //     name: 'task_gradeid',
+            //     fieldLabel: '年级ID'
+            // }, {
                 xtype: 'gradecombo',
                 name: 'si_grade',
-                fieldLabel: '年级'
+                fieldLabel: '年级',
+                listeners: {
+                    select: function (combo, record, eOpts) {
+                        let viewModel = me.getViewModel();
+                        // viewModel.set('task_gradeid', record.get('grade_id'));
+                        viewModel.set('clazz_id', null);
+                        viewModel.set('si_class', null);
+                    }
+                },
+                allowBlank: false
+            }, {
+                xtype: 'hidden',
+                name: 'clazz_id',
+                fieldLabel: '班级ID'
             }, {
                 xtype: 'classcombo',
                 name: 'si_class',
-                fieldLabel: '班级'
+                fieldLabel: '班级',
+                listeners: {
+                    expand: function (combo, eOpts) {
+                        combo.store.clearFilter();
+
+                        var gradeCombo = combo.up('form').getForm().findField('si_grade');
+                        var gradeName = gradeCombo.getValue();
+
+                        var filter = new Ext.util.Filter({
+                            property: 'clazz_grade',
+                            value: gradeName
+                        });
+
+                        if (!!gradeName) {
+                            combo.store.setFilters([filter]);
+                        }
+                    },
+                    select: function (combo, record, eOpts) {
+                        let viewModel = me.getViewModel();
+                        viewModel.set('clazz_id', record.get('clazz_id'));
+                        // viewModel.set('task_gradeid', record.get('grade_id'));
+                        viewModel.set('si_grade', record.get('clazz_grade'));
+                    }
+                },
+                allowBlank: false
             }, {
                 xtype: 'combobox',
                 name: 'si_publish',
@@ -66,7 +108,7 @@ Ext.define('school.view.interaction.score.Detail', {
                 detnoColumn: 'no',
                 storeModel: 'school.model.Score',
                 deleteDetailUrl: '/api/school/score/deleteDetail',
-                allowEmpty: true,
+                allowEmpty: false,
                 showCount: false,
                 emptyRows: 10,
                 rowViewModel: {},
@@ -77,56 +119,21 @@ Ext.define('school.view.interaction.score.Detail', {
                 }, {
                     text: '学生编号',
                     dataIndex: 'sd_stuNumber',
+                    allowBlank: false,
                     editor: {
                         xtype: 'textfield'
                     }
                 }, {
                     text: '姓名',
                     dataIndex: 'sd_stu',
+                    allowBlank: false,
                     editor: {
-                        addTitle: '学生',
                         xtype: 'dbfindtrigger',
-                        //数据接口
-                        dataUrl:'/api/school/student/list',
-                        //联想设置
-                        dbtpls:[{
-                            field:'stu_name',width:150
-                        }],
-                        dbfinds:[{
-                            from: 'stu_name', to: 'sd_stu',
-                        }, {
-                            from: 'stu_number', to: 'sd_stuNumber'
-                        }],
-                        defaultCondition: "1=1",
-                        dbSearchFields:[{
-                            emptyText:'请输入学生学号或姓名',
-                            xtype : "textfield", 
-                            name : "search", 
-                            getCondition: function(v) {
-                                return "(upper(stu_name) like '%"+v.toUpperCase()+"%' or upper(stu_number) like '%"+v.toUpperCase()+"%')";
-                            },
-                            allowBlank : true, 
-                            width:300
-                        }],
-                        //放大镜窗口列表
-                        dbColumns:[{
-                            text: "ID",
-                            dataIndex: "stu_id",
-                            hidden:true,
-                            xtype: "numbercolumn"
-                        }, {
-                            text: '工号',
-                            dataIndex: 'stu_number',
-                            width: 110
-                        }, {
-                            text: "姓名",
-                            dataIndex: "stu_name",
-                            width: 110
-                        }]
                     }
                 }, {
                     text: '科目',
                     dataIndex: 'sd_subject',
+                    allowBlank: false,
                     editor: {
                         xtype: 'subjectcombo',
                         valueField: 'subject_name',
@@ -135,6 +142,7 @@ Ext.define('school.view.interaction.score.Detail', {
                 }, {
                     text: '成绩',
                     dataIndex: 'sd_score',
+                    allowBlank: false,
                     editor: {
                         xtype: 'numberfield',
                         minValue: 0

+ 124 - 1
frontend/pc-web/app/view/Interaction/score/DetailController.js

@@ -2,6 +2,90 @@ Ext.define('school.view.interaction.score.DetailController', {
     extend: 'school.view.core.form.FormPanelController',
     alias: 'controller.interaction-score-detail',
 
+    init: function (form) {
+        var me = this;
+        this.control({
+            'dbfindtrigger[name=sd_stu]':{
+                beforerender:function(f){
+                    Ext.apply(f,{
+                        addTitle: '学生',
+                        //数据接口
+                        dataUrl:'/api/school/student/list',
+                        //联想设置
+                        dbtpls:[{
+                            field:'stu_name',width:150
+                        }],
+                        dbfinds:[{
+                            from: 'stu_name', to: 'sd_stu',
+                        }, {
+                            from: 'stu_number', to: 'sd_stuNumber'
+                        }],
+                        defaultCondition: "1=1",
+                        dbSearchFields:[{
+                            emptyText:'请输入学生学号或姓名',
+                            xtype : "textfield", 
+                            name : "search", 
+                            getCondition: function(v) {
+                                return "(upper(stu_name) like '%"+v.toUpperCase()+"%' or upper(stu_number) like '%"+v.toUpperCase()+"%')";
+                            },
+                            allowBlank : true, 
+                            width:300
+                        }],
+                        //放大镜窗口列表
+                        dbColumns:[{
+                            text: "ID",
+                            dataIndex: "stu_id",
+                            hidden:true,
+                            xtype: "numbercolumn"
+                        }, {
+                            text: '工号',
+                            dataIndex: 'stu_number',
+                            width: 110
+                        }, {
+                            text: "姓名",
+                            dataIndex: "stu_name",
+                            width: 110
+                        }]
+                    }) ; 
+                },
+                beforequery: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                },
+                beforetriggerclick: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                }
+            },
+        });
+    },
+
+    getDefaultCondition: function(idx) {
+        var me = this,
+        form = me.getView(),
+        formItems = form.formItems,
+        viewModel = me.getViewModel(),
+        gradeName = viewModel.get('si_grade'),
+        clazzName = viewModel.get('si_class');
+
+        if(gradeName && clazzName) {
+            return 'stu_grade=\'' + gradeName + '\' and stu_class = \'' + clazzName + '\'';
+        }else {
+            school.util.BaseUtil.showErrorToast('请先选择【' + '<span style="color: red;">班级</span>】');
+            return null;
+        }
+    },
+
     onAfterSave: function(localJson) {
         var form = this.getView();
         var id = localJson.data.id;
@@ -36,5 +120,44 @@ Ext.define('school.view.interaction.score.DetailController', {
             view.setLoading(false);
             school.util.BaseUtil.showErrorToast('发布失败: ' + e.message);
         });
-    }
+    },
+
+    /**
+     * 清空所有从表数据
+     */
+    clearDetails: function() {
+        var me = this;
+        
+        me.clearDetail0();
+    },
+
+    /**
+     * 清空第一个从表数据
+     */
+    clearDetail0: function(f, n, o) {
+        var me = this,
+        form = me.getView(),
+        grid = form.query('detailGridField')[0];
+        me.clearDetail(grid);
+    },
+
+    /**
+     * 清空一个从表数据
+     */
+    clearDetail: function(grid) {
+        var datas = [],
+        emptyRows = grid.emptyRows,
+        detnoColumn = grid.detnoColumn,
+        detno = 0,
+        store = grid.getStore();
+        
+        Ext.Array.each(new Array(emptyRows), function() {
+            detno += 1;
+            var data = {};
+            data[detnoColumn] = detno;
+            datas.push(data);
+        })
+        store.removeAll();
+        store.add(datas);
+    },
 });