LIVE_YE 1 жил өмнө
parent
commit
c627b3aae9

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/xiake/XiakeConfigController.java

@@ -54,9 +54,9 @@ public class XiakeConfigController extends BaseController {
      * 根据参数键名(班级id)查询参数值config_value(下课时间)
      */
     @PostMapping(value = "/configKey")
-    public R<XiakeConfigVo> getConfigKey(@Validated @RequestBody XiakeConfigBo config)
+    public AjaxResult getConfigKey(@Validated @RequestBody XiakeConfigBo config)
     {
-        return R.ok(xiakeConfigService.selectConfigByKey(config));
+        return success(xiakeConfigService.selectConfigByKey(config));
     }
 
     /**

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/xiake/XiakeConfigMapper.java

@@ -14,7 +14,7 @@ import org.springframework.data.repository.query.Param;
  * @date 2023-08-16
  */
 public interface XiakeConfigMapper extends BaseMapperPlus<XiakeConfig, XiakeConfigVo> {
-    public XiakeConfig selectConfig(XiakeConfigBo config);
+    public XiakeConfigVo selectConfig(XiakeConfigBo config);
     public XiakeConfigVo checkConfigKeyUnique(@Param("configKey") String configKey);
     public int updateConfigByKey(XiakeConfigBo bo);
 }

+ 7 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java

@@ -16,6 +16,7 @@ import org.dromara.common.core.service.DeptService;
 import org.dromara.common.core.utils.*;
 import org.dromara.common.mybatis.helper.DataBaseHelper;
 import org.dromara.common.redis.utils.CacheUtils;
+import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.system.domain.SysDept;
 import org.dromara.system.domain.SysRole;
@@ -256,7 +257,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
         }
         SysDept dept = MapstructUtils.convert(bo, SysDept.class);
         dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
-
+        int i = baseMapper.insert(dept);
         if(info!=null){
             //往xiake_config插入数据
             XiakeConfig config = new XiakeConfig();
@@ -275,9 +276,13 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
             config1.setCreateTime(DateUtils.getNowDate());
             config1.setUpdateTime(DateUtils.getNowDate());
             configMapper.insert(config1);
+
+            String key = dept.getParentId() + ":" + dept.getDeptId();
+            String value = dept.getDeptName() + ":time";
+            RedisUtils.setCacheObject(key, value);
         }
 
