Browse Source

优化了外部任务接口

dev
vincent 3 weeks ago
parent
commit
a4c4bc6895
  1. 42
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/IOutEfcodeCpTaskService.java
  2. 163
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/OutEfcodeCpTaskServiceImpl.java

42
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/IOutEfcodeCpTaskService.java

@ -60,7 +60,6 @@ public interface IOutEfcodeCpTaskService {
*/
Boolean updateByBo(EfcodeCpTaskBo bo);
Boolean updateIsRead(String taskId);
/**
* 校验并批量删除行政执法检查计划-任务信息
@ -71,39 +70,6 @@ public interface IOutEfcodeCpTaskService {
*/
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
/**
* 查询我的任务列表(通过计划表关联,筛选当前用户参与的任务)
*
* @param userId 当前用户ID
* @param planDate 计划执行日期(可为null)
* @return 任务列表
*/
List<EfcodeCpTaskVo> queryMyTaskList(Long userId, Date planDate,String searchValue);
/**
* 查询指定月份中有任务的日期列表(用于日历打点)
*
* @param userId 当前用户ID
* @param yearMonth 年月,格式如 "2026-03"
* @return 日期字符串列表
*/
List<String> queryMyTaskDates(Long userId, String yearMonth);
/**
* 查询我的任务详情(通过 planId 查询任务+计划完整信息)
*
* @param planId 计划ID
* @return 任务详情
*/
EfcodeCpTaskVo queryMyTaskDetail(String planId);
/**
* 批量查询关联计划信息(用于列表页第二次请求加载联合执法关联单位信息)
*
* @param planIds 计划ID列表(通常为isUnion=1的任务对应的planId)
* @return Map: key=planId, value=该计划关联的其他单位信息
*/
Map<String, List<EfcodeCpTaskVo.AssociatedPlan>> queryAssociatedPlansBatch(List<String> planIds);
/**
* 强制创建任务(忽略其他条件),根据计划信息直接生成任务记录并回写 plan.task_id
@ -111,12 +77,6 @@ public interface IOutEfcodeCpTaskService {
* @param plan 来源计划
* @return 新建任务ID
*/
String forceGenerateTask(EfcodeCpPlan plan);
public String forceGenerateTask(EfcodeCpPlan plan);
/**
* 统计当前登录用户的执任务未读个数
*
* @return 未读执法任务数量
*/
Long countUnreadTasksForCurrentUser();
}

163
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/OutEfcodeCpTaskServiceImpl.java

