Commit fc83679d by 叶立庆

Merge branch 'v5.8.2' into 'master'

上线合并

See merge request !20
2 parents e55f6df4 9343ee91
......@@ -7,7 +7,7 @@
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.4-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<name>rpc-dj-staff-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.staff.remote</deploy.scanPackage>
......@@ -37,7 +37,7 @@
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.4-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
......
package cn.com.glsx.dj.staff.dto.taskcenter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 事项任务统计数量 DTO
* <p>用于事项首页/页签上展示 待完成/已完成/全部 三个数字。</p>
*/
@Data
@ApiModel(value = "TaskCountStatDTO", description = "事项任务统计数量")
public class TaskCountStatDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 待完成数量(status=0)
*/
@ApiModelProperty(notes = "待完成数量")
private Long pendingCount;
/**
* 已完成数量(status=1)
*/
@ApiModelProperty(notes = "已完成数量")
private Long completedCount;
/**
* 全部数量(不区分状态)
*/
@ApiModelProperty(notes = "全部数量")
private Long totalCount;
}
package cn.com.glsx.dj.staff.dto.taskcenter;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 任务信息 DTO(分页列表/详情通用)
*/
@Data
public class TaskInfoDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键id")
private Long id;
@ApiModelProperty(notes = "外部任务中心关联id")
private Long taskCenterId;
@ApiModelProperty(notes = "任务类型,人员更换评估:staff-replace-access、商务政策更新评估:policy-update-access、多品类扩张:scene-expand、流量问题改善:traffic-optimize")
private String taskType;
@ApiModelProperty(notes = "任务类型名称")
private String taskTypeName;
@ApiModelProperty(notes = "状态:0-待完成,1-已完成")
private Integer status;
@ApiModelProperty(notes = "归属门店名称")
private String storeName;
@ApiModelProperty(notes = "归属门店id")
private String storeId;
@ApiModelProperty(notes = "归属业务:1.延保 2.轻改 3.权益")
private Integer businessType;
@ApiModelProperty(notes = "归属业务名称(多个用/隔开)")
private String businessTypeName;
@ApiModelProperty(notes = "创建人")
private String creator;
@ApiModelProperty(notes = "创建人手机号")
private String creatorPhone;
@ApiModelProperty(notes = "任务描述(完整)")
private String taskDescription;
@ApiModelProperty(notes = "专项任务回复")
private String replyContent;
@ApiModelProperty(notes = "回复时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date replyTime;
@ApiModelProperty(notes = "指派的区域运营id")
private String assignedToId;
@ApiModelProperty(notes = "指派的区域运营名称")
private String assignedToName;
@ApiModelProperty(notes = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@ApiModelProperty(notes = "问题驻店人员列表")
private List<TaskStaffRelDTO> staffList;
}
package cn.com.glsx.dj.staff.dto.taskcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 任务分页查询条件 DTO
*/
@Data
public class TaskInfoQueryDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "状态:0-待完成,1-已完成,null-全部")
private Integer status;
@ApiModelProperty(notes = "模糊搜索关键词(门店名称/业务名称/驻店销售/创建人/任务描述)")
private String keyword;
@ApiModelProperty(notes = "指派的区域运营id(当前登录人uuid,限制只能查看自己的任务)")
private String assignedToId;
}
package cn.com.glsx.dj.staff.dto.taskcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 专项任务回复提交 DTO
*/
@Data
public class TaskInfoSubmitDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "任务主键id", required = true)
private Long id;
@ApiModelProperty(notes = "专项任务回复内容,1-800字符", required = true)
private String replyContent;
@ApiModelProperty(notes = "修改人")
private String updatedBy;
}
package cn.com.glsx.dj.staff.dto.taskcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 任务-问题驻店人员关联 DTO
*/
@Data
public class TaskStaffRelDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "人员名称")
private String staffName;
@ApiModelProperty(notes = "人员手机号")
private String staffPhone;
@ApiModelProperty(notes = "人员uuid")
private String staffUuid;
@ApiModelProperty(notes = "岗位类型:0-驻店")
private Integer userPosition;
}
package cn.com.glsx.dj.staff.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 任务信息表
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Table(name = "dj_car_life_task_info")
public class TaskInfo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/** 外部任务中心关联id */
@Column(name = "task_center_id")
private Long taskCenterId;
/** 任务类型 */
@Column(name = "task_type")
private String taskType;
/** 任务类型名称 */
@Column(name = "task_type_name")
private String taskTypeName;
/** 状态:0-待完成,1-已完成 */
@Column(name = "status")
private Integer status;
/** 归属门店名称 */
@Column(name = "store_name")
private String storeName;
/** 归属门店id */
@Column(name = "store_id")
private String storeId;
/** 归属业务:1.延保 2.轻改 3.权益 */
@Column(name = "business_type")
private Integer businessType;
/** 归属业务名称 */
@Column(name = "business_type_name")
private String businessTypeName;
/** 创建人 */
@Column(name = "creator")
private String creator;
/** 创建人手机号 */
@Column(name = "creator_phone")
private String creatorPhone;
/** 任务描述(完整) */
@Column(name = "task_description")
private String taskDescription;
/** 专项任务回复 */
@Column(name = "reply_content")
private String replyContent;
/** 回复时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "reply_time")
private Date replyTime;
/** 指派的区域运营id */
@Column(name = "assigned_to_id")
private String assignedToId;
/** 指派的区域运营名称 */
@Column(name = "assigned_to_name")
private String assignedToName;
/** 创建人(系统字段) */
@Column(name = "created_by")
private String createdBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "created_date")
private Date createdDate;
/** 修改人 */
@Column(name = "updated_by")
private String updatedBy;
/** 修改时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "updated_date")
private Date updatedDate;
/** 删除标识(D:已删除;N:未删除) */
@Column(name = "deleted_flag")
private String deletedFlag;
}
package cn.com.glsx.dj.staff.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 任务-人员关联表
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Table(name = "dj_car_life_task_staff_rel")
public class TaskStaffRel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/** 任务id,关联dj_car_life_task_info.id */
@Column(name = "task_id")
private Long taskId;
/** 外部任务中心关联id(冗余字段) */
@Column(name = "task_center_id")
private Long taskCenterId;
/** 人员名称 */
@Column(name = "staff_name")
private String staffName;
/** 人员手机号 */
@Column(name = "staff_phone")
private String staffPhone;
/** 人员uuid */
@Column(name = "staff_uuid")
private String staffUuid;
/** 岗位类型:0-驻店 */
@Column(name = "user_position")
private Integer userPosition;
/** 创建人 */
@Column(name = "created_by")
private String createdBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "created_date")
private Date createdDate;
/** 修改人 */
@Column(name = "updated_by")
private String updatedBy;
/** 修改时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "updated_date")
private Date updatedDate;
/** 删除标识(D:已删除;N:未删除) */
@Column(name = "deleted_flag")
private String deletedFlag;
}
package cn.com.glsx.dj.staff.remote;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskCountStatDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoSubmitDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import javax.validation.constraints.NotNull;
@ApiService(value = "事项(专项任务)接口", owner = "staff", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public interface TaskInfoRemote {
@ApiMethod("分页查询事项列表")
@ApiParam(name = "pagination", notes = "分页查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("事项分页结果")
RpcResponse<RpcPagination<TaskInfoDTO>> pageTaskInfo(@NotNull RpcPagination<TaskInfoQueryDTO> pagination);
@ApiMethod("统计事项任务数量(待完成/已完成/全部)")
@ApiParam(name = "query", notes = "查询条件(assignedToId/keyword)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("事项任务统计数量")
RpcResponse<TaskCountStatDTO> countTaskStat(@NotNull TaskInfoQueryDTO query);
@ApiMethod("查询事项详情")
@ApiParam(name = "id", notes = "任务主键id", dataType = ApiParam.DataTypeEnum.LONG, required = true)
@ApiResponse("事项详情")
RpcResponse<TaskInfoDTO> getTaskInfoDetail(@NotNull Long id);
@ApiMethod("专项任务回复提交(去处理页面提交)")
@ApiParam(name = "dto", notes = "提交信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("提交结果")
RpcResponse<Boolean> submitTaskReply(@NotNull TaskInfoSubmitDTO dto);
}
......@@ -7,14 +7,14 @@
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff</artifactId>
<version>5.7.4-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<name>rpc-dj-staff</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.4-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
......@@ -84,5 +84,10 @@
<artifactId>platform-merchants-api</artifactId>
<version>5.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-taskcenter-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.staff.job;
import cn.com.glsx.dj.staff.service.TaskInfoSyncService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 任务信息同步定时任务:每分钟从任务中心同步新增任务到本地
*/
@Slf4j
@ElasticJobConf(name = "TaskInfoSyncJob", cron = "0 0/1 * * * ?", description = "从任务中心同步新增任务到本地", overwrite = false)
public class TaskInfoSyncJob implements SimpleJob {
@Autowired
private TaskInfoSyncService taskInfoSyncService;
@Override
public void execute(ShardingContext shardingContext) {
try {
taskInfoSyncService.syncTaskFromCenter();
} catch (Exception e) {
log.error("TaskInfoSyncJob__execute__error", e);
}
}
}
package cn.com.glsx.dj.staff.mapper;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskStaffRelDTO;
import cn.com.glsx.dj.staff.model.TaskInfo;
import cn.com.glsx.dj.staff.model.TaskStaffRel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
@Mapper
public interface TaskInfoMapper {
/**
* 分页查询事项列表(支持状态和关键词过滤)
*/
List<TaskInfoDTO> pageTaskInfo(TaskInfoQueryDTO query);
/**
* 按条件统计事项数量
* <p>当 query.status 为空时,统计该用户全部任务数;不为空则按状态统计。</p>
*/
Long countTaskInfo(TaskInfoQueryDTO query);
/**
* 根据id查询事项详情
*/
TaskInfoDTO getTaskInfoById(@Param("id") Long id);
/**
* 根据任务id列表查询关联的人员
*/
List<TaskStaffRelDTO> listStaffByTaskId(@Param("taskId") Long taskId);
/**
* 提交回复(更新 reply_content、reply_time、status)
*/
int updateTaskReply(@Param("id") Long id,
@Param("replyContent") String replyContent,
@Param("updatedBy") String updatedBy);
/**
* 查询本地任务表最大创建时间
*/
Date getMaxCreatedDate();
/**
* 根据task_center_id判断本地是否已存在该任务
*/
int countByTaskCenterId(@Param("taskCenterId") Long taskCenterId);
/**
* 新增任务信息(同步用)
*/
int insertTaskInfo(TaskInfo taskInfo);
/**
* 批量新增任务关联人员(同步用)
*/
int batchInsertStaffRel(@Param("list") List<TaskStaffRel> list);
/**
* 根据task_center_id查询本地任务主键id
*/
Long getIdByTaskCenterId(@Param("taskCenterId") Long taskCenterId);
}
package cn.com.glsx.dj.staff.remote;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskCountStatDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoSubmitDTO;
import cn.com.glsx.dj.staff.service.TaskInfoService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@DubboService(version = "1.0.0", validation = "true")
public class TaskInfoRemoteImpl implements TaskInfoRemote {
@Autowired
private TaskInfoService taskInfoService;
@Override
public RpcResponse<RpcPagination<TaskInfoDTO>> pageTaskInfo(RpcPagination<TaskInfoQueryDTO> pagination) {
try {
Page<TaskInfoDTO> page = taskInfoService.pageTaskInfo(pagination);
RpcPagination<TaskInfoDTO> result = RpcPagination.copyPage(page);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("TaskInfoRemoteImpl__pageTaskInfo__bizException:{}", e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("TaskInfoRemoteImpl__pageTaskInfo__exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<TaskCountStatDTO> countTaskStat(TaskInfoQueryDTO query) {
try {
TaskCountStatDTO stat = taskInfoService.countTaskStat(query);
return RpcResponse.success(stat);
} catch (RpcServiceException e) {
log.error("TaskInfoRemoteImpl__countTaskStat__bizException:{}", e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("TaskInfoRemoteImpl__countTaskStat__exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<TaskInfoDTO> getTaskInfoDetail(Long id) {
try {
TaskInfoDTO detail = taskInfoService.getTaskInfoDetail(id);
return RpcResponse.success(detail);
} catch (RpcServiceException e) {
log.error("TaskInfoRemoteImpl__getTaskInfoDetail__bizException:{}", e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("TaskInfoRemoteImpl__getTaskInfoDetail__exception", e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> submitTaskReply(TaskInfoSubmitDTO dto) {
try {
taskInfoService.submitTaskReply(dto);
return RpcResponse.success(true);
} catch (RpcServiceException e) {
log.error("TaskInfoRemoteImpl__submitTaskReply__bizException:{}", e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error("TaskInfoRemoteImpl__submitTaskReply__exception", e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.staff.service;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskCountStatDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoSubmitDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskStaffRelDTO;
import cn.com.glsx.dj.staff.mapper.TaskInfoMapper;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.request.FinishTaskAssigneeRequest;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.request.GetTaskDetailRequest;
import cn.com.glsx.dj.taskcenter.remote.TaskCenterRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
public class TaskInfoService {
@Autowired
private TaskInfoMapper taskInfoMapper;
@DubboReference(check = false)
private TaskCenterRemote taskCenterRemote;
/**
* 分页查询事项列表,列表中同时带出每条任务关联的人员
*/
public Page<TaskInfoDTO> pageTaskInfo(RpcPagination<TaskInfoQueryDTO> pagination) {
TaskInfoQueryDTO query = pagination.getCondition();
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
List<TaskInfoDTO> list = taskInfoMapper.pageTaskInfo(query);
// 填充人员列表
if (CollectionUtils.isNotEmpty(list)) {
for (TaskInfoDTO dto : list) {
dto.setStaffList(taskInfoMapper.listStaffByTaskId(dto.getId()));
}
}
return (Page<TaskInfoDTO>) list;
}
/**
* 查询事项详情(含人员列表)
*/
public TaskInfoDTO getTaskInfoDetail(Long id) {
TaskInfoDTO dto = taskInfoMapper.getTaskInfoById(id);
if (dto == null) {
throw new RpcServiceException("任务不存在或已删除");
}
List<TaskStaffRelDTO> staffList = taskInfoMapper.listStaffByTaskId(id);
dto.setStaffList(staffList);
return dto;
}
/**
* 统计事项任务数量:待完成 / 已完成 / 全部
* <p>为避免三次 SQL,全部数 = 待完成 + 已完成,由 status=0 与 status=1 两次查询汇总。</p>
*/
public TaskCountStatDTO countTaskStat(TaskInfoQueryDTO query) {
// 1. 统计待完成(status=0)
TaskInfoQueryDTO pendingQuery = copyForCount(query, 0);
Long pendingCount = taskInfoMapper.countTaskInfo(pendingQuery);
// 2. 统计已完成(status=1)
TaskInfoQueryDTO completedQuery = copyForCount(query, 1);
Long completedCount = taskInfoMapper.countTaskInfo(completedQuery);
TaskCountStatDTO result = new TaskCountStatDTO();
result.setPendingCount(pendingCount == null ? 0L : pendingCount);
result.setCompletedCount(completedCount == null ? 0L : completedCount);
result.setTotalCount(result.getPendingCount() + result.getCompletedCount());
return result;
}
/**
* 拷贝查询条件并覆盖 status,避免修改入参
*/
private TaskInfoQueryDTO copyForCount(TaskInfoQueryDTO src, Integer status) {
TaskInfoQueryDTO dest = new TaskInfoQueryDTO();
if (src != null) {
dest.setAssignedToId(src.getAssignedToId());
dest.setKeyword(src.getKeyword());
}
dest.setStatus(status);
return dest;
}
/**
* 专项任务回复提交:更新本地数据状态 + 回调任务中心同步
*/
@Transactional(rollbackFor = Exception.class)
public void submitTaskReply(TaskInfoSubmitDTO dto) {
if (dto.getId() == null) {
throw new RpcServiceException("任务id不能为空");
}
if (StringUtils.isBlank(dto.getReplyContent())) {
throw new RpcServiceException("专项任务回复不能为空");
}
if (dto.getReplyContent().length() > 800) {
throw new RpcServiceException("专项任务回复不能超过800字符");
}
// 1. 查询任务信息
TaskInfoDTO taskInfo = taskInfoMapper.getTaskInfoById(dto.getId());
if (taskInfo == null) {
throw new RpcServiceException("任务不存在或已删除");
}
// 2. 更新本地任务状态
int rows = taskInfoMapper.updateTaskReply(dto.getId(), dto.getReplyContent(), dto.getUpdatedBy());
if (rows == 0) {
throw new RpcServiceException("任务更新失败");
}
// 3. 回调任务中心-标记任务完成并同步业务上下文
Long taskCenterId = taskInfo.getTaskCenterId();
if (taskCenterId != null) {
// 3.1 查询任务中心任务详情,获取现有bizContext
GetTaskDetailRequest detailRequest = new GetTaskDetailRequest();
detailRequest.setTaskId(taskCenterId);
RpcResponse<TaskDTO> detailResp = taskCenterRemote.getTaskDetail(detailRequest);
String existingBizContext = null;
if (detailResp.isSuccess() && detailResp.getResult() != null) {
existingBizContext = detailResp.getResult().getBizContext();
}
// 3.2 组装回复内容信息,添加到任务中心任务上下文字段中
String updatedBizContext = buildUpdatedBizContext(existingBizContext, dto.getReplyContent());
// 3.3 调用finishTaskAssignee接口,标记任务完成
FinishTaskAssigneeRequest finishRequest = new FinishTaskAssigneeRequest();
finishRequest.setTaskId(taskCenterId);
finishRequest.setAssigneeId(taskInfo.getAssignedToId());
finishRequest.setUpdatedBy(dto.getUpdatedBy());
finishRequest.setBizContext(updatedBizContext);
RpcResponse<Boolean> finishResp = taskCenterRemote.finishTaskAssignee(finishRequest);
if (!finishResp.isSuccess()) {
log.error("submitTaskReply__finishTaskAssignee__fail:{}", JSONUtil.toJsonStr(finishResp));
throw new RpcServiceException("回调任务中心失败");
}
}
}
private JSONObject buildField(String fieldId, String fieldName, String fieldType, String fieldValue, String linkAlias) {
JSONObject field = new JSONObject();
field.set("fieldId", fieldId);
field.set("fieldName", fieldName);
field.set("fieldType", fieldType);
field.set("fieldValue", fieldValue == null ? "" : fieldValue);
field.set("linkAlias", linkAlias);
return field;
}
/**
* 构建更新后的业务上下文(bizContext)
* 在已有上下文基础上追加回复内容信息
* 格式:[{"fieldId":"xxx","fieldName":"xxx","fieldType":"text","fieldValue":"xxx","linkAlias":null}]
*/
private String buildUpdatedBizContext(String existingBizContext, String replyContent) {
JSONArray contextArray;
// 解析已有上下文,解析失败则新建
if (StringUtils.isNotBlank(existingBizContext)) {
try {
contextArray = JSONUtil.parseArray(existingBizContext);
} catch (Exception e) {
log.warn("submitTaskReply__parseBizContext__fail, build new", e);
contextArray = new JSONArray();
}
} else {
contextArray = new JSONArray();
}
// 将回复内容按标准字段格式追加到上下文中
contextArray.add(buildField("reply_content", "专项任务回复", "textarea", replyContent, null));
return contextArray.toString();
}
}
......@@ -1264,10 +1264,7 @@ public class RecruitmentDemandService {
RecruitmentDemandStatusEnum.COMPLETED.getValue(),
RecruitmentDemandStatusEnum.WAIT_SUPERVISOR_CONFIRM.getValue()
))
.andIn("businessType", Arrays.asList(
RecruitmentDemandBusinessTypeEnum.EXTENDED_WARRANTY.getValue(),
RecruitmentDemandBusinessTypeEnum.RIGHTS_EXTENDED_WARRANTY.getValue()
));
.andIn("businessType", mapBizToDemandBusinessTypeList(dto.getBiz()));
List<RecruitmentDemand> demands = recruitmentDemandMapper.selectByExample(demandExample);
Integer allOfDemand = 0;
int allOfOnboarding = 0;
......@@ -1347,6 +1344,38 @@ public class RecruitmentDemandService {
}
}
private List<String> mapBizToDemandBusinessTypeList(Integer biz) {
if (biz == null) {
return Arrays.asList(
RecruitmentDemandBusinessTypeEnum.EXTENDED_WARRANTY.getValue(),
RecruitmentDemandBusinessTypeEnum.RIGHTS.getValue(),
RecruitmentDemandBusinessTypeEnum.LIGHT_MODIFICATION.getValue(),
RecruitmentDemandBusinessTypeEnum.RIGHTS_EXTENDED_WARRANTY.getValue()
);
}
// 1-延保(场景) → 延保 + 权益+延保
if (Objects.equals(biz, 1)) {
return Arrays.asList(
RecruitmentDemandBusinessTypeEnum.EXTENDED_WARRANTY.getValue(),
RecruitmentDemandBusinessTypeEnum.RIGHTS_EXTENDED_WARRANTY.getValue()
);
}
// 3-权益(场景) → 权益 + 权益+延保
if (Objects.equals(biz, 3)) {
return Arrays.asList(
RecruitmentDemandBusinessTypeEnum.RIGHTS.getValue(),
RecruitmentDemandBusinessTypeEnum.RIGHTS_EXTENDED_WARRANTY.getValue()
);
}
// 2-轻改(场景) → 轻改
if (Objects.equals(biz, 2)) {
return Collections.singletonList(
RecruitmentDemandBusinessTypeEnum.LIGHT_MODIFICATION.getValue()
);
}
return Collections.emptyList();
}
private List<Integer> mapBizToOrderBusinessTypeList(Integer biz) {
if (biz == null) {
return Arrays.asList(1, 2);
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.staff.mapper.TaskInfoMapper">
<resultMap id="TaskInfoDTOMap" type="cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="task_center_id" property="taskCenterId" jdbcType="BIGINT"/>
<result column="task_type" property="taskType" jdbcType="VARCHAR"/>
<result column="task_type_name" property="taskTypeName" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="store_name" property="storeName" jdbcType="VARCHAR"/>
<result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="business_type" property="businessType" jdbcType="TINYINT"/>
<result column="business_type_name" property="businessTypeName" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="creator_phone" property="creatorPhone" jdbcType="VARCHAR"/>
<result column="task_description" property="taskDescription" jdbcType="LONGVARCHAR"/>
<result column="reply_content" property="replyContent" jdbcType="LONGVARCHAR"/>
<result column="reply_time" property="replyTime" jdbcType="TIMESTAMP"/>
<result column="assigned_to_id" property="assignedToId" jdbcType="VARCHAR"/>
<result column="assigned_to_name" property="assignedToName" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="TaskStaffRelDTOMap" type="cn.com.glsx.dj.staff.dto.taskcenter.TaskStaffRelDTO">
<result column="staff_name" property="staffName" jdbcType="VARCHAR"/>
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR"/>
<result column="staff_uuid" property="staffUuid" jdbcType="VARCHAR"/>
<result column="user_position" property="userPosition" jdbcType="INTEGER"/>
</resultMap>
<!-- 分页查询事项列表 -->
<select id="pageTaskInfo" parameterType="cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO"
resultMap="TaskInfoDTOMap">
SELECT
t.id, t.task_center_id, t.task_type, t.task_type_name, t.status,
t.store_name, t.store_id, t.business_type, t.business_type_name,
t.creator, t.creator_phone, t.task_description, t.reply_content,
t.reply_time, t.assigned_to_id, t.assigned_to_name, t.created_date
FROM dj_car_life_task_info t
<where>
t.deleted_flag = 'N'
<if test="assignedToId != null and assignedToId != ''">
AND t.assigned_to_id = #{assignedToId}
</if>
<if test="status != null">
AND t.status = #{status}
</if>
<if test="keyword != null and keyword != ''">
AND (
t.store_name LIKE CONCAT('%', #{keyword}, '%')
OR t.business_type_name LIKE CONCAT('%', #{keyword}, '%')
OR t.creator LIKE CONCAT('%', #{keyword}, '%')
OR t.task_description LIKE CONCAT('%', #{keyword}, '%')
OR EXISTS (
SELECT 1 FROM dj_car_life_task_staff_rel s
WHERE s.task_id = t.id AND s.deleted_flag = 'N'
AND s.staff_name LIKE CONCAT('%', #{keyword}, '%')
)
)
</if>
</where>
ORDER BY t.created_date DESC
</select>
<!-- 按条件统计事项数量(支持状态和关键词过滤) -->
<select id="countTaskInfo" parameterType="cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoQueryDTO"
resultType="java.lang.Long">
SELECT COUNT(1)
FROM dj_car_life_task_info t
<where>
t.deleted_flag = 'N'
<if test="assignedToId != null and assignedToId != ''">
AND t.assigned_to_id = #{assignedToId}
</if>
<if test="status != null">
AND t.status = #{status}
</if>
<if test="keyword != null and keyword != ''">
AND (
t.store_name LIKE CONCAT('%', #{keyword}, '%')
OR t.business_type_name LIKE CONCAT('%', #{keyword}, '%')
OR t.creator LIKE CONCAT('%', #{keyword}, '%')
OR t.task_description LIKE CONCAT('%', #{keyword}, '%')
OR EXISTS (
SELECT 1 FROM dj_car_life_task_staff_rel s
WHERE s.task_id = t.id AND s.deleted_flag = 'N'
AND s.staff_name LIKE CONCAT('%', #{keyword}, '%')
)
)
</if>
</where>
</select>
<!-- 根据id查询事项详情 -->
<select id="getTaskInfoById" resultMap="TaskInfoDTOMap">
SELECT
t.id, t.task_center_id, t.task_type, t.task_type_name, t.status,
t.store_name, t.store_id, t.business_type, t.business_type_name,
t.creator, t.creator_phone, t.task_description, t.reply_content,
t.reply_time, t.assigned_to_id, t.assigned_to_name, t.created_date
FROM dj_car_life_task_info t
WHERE t.id = #{id} AND t.deleted_flag = 'N'
</select>
<!-- 根据任务id查询关联人员 -->
<select id="listStaffByTaskId" resultMap="TaskStaffRelDTOMap">
SELECT staff_name, staff_phone, staff_uuid, user_position
FROM dj_car_life_task_staff_rel
WHERE task_id = #{taskId} AND deleted_flag = 'N'
</select>
<!-- 提交回复:更新reply_content、reply_time、status -->
<update id="updateTaskReply">
UPDATE dj_car_life_task_info
SET reply_content = #{replyContent},
reply_time = NOW(),
status = 1,
updated_by = #{updatedBy},
updated_date = NOW()
WHERE id = #{id} AND deleted_flag = 'N'
</update>
<!-- 查询本地任务表最大创建时间 -->
<select id="getMaxCreatedDate" resultType="java.util.Date">
SELECT MAX(created_date) FROM dj_car_life_task_info WHERE deleted_flag = 'N'
</select>
<!-- 根据task_center_id判断本地是否已存在该任务 -->
<select id="countByTaskCenterId" resultType="int">
SELECT COUNT(1) FROM dj_car_life_task_info
WHERE task_center_id = #{taskCenterId} AND deleted_flag = 'N'
</select>
<!-- 新增任务信息(同步用) -->
<insert id="insertTaskInfo" parameterType="cn.com.glsx.dj.staff.model.TaskInfo" useGeneratedKeys="true" keyProperty="id">
INSERT INTO dj_car_life_task_info
(task_center_id, task_type, task_type_name, status, store_name, store_id,
business_type, business_type_name, creator, creator_phone,
task_description, assigned_to_id, assigned_to_name,
created_by, created_date, updated_by, updated_date, deleted_flag)
VALUES
(#{taskCenterId}, #{taskType}, #{taskTypeName}, #{status}, #{storeName}, #{storeId},
#{businessType}, #{businessTypeName}, #{creator}, #{creatorPhone},
#{taskDescription}, #{assignedToId}, #{assignedToName},
#{createdBy}, #{createdDate}, #{updatedBy}, NOW(), 'N')
</insert>
<!-- 批量新增任务关联人员(同步用) -->
<insert id="batchInsertStaffRel">
INSERT INTO dj_car_life_task_staff_rel
(task_id, task_center_id, staff_name, staff_phone, staff_uuid, user_position,
created_by, created_date, updated_by, updated_date, deleted_flag)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.taskId}, #{item.taskCenterId}, #{item.staffName}, #{item.staffPhone},
#{item.staffUuid}, #{item.userPosition},
#{item.createdBy}, NOW(), #{item.updatedBy}, NOW(), 'N')
</foreach>
</insert>
<!-- 根据task_center_id查询本地任务主键id -->
<select id="getIdByTaskCenterId" resultType="java.lang.Long">
SELECT id FROM dj_car_life_task_info
WHERE task_center_id = #{taskCenterId} AND deleted_flag = 'N'
LIMIT 1
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!