-        return baseMapper.insert(dept);
+        return i;
     }
 
     /**

+ 108 - 68
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/common/AppletServiceImpl.java

@@ -10,18 +10,14 @@ import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.system.domain.*;
+import org.dromara.system.domain.bo.SysDeptBo;
 import org.dromara.system.domain.notice.XiaoyuanNotice;
 import org.dromara.system.domain.notice.vo.XiaoyuanNoticeVo;
-import org.dromara.system.domain.vo.CourseChangeVo;
-import org.dromara.system.domain.vo.FormalTeacherClassVo;
-import org.dromara.system.domain.vo.RegisterParentsStudentVo;
-import org.dromara.system.domain.vo.RegisterTeacherVo;
+import org.dromara.system.domain.vo.*;
 import org.dromara.system.domain.xiake.XiakeConfig;
 import org.dromara.system.domain.xiake.bo.XiakeConfigBo;
-import org.dromara.system.mapper.CourseChangeMapper;
-import org.dromara.system.mapper.FormalTeacherClassMapper;
-import org.dromara.system.mapper.RegisterParentsStudentMapper;
-import org.dromara.system.mapper.RegisterTeacherMapper;
+import org.dromara.system.domain.xiake.vo.XiakeConfigVo;
+import org.dromara.system.mapper.*;
 import org.dromara.system.mapper.notice.XiaoyuanNoticeMapper;
 import org.dromara.system.mapper.xiake.XiakeConfigMapper;
 import org.dromara.system.service.common.IAppletService;
@@ -56,8 +52,11 @@ public class AppletServiceImpl implements IAppletService {
 
     private final RegisterTeacherMapper registerTeacherMapper;
 
+    private final SysDeptMapper sysDeptMapper;
+
     @Autowired
     private XiaoyuanNoticeMapper xiaoyuanNoticeMapper;
+
     @Override
     public R<Void> xiake(FormalTeacherClass formalTeacherClass) {
         String key = formalTeacherClass.getSchoolId() + ":" + formalTeacherClass.getClassId();
@@ -71,20 +70,22 @@ public class AppletServiceImpl implements IAppletService {
                 //延迟放学
                 String[] split = value.split(":");
                 //下课时间
-                String xiakeTime = split[1];
+                String xiakeTime = split[1] + ":" + split[2] + ":" + split[3];
                 //获取参数中默认下课时间
                 XiakeConfigBo config = new XiakeConfigBo();
-                config.setConfigKey(formalTeacherClass.getClassId()+":2");
-                XiakeConfig retConfig = xiakeConfigMapper.selectConfig(config);
+                config.setConfigKey(formalTeacherClass.getClassId() + ":2");
+                XiakeConfigVo retConfig = xiakeConfigMapper.selectConfig(config);
                 //延迟下课的默认值
                 String configValue = retConfig.getConfigValue();
-                SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 Date date = null;
                 try {
                     date = sdf.parse(xiakeTime);
                     Calendar calendar = Calendar.getInstance();
                     calendar.setTime(date);
                     calendar.add(Calendar.MINUTE, Integer.parseInt(configValue));
+                    String time = sdf.format(calendar.getTime());
+                    value = split[0] + ":" + time;
                     RedisUtils.setCacheObject(key, value);
                     return R.ok("延迟放学成功");
                 } catch (ParseException e) {
@@ -101,8 +102,8 @@ public class AppletServiceImpl implements IAppletService {
             Calendar nowTime = Calendar.getInstance();
             //获取参数中默认下课时间
             XiakeConfigBo config = new XiakeConfigBo();
-            config.setConfigKey(formalTeacherClass.getClassId()+":1");
-            XiakeConfig retConfig = xiakeConfigMapper.selectConfig(config);
+            config.setConfigKey(formalTeacherClass.getClassId() + ":1");
+            XiakeConfigVo retConfig = xiakeConfigMapper.selectConfig(config);
             String configValue = retConfig.getConfigValue();
             nowTime.add(Calendar.MINUTE, Integer.parseInt(configValue));
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -113,12 +114,15 @@ public class AppletServiceImpl implements IAppletService {
     }
 
 
-
     @Override
     public AjaxResult index(FormalTeacherClass formalTeacherClass) {
         Map<String, Object> map = new HashMap<>(3);
         map.put("all", 0);
         Collection<String> keys = RedisUtils.keys(formalTeacherClass.getSchoolId() + "*");
+        if (keys == null || keys.size() == 0) {
+            afterClass();
+            keys = RedisUtils.keys(formalTeacherClass.getSchoolId() + "*");
+        }
         if (keys != null && keys.size() > 0) {
             map.put("all", keys.size());
             map.put("n", 0);
@@ -144,6 +148,38 @@ public class AppletServiceImpl implements IAppletService {
         return AjaxResult.success(map);
     }
 
+    public void afterClass() {
+
+        LoginUser user = LoginHelper.getLoginUser();
+        //获取所有部门
+        SysDeptBo bo = new SysDeptBo();
+        bo.setTenantId(user.getTenantId());
+        List<SysDeptVo> sysDeptList = sysDeptMapper.selectDeptListMapper(new SysDeptBo());
+
+        //学校部门
+        List<SysDeptVo> fSysDeptList = new ArrayList<>();
+        //班级部门
+        List<SysDeptVo> pSysDeptList = new ArrayList<>();
+
+        for (SysDeptVo sysDept : sysDeptList) {
+            if (sysDept.getParentId() == 0) {
+                fSysDeptList.add(sysDept);
+            } else {
+                pSysDeptList.add(sysDept);
+            }
+        }
+
+        for (SysDeptVo sysDept : fSysDeptList) {
+            for (SysDeptVo dept : pSysDeptList) {
+                if (sysDept.getDeptId().equals(dept.getParentId())) {
+                    String key = sysDept.getDeptId() + ":" + dept.getDeptId();
+                    String value = dept.getDeptName() + ":time";
+                    RedisUtils.setCacheObject(key, value);
+                }
+            }
+        }
+    }
+
     @Override
     public AjaxResult indexList(FormalTeacherClass formalTeacherClass) {
         List<Map<String, Object>> list = new ArrayList<>();
@@ -155,11 +191,15 @@ public class AppletServiceImpl implements IAppletService {
                 String[] split = value.split(":");
                 Map<String, Object> map = new HashMap<>();
                 map.put("className", split[0]);
-                map.put("time", split[1]);
+                if ("time".equals(split[1])) {
+                    map.put("time", split[1]);
+                } else {
+                    map.put("time", value.split(" ")[1]);
+                }
                 list.add(map);
             }
         }
-        return  AjaxResult.success(list);
+        return AjaxResult.success(list);
     }
 
     @Override
@@ -185,62 +225,62 @@ public class AppletServiceImpl implements IAppletService {
         //调课
         int ttkysh = 0;
         int ttkwsh = 0;
-        Map<String,Object> map1 = new HashMap<>();
-        Map<String,Object> map2 = new HashMap<>();
-        Map<String,Object> map3 = new HashMap<>();
+        Map<String, Object> map1 = new HashMap<>();
+        Map<String, Object> map2 = new HashMap<>();
+        Map<String, Object> map3 = new HashMap<>();
 
         //计算本人
         XiaoyuanNotice xiaoyuanNotice = new XiaoyuanNotice();
         xiaoyuanNotice.setSenderId(String.valueOf(loginUser.getUserId()));
         List<XiaoyuanNoticeVo> xiaoyuanNoticeList = xiaoyuanNoticeMapper.selectXiaoyuanNoticeMyList(xiaoyuanNotice);
         int xwsl = 0;
-        if(xiaoyuanNoticeList!=null && xiaoyuanNoticeList.size()>0){
+        if (xiaoyuanNoticeList != null && xiaoyuanNoticeList.size() > 0) {
             xwsl = xiaoyuanNoticeList.size();
         }
-        map.put("xwsl",xwsl);
+        map.put("xwsl", xwsl);
 
-        map1.put("zhysh",tzhysh);
-        map1.put("zhwsh",tzhwsh);
-        map.put("byzhsh",map1);
-        map2.put("tkysh",ttkysh);
-        map2.put("tkwsh",ttkwsh);
-        map.put("bytksh",map2);
+        map1.put("zhysh", tzhysh);
+        map1.put("zhwsh", tzhwsh);
+        map.put("byzhsh", map1);
+        map2.put("tkysh", ttkysh);
+        map2.put("tkwsh", ttkwsh);
+        map.put("bytksh", map2);
 
         //老师
-        if(blt){
+        if (blt) {
             //获取老师所属班级
             FormalTeacherClass formalTeacherClass = new FormalTeacherClass();
             formalTeacherClass.setTeacherId(loginUser.getUserId());
             List<FormalTeacherClassVo> formalTeacherClasses = formalTeacherClassMapper.selectFormalTeacherClassList(formalTeacherClass);
             List<Long> classIds = formalTeacherClasses.stream().map(FormalTeacherClassVo::getClassId).collect(Collectors.toList());
             //查询本月家长的审核数据
-            List<RegisterParentsStudentVo> registerParentsStudentList = registerParentsStudentMapper.selectRegisterParentsStudentListByTime(monthFirst,classIds);
-            if(registerParentsStudentList!=null && registerParentsStudentList.size()>0){
+            List<RegisterParentsStudentVo> registerParentsStudentList = registerParentsStudentMapper.selectRegisterParentsStudentListByTime(monthFirst, classIds);
+            if (registerParentsStudentList != null && registerParentsStudentList.size() > 0) {
                 for (RegisterParentsStudentVo registerParentsStudent : registerParentsStudentList) {
-                    if("1".equals(registerParentsStudent.getIsPass())){
+                    if ("1".equals(registerParentsStudent.getIsPass())) {
                         tzhwsh++;
-                    }else{
+                    } else {
                         tzhysh++;
                     }
                 }
             }
             //查询本月调课审核
-            List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByTime(monthFirst,loginUser.getUserId(),0L);
-            if(courseChangeList!=null && courseChangeList.size()>0){
+            List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByTime(monthFirst, loginUser.getUserId(), 0L);
+            if (courseChangeList != null && courseChangeList.size() > 0) {
                 for (CourseChangeVo courseChange : courseChangeList) {
-                    if("1".equals(courseChange.getIsPass())){
+                    if ("1".equals(courseChange.getIsPass())) {
                         ttkwsh++;
-                    }else{
+                    } else {
                         ttkysh++;
                     }
                 }
             }
-            map1.put("zhysh",tzhysh);
-            map1.put("zhwsh",tzhwsh);
-            map.put("byzhsh",map1);
-            map2.put("tkysh",ttkysh);
-            map2.put("tkwsh",ttkwsh);
-            map.put("bytksh",map2);
+            map1.put("zhysh", tzhysh);
+            map1.put("zhwsh", tzhwsh);
+            map.put("byzhsh", map1);
+            map2.put("tkysh", ttkysh);
+            map2.put("tkwsh", ttkwsh);
+            map.put("bytksh", map2);
 
         }
 
@@ -252,54 +292,54 @@ public class AppletServiceImpl implements IAppletService {
         //调课
         int stkysh = 0;
         int stkwsh = 0;
-        if(bls){
+        if (bls) {
             //查询本月老师的审核数据
-            List<RegisterTeacherVo> registerTeacherList = registerTeacherMapper.selectRegisterTeacherListByTime(monthFirst,loginUser.getDeptId());
-            if(registerTeacherList!=null && registerTeacherList.size()>0){
+            List<RegisterTeacherVo> registerTeacherList = registerTeacherMapper.selectRegisterTeacherListByTime(monthFirst, loginUser.getDeptId());
+            if (registerTeacherList != null && registerTeacherList.size() > 0) {
                 for (RegisterTeacherVo registerTeacher : registerTeacherList) {
-                    if("1".equals(registerTeacher.getIsPass())){
+                    if ("1".equals(registerTeacher.getIsPass())) {
                         szhysh++;
-                    }else{
+                    } else {
                         szhwsh++;
                     }
                 }
             }
             //查询本月学校的调课审核
-            List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByTime(monthFirst,0L,loginUser.getDeptId());
-            if(courseChangeList!=null && courseChangeList.size()>0){
+            List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByTime(monthFirst, 0L, loginUser.getDeptId());
+            if (courseChangeList != null && courseChangeList.size() > 0) {
                 for (CourseChangeVo courseChange : courseChangeList) {
-                    if("1".equals(courseChange.getIsPass())){
+                    if ("1".equals(courseChange.getIsPass())) {
                         stkysh++;
-                    }else{
+                    } else {
                         stkwsh++;
                     }
                 }
             }
 
-            map1.put("zhysh",szhysh);
-            map1.put("zhwsh",szhwsh);
-            map.put("byzhsh",map1);
-            map2.put("tkysh",stkysh);
-            map2.put("tkwsh",stkwsh);
-            map.put("bytksh",map2);
+            map1.put("zhysh", szhysh);
+            map1.put("zhwsh", szhwsh);
+            map.put("byzhsh", map1);
+            map2.put("tkysh", stkysh);
+            map2.put("tkwsh", stkwsh);
+            map.put("bytksh", map2);
         }
         //两个都有
 
-        if(blt && bls){
+        if (blt && bls) {
 
             //账号
             int zzhysh = tzhysh + szhysh;
             int zzhwsh = tzhwsh + szhwsh;
             //调课
-            int ztkysh =  stkysh;
-            int ztkwsh =  stkwsh;
-
-            map1.put("zhysh",zzhysh);
-            map1.put("zhwsh",zzhwsh);
-            map.put("byzhsh",map1);
-            map2.put("tkysh",ztkysh);
-            map2.put("tkwsh",ztkwsh);
-            map.put("bytksh",map2);
+            int ztkysh = stkysh;
+            int ztkwsh = stkwsh;
+
+            map1.put("zhysh", zzhysh);
+            map1.put("zhwsh", zzhwsh);
+            map.put("byzhsh", map1);
+            map2.put("tkysh", ztkysh);
+            map2.put("tkwsh", ztkwsh);
+            map.put("bytksh", map2);
 
         }
         return AjaxResult.success(map);

+ 8 - 4
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/xiake/XiakeConfigServiceImpl.java

@@ -37,14 +37,18 @@ public class XiakeConfigServiceImpl implements IXiakeConfigService {
 
     private final XiakeConfigMapper baseMapper;
 
-    /**
+/*
+    */
+/**
      * 项目启动时,初始化参数到缓存
-     */
+     *//*
+
     @PostConstruct
     public void init()
     {
         loadingConfigCache();
     }
