zouxuan пре 3 година
родитељ
комит
96a738e1fb

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/config/MecInstantiationAwareBeanPostProcessor.java

@@ -0,0 +1,13 @@
+package com.ym.mec.biz.dal.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
+
+public class MecInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
+
+    @Override
+    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException{
+
+        return true;
+    }
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysTenantConfigDao.java

@@ -18,4 +18,6 @@ public interface SysTenantConfigDao extends BaseDAO<Integer, SysTenantConfig> {
     void batchInsert(@Param("sysConfigs") List<SysConfig> sysConfigs, @Param("tenantId") Integer tenantId);
 
     String getConfigValue(@Param("paramName") String paramName, @Param("tenantId") Integer tenantId);
+
+    List<Map<String, String>> queryAllMap(@Param("tenantId") Integer tenantId);
 }

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/TenantConfigChangeEvent.java

@@ -0,0 +1,24 @@
+package com.ym.mec.biz.event;
+
+import org.springframework.context.ApplicationEvent;
+
+public class TenantConfigChangeEvent extends ApplicationEvent {
+    private Integer tenantId;
+
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public TenantConfigChangeEvent(Object source,Integer tenantId) {
+        super(source);
+        this.tenantId = tenantId;
+    }
+
+    public TenantConfigChangeEvent(Object source) {
+        super(source);
+    }
+}

+ 46 - 0
mec-biz/src/main/java/com/ym/mec/biz/event/listener/TenantConfigListener.java

@@ -0,0 +1,46 @@
+package com.ym.mec.biz.event.listener;
+
+import com.ym.mec.biz.dal.dao.TenantInfoDao;
+import com.ym.mec.biz.dal.entity.TenantInfo;
+import com.ym.mec.biz.event.TenantConfigChangeEvent;
+import com.ym.mec.biz.service.SysTenantConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class TenantConfigListener implements ApplicationListener<TenantConfigChangeEvent> {
+
+    @Autowired
+    private SysTenantConfigService sysTenantConfigService;
+    @Autowired
+    private TenantInfoDao tenantInfoDao;
+
+    @Override
+    public void onApplicationEvent(TenantConfigChangeEvent event) {
+        if(event.getTenantId() != null){
+            TenantInfo tenantInfo = tenantInfoDao.selectByPrimaryKey(event.getTenantId());
+            if(tenantInfo != null){
+                Map<Integer, Map<String, String>> allTenantConfig = sysTenantConfigService.getAllTenantConfig();
+                allTenantConfig.put(tenantInfo.getId(),sysTenantConfigService.queryAllMap(tenantInfo.getId()));
+                sysTenantConfigService.setTenantConfig(allTenantConfig);
+            }
+        }else {
+            Map<String,Object> paramMap = new HashMap<>(1);
+            paramMap.put("state",1);
+            List<TenantInfo> tenantInfos = tenantInfoDao.queryList(paramMap);
+            if(tenantInfos != null && tenantInfos.size() > 0){
+                Map<Integer,Map<String,String>> tenantConfig = new HashMap<>(tenantInfos.size());
+                for (TenantInfo tenantInfo : tenantInfos) {
+                    tenantConfig.put(tenantInfo.getId(),sysTenantConfigService.queryAllMap(tenantInfo.getId()));
+                }
+                sysTenantConfigService.setTenantConfig(tenantConfig);
+            }
+        }
+    }
+}

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysTenantConfigService.java

@@ -3,10 +3,18 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.entity.SysTenantConfig;
 import com.ym.mec.common.service.BaseService;
