Pārlūkot izejas kodu

首页考试限制考试时间考试完成合格取消弹框提醒

xiexh 1 mēnesi atpakaļ
vecāks
revīzija
0ce9b8226a

+ 46 - 0
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/common/provider/DesktopFacadeProvider.java

@@ -9,6 +9,7 @@ import com.lc.ibps.api.base.query.QueryOP;
 import com.lc.ibps.base.core.constants.StringPool;
 import com.lc.ibps.base.core.exception.BaseException;
 import com.lc.ibps.base.core.monitor.StopWatchUtil;
+import com.lc.ibps.base.core.util.AppUtil;
 import com.lc.ibps.base.core.util.BeanUtils;
 import com.lc.ibps.base.core.util.I18nUtil;
 import com.lc.ibps.base.core.util.string.StringUtil;
@@ -18,6 +19,7 @@ import com.lc.ibps.base.db.model.DefaultQueryFilter;
 import com.lc.ibps.base.db.mybatis.domain.DefaultPage;
 import com.lc.ibps.base.db.tenant.utils.TenantUtil;
 import com.lc.ibps.base.framework.id.UniqueIdUtil;
+import com.lc.ibps.base.framework.table.ICommonDao;
 import com.lc.ibps.base.saas.context.TenantContext;
 import com.lc.ibps.base.web.context.ContextUtil;
 import com.lc.ibps.base.web.context.RequestContext;
@@ -51,6 +53,7 @@ import com.lc.ibps.org.party.persistence.entity.*;
 import com.lc.ibps.org.party.repository.*;
 import com.lc.ibps.org.spi.SpiUserService;
 import com.lc.ibps.org.spi.SpiUserServiceUtil;
+import com.lc.ibps.platform.service.DesktopFacadeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -102,6 +105,8 @@ public class DesktopFacadeProvider extends GenericProvider implements IDesktopFa
 	private InnerMessageRepository innerMessageRepository;
 	@Autowired
 	private PartyUserNavigateRepository userNavigateRepository;
+	@Autowired
+	private ICommonDao<?> commonDao;
 	@Resource
 	private PartyEntityRepository partyEntityRepository;
 
@@ -244,11 +249,17 @@ public class DesktopFacadeProvider extends GenericProvider implements IDesktopFa
 		try {
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 			String currentDate = sdf.format(new Date());
+			DesktopFacadeService desktopFacadeService = AppUtil.getBean(DesktopFacadeService.class);
 			List<PartyUserCalendarPo> calendarPoList = calendarRepository.findByUserId(ContextUtil.getCurrentUserId());
 			for (PartyUserCalendarPo bean : calendarPoList){
 				if (BeanUtils.isEmpty(bean.getMarkDate()) || !bean.getMarkDate().equals(currentDate)){
 					bean.setPopUp(1);// 标记为弹窗提醒
 				}
+				String flag = desktopFacadeService.chargeExamPassingStatus(bean.getDataSourceId());
+				if("pass".equals(flag)){
+					logger.warn("已限制时间考试id{},已通过取消弹窗提醒",bean.getDataSourceId());
+					bean.setPopUp(0);// 取消弹窗提醒
+				}
 			}
 			result.setData(calendarPoList);
 		} catch (Exception e) {
@@ -257,6 +268,41 @@ public class DesktopFacadeProvider extends GenericProvider implements IDesktopFa
 		return result;
 	}
 
