Commit c2422c65 by zhaolianjie

Merge remote-tracking branch 'origin/master'

2 parents 4d1274c8 c9bafd46
......@@ -11,10 +11,12 @@ import com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO;
import com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.entity.Employee;
import com.pipihelper.project.feishu.entity.LastMaxPain;
import com.pipihelper.project.feishu.entity.Pain;
import com.pipihelper.project.feishu.service.EmployeeService;
import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.FeiShuEventService;
import com.pipihelper.project.feishu.service.LastMaxPainService;
import com.pipihelper.project.feishu.service.PainService;
import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
import com.pipihelper.project.feishu.service.massage.MassageService;
......@@ -30,6 +32,7 @@ import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
......@@ -57,6 +60,8 @@ public class FeiShuEventController {
@Autowired
private EmployeeService employeeService;
@Autowired
private LastMaxPainService lastMaxPainService;
@Autowired
private PainService painService;
@Autowired
private MassageService massageService;
......@@ -176,19 +181,42 @@ public class FeiShuEventController {
@PostMapping("/employee-list")
public Object event() {
employeeService.uprsetAllEmployee();
List<Employee> startList = employeeService.findStartList(1, 14, 30);
//employeeService.uprsetAllEmployee();
LastMaxPain maxPain = lastMaxPainService.findByFloor(14);
int startEmployeeId = 0;
if (maxPain != null) {
startEmployeeId = maxPain.getId();
}
List<Employee> employeeList = employeeService.findStartList(startEmployeeId, 14, 30);
Integer maxEmploeeId = 0;
if (employeeList.size() == 30) {
maxEmploeeId = employeeList.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0);
} else {
List<Employee> employees = employeeService.findStartList(0, 14, 30 - employeeList.size());
maxEmploeeId = employees.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0);
employeeList.addAll(employees);
}
AtomicInteger i = new AtomicInteger();
startList.forEach(it -> {
employeeList.forEach(it -> {
Pain pain = new Pain();
pain.setOpenId(it.getOpenId());
pain.setStatus(0);
pain.setFloor(it.getFloor());
pain.setIndex(i.getAndIncrement());
pain.setName(it.getName());
painService.create(pain);
});
/* massageService.sendMassageMsgCardToPiPiChat(userList);*/
if (maxPain != null) {
maxPain.setEmployeeId(maxEmploeeId);
lastMaxPainService.update(maxPain);
} else {
maxPain = new LastMaxPain();
maxPain.setEmployeeId(maxEmploeeId);
maxPain.setFloor(14);
lastMaxPainService.create(maxPain);
}
List<FeiShuEmployeeDTO> dtos = feiShuApiService.getEmployeeList();
return dtos;
}
......
package com.pipihelper.project.feishu.dao;
import com.pipihelper.project.feishu.entity.LastMaxPain;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface LastMaxPainDao {
LastMaxPain findById(Integer id);
LastMaxPain findByFloor(Integer floor);
void create(LastMaxPain pain);
void update(LastMaxPain pain);
}
package com.pipihelper.project.feishu.entity;
import lombok.Data;
/**
* 上一次按摩id最大的雇员
*/
@Data
public class LastMaxPain {
private Integer id;
private Integer employeeId;
private Integer floor;
}
......@@ -9,6 +9,7 @@ public class Pain {
private Integer id;
private String openId;
private Integer index;
private String name;
private Integer status;
private Date startTime;
private Date endTime;
......
package com.pipihelper.project.feishu.service;
import com.pipihelper.project.feishu.dao.LastMaxPainDao;
import com.pipihelper.project.feishu.entity.LastMaxPain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class LastMaxPainService {
@Autowired
private LastMaxPainDao lastMaxPainDao;
public LastMaxPain findById(Integer id) {
return lastMaxPainDao.findById(id);
}
public LastMaxPain findByFloor(Integer floor) {
return lastMaxPainDao.findByFloor(floor);
}
public void create(LastMaxPain pain) {
lastMaxPainDao.create(pain);
}
public void update(LastMaxPain pain) {
lastMaxPainDao.update(pain);
}
}
<?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="com.pipihelper.project.feishu.dao.LastMaxPainDao">
<resultMap id="LastMaxPainResultMap" type="com.pipihelper.project.feishu.entity.LastMaxPain">
<id column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="floor" property="floor"/>
</resultMap>
<sql id="Base_Column_List">
id,employee_id,floor
</sql>
<select id="findById" parameterType="java.lang.Integer" resultMap="LastMaxPainResultMap">
select
<include refid="Base_Column_List"/>
from t_last_max_pain
<where>
id = #{id}
</where>
</select>
<select id="findByFloor" parameterType="java.lang.Integer" resultMap="LastMaxPainResultMap">
select
<include refid="Base_Column_List"/>
from t_last_max_pain
<where>
floor = #{floor}
</where>
</select>
<select id="findBackIndex" resultMap="LastMaxPainResultMap">
select
<include refid="Base_Column_List"/>
from t_last_max_pain
<where>
index >= #{index}
order by index asc
limit #{limit}
</where>
</select>
<insert id="create" useGeneratedKeys="true" keyProperty="id"
parameterType="com.pipihelper.project.feishu.entity.LastMaxPain">
insert into t_last_max_pain (employee_id, floor)
values (#{employeeId},#{floor})
</insert>
<update id="update" parameterType="com.pipihelper.project.feishu.entity.LastMaxPain">
update t_last_max_pain
<set>
<if test="employeeId != null">
employee_id = #{employeeId},
</if>
<if test="floor != null">
floor = #{floor},
</if>
</set>
<where>
id = #{id}
</where>
</update>
</mapper>
......@@ -9,7 +9,8 @@
<result column="end_time" property="endTime"/>
<result column="status" property="status"/>
<result column="floor" property="floor"/>
<result column="messageId" property="messageId"/>
<result column="message_id" property="messageId"/>
<result column="name" property="name"/>
<result column="index" property="index"/>
</resultMap>
......@@ -18,7 +19,7 @@
</resultMap>-->
<sql id="Base_Column_List">
id,open_id,start_time,end_time,status,floor
id,open_id,start_time,end_time,status,floor,message_id,name
</sql>
<select id="findById" parameterType="java.lang.Integer" resultMap="PainResultMap">
......@@ -86,8 +87,8 @@
<insert id="create" useGeneratedKeys="true" keyProperty="id"
parameterType="com.pipihelper.project.feishu.entity.Pain">
insert into t_pain (open_id, start_time, end_time, status, floor,message_id)
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId})
insert into t_pain (open_id, start_time, end_time, status, floor,message_id,name)
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId},#{name})
</insert>
<update id="waitPain" parameterType="com.pipihelper.project.feishu.entity.Pain">
......@@ -121,6 +122,9 @@
<if test="messageId != null">
message_id = #{messageId},
</if>
<if test="name != null">
name = #{name},
</if>
</set>
<where>
id = #{id}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!