Browse Source

区域添加升级时间限制,学校升级时间段判断

tags/正式3.10.0
王宁 1 year ago
parent
commit
49e96bd045

+ 24
- 2
sapi/src/main/java/com/xhkjedu/sapi/controller/system/SchoolController.java View File

@@ -9,6 +9,7 @@ import com.xhkjedu.utils.N_Utils;
9 9
 import com.xhkjedu.utils.PageUtil;
10 10
 import com.xhkjedu.vo.PageResult;
11 11
 import com.xhkjedu.vo.ResultVo;
12
+import lombok.extern.slf4j.Slf4j;
12 13
 import org.springframework.web.bind.annotation.PostMapping;
13 14
 import org.springframework.web.bind.annotation.RequestBody;
14 15
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,6 +25,7 @@ import java.util.Map;
24 25
  * @description
25 26
  * @date 2020/6/2 15:06
26 27
  **/
28
+@Slf4j
27 29
 @RestController
28 30
 @RequestMapping("/school")
29 31
 public class SchoolController {
@@ -69,19 +71,39 @@ public class SchoolController {
69 71
         return new ResultVo(0,"获取列表成功",pageResult);
70 72
     }
71 73
 
74
+    /*
75
+    * @Description 检测学年升级
76
+    * @Author WN
77
+    * @Date 2023/6/15 11:40:10
78
+    */
79
+    @PostMapping("/check_upgrade")
80
+    public ResultVo checkUpgrade(@RequestBody TSchool tSchool) {
81
+        Integer schoolid = tSchool.getSchoolid();
82
+        N_Utils.validation(new Object[]{schoolid,"学校id",1});
83
+
84
+        try {
85
+            Map rtnmap = schoolService.checkSchoolUpgrade(schoolid);
86
+            return new ResultVo(0,"成功检测学年升级",rtnmap);
87
+        } catch (Exception e) {
88
+            log.error("检测学年升级失败:" + e.getMessage());
89
+            return new ResultVo(1,"检测学年升级失败");
90
+        }
91
+    }
92
+
72 93
     //学年升级
73 94
     @PostMapping("/upgrade")
74 95
     public ResultVo upgrade(@RequestBody TSchool tSchool) {
75 96
         Integer schoolid = tSchool.getSchoolid();
76
-        Integer year = schoolService.getYearById(schoolid);
77 97
         N_Utils.validation(new Object[]{schoolid,"学校id",1});
98
+        Integer year = schoolService.getYearById(schoolid);
78 99
         Integer nowYear = N_Utils.getNodeDateTime("year");//当前年份
79 100
         if (year >= nowYear) return new ResultVo(1,"当前学年不用升级");
80 101
         try {
81 102
             schoolService.upgrade(schoolid, year);
82 103
             return new ResultVo(0,"学年升级成功");
83 104
         } catch (Exception e) {
84
-            return new ResultVo(1,e.getMessage());
105
+            log.error("学年升级失败:" + e.getMessage());
106
+            return new ResultVo(1,"学年升级失败");
85 107
         }
86 108
     }
87 109
 

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/cloud/CloudMapper.java View File

@@ -18,4 +18,7 @@ public interface CloudMapper extends TkMapper<TCloud> {
18 18
 
19 19
     //区域学段列表
20 20
     List<Integer> listLevel();
21
+
22
+    //获取区域升级时间段限制
23
+    TCloud getCloudUpTime();
21 24
 }

+ 6
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/cloud/TCloud.java View File

@@ -62,4 +62,10 @@ public class TCloud extends BaseBean {
62 62
 
63 63
     //区地区显示json
64 64
     private String cloudmap;
65
+
66
+    //学年升级开始时间
67
+    private String starttime;
68
+
69
+    //学年升级结束时间
70
+    private String stoptime;
65 71
 }

+ 35
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolService.java View File

@@ -1,7 +1,9 @@
1 1
 package com.xhkjedu.sapi.service.system;
2 2
 
3
+import com.xhkjedu.sapi.mapper.cloud.CloudMapper;
3 4
 import com.xhkjedu.sapi.mapper.gradeclass.*;
4 5
 import com.xhkjedu.sapi.mapper.system.*;
6
+import com.xhkjedu.sapi.model.cloud.TCloud;
5 7
 import com.xhkjedu.sapi.model.gradeclass.*;
6 8
 import com.xhkjedu.sapi.model.system.*;
7 9
 import com.xhkjedu.sapi.utils.ApiUtil;
@@ -54,6 +56,8 @@ public class SchoolService {
54 56
     private UserRoleMapper userRoleMapper;
55 57
     @Resource
56 58
     private SchoolFriendMapper schoolFriendMapper;
59
+    @Resource
60
+    private CloudMapper cloudMapper;
57 61
 
58 62
     //添加
59 63
     @Transactional(rollbackFor = Exception.class)
@@ -230,6 +234,31 @@ public class SchoolService {
230 234
         return schoolMapper.findAll();
231 235
     }
232 236
 
237
+    public Map checkSchoolUpgrade(Integer schoolid) throws Exception{
238
+        Map rtnMap = new HashMap();
239
+        TCloud cloud = cloudMapper.getCloudUpTime();
240
+        boolean isup = false;
241
+        if(ApiUtil.compareCurrDateTime(cloud.getStarttime(),cloud.getStoptime())){
242
+            isup = true;
243
+        }
244
+
245
+        //获取当前学校的学年
246
+        int year = schoolMapper.getYearById(schoolid);
247
+
248
+        Integer nowYear = N_Utils.getNodeDateTime("year");//当前年份
249
+        //如果学校年份大于等于当前年份无需升级
250
+        if(year >= nowYear){
251
+            isup = false;
252
+        }
253
+
254
+        rtnMap.put("isup",isup);
255
+        rtnMap.put("year",year);
256
+        rtnMap.put("upyear",(year + 1));//学年升级之后年份
257
+        rtnMap.put("starttime",cloud.getStarttime());
258
+        rtnMap.put("stoptime",cloud.getStoptime());
259
+        return rtnMap;
260
+    }
261
+
233 262
     /**
234 263
      * 学年升级
235 264
      * @Param [schoolid, year]
@@ -239,6 +268,12 @@ public class SchoolService {
239 268
      **/
240 269
     @Transactional(rollbackFor = Exception.class)
241 270
     public void upgrade(Integer schoolid, Integer year) throws Exception {
271
+        //获取区域限制学年升级时间
272
+        TCloud cloud = cloudMapper.getCloudUpTime();
273
+        if(!ApiUtil.compareCurrDateTime(cloud.getStarttime(),cloud.getStoptime())){
274
+           throw new Exception("不在学年升级时间范围,禁止升级");
275
+        }
276
+
242 277
         try {
243 278
             List<TClass> classes = classMapper.listClassBySchoolId(schoolid, year);//要升级的班级列表
244 279
             if (N_Utils.isListNotEmpty(classes)) {

+ 31
- 0
sapi/src/main/java/com/xhkjedu/sapi/utils/ApiUtil.java View File

@@ -1,6 +1,7 @@
1 1
 package com.xhkjedu.sapi.utils;
2 2
 
3 3
 import com.xhkjedu.sapi.config.ConfigKey;
4
+import com.xhkjedu.utils.N_Utils;
4 5
 import lombok.extern.slf4j.Slf4j;
5 6
 import org.springframework.http.HttpEntity;
6 7
 import org.springframework.http.HttpHeaders;
@@ -10,7 +11,9 @@ import org.springframework.util.MultiValueMap;
10 11
 import org.springframework.web.client.RestClientException;
11 12
 import org.springframework.web.client.RestTemplate;
12 13
 
14
+import java.text.SimpleDateFormat;
13 15
 import java.util.ArrayList;
16
+import java.util.Date;
14 17
 import java.util.List;
15 18
 import java.util.Map;
16 19
 import java.util.concurrent.ConcurrentHashMap;
@@ -65,4 +68,32 @@ public class ApiUtil {
65 68
             return null;
66 69
         }
67 70
     }
71
+
72
+    /*
73
+    * @Description 比较当前时间和时间段
74
+    * @Author WN
75
+    * @Date 2023/6/15 11:24:59
76
+    */
77
+    public static boolean compareCurrDateTime(String starttimeStr,String stoptimeStr) throws Exception{
78
+        boolean rtn = false;
79
+        if(N_Utils.isEmpty(starttimeStr) || N_Utils.isEmpty(stoptimeStr)){
80
+            rtn = false;
81
+        }else{
82
+            SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
83
+
84
+            Date starttime = sdf.parse(starttimeStr); //开始时间
85
+            Date stoptime = sdf.parse(stoptimeStr); //结束时间
86
+
87
+            Date nowtime = new Date();
88
+            String times = sdf.format(nowtime);
89
+            Date currtime = sdf.parse(times);//当前时间
90
+
91
+            //当前时间在开始时间之前或者等于开始时间  并且 当前时间在结束时间之后或者等于结束时间
92
+            if((starttime.before(currtime) || starttime.equals(currtime)) && (stoptime.after(currtime) || stoptime.equals(currtime))){
93
+                rtn = true;
94
+            }
95
+        }
96
+
97
+        return rtn;
98
+    }
68 99
 }

+ 7
- 0
sapi/src/main/resources/mapper/cloud/CloudMapper.xml View File

@@ -21,6 +21,8 @@
21 21
           <if test="cloud.stuweb!=null">stuweb=#{cloud.stuweb},</if>
22 22
           <if test="cloud.tesupport!=null">tesupport=#{cloud.tesupport},</if>
23 23
           <if test="cloud.recordno!=null">recordno=#{cloud.recordno},</if>
24
+          <if test="cloud.starttime!=null">starttime=#{cloud.starttime},</if>
25
+          <if test="cloud.stoptime!=null">stoptime=#{cloud.stoptime},</if>
24 26
       </trim>
25 27
         WHERE cloudid=#{cloud.cloudid}
26 28
     </update>
@@ -32,4 +34,9 @@
32 34
     <select id="listLevel" resultType="java.lang.Integer">
33 35
         select schoollevel from t_school where schoolstate=1 group by schoollevel order by schoollevel
34 36
     </select>
37
+
38
+    <!--获取区域升级时间段限制-->
39
+    <select id="getCloudUpTime" resultType="com.xhkjedu.sapi.model.cloud.TCloud">
40
+        select starttime,stoptime from t_cloud limit 1
41
+    </select>
35 42
 </mapper>

+ 1
- 1
sclass/src/main/resources/mapper/classroom/ClassroomMapper.xml View File

@@ -464,7 +464,7 @@
464 464
         group by cs.studentid order by convert(u.username using gbk)
465 465
     </select>-->
466 466
     <select id="listStudent" resultType="java.util.Map">
467
-        select cs.studentid,u.username studentname
467
+        select cs.studentid,u.username studentname,u.headpic
468 468
         from t_class_student cs left join t_user u on cs.studentid=u.userid
469 469
         where cs.classid=#{classid}
470 470
         group by cs.studentid order by convert(u.username using gbk)

Loading…
Cancel
Save