+
 import java.util.List;
 import java.util.Map;
 
 public interface SysTenantConfigService extends BaseService<Integer, SysTenantConfig> {
+    void setTenantConfig(Map<Integer,Map<String,String>> tenantConfig);
+
+    Map<String,String> getTenantConfig(Integer tenantId);
+
+    String getTenantConfigValue(Integer tenantId,String paramName);
+
+    Map<Integer,Map<String,String>> getAllTenantConfig();
 
     List<SysConfig> queryAll(Map<String, Object> params);
 
@@ -14,4 +22,5 @@ public interface SysTenantConfigService extends BaseService<Integer, SysTenantCo
 
     String getConfigValue(String paramName, Integer tenantId);
 
+    Map<String, String> queryAllMap(Integer tenantId);
 }

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -231,7 +231,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         currentCourseDetail.setNormalRemind(normalRemindNum<=0?0:1);
 		currentCourseDetail.setCurrentTime(new Date());
         currentCourseDetail.setAdvanceSignInMinutes(Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ADVANCE_SIGN_IN_MINUTES)));
-		currentCourseDetail.setAttendanceRange(sysTenantConfigService.getAttendanceRange(user.getTenantId(),currentCourseDetail.getTeachMode()));
+		String gpsRange = sysTenantConfigService.getConfigValue(SysConfigService.ATTENDANCE_RANGE,user.getTenantId());
+		Integer attendanceRange = 0;
+		if(StringUtils.isNotEmpty(gpsRange)){
+			attendanceRange = Integer.parseInt(gpsRange);
+		}
+		currentCourseDetail.setAttendanceRange(attendanceRange);
         currentCourseDetail.setAdvanceSignOutMinutes(Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ADVANCE_SIGN_OUT_MINUTES)));
 		CourseSchedule courseSchedule = courseScheduleDao.get(courseID);
 		//获取课程规划

+ 52 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysTenantConfigServiceImpl.java

@@ -3,24 +3,23 @@ package com.ym.mec.biz.service.impl;
 import com.ym.mec.biz.dal.dao.SysTenantConfigDao;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.entity.SysTenantConfig;
-import com.ym.mec.biz.dal.entity.Teacher;
-import com.ym.mec.biz.dal.enums.TeachModeEnum;
-import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.event.TenantConfigChangeEvent;
 import com.ym.mec.biz.service.SysTenantConfigService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
+import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.context.ApplicationEventPublisherAware;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.math.BigDecimal;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service
-public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTenantConfig>  implements SysTenantConfigService {
+public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTenantConfig>  implements SysTenantConfigService, ApplicationEventPublisherAware {
 	
 	@Autowired
 	private SysTenantConfigDao sysTenantConfigDao;
@@ -30,6 +29,39 @@ public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTena
 		return sysTenantConfigDao;
 	}
 
+	Map<Integer,Map<String,String>> tenantConfig;
+	private ApplicationEventPublisher applicationEventPublisher;
+
+	@Override
+	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
+		this.applicationEventPublisher = applicationEventPublisher;
+		applicationEventPublisher.publishEvent(new TenantConfigChangeEvent(this,null));
+	}
+
+	@Override
+	public void setTenantConfig(Map<Integer, Map<String, String>> tenantConfig) {
+		this.tenantConfig = tenantConfig;
+	}
+
+	@Override
+	public Map<String, String> getTenantConfig(Integer tenantId) {
+		return tenantConfig.get(tenantId);
+	}
+
+	@Override
+	public String getTenantConfigValue(Integer tenantId,String paramName) {
+		Map<String, String> map = tenantConfig.get(tenantId);
+		if(map != null){
+			return map.get(paramName);
+		}
+		return null;
+	}
+
+	@Override
+	public Map<Integer, Map<String, String>> getAllTenantConfig() {
+		return tenantConfig;
+	}
+
 	@Override
 	public List<SysConfig> queryAll(Map<String, Object> params) {
 		return sysTenantConfigDao.queryALl(params);
@@ -44,10 +76,22 @@ public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTena
 		List<Long> configIdList = sysConfigs.stream().map(e -> e.getId()).collect(Collectors.toList());
 		sysTenantConfigDao.delByConfigId(configIdList,tenantId);
 		sysTenantConfigDao.batchInsert(sysConfigs,tenantId);
+		applicationEventPublisher.publishEvent(new TenantConfigChangeEvent(this,tenantId));
 	}
 
 	@Override
 	public String getConfigValue(String paramName, Integer tenantId) {
 		return sysTenantConfigDao.getConfigValue(paramName, tenantId);
 	}