+*/
 
     /**
      * 查询下课时间配置
@@ -66,12 +70,12 @@ public class XiakeConfigServiceImpl implements IXiakeConfigService {
         String cacheKey = getCacheKey(bo.getConfigKey());
         cacheKey = cacheKey + ":"+configType;
         String configValue = Convert.toStr(RedisUtils.getCacheObject(cacheKey));
-        if (StringUtils.isNotEmpty(configValue))
+        if (StringUtils.isNotBlank(configValue))
         {
             return configValue;
         }
         bo.setConfigKey(bo.getConfigKey()+ ":"+configType);
-        XiakeConfig retConfig = baseMapper.selectConfig(bo);
+        XiakeConfigVo retConfig = baseMapper.selectConfig(bo);
         if (retConfig != null)
         {
             RedisUtils.setCacheObject(getCacheKey(cacheKey), retConfig.getConfigValue());

+ 3 - 3
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -66,9 +66,9 @@
         <if test="parentId != null and parentId != 0">
             AND (dept_id = #{deptId} or parent_id = #{parentId})
         </if>
-        <!--<if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>-->
+        <if test="tenantId != null and tenantId != ''">
+            and tenant_id = #{tenantId}
+        </if>
         <if test="deptName != null and deptName != ''">
             AND dept_name like concat('%', #{deptName}, '%')
         </if>

+ 3 - 6
ruoyi-modules/ruoyi-system/src/main/resources/mapper/xiake/XiakeConfigMapper.xml

@@ -4,16 +4,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.system.mapper.xiake.XiakeConfigMapper">
 
-    <resultMap type="XiakeConfigVo" id="XiakeConfigResult">
+    <resultMap type="org.dromara.system.domain.xiake.vo.XiakeConfigVo" id="XiakeConfigResult">
         <id     property="configId"      column="config_id"      />
         <result property="configName"    column="config_name"    />
         <result property="configKey"     column="config_key"     />
         <result property="configValue"   column="config_value"   />
         <result property="configType"    column="config_type"    />
-        <result property="createBy"      column="create_by"      />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"      column="update_by"      />
-        <result property="updateTime"    column="update_time"    />
     </resultMap>
     <sql id="selectConfigVo">
         select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
@@ -35,7 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where config_key = #{configKey} limit 1
     </select>
     <select id="selectConfig" parameterType="org.dromara.system.domain.xiake.bo.XiakeConfigBo" resultMap="XiakeConfigResult">
-        <include refid="selectConfigVo"/>
+        select config_value
+        from xiake_config
         <include refid="sqlwhereSearch"/>
     </select>
     <update id="updateConfigByKey">