问卷整改
This commit is contained in:
+10
-2
@@ -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<QsvActivity> activities = dao.query(QsvActivity.class, cnd);
|
||||
@@ -107,6 +111,10 @@ public class QsvOnlineController {
|
||||
List<NutMap> 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");
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
+32
-2
@@ -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<QsvUserAnswerRecord> i
|
||||
// .and("isFinish", "=", true)
|
||||
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
List<NutMap> answerRecords = pagination.getList();
|
||||
Map<String, String> userMobileMap = queryUserMobileMap(answerRecords.stream()
|
||||
.map(record -> record.getString("userId"))
|
||||
.toList());
|
||||
|
||||
// 查询用户答题记录
|
||||
// List<QsvUserAnswerRecord> answerRecords = dao().query(QsvUserAnswerRecord.class, Cnd.where("activityId", "=", activityId)
|
||||
@@ -464,7 +469,8 @@ public class QsvSurveyServiceImpl extends BaseServiceImpl<QsvUserAnswerRecord> 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<QsvUserAnswerRecord> i
|
||||
}
|
||||
|
||||
private List<NutMap> buildAnswerRecords(List<QsvUserAnswerRecord> answerRecords, Map<String, QsvSubject> subjectMap, Map<String, QsvOption> optionMap) {
|
||||
Map<String, String> 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<QsvUserAnswerRecord> i
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据答题记录中的用户ID批量查询当前手机号,供后台查看答卷和导出使用。
|
||||
*
|
||||
* @param userIds 答题用户ID列表,允许包含重复值或空值
|
||||
* @return key为用户ID、value为View_user当前手机号的映射;用户不存在时不返回对应项
|
||||
*/
|
||||
private Map<String, String> queryUserMobileMap(List<String> userIds) {
|
||||
Map<String, String> userMobileMap = new HashMap<>();
|
||||
List<String> validUserIds = userIds.stream()
|
||||
.filter(ObjectUtil::isNotEmpty)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (validUserIds.isEmpty()) {
|
||||
return userMobileMap;
|
||||
}
|
||||
List<View_user> users = dao().query(View_user.class, Cnd.where("id", "in", validUserIds));
|
||||
users.forEach(user -> userMobileMap.put(user.getId(), user.getMobile()));
|
||||
return userMobileMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装单题答案展示内容。填空题返回填写文本;选择题返回选项文本,若选项配置了补充填写,
|
||||
* 则追加对应补充内容,保证后台查看答卷和导出能看到用户填写的说明。
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,6 +545,7 @@ layout("/layouts/platform.html"){
|
||||
:class="['qsv-online-vote-option', isOptionSelected(currentVoteSubject, option.id) ? 'active' : '']"
|
||||
@click="toggleVoteOption(option)">
|
||||
<el-checkbox
|
||||
v-if="isOptionSelected(currentVoteSubject, option.id)"
|
||||
class="qsv-online-vote-option-check"
|
||||
:value="isOptionSelected(currentVoteSubject, option.id)"
|
||||
:disabled="answerDialog.readonly || isVoteEnd"
|
||||
@@ -827,6 +828,34 @@ layout("/layouts/platform.html"){
|
||||
}
|
||||
return ""
|
||||
},
|
||||
// 首页链接通过 id 指定活动;先查询当前用户对应的真实答题状态,再复用现有答题入口。
|
||||
openAnswerFromUrl() {
|
||||
const activityId = new URLSearchParams(window.location.search).get("id")
|
||||
if (!activityId) {
|
||||
return
|
||||
}
|
||||
this.answerDialog.loading = true
|
||||
this.$axios.post("/platform/qsv/online/pageData", {
|
||||
pageNumber: 1,
|
||||
pageSize: 1,
|
||||
activityId: activityId
|
||||
}).then((res) => {
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user