+
+	@Override
+	public Map<String, String> queryAllMap(Integer tenantId) {
+		List<Map<String, String>> maps = sysTenantConfigDao.queryAllMap(tenantId);
+		Map<String, String> resultMap = null;
+		if(maps != null){
+			resultMap = MapUtil.convertMybatisMap(maps);
+		}
+		return resultMap;
+	}
+
 }

+ 11 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java

@@ -66,15 +66,14 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 	private SubjectDao subjectDao;
 	@Autowired
 	private SchoolDao schoolDao;
-
 	@Autowired
 	private RedisCache<String,Object> redisCache;
-
 	@Autowired
 	private CourseHomeworkDao courseHomeworkDao;
-
 	@Autowired
 	private StudentServeService studentServeService;
+	@Autowired
+	private SysTenantConfigService sysTenantConfigService;
 
 	@Override
 	public BaseDAO<Long, TeacherAttendance> getDAO() {
@@ -754,6 +753,15 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 		sysMessageService.batchSendMessage(MessageSender.JIGUANG,MessageTypeEnum.TEACHER_PUSH_EXCEPTION_ATTENDANCE,receivers,null,0,url,"TEACHER",format);
 	}
 
+	void checkComplaints(JobNatureEnum jobNatureEnum,Integer tenantId){
+//		String configValue = sysTenantConfigService.getConfigValue(SysConfigService.parp_teacher_salary, tenantId);
+//		String configValue1 = sysTenantConfigService.getConfigValue(SysConfigService.parp_teacher_salary_type, tenantId);
+//		String configValue = sysTenantConfigService.getConfigValue(SysConfigService.full_teacher_salary, tenantId);
+//		String configValue = sysTenantConfigService.getConfigValue(SysConfigService.full_teacher_salary_type, tenantId);
+//		String configValue = sysTenantConfigService.getConfigValue(SysConfigService.labour_teacher_salary, tenantId);
+//		String configValue = sysTenantConfigService.getConfigValue(SysConfigService.labour_teacher_salary_type, tenantId);
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void addComplaints(Long courseScheduleId, String content,String url,Integer userId, UpdateAttendanceEnum complaintsType) {

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/SysTenantConfigMapper.xml

@@ -92,4 +92,9 @@
     LEFT JOIN sys_tenant_config stc ON sc.id_ = stc.sys_config_id_ AND sc.group_ = #{tenantId}
     WHERE sc.group_ IS NOT NULL AND sc.group_ != '' AND sc.param_name_ = #{paramName}
   </select>
+  <select id="queryAllMap" resultType="java.util.Map">
+    SELECT sc.param_name_ 'key',CASE WHEN stc.id_ IS NULL THEN sc.paran_value_ ELSE stc.param_value_ END 'value' FROM sys_config sc
+    LEFT JOIN sys_tenant_config stc ON sc.id_ = stc.sys_config_id_ AND stc.tenant_id_ = #{tenantId}
+    WHERE sc.group_ IS NOT NULL AND sc.group_ != ''
+  </select>
 </mapper>

+ 5 - 2
mec-biz/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -39,8 +39,11 @@
         <include refid="Base_Column_List"/>
         from tenant_info
         <where>
-            <if test="state != null">
-                and state_ = #{state,jdbcType=INTEGER}
+            <if test="param.state != null">
+                AND state_ = #{param.state,jdbcType=INTEGER}
+            </if>
+            <if test="param.id != null">
+                AND id_ = #{param.id,jdbcType=INTEGER}
             </if>
         </where>
     </select>

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -75,7 +75,7 @@ public class VipGroupManageController extends BaseController {
 
     @GetMapping("/teacherSalarySettlement")
     public Object teacherSalarySettlement(){
-        courseScheduleTeacherSalaryService.teacherSalarySettlement();
+//        courseScheduleTeacherSalaryService.teacherSalarySettlement();
         return succeed();
     }