diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/controller/QsvOnlineController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/controller/QsvOnlineController.java index e897b48e..f282478f 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/controller/QsvOnlineController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/controller/QsvOnlineController.java @@ -68,21 +68,25 @@ public class QsvOnlineController { /** * 查询当前用户可参与的在线问卷、答题和投票活动。 * pageForm 传入页码、每页数量与搜索关键字;year 为活动开始年份;title 为标题关键字; - * isAnswered 用于筛选已答或未答活动。返回 Pagination,列表数据仅包含当前用户命中活动分组的活动。 + * isAnswered 用于筛选已答或未答活动;activityId 用于首页活动携带 ID 直达指定答题任务。 + * 返回 Pagination,列表数据仅包含当前用户命中活动分组的活动;指定 activityId 时不受已答筛选影响, + * 以便前端根据实际 actionType 自动进入答题、继续答题或查看答题。 * * @param pageForm 分页及搜索参数 * @param year 活动开始年份 * @param title 活动标题关键字 * @param isAnswered 是否只查看已答活动 + * @param activityId 指定活动 ID,为空时按普通在线答题列表查询 * @return 当前用户可参与的在线活动分页结果 */ @At @SaCheckPermission("qsv.online") @ApiOperation("在线答题任务分页") - public Result pageData(@Valid PageForm pageForm, Integer year, String title, Boolean isAnswered) { + public Result pageData(@Valid PageForm pageForm, Integer year, String title, Boolean isAnswered, String activityId) { Cnd cnd = Cnd.where("enabled", "=", true); cnd.andEX("YEAR(startTime)", "=", year); cnd.and(Cnd.likeEX("title", title)); + cnd.andEX("id", "=", activityId); cnd.desc("startTime"); List activities = dao.query(QsvActivity.class, cnd); @@ -107,6 +111,10 @@ public class QsvOnlineController { List rows = activities.stream() .map((activity) -> buildOnlineRow(activity, recordGroup.getOrDefault(activity.getId(), new ArrayList<>()))) .filter((row) -> { + // 首页携带活动 ID 直达时保留真实答题状态,由前端根据 actionType 决定答题或查看。 + if (ObjectUtil.isNotEmpty(activityId)) { + return true; + } if (Boolean.TRUE.equals(isAnswered)) { return row.getBoolean("isAnswered"); } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvActivity.java b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvActivity.java index ea94a8d9..38cbdf3d 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvActivity.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvActivity.java @@ -123,7 +123,7 @@ public class QsvActivity extends BaseModel implements Serializable, SysHomeConve sysHomeActivity.setName(this.getTitle()); sysHomeActivity.setCover(this.getCover()); sysHomeActivity.setContent(this.getDescription()); - sysHomeActivity.setUrl("/platform/qsv/activity"); + sysHomeActivity.setUrl("/platform/qsv/online?id=" + this.getId()); sysHomeActivity.setH5Url(getH5Url()); sysHomeActivity.setStartDate(this.getStartTime()); sysHomeActivity.setEndDate(this.getEndTime()); diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/service/impl/QsvSurveyServiceImpl.java b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/service/impl/QsvSurveyServiceImpl.java index 231be8a3..09089681 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/service/impl/QsvSurveyServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/service/impl/QsvSurveyServiceImpl.java @@ -13,6 +13,7 @@ import com.budwk.app.base.page.Pagination; import com.budwk.app.base.param.PageForm; import com.budwk.app.base.service.impl.BaseServiceImpl; import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.sys.views.View_user; import com.budwk.app.zhgh.dayofficework.qsv.models.QsvActivity; import com.budwk.app.zhgh.dayofficework.qsv.models.QsvOption; import com.budwk.app.zhgh.dayofficework.qsv.models.QsvSubject; @@ -31,6 +32,7 @@ import org.nutz.lang.util.NutMap; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -436,6 +438,9 @@ public class QsvSurveyServiceImpl extends BaseServiceImpl i // .and("isFinish", "=", true) Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd); List answerRecords = pagination.getList(); + Map userMobileMap = queryUserMobileMap(answerRecords.stream() + .map(record -> record.getString("userId")) + .toList()); // 查询用户答题记录 // List answerRecords = dao().query(QsvUserAnswerRecord.class, Cnd.where("activityId", "=", activityId) @@ -464,7 +469,8 @@ public class QsvSurveyServiceImpl extends BaseServiceImpl i .addv("loginName", record.getString("loginName")) .addv("userName", record.getString("userName")) .addv("unitName", record.getString("unitName")) - .addv("unionName", record.getString("unionName")); + .addv("unionName", record.getString("unionName")) + .addv("mobile", userMobileMap.get(record.getString("userId"))); JSONObject extJson = record.getAs("extJson", JSONObject.class); if (ObjectUtil.isEmpty(extJson)) { return map; @@ -723,13 +729,17 @@ public class QsvSurveyServiceImpl extends BaseServiceImpl i } private List buildAnswerRecords(List answerRecords, Map subjectMap, Map optionMap) { + Map userMobileMap = queryUserMobileMap(answerRecords.stream() + .map(QsvUserAnswerRecord::getUserId) + .toList()); return answerRecords.stream().map(record -> { NutMap map = NutMap.NEW() .addv("id", record.getId()) .addv("loginName", record.getLoginName()) .addv("userName", record.getUserName()) .addv("unitName", record.getUnitName()) - .addv("unionName", record.getUnionName()); + .addv("unionName", record.getUnionName()) + .addv("mobile", userMobileMap.get(record.getUserId())); JSONObject extJson = record.getExtJson(); if (ObjectUtil.isEmpty(extJson)) { return map; @@ -745,6 +755,26 @@ public class QsvSurveyServiceImpl extends BaseServiceImpl i }).collect(Collectors.toList()); } + /** + * 根据答题记录中的用户ID批量查询当前手机号,供后台查看答卷和导出使用。 + * + * @param userIds 答题用户ID列表,允许包含重复值或空值 + * @return key为用户ID、value为View_user当前手机号的映射;用户不存在时不返回对应项 + */ + private Map queryUserMobileMap(List userIds) { + Map userMobileMap = new HashMap<>(); + List validUserIds = userIds.stream() + .filter(ObjectUtil::isNotEmpty) + .distinct() + .toList(); + if (validUserIds.isEmpty()) { + return userMobileMap; + } + List users = dao().query(View_user.class, Cnd.where("id", "in", validUserIds)); + users.forEach(user -> userMobileMap.put(user.getId(), user.getMobile())); + return userMobileMap; + } + /** * 组装单题答案展示内容。填空题返回填写文本;选择题返回选项文本,若选项配置了补充填写, * 则追加对应补充内容,保证后台查看答卷和导出能看到用户填写的说明。 diff --git a/src/main/resources/views/layouts/v4/home/act.js b/src/main/resources/views/layouts/v4/home/act.js index 2f3ef6f2..6e8a35be 100644 --- a/src/main/resources/views/layouts/v4/home/act.js +++ b/src/main/resources/views/layouts/v4/home/act.js @@ -308,7 +308,7 @@ const act = { height: 100% !important; max-width: 100% !important; max-height: 128px !important; - object-fit: cover !important; + object-fit: fill !important; transition: transform 0.3s ease; } diff --git a/src/main/resources/views/platform/zhgh/dayofficework/qsv/online/index.html b/src/main/resources/views/platform/zhgh/dayofficework/qsv/online/index.html index 74d270c0..53554f2a 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/qsv/online/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/qsv/online/index.html @@ -545,6 +545,7 @@ layout("/layouts/platform.html"){ :class="['qsv-online-vote-option', isOptionSelected(currentVoteSubject, option.id) ? 'active' : '']" @click="toggleVoteOption(option)"> { + if (res.code !== 0) { + this.$message.error(res.msg) + return + } + const rows = res.data && res.data.list ? res.data.list : [] + if (rows.length === 0) { + this.$message.warning("未找到可参与的答题活动") + return + } + this.openAnswer(rows[0]) + }).finally(() => { + if (!this.answerDialog.visible) { + this.answerDialog.loading = false + } + }) + }, openAnswer(row) { const unavailableMessage = this.getActivityUnavailableMessage(row) if (unavailableMessage) { @@ -1205,6 +1234,7 @@ layout("/layouts/platform.html"){ }, created() { this.pageData() + this.openAnswerFromUrl() }, beforeDestroy() { this.stopVoteCountdown()