@ -117,21 +117,6 @@ public class OutEfcodeCpTaskServiceImpl implements IOutEfcodeCpTaskService {
return baseMapper.updateById(update) > 0;
}
/**
* 修改任务已读状态
*
* @param taskId 任务ID
* @return 是否修改成功
*/
@Override
public Boolean updateIsRead(String taskId) {
LambdaUpdateWrapper<EfcodeCpTask> wrapper = Wrappers.lambdaUpdate();
wrapper.eq(EfcodeCpTask::getId, taskId)
.set(EfcodeCpTask::getIsRead, 1)
.set(EfcodeCpTask::getUpdateBy, LoginHelper.getUserId())
.set(EfcodeCpTask::getUpdateTime, new Date());
return baseMapper.update(null, wrapper) > 0;
}
/**
@ -153,114 +138,22 @@ public class OutEfcodeCpTaskServiceImpl implements IOutEfcodeCpTaskService {
return true;
}
/**
* 查询我的任务列表
*/
@Override
public List<EfcodeCpTaskVo> queryMyTaskList(Long userId, Date planDate,String searchValue) {
return baseMapper.selectMyTaskList(userId, planDate,searchValue);
}
/**
* 查询指定月份中有任务的日期列表
*/
@Override
public List<String> queryMyTaskDates(Long userId, String yearMonth) {
return baseMapper.selectMyTaskDates(userId, yearMonth);
}
/**
* 查询我的任务详情
* 校验并批量删除行政执法检查计划-任务信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public EfcodeCpTaskVo queryMyTaskDetail(String planId) {
EfcodeCpTaskVo detail = baseMapper.selectMyTaskDetail(planId);
if (detail == null || StringUtils.isBlank(detail.getId())) {
return detail;
}
// 查询同一 task_id 下其他单位的计划(排除当前 planId)
List<EfcodeCpPlan> otherPlans = cpPlanMapper.selectList(
Wrappers.<EfcodeCpPlan>lambdaQuery()
.eq(EfcodeCpPlan::getTaskId, detail.getId())
.ne(EfcodeCpPlan::getId, planId)
.eq(EfcodeCpPlan::getIsDelete, 0L)
);
if (otherPlans != null && !otherPlans.isEmpty()) {
List<EfcodeCpTaskVo.AssociatedPlan> associated = new ArrayList<>();
for (EfcodeCpPlan p : otherPlans) {
EfcodeCpTaskVo.AssociatedPlan ap = new EfcodeCpTaskVo.AssociatedPlan();
ap.setBureauDeptName(p.getBureauDeptName());
ap.setEnforceUserNames(p.getEnforceUserNames());
ap.setEnforceUserTels(p.getEnforceUserTels());
ap.setEnforceContent(p.getEnforceContent());
associated.add(ap);
}
detail.setAssociatedPlans(associated);
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return detail;
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 批量查询关联计划信息(用于列表页第二次请求加载联合执法关联单位信息)
*/
@Override
public Map<String, List<EfcodeCpTaskVo.AssociatedPlan>> queryAssociatedPlansBatch(List<String> planIds) {
Map<String, List<EfcodeCpTaskVo.AssociatedPlan>> result = new HashMap<>();
if (planIds == null || planIds.isEmpty()) {
return result;
}
// 1. 查询这些planId对应的计划,获取各自的taskId
List<EfcodeCpPlan> sourcePlans = cpPlanMapper.selectList(
Wrappers.<EfcodeCpPlan>lambdaQuery()
.in(EfcodeCpPlan::getId, planIds)
.eq(EfcodeCpPlan::getIsDelete, 0L)
.isNotNull(EfcodeCpPlan::getTaskId)
);
if (sourcePlans == null || sourcePlans.isEmpty()) {
return result;
}
// 2. 收集所有taskId,并建立 planId -> taskId 的映射
Map<String, String> planToTask = new HashMap<>();
List<String> taskIds = new ArrayList<>();
for (EfcodeCpPlan p : sourcePlans) {
planToTask.put(p.getId(), p.getTaskId());
if (!taskIds.contains(p.getTaskId())) {
taskIds.add(p.getTaskId());
}
}
// 3. 查询所有相关taskId下的计划(排除当前用户的planId)
List<EfcodeCpPlan> allRelatedPlans = cpPlanMapper.selectList(
Wrappers.<EfcodeCpPlan>lambdaQuery()
.in(EfcodeCpPlan::getTaskId, taskIds)
.notIn(EfcodeCpPlan::getId, planIds)
.eq(EfcodeCpPlan::getIsDelete, 0L)
);
if (allRelatedPlans == null || allRelatedPlans.isEmpty()) {
return result;
}
// 4. 按taskId分组
Map<String, List<EfcodeCpPlan>> groupedByTask = allRelatedPlans.stream()
.collect(Collectors.groupingBy(EfcodeCpPlan::getTaskId));
// 5. 映射回各planId
for (Map.Entry<String, String> entry : planToTask.entrySet()) {
String planId = entry.getKey();
String taskId = entry.getValue();
List<EfcodeCpPlan> otherPlans = groupedByTask.get(taskId);
if (otherPlans != null && !otherPlans.isEmpty()) {
List<EfcodeCpTaskVo.AssociatedPlan> associated = new ArrayList<>();
for (EfcodeCpPlan p : otherPlans) {
EfcodeCpTaskVo.AssociatedPlan ap = new EfcodeCpTaskVo.AssociatedPlan();
ap.setBureauDeptName(p.getBureauDeptName());
ap.setEnforceUserNames(p.getEnforceUserNames());
ap.setEnforceUserTels(p.getEnforceUserTels());
ap.setEnforceContent(p.getEnforceContent());
associated.add(ap);
}
result.put(planId, associated);
}
}
return result;
}
/**
* 强制创建任务(忽略其他条件),根据计划信息直接生成任务记录并回写 plan.task_id
@ -292,42 +185,4 @@ public class OutEfcodeCpTaskServiceImpl implements IOutEfcodeCpTaskService {
return task.getId();
}
/**
* 校验并批量删除行政执法检查计划-任务信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 统计当前用户未读任务数量
*/
@Override
public Long countUnreadTasksForCurrentUser() {
Integer platformType = LoginHelper.getPlatformType();
Long userId = LoginHelper.getUserId();
// 默认来源类型:执法任务
final Integer sourceType = 4;
// 执法端:根据用户ID统计
if (PlatformTypeEnums.ENFORCEMENT.getKey().equals(platformType)) {
if (userId == null) {
log.warn("当前用户未登录,无法统计未读执法任务消息");
return 0L;
}
return baseMapper.countTasksForCurrentUser(userId,sourceType);
}
return 0L;
}
}

Loading…
Cancel
Save