Commit c8ab130a by zhouhaibao

[+]新增任务管理

1 parent 2bacdb7f
package cn.com.glsx.execute.api;
import cn.com.glsx.execute.modules.entity.SopNodeTaskInfo;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "platform-process", contextId = "platform-process", path = "/api/soptask/", decode404 = true)
public interface SopInstNodeTaskApiClient {
/**
* 查询任务的统计
*
* @param sopNodeTaskSearch
* @return
*/
@GetMapping("/findList")
List<SopNodeTaskStaticModel> findList(@RequestParam SopNodeTaskSearch sopNodeTaskSearch);
/**
* 新增任务
*
* @param sopNodeTaskInfoList 任务列表
*/
@PostMapping("/add")
void add(@RequestBody List<SopNodeTaskInfo> sopNodeTaskInfoList);
}
package cn.com.glsx.execute.modules.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sop_node_task_info")
public class SopNodeTaskInfo implements Serializable {
/**
* id
*/
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 实例id
*/
@Column(name = "inst_id")
private Integer instId;
/**
* 节点id
*/
@Column(name = "node_id")
private Integer nodeId;
/**
* 外部联系人id
*/
@Column(name = "external_userId")
private String externalUserid;
/**
* 手机号码
*/
@Column(name = "customer_phone")
private String customerPhone;
/**
* 员工userid
*/
@Column(name = "user_id")
private String userId;
/**
* 员工手机号
*/
@Column(name = "staff_phone")
private String staffPhone;
/**
* 创建结果
*/
@Column(name = "create_time")
private Date createTime;
/**
* 批次号
*/
@Column(name = "batch_no")
private String batchNo;
/**
* 触达结果
*/
@Column(name = "result_flag")
private Byte resultFlag;
private static final long serialVersionUID = 1L;
/**
* 获取id
*
* @return id - id
*/
public Integer getId() {
return id;
}
/**
* 设置id
*
* @param id id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取实例id
*
* @return inst_id - 实例id
*/
public Integer getInstId() {
return instId;
}
/**
* 设置实例id
*
* @param instId 实例id
*/
public void setInstId(Integer instId) {
this.instId = instId;
}
/**
* 获取节点id
*
* @return node_id - 节点id
*/
public Integer getNodeId() {
return nodeId;
}
/**
* 设置节点id
*
* @param nodeId 节点id
*/
public void setNodeId(Integer nodeId) {
this.nodeId = nodeId;
}
/**
* 获取外部联系人id
*
* @return external_userId - 外部联系人id
*/
public String getExternalUserid() {
return externalUserid;
}
/**
* 设置外部联系人id
*
* @param externalUserid 外部联系人id
*/
public void setExternalUserid(String externalUserid) {
this.externalUserid = externalUserid == null ? null : externalUserid.trim();
}
/**
* 获取手机号码
*
* @return customer_phone - 手机号码
*/
public String getCustomerPhone() {
return customerPhone;
}
/**
* 设置手机号码
*
* @param customerPhone 手机号码
*/
public void setCustomerPhone(String customerPhone) {
this.customerPhone = customerPhone == null ? null : customerPhone.trim();
}
/**
* 获取员工userid
*
* @return user_id - 员工userid
*/
public String getUserId() {
return userId;
}
/**
* 设置员工userid
*
* @param userId 员工userid
*/
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
/**
* 获取员工手机号
*
* @return staff_phone - 员工手机号
*/
public String getStaffPhone() {
return staffPhone;
}
/**
* 设置员工手机号
*
* @param staffPhone 员工手机号
*/
public void setStaffPhone(String staffPhone) {
this.staffPhone = staffPhone == null ? null : staffPhone.trim();
}
/**
* 获取创建结果
*
* @return create_time - 创建结果
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置创建结果
*
* @param createTime 创建结果
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取批次号
*
* @return batch_no - 批次号
*/
public String getBatchNo() {
return batchNo;
}
/**
* 设置批次号
*
* @param batchNo 批次号
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
/**
* 获取触达结果
*
* @return result_flag - 触达结果
*/
public Byte getResultFlag() {
return resultFlag;
}
/**
* 设置触达结果
*
* @param resultFlag 触达结果
*/
public void setResultFlag(Byte resultFlag) {
this.resultFlag = resultFlag;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", instId=").append(instId);
sb.append(", nodeId=").append(nodeId);
sb.append(", externalUserid=").append(externalUserid);
sb.append(", customerPhone=").append(customerPhone);
sb.append(", userId=").append(userId);
sb.append(", staffPhone=").append(staffPhone);
sb.append(", createTime=").append(createTime);
sb.append(", batchNo=").append(batchNo);
sb.append(", resultFlag=").append(resultFlag);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.execute.modules.mapper;
import cn.com.glsx.execute.modules.entity.SopNodeTaskInfo;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SopNodeTaskInfoMapper extends CommonBaseMapper<SopNodeTaskInfo> {
List<SopNodeTaskStaticModel> findTodayCusList(
@Param("sopNodeTaskSearch") SopNodeTaskSearch sopNodeTaskSearch);
List<SopNodeTaskStaticModel> findCusList(
@Param("sopNodeTaskSearch") SopNodeTaskSearch sopNodeTaskSearch);
List<SopNodeTaskStaticModel> findTodayTaskList(
@Param("sopNodeTaskSearch") SopNodeTaskSearch sopNodeTaskSearch);
List<SopNodeTaskStaticModel> findTaskList(
@Param("sopNodeTaskSearch") SopNodeTaskSearch sopNodeTaskSearch);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.execute.modules.model.task;
import cn.hutool.db.Page;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
@Data
public class SopNodeTaskSearch {
/**
* 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
private String instId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
private Integer grantId;
/**
* 节点id
*/
private List<Integer> nodeIds;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.execute.modules.model.task;
import java.util.List;
import lombok.Data;
@Data
public class SopNodeTaskStaticModel {
/**
* 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
private String instId;
/**
* 节点id
*/
private Integer nodeId;
/**
* 今日营销客户总数
*/
private int todayCusCount;
/**
* 累计营销客户数
*/
private int totalCusCount;
/**
* 今日下发任务总数
*/
private int todayTaskCount;
/**
* 累计下发任务总数
*/
private int totalTaskCount;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.execute.modules.api;
import cn.com.glsx.execute.api.SopInstNodeTaskApiClient;
import cn.com.glsx.execute.modules.entity.SopNodeTaskInfo;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel;
import cn.com.glsx.execute.modules.service.task.SopNodeTaskInfoService;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* 微服务应用在网关中处理统一返回体
*
* @author payu
*/
@Slf4j
@Tag(name = "SOP任务统计")
@RestController
@RequestMapping(value = "/api/soptask")
@ResponseResultBody
public class SopInstNodeTaskApiController implements SopInstNodeTaskApiClient {
@Resource
private SopNodeTaskInfoService sopNodeTaskInfoService;
@Operation(summary = "查询任务的统计")
@GetMapping("/findList")
@Override
public List<SopNodeTaskStaticModel> findList(@RequestParam SopNodeTaskSearch sopNodeTaskSearch) {
return sopNodeTaskInfoService.findList(sopNodeTaskSearch);
}
@Operation(summary = "新增任务")
@PostMapping("/add")
@Override
public void add(@RequestBody List<SopNodeTaskInfo> sopNodeTaskInfoList) {
sopNodeTaskInfoService.insertTask(sopNodeTaskInfoList);
}
}
package cn.com.glsx.execute.modules.service.task;
import cn.com.glsx.execute.modules.entity.SopNodeTaskInfo;
import cn.com.glsx.execute.modules.mapper.SopNodeTaskInfoMapper;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SopNodeTaskInfoService {
@Autowired
private SopNodeTaskInfoMapper sopNodeTaskInfoMapper;
/**
* 查询节点任务列表
*/
public List<SopNodeTaskStaticModel> findList(SopNodeTaskSearch sopNodeTaskSearch) {
List<Integer> nodeIds = sopNodeTaskSearch.getNodeIds();
if (CollectionUtils.isNotEmpty(nodeIds)) {
return new ArrayList<>();
}
// 查询今日营销客户总数
List<SopNodeTaskStaticModel> todayCusList = sopNodeTaskInfoMapper.findTodayCusList(
sopNodeTaskSearch);
// 查询今日客户总数
List<SopNodeTaskStaticModel> todayTaskList = sopNodeTaskInfoMapper.findTodayTaskList(
sopNodeTaskSearch);
// 查询今日任务总数
List<SopNodeTaskStaticModel> taskList = sopNodeTaskInfoMapper.findTaskList(sopNodeTaskSearch);
// 查询任务总数
List<SopNodeTaskStaticModel> cusList = sopNodeTaskInfoMapper.findCusList(sopNodeTaskSearch);
return nodeIds.stream().map(index -> {
// 处理数据
SopNodeTaskStaticModel sopNodeTaskStaticModel = new SopNodeTaskStaticModel();
sopNodeTaskStaticModel.setNodeId(index);
sopNodeTaskStaticModel.setInstId(sopNodeTaskSearch.getInstId());
if (CollectionUtils.isNotEmpty(todayCusList)) {
List<SopNodeTaskStaticModel> collect = todayCusList.stream()
.filter(inx -> inx.getInstId().equals(index)).collect(
Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
sopNodeTaskStaticModel.setTodayCusCount(collect.get(0).getTodayCusCount());
}
}
if (CollectionUtils.isNotEmpty(todayCusList)) {
List<SopNodeTaskStaticModel> collect = todayCusList.stream()
.filter(inx -> inx.getInstId().equals(index)).collect(
Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
sopNodeTaskStaticModel.setTodayCusCount(collect.get(0).getTodayCusCount());
}
}
if (CollectionUtils.isNotEmpty(cusList)) {
List<SopNodeTaskStaticModel> collect = cusList.stream()
.filter(inx -> inx.getInstId().equals(index)).collect(
Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
sopNodeTaskStaticModel.setTotalCusCount(collect.get(0).getTotalCusCount());
}
}
if (CollectionUtils.isNotEmpty(taskList)) {
List<SopNodeTaskStaticModel> collect = taskList.stream()
.filter(inx -> inx.getInstId().equals(index)).collect(
Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
sopNodeTaskStaticModel.setTotalTaskCount(collect.get(0).getTotalTaskCount());
}
}
return sopNodeTaskStaticModel;
}).collect(Collectors.toList());
}
/**
* 执行任务列表
*
* @param sopNodeTaskInfo 任务list以员工单一客户维度统计
*/
public void insertTask(List<SopNodeTaskInfo> sopNodeTaskInfo) {
if (CollectionUtils.isNotEmpty(sopNodeTaskInfo)) {
for (SopNodeTaskInfo nodeTaskInfo : sopNodeTaskInfo) {
nodeTaskInfo.setCreateTime(new Date());
nodeTaskInfo.setBatchNo(UUID.randomUUID().toString());
}
sopNodeTaskInfoMapper.insertList(sopNodeTaskInfo);
}
}
}
<?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.execute.modules.mapper.SopNodeTaskInfoMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.execute.modules.entity.SopNodeTaskInfo">
<!--
WARNING - @mbg.generated
-->
<result column="id" jdbcType="INTEGER" property="id"/>
<result column="inst_id" jdbcType="INTEGER" property="instId"/>
<result column="node_id" jdbcType="INTEGER" property="nodeId"/>
<result column="external_userId" jdbcType="VARCHAR" property="externalUserid"/>
<result column="customer_phone" jdbcType="VARCHAR" property="customerPhone"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="staff_phone" jdbcType="VARCHAR" property="staffPhone"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="batch_no" jdbcType="VARCHAR" property="batchNo"/>
<result column="result_flag" jdbcType="TINYINT" property="resultFlag"/>
</resultMap>
<select id="findTodayCusList"
resultType="cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel">
select inst_id as instId,node_id as nodeId,COUNT(DISTINCT external_userId, customer_phone) as
todayCusCount from
sop_node_task_info
where inst_id=#{sopNodeTaskSearch.instId}
and node_id in
<foreach collection="sopNodeTaskSearch.nodeIds" open="(" separator="," close=")" item="nodeIds">
#{nodeIds}
</foreach>
and DATE(create_time) = DATE(NOW())
group by t.instId,t.nodeId
</select>
<select id="findCusList"
resultType="cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel">
select inst_id as instId,node_id as nodeId,COUNT(DISTINCT external_userId, customer_phone) as
totalCusCount from
sop_node_task_info
where inst_id=#{sopNodeTaskSearch.instId}
and node_id in
<foreach collection="sopNodeTaskSearch.nodeIds" open="(" separator="," close=")" item="nodeIds">
#{nodeIds}
</foreach>
group by t.instId,t.nodeId
</select>
<select id="findTodayTaskList"
resultType="cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel">
select inst_id as instId,node_id as nodeId,COUNT(DISTINCT batch_no) as todayTaskCount from
sop_node_task_info
where inst_id=#{sopNodeTaskSearch.instId}
and node_id in
<foreach collection="sopNodeTaskSearch.nodeIds" open="(" separator="," close=")" item="nodeIds">
#{nodeIds}
</foreach>
and DATE(create_time) = DATE(NOW())
group by t.instId,t.nodeId
</select>
<select id="findTaskList"
resultType="cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel">
select inst_id as instId,node_id as nodeId,COUNT(DISTINCT batch_no) as totalTaskCount from
sop_node_task_info
where inst_id=#{sopNodeTaskSearch.instId}
and node_id in
<foreach collection="sopNodeTaskSearch.nodeIds" open="(" separator="," close=")" item="nodeIds">
#{nodeIds}
</foreach>
group by t.instId,t.nodeId
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<!-- <property name="nullCatalogMeansCurrent" value="true"/>--> <!-- <property name="nullCatalogMeansCurrent" value="true"/>-->
<!-- </jdbcConnection>--> <!-- </jdbcConnection>-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.227:3306/platform_execute?characterEncoding=utf8" <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.227:3306/platform_execute?characterEncoding=utf8"
userId="root" password="manager" /> userId="dev_admin" password="1f7e1ed2"/>
<!-- 类型转换 --> <!-- 类型转换 -->
<javaTypeResolver> <javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) --> <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<!-- &lt;!&ndash; 从数据库返回的值去掉前后空格 &ndash;&gt;--> <!-- &lt;!&ndash; 从数据库返回的值去掉前后空格 &ndash;&gt;-->
<!-- <property name="trimStrings" value="true"/>--> <!-- <property name="trimStrings" value="true"/>-->
<!-- </javaModelGenerator>--> <!-- </javaModelGenerator>-->
<javaModelGenerator targetPackage="cn.com.glsx.execute.modules.entity" targetProject="D:\projects\sop\execute\platform-execute-api\src\main\java"> <javaModelGenerator targetPackage="cn.com.glsx.execute.modules.entity" targetProject="F:\360MoveData\Users\11\Desktop\企微SAAS\2023\12\sop\execute\platform-execute-server\platform-execute-api\src\main\java">
<property name="enableSubPackages" value="true" /> <property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" /> <property name="trimStrings" value="true" />
</javaModelGenerator> </javaModelGenerator>
...@@ -79,14 +79,14 @@ ...@@ -79,14 +79,14 @@
<!-- <javaClientGenerator targetPackage="cn.com.payu.modules.mapper" targetProject="src/main/java" type="XMLMAPPER">--> <!-- <javaClientGenerator targetPackage="cn.com.payu.modules.mapper" targetProject="src/main/java" type="XMLMAPPER">-->
<!-- <property name="enableSubPackages" value="false"/>--> <!-- <property name="enableSubPackages" value="false"/>-->
<!-- </javaClientGenerator>--> <!-- </javaClientGenerator>-->
<javaClientGenerator targetPackage="cn.com.glsx.execute.modules.mapper" targetProject="D:\projects\sop\execute\platform-execute-api\src\main\java" type="XMLMAPPER"> <javaClientGenerator targetPackage="cn.com.glsx.execute.modules.mapper" targetProject="F:\360MoveData\Users\11\Desktop\企微SAAS\2023\12\sop\execute\platform-execute-server\platform-execute-api\src\main\java" type="XMLMAPPER">
<property name="enableSubPackages" value="true" /> <property name="enableSubPackages" value="true" />
</javaClientGenerator> </javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 --> <!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<!-- <table tableName="t_storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" --> <!-- <table tableName="t_storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" -->
<!-- selectByExampleQueryId="false"/>--> <!-- selectByExampleQueryId="false"/>-->
<table tableName="sop_event_delay_send_log" domainObjectName="SopEventDelaySendLogDTO" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false"> <table tableName="sop_node_task_info" domainObjectName="SopNodeTaskInfo" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/> <generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table> </table>
</context> </context>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!