+	public String chargeExamPassingStatus(String dataSourceId) {
+		//List<Map<String,Object>> list = desktopFacadeDao.selectExamViewInfo(dataSourceId);
+		String sql = " select * from v_examination ;";
+		List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
+		if (list == null || list.isEmpty()) {
+			return "empt";//未发布考试或者非考试弹窗
+		}
+		Map<String, Object> record = list.get(0);
+		String flag ="NotExaminedStatus";//考试已发布但是未考试完成状态
+		// 获取字段
+		Object limitDateObj = record.get("limitDate");
+		String examState = (String) record.get("examState");
+		String paperState = (String) record.get("paperState");
+		// 检查条件
+		if (limitDateObj != null && !limitDateObj.toString().isEmpty() && "已发布".equals(examState) && "已完成".equals(paperState)) {
+			// 获取分数相关字段
+			Number totalScore = (Number) record.get("totalScore");
+			Number qualifiedRadio = (Number) record.get("qualifiedRadio");
+			String scoringType = (String) record.get("scoringType");
+			Number curScore = null;
+			if ("平均分".equals(scoringType)) {
+				curScore = (Number) record.get("averageScore");
+			} else if ("最高分".equals(scoringType)) {
+				curScore = (Number) record.get("maxScore");
+			} else if ("最近得分".equals(scoringType)) {
+				curScore = (Number) record.get("recentScore");
+			}
+			if (totalScore != null && qualifiedRadio != null && curScore != null) {
+				double passScore = totalScore.doubleValue() * qualifiedRadio.doubleValue() / 100.0;
+				return curScore.doubleValue() >= passScore?flag="pass":"failure";//pass 考试已通过
+			}
+		}
+		return flag;
+	}
+
 	@ApiOperation(value = "批量删除用户日历日程", notes = "批量删除用户日历日程")
 	@Override
 	public APIResult<Void> removeCalendar(

+ 46 - 1
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/platform/service/DesktopFacadeService.java

@@ -3,6 +3,7 @@ package com.lc.ibps.platform.service;
 import java.util.List;
 import java.util.Map;
 
+import com.lc.ibps.base.framework.table.ICommonDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,7 +18,9 @@ public class DesktopFacadeService {
 
 	@Autowired
 	private IDesktopFacadeService desktopFacadeService;
-	
+	@Autowired
+	private ICommonDao<?> commonDao;
+
 	/**
 	 * 个人信息
 	 * 
@@ -198,5 +201,47 @@ public class DesktopFacadeService {
 		}
 		return null;
 	}
+
+	public String chargeExamPassingStatus(String dataSourceId) {
+		//List<Map<String,Object>> list = desktopFacadeDao.selectExamViewInfo(dataSourceId);
+		String sql = " select * from v_examination where examId ='"+dataSourceId+"' limit 1;";
+		Map<String,Object> record = commonDao.queryOne(sql);
+		if (record == null || record.isEmpty()) {
+			return "empt";//未发布考试或者非考试弹窗
+		}
+		String flag ="NotExaminedStatus";//考试已发布但是未考试完成状态
+		// 获取字段
+		Object limitDateObj =record.get("limitDate");
+		String examState = (String) record.get("examState");
+		String paperState = (String) record.get("paperState");
+		// 检查条件
+		if (limitDateObj != null && !limitDateObj.toString().isEmpty() && "已发布".equals(examState) && "已完成".equals(paperState)) {
+			// 获取字段值
+			Object totalScoreObj = record.get("totalScore");
+			Object qualifiedRadioObj = record.get("qualifiedRadio");
+			if (totalScoreObj == null || qualifiedRadioObj == null
+					|| "".equals(totalScoreObj) || "".equals(qualifiedRadioObj)) {
+				// 关键字段缺失,返回未完成状态
+				return "NotExaminedStatus";
+			}
+
+			double totalScore = Double.parseDouble(record.get("totalScore").toString());
+			double qualifiedRadio = Double.parseDouble(record.get("qualifiedRadio").toString());
+			String scoringType = (String) record.get("scoringType");
+			Number curScore = null;
+			if ("平均分".equals(scoringType)) {
+				curScore = (Number) record.get("averageScore");
+			} else if ("最高分".equals(scoringType)) {
+				curScore = (Number) record.get("maxScore");
+			} else if ("最近得分".equals(scoringType)) {
+				curScore = (Number) record.get("recentScore");
+			}
+			if (curScore != null) {
+				double passScore = totalScore * qualifiedRadio / 100.0;
+				return curScore.doubleValue() >= passScore?flag="pass":"failure";//pass 考试已通过
+			}
+		}
+		return flag;
+	}
 	
 }