diff --git a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyAssessmentController.java b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyAssessmentController.java index 17d426b0..edaf179c 100644 --- a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyAssessmentController.java +++ b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyAssessmentController.java @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.ddnai.common.annotation.Log; import com.ddnai.common.core.controller.BaseController; @@ -36,7 +37,6 @@ import com.ddnai.system.service.psychology.IPsyAssessmentService; import com.ddnai.system.service.psychology.IPsyAssessmentAnswerService; import com.ddnai.system.service.psychology.IPsyScaleItemService; import java.util.ArrayList; -import java.math.BigDecimal; /** * 测评记录 信息操作处理 @@ -87,10 +87,33 @@ public class PsyAssessmentController extends BaseController * 获取暂停的测评列表 */ @GetMapping("/pausedList") - public AjaxResult pausedList() + public AjaxResult pausedList(@RequestParam(value = "userId", required = false) Long userId) { - Long userId = SecurityUtils.getUserId(); - List list = assessmentService.selectPausedAssessmentList(userId); + Long currentUserId = SecurityUtils.getUserId(); + boolean hasManagePerm = false; + try + { + hasManagePerm = SecurityUtils.hasPermi("psychology:assessment:list"); + } + catch (Exception ignored) + { + } + + Long targetUserId = null; + if (userId != null) + { + if (!userId.equals(currentUserId) && !hasManagePerm) + { + return error("无权查看其他用户的暂停测评记录"); + } + targetUserId = userId; + } + else if (!hasManagePerm) + { + targetUserId = currentUserId; + } + + List list = assessmentService.selectPausedAssessmentList(targetUserId); return success(list); } diff --git a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyScaleController.java b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyScaleController.java index 28d678dc..1c21c75d 100644 --- a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyScaleController.java +++ b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyScaleController.java @@ -1,7 +1,6 @@ package com.ddnai.web.controller.psychology; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -74,6 +73,7 @@ public class PsyScaleController extends BaseController public TableDataInfo list(PsyScale scale, @RequestParam(required = false, defaultValue = "true") Boolean includeQuestionnaire) { Set allowedScaleIds = resolveAllowedScaleIdsForCurrentUser(); + Set restrictedScaleIds = resolveRestrictedScaleIds(); boolean needPermissionFilter = allowedScaleIds != null; // 如果需要包含问卷,需要先查询所有数据,合并后再分页 @@ -91,7 +91,7 @@ public class PsyScaleController extends BaseController } } - scaleList = filterScaleListByPermission(scaleList, allowedScaleIds); + scaleList = filterScaleListByPermission(scaleList, allowedScaleIds, restrictedScaleIds); // 查询问卷列表(不分页,因为需要合并后再分页) PsyQuestionnaire questionnaireQuery = new PsyQuestionnaire(); @@ -119,7 +119,7 @@ public class PsyScaleController extends BaseController scaleList.add(scaleItem); } - scaleList = filterScaleListByPermission(scaleList, allowedScaleIds); + scaleList = filterScaleListByPermission(scaleList, allowedScaleIds, restrictedScaleIds); // 按排序顺序和创建时间排序 scaleList.sort((a, b) -> { @@ -157,7 +157,7 @@ public class PsyScaleController extends BaseController } } - scaleList = filterScaleListByPermission(scaleList, allowedScaleIds); + scaleList = filterScaleListByPermission(scaleList, allowedScaleIds, restrictedScaleIds); if (needPermissionFilter) { @@ -193,7 +193,6 @@ public class PsyScaleController extends BaseController scale.setRemark(questionnaire.getRemark()); return scale; } - /** * 构建手动分页结果,适用于自定义过滤后的列表 */ @@ -224,7 +223,7 @@ public class PsyScaleController extends BaseController * @param scaleList 原始列表 * @param allowedScaleIds null表示无需过滤;非null表示仅可访问允许集合中的量表 */ - private List filterScaleListByPermission(List scaleList, Set allowedScaleIds) + private List filterScaleListByPermission(List scaleList, Set allowedScaleIds, Set restrictedScaleIds) { if (allowedScaleIds == null || scaleList == null) { @@ -238,13 +237,16 @@ public class PsyScaleController extends BaseController continue; } String sourceType = scale.getSourceType(); + Long scaleId = scale.getScaleId(); if ("questionnaire".equalsIgnoreCase(sourceType)) { - // 问卷类型默认对所有学员开放 - filtered.add(scale); - continue; + boolean restricted = restrictedScaleIds != null && restrictedScaleIds.contains(scaleId); + if (!restricted) + { + filtered.add(scale); + continue; + } } - Long scaleId = scale.getScaleId(); if (scaleId != null && allowedScaleIds.contains(scaleId)) { filtered.add(scale); @@ -585,6 +587,24 @@ public class PsyScaleController extends BaseController } } } + + private Set resolveRestrictedScaleIds() + { + try + { + List ids = scalePermissionService.selectAllScaleIdsWithPermission(); + if (ids == null || ids.isEmpty()) + { + return java.util.Collections.emptySet(); + } + return new java.util.HashSet<>(ids); + } + catch (Exception e) + { + logger.warn("解析量表权限限制列表失败: {}", e.getMessage()); + return java.util.Collections.emptySet(); + } + } @SuppressWarnings("unchecked") private Map normalizeScaleImportMap(Map root) diff --git a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyUserProfileController.java b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyUserProfileController.java index 9d536f74..dfa532d6 100644 --- a/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyUserProfileController.java +++ b/ry-xinli-admin/src/main/java/com/ddnai/web/controller/psychology/PsyUserProfileController.java @@ -24,6 +24,7 @@ import com.ddnai.common.enums.BusinessType; import com.ddnai.common.utils.SecurityUtils; import com.ddnai.common.utils.StringUtils; import com.ddnai.common.utils.poi.ExcelUtil; +import com.ddnai.system.domain.dto.ImportProgress; import com.ddnai.system.domain.psychology.PsyUserProfile; import com.ddnai.system.service.ISysDeptService; import com.ddnai.system.service.ISysPostService; @@ -280,4 +281,15 @@ public class PsyUserProfileController extends BaseController String message = profileService.importProfile(profileList, updateSupport, operName); return success(message); } + + /** + * 查询导入进度 + */ + @PreAuthorize("@ss.hasPermi('psychology:profile:import')") + @GetMapping("/importProgress") + public AjaxResult getImportProgress() + { + ImportProgress progress = profileService.getImportProgress(getUsername()); + return success(progress); + } } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/domain/dto/ImportProgress.java b/ry-xinli-system/src/main/java/com/ddnai/system/domain/dto/ImportProgress.java new file mode 100644 index 00000000..51933b55 --- /dev/null +++ b/ry-xinli-system/src/main/java/com/ddnai/system/domain/dto/ImportProgress.java @@ -0,0 +1,150 @@ +package com.ddnai.system.domain.dto; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 通用导入进度信息 + */ +public class ImportProgress implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 总数量 */ + private int total; + + /** 已处理数量 */ + private int processed; + + /** 成功数量 */ + private int success; + + /** 失败数量 */ + private int failure; + + /** 状态:processing、success、failed */ + private String status; + + /** 状态描述/提示 */ + private String message; + + /** 开始时间 */ + private LocalDateTime startTime; + + /** 最近更新时间 */ + private LocalDateTime lastUpdateTime; + + /** 过期时间戳(毫秒) */ + private long expireAt; + + public int getTotal() + { + return total; + } + + public void setTotal(int total) + { + this.total = total; + } + + public int getProcessed() + { + return processed; + } + + public void setProcessed(int processed) + { + this.processed = processed; + } + + public int getSuccess() + { + return success; + } + + public void setSuccess(int success) + { + this.success = success; + } + + public int getFailure() + { + return failure; + } + + public void setFailure(int failure) + { + this.failure = failure; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public LocalDateTime getStartTime() + { + return startTime; + } + + public void setStartTime(LocalDateTime startTime) + { + this.startTime = startTime; + } + + public LocalDateTime getLastUpdateTime() + { + return lastUpdateTime; + } + + public void setLastUpdateTime(LocalDateTime lastUpdateTime) + { + this.lastUpdateTime = lastUpdateTime; + } + + public long getExpireAt() + { + return expireAt; + } + + public void setExpireAt(long expireAt) + { + this.expireAt = expireAt; + } + + public boolean isExpired(long now) + { + return expireAt > 0 && now > expireAt; + } + + public ImportProgress copy() + { + ImportProgress copy = new ImportProgress(); + copy.setTotal(this.total); + copy.setProcessed(this.processed); + copy.setSuccess(this.success); + copy.setFailure(this.failure); + copy.setStatus(this.status); + copy.setMessage(this.message); + copy.setStartTime(this.startTime); + copy.setLastUpdateTime(this.lastUpdateTime); + copy.setExpireAt(this.expireAt); + return copy; + } +} + diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/domain/psychology/PsyScalePermission.java b/ry-xinli-system/src/main/java/com/ddnai/system/domain/psychology/PsyScalePermission.java index 6745e914..afafd85d 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/domain/psychology/PsyScalePermission.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/domain/psychology/PsyScalePermission.java @@ -46,6 +46,9 @@ public class PsyScalePermission extends BaseEntity /** 量表名称(关联查询字段,不存储在表中) */ private String scaleName; + /** 来源类型(scale/questionnaire) */ + private String sourceType; + /** 部门名称(关联查询字段,不存储在表中) */ private String deptName; @@ -155,6 +158,16 @@ public class PsyScalePermission extends BaseEntity this.scaleName = scaleName; } + public String getSourceType() + { + return sourceType; + } + + public void setSourceType(String sourceType) + { + this.sourceType = sourceType; + } + public String getDeptName() { return deptName; @@ -202,6 +215,8 @@ public class PsyScalePermission extends BaseEntity .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) + .append("scaleName", getScaleName()) + .append("sourceType", getSourceType()) .toString(); } } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/mapper/psychology/PsyScalePermissionMapper.java b/ry-xinli-system/src/main/java/com/ddnai/system/mapper/psychology/PsyScalePermissionMapper.java index 3dba4814..41058155 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/mapper/psychology/PsyScalePermissionMapper.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/mapper/psychology/PsyScalePermissionMapper.java @@ -91,5 +91,12 @@ public interface PsyScalePermissionMapper * @return 结果 */ public int deletePermissionByScaleId(Long scaleId); + + /** + * 查询所有已配置权限的量表ID + * + * @return 量表ID集合 + */ + public List selectAllScaleIdsWithPermission(); } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyScalePermissionServiceImpl.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyScalePermissionServiceImpl.java index e82a1629..6664dcd3 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyScalePermissionServiceImpl.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyScalePermissionServiceImpl.java @@ -9,8 +9,10 @@ import org.springframework.transaction.annotation.Transactional; import com.ddnai.common.utils.SecurityUtils; import com.ddnai.system.domain.psychology.PsyScalePermission; import com.ddnai.system.mapper.psychology.PsyScalePermissionMapper; +import com.ddnai.system.domain.psychology.PsyQuestionnaire; import com.ddnai.system.service.psychology.IPsyScalePermissionService; import com.ddnai.system.service.psychology.IPsyScaleService; +import com.ddnai.system.service.psychology.IPsyQuestionnaireService; /** * 量表权限 服务层实现 @@ -27,6 +29,9 @@ public class PsyScalePermissionServiceImpl implements IPsyScalePermissionService @Autowired private IPsyScaleService scaleService; + + @Autowired + private IPsyQuestionnaireService questionnaireService; /** * 查询量表权限信息 @@ -92,15 +97,7 @@ public class PsyScalePermissionServiceImpl implements IPsyScalePermissionService @Override public int insertPermission(PsyScalePermission permission) { - // 验证 scale_id 是否存在 - if (permission.getScaleId() != null) - { - com.ddnai.system.domain.psychology.PsyScale scale = scaleService.selectScaleById(permission.getScaleId()); - if (scale == null) - { - throw new RuntimeException("量表不存在,scaleId: " + permission.getScaleId()); - } - } + validateScaleExists(permission.getScaleId()); if (permission.getStatus() == null) { @@ -150,15 +147,7 @@ public class PsyScalePermissionServiceImpl implements IPsyScalePermissionService @Override public int updatePermission(PsyScalePermission permission) { - // 验证 scale_id 是否存在 - if (permission.getScaleId() != null) - { - com.ddnai.system.domain.psychology.PsyScale scale = scaleService.selectScaleById(permission.getScaleId()); - if (scale == null) - { - throw new RuntimeException("量表不存在,scaleId: " + permission.getScaleId()); - } - } + validateScaleExists(permission.getScaleId()); return permissionMapper.updatePermission(permission); } @@ -239,12 +228,10 @@ public class PsyScalePermissionServiceImpl implements IPsyScalePermissionService } try { - // 验证 scale_id 是否存在 - com.ddnai.system.domain.psychology.PsyScale scale = scaleService.selectScaleById(scaleId); - if (scale == null) + if (!validateScaleExistsSilent(scaleId)) { - log.warn("量表不存在,跳过该权限分配,scaleId: {}", scaleId); - continue; // 跳过不存在的量表 + log.warn("量表/问卷不存在,跳过该权限分配,scaleId: {}", scaleId); + continue; } PsyScalePermission permission = new PsyScalePermission(); @@ -267,5 +254,35 @@ public class PsyScalePermissionServiceImpl implements IPsyScalePermissionService } return count; } + + @Override + public List selectAllScaleIdsWithPermission() + { + return permissionMapper.selectAllScaleIdsWithPermission(); + } + + private void validateScaleExists(Long scaleId) + { + if (!validateScaleExistsSilent(scaleId)) + { + throw new RuntimeException("量表或问卷不存在,scaleId: " + scaleId); + } + } + + private boolean validateScaleExistsSilent(Long scaleId) + { + if (scaleId == null) + { + return true; + } + if (scaleId < 0) + { + Long questionnaireId = Math.abs(scaleId); + PsyQuestionnaire questionnaire = questionnaireService.selectQuestionnaireById(questionnaireId); + return questionnaire != null; + } + com.ddnai.system.domain.psychology.PsyScale scale = scaleService.selectScaleById(scaleId); + return scale != null; + } } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java index 5c9caea5..84916dd7 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java @@ -14,10 +14,12 @@ import com.ddnai.common.utils.SecurityUtils; import com.ddnai.common.utils.StringUtils; import com.ddnai.system.domain.psychology.PsyUserProfile; import com.ddnai.system.mapper.psychology.PsyUserProfileMapper; +import com.ddnai.system.domain.dto.ImportProgress; import com.ddnai.system.service.ISysConfigService; import com.ddnai.system.service.ISysRoleService; import com.ddnai.system.service.ISysUserService; import com.ddnai.system.service.psychology.IPsyUserProfileService; +import com.ddnai.system.service.psychology.support.ImportProgressManager; /** * 用户档案扩展表 服务层实现 @@ -41,6 +43,9 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService @Autowired private ISysRoleService roleService; + @Autowired + private ImportProgressManager importProgressManager; + /** * 查询档案信息 * @@ -475,13 +480,16 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService { throw new ServiceException("导入用户档案数据不能为空!"); } + final String progressKey = importProgressManager.buildProfileKey(operName); + importProgressManager.start(progressKey, profileList.size()); int successNum = 0; int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); - - for (PsyUserProfile profile : profileList) + try { + for (PsyUserProfile profile : profileList) + { try { // 设置创建者 @@ -492,6 +500,7 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService { failureNum++; failureMsg.append("
").append(failureNum).append("、档案信息编号为空"); + importProgressManager.recordFailure(progressKey); continue; } @@ -503,6 +512,7 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService this.insertProfile(profile); successNum++; successMsg.append("
").append(successNum).append("、信息编号 ").append(profile.getInfoNumber()).append(" 导入成功"); + importProgressManager.recordSuccess(progressKey); } else if (isUpdateSupport) { @@ -513,11 +523,13 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService this.updateProfile(profile); successNum++; successMsg.append("
").append(successNum).append("、信息编号 ").append(profile.getInfoNumber()).append(" 更新成功"); + importProgressManager.recordSuccess(progressKey); } else { failureNum++; failureMsg.append("
").append(failureNum).append("、信息编号 ").append(profile.getInfoNumber()).append(" 已存在"); + importProgressManager.recordFailure(progressKey); } } catch (Exception e) @@ -525,20 +537,51 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService failureNum++; String msg = "
" + failureNum + "、信息编号 " + profile.getInfoNumber() + " 导入失败:"; failureMsg.append(msg).append(e.getMessage()); + importProgressManager.recordFailure(progressKey); log.error(msg, e); } } + + if (successNum > 0) + { + successMsg.insert(0, "以下数据处理成功(共 " + successNum + " 条):"); + } if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + if (successNum > 0) + { + failureMsg.append("

").append(successMsg); + } + importProgressManager.finishFailure(progressKey, failureMsg.toString()); throw new ServiceException(failureMsg.toString()); } - else + + if (successNum > 0) { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + String successMessage = "恭喜您,数据已全部导入成功!
" + successMsg.toString(); + importProgressManager.finishSuccess(progressKey, successMessage); + return successMessage; + } + importProgressManager.finishSuccess(progressKey, "导入完成,但未检测到需要处理的数据。"); + return "导入完成,但未检测到需要处理的数据。"; } - return successMsg.toString(); + catch (RuntimeException ex) + { + if (!(ex instanceof ServiceException)) + { + importProgressManager.finishFailure(progressKey, ex.getMessage()); + } + throw ex; + } + } + + @Override + public ImportProgress getImportProgress(String operName) + { + String progressKey = importProgressManager.buildProfileKey(operName); + return importProgressManager.snapshot(progressKey); } } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyScalePermissionService.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyScalePermissionService.java index 9e7d368f..380a1c1e 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyScalePermissionService.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyScalePermissionService.java @@ -83,6 +83,13 @@ public interface IPsyScalePermissionService */ public int deletePermissionByScaleId(Long scaleId); + /** + * 查询所有已配置权限的量表ID + * + * @return 量表ID集合 + */ + public List selectAllScaleIdsWithPermission(); + /** * 批量分配用户量表权限 * diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyUserProfileService.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyUserProfileService.java index b670a5c6..97a94af2 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyUserProfileService.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/IPsyUserProfileService.java @@ -1,6 +1,7 @@ package com.ddnai.system.service.psychology; import java.util.List; +import com.ddnai.system.domain.dto.ImportProgress; import com.ddnai.system.domain.psychology.PsyUserProfile; /** @@ -75,5 +76,13 @@ public interface IPsyUserProfileService * @return 结果 */ public String importProfile(List profileList, Boolean isUpdateSupport, String operName); + + /** + * 查询导入进度 + * + * @param operName 操作人 + * @return 进度信息 + */ + public ImportProgress getImportProgress(String operName); } diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/support/ImportProgressManager.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/support/ImportProgressManager.java new file mode 100644 index 00000000..08ad2cae --- /dev/null +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/psychology/support/ImportProgressManager.java @@ -0,0 +1,130 @@ +package com.ddnai.system.service.psychology.support; + +import java.time.LocalDateTime; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +import org.springframework.stereotype.Component; + +import com.ddnai.system.domain.dto.ImportProgress; + +/** + * 导入进度管理 + */ +@Component +public class ImportProgressManager +{ + private static final long EXPIRE_MILLIS = TimeUnit.MINUTES.toMillis(30); + + private final Map cache = new ConcurrentHashMap<>(); + + public String buildProfileKey(String username) + { + return "psychology_profile:" + username; + } + + public void start(String key, int total) + { + if (Objects.isNull(key)) + { + return; + } + ImportProgress progress = new ImportProgress(); + progress.setTotal(total); + progress.setProcessed(0); + progress.setSuccess(0); + progress.setFailure(0); + progress.setStatus("processing"); + progress.setStartTime(LocalDateTime.now()); + progress.setLastUpdateTime(LocalDateTime.now()); + progress.setExpireAt(System.currentTimeMillis() + EXPIRE_MILLIS); + cache.put(key, progress); + } + + public void recordSuccess(String key) + { + adjustProgress(key, true); + } + + public void recordFailure(String key) + { + adjustProgress(key, false); + } + + private void adjustProgress(String key, boolean success) + { + ImportProgress progress = cache.get(key); + if (progress == null) + { + return; + } + progress.setProcessed(progress.getProcessed() + 1); + if (success) + { + progress.setSuccess(progress.getSuccess() + 1); + } + else + { + progress.setFailure(progress.getFailure() + 1); + } + refreshMeta(progress); + } + + public void finishSuccess(String key, String message) + { + ImportProgress progress = cache.get(key); + if (progress == null) + { + return; + } + progress.setStatus("success"); + progress.setMessage(message); + progress.setProcessed(progress.getTotal()); + refreshMeta(progress); + } + + public void finishFailure(String key, String message) + { + ImportProgress progress = cache.get(key); + if (progress == null) + { + return; + } + progress.setStatus("failed"); + progress.setMessage(message); + refreshMeta(progress); + } + + private void refreshMeta(ImportProgress progress) + { + progress.setLastUpdateTime(LocalDateTime.now()); + progress.setExpireAt(System.currentTimeMillis() + EXPIRE_MILLIS); + } + + public ImportProgress snapshot(String key) + { + ImportProgress progress = cache.get(key); + if (progress == null) + { + return null; + } + long now = System.currentTimeMillis(); + if (progress.isExpired(now)) + { + cache.remove(key); + return null; + } + return progress.copy(); + } + + public void clear(String key) + { + if (key != null) + { + cache.remove(key); + } + } +} + diff --git a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyAssessmentMapper.xml b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyAssessmentMapper.xml index c685a5c0..95be61eb 100644 --- a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyAssessmentMapper.xml +++ b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyAssessmentMapper.xml @@ -77,7 +77,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -349,4 +354,3 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - diff --git a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyScalePermissionMapper.xml b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyScalePermissionMapper.xml index 8da382f5..e81148a7 100644 --- a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyScalePermissionMapper.xml +++ b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyScalePermissionMapper.xml @@ -28,9 +28,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select p.permission_id, p.scale_id, p.dept_id, p.role_id, p.user_id, p.class_name, p.start_time, p.end_time, p.status, p.create_by, p.create_time, p.update_by, p.update_time, p.remark, - s.scale_name, d.dept_name, r.role_name, u.user_name + case when p.scale_id < 0 then q.questionnaire_name else s.scale_name end as scale_name, + case when p.scale_id < 0 then 'questionnaire' else 'scale' end as source_type, + d.dept_name, r.role_name, u.user_name from psy_scale_permission p left join psy_scale s on p.scale_id = s.scale_id + left join psy_questionnaire q on q.questionnaire_id = -p.scale_id left join sys_dept d on p.dept_id = d.dept_id left join sys_role r on p.role_id = r.role_id left join sys_user u on p.user_id = u.user_id @@ -175,4 +178,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from psy_scale_permission where scale_id = #{scaleId} + + diff --git a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyUserProfileMapper.xml b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyUserProfileMapper.xml index 94c0c941..6242bb0a 100644 --- a/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyUserProfileMapper.xml +++ b/ry-xinli-system/src/main/resources/mapper/system/psychology/PsyUserProfileMapper.xml @@ -94,6 +94,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND u.phonenumber like concat('%', #{phone}, '%') + + AND p.prison = #{prison} + + + AND p.prison_area = #{prisonArea} + AND u.status = #{status} @@ -196,4 +202,3 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - diff --git a/xinli-ui/src/api/psychology/assessment.js b/xinli-ui/src/api/psychology/assessment.js index fe406a5c..5f885338 100644 --- a/xinli-ui/src/api/psychology/assessment.js +++ b/xinli-ui/src/api/psychology/assessment.js @@ -19,10 +19,11 @@ export function myAssessmentList(query) { } // 查询暂停的测评列表 -export function pausedAssessmentList() { +export function pausedAssessmentList(params) { return request({ url: '/psychology/assessment/pausedList', - method: 'get' + method: 'get', + params: params }) } diff --git a/xinli-ui/src/api/psychology/profile.js b/xinli-ui/src/api/psychology/profile.js index 47894322..a0e89c17 100644 --- a/xinli-ui/src/api/psychology/profile.js +++ b/xinli-ui/src/api/psychology/profile.js @@ -93,3 +93,11 @@ export function delUserInProfile(userIds) { }) } +// 查询档案导入进度 +export function getProfileImportProgress() { + return request({ + url: '/psychology/profile/importProgress', + method: 'get' + }) +} + diff --git a/xinli-ui/src/views/psychology/assessment/index.vue b/xinli-ui/src/views/psychology/assessment/index.vue index 3b0d222c..0993faea 100644 --- a/xinli-ui/src/views/psychology/assessment/index.vue +++ b/xinli-ui/src/views/psychology/assessment/index.vue @@ -61,7 +61,11 @@ - + + +