Commit 75cc3f28 by weiss

1

1 parent 331a5a2a
package com.pipihelper.project.feishu.controller; package com.pipihelper.project.feishu.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.pipihelper.project.core.Result; import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultGenerator; import com.pipihelper.project.core.ResultGenerator;
import com.pipihelper.project.feishu.bo.PushPainBO;
import com.pipihelper.project.feishu.dto.FeiShuConfig; import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.dto.FeiShuEventDTO; import com.pipihelper.project.feishu.dto.FeiShuEventDTO;
import com.pipihelper.project.feishu.dto.FeiShuMsgCardEventDTO; import com.pipihelper.project.feishu.dto.FeiShuMsgCardEventDTO;
...@@ -16,11 +18,7 @@ import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO; ...@@ -16,11 +18,7 @@ import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.entity.Employee; import com.pipihelper.project.feishu.entity.Employee;
import com.pipihelper.project.feishu.entity.LastMaxPain; import com.pipihelper.project.feishu.entity.LastMaxPain;
import com.pipihelper.project.feishu.entity.Pain; import com.pipihelper.project.feishu.entity.Pain;
import com.pipihelper.project.feishu.service.EmployeeService; import com.pipihelper.project.feishu.service.*;
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.MassageMsgCardSerivce;
import com.pipihelper.project.feishu.service.massage.MassageService; import com.pipihelper.project.feishu.service.massage.MassageService;
import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter; import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter;
...@@ -35,12 +33,7 @@ import javax.annotation.Resource; ...@@ -35,12 +33,7 @@ import javax.annotation.Resource;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -195,18 +188,23 @@ public class FeiShuEventController { ...@@ -195,18 +188,23 @@ public class FeiShuEventController {
@PostMapping("/employee-list") @PostMapping("/employee-list")
public Object event() { public Object event() {
//employeeService.uprsetAllEmployee(); employeeService.uprsetAllEmployee();
LastMaxPain maxPain = lastMaxPainService.findByFloor(14); LastMaxPain maxPain = lastMaxPainService.findByFloor(14);
int startEmployeeId = 0; int startEmployeeId = 0;
if (maxPain != null) { if (maxPain != null) {
startEmployeeId = maxPain.getEmployeeId(); startEmployeeId = maxPain.getEmployeeId();
} }
List<Employee> employeeList = employeeService.findStartList(startEmployeeId, 14, 30); int countByFloor = employeeService.findCountByFloor(14);
int limit = 30;
if(countByFloor < 30){
limit = countByFloor;
}
List<Employee> employeeList = employeeService.findStartList(startEmployeeId, 14, limit);
Integer maxEmploeeId = 0; Integer maxEmploeeId = 0;
if (employeeList.size() == 30) { if (employeeList.size() == limit) {
maxEmploeeId = employeeList.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0); maxEmploeeId = employeeList.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0);
} else { } else {
List<Employee> employees = employeeService.findStartList(0, 14, 30 - employeeList.size()); List<Employee> employees = employeeService.findStartList(0, 14, limit - employeeList.size());
maxEmploeeId = employees.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0); maxEmploeeId = employees.stream().map(Employee::getId).max(Comparator.comparing(x -> x)).orElse(0);
employeeList.addAll(employees); employeeList.addAll(employees);
} }
...@@ -220,19 +218,40 @@ public class FeiShuEventController { ...@@ -220,19 +218,40 @@ public class FeiShuEventController {
}); });
painService.deleteAllByFloor(14); painService.deleteAllByFloor(14);
System.out.println(employeeList);
AtomicInteger i = new AtomicInteger(); List<PushPainBO> pushPainBOList = new ArrayList<>();
String[] userIdList = new String[employeeList.size()];
AtomicInteger i = new AtomicInteger(1);
employeeList.forEach(it -> { employeeList.forEach(it -> {
Pain pain = new Pain(); Pain pain = new Pain();
pain.setOpenId(it.getOpenId()); pain.setOpenId(it.getOpenId());
pain.setStatus(0); pain.setStatus(0);
pain.setFloor(it.getFloor()); pain.setFloor(Optional.ofNullable(it.getFloor()).orElse(14));
pain.setIndex(i.getAndIncrement()); int increment = i.getAndIncrement();
pain.setIndex(increment);
pain.setName(it.getName()); pain.setName(it.getName());
pain.setDepartMentName(departmentMap.getOrDefault(it.getDepartmentId(), new FeiShuDepartmentDTO()).getName()); String departMentName = departmentMap.getOrDefault(it.getDepartmentId(), new FeiShuDepartmentDTO()).getName();
pain.setDepartMentName(departMentName);
painService.create(pain); painService.create(pain);
PushPainBO pushPainBO = new PushPainBO();
pushPainBO.setIndex(increment);
pushPainBO.setName(it.getName());
pushPainBO.setDepartMentName(departMentName);
pushPainBO.setOpenId(it.getOpenId());
pushPainBO.setTimeRange("15:00-16:00");
pushPainBOList.add(pushPainBO);
userIdList[increment-1] = it.getOpenId();
}); });
/* massageService.sendMassageMsgCardToPiPiChat(userList);*/
System.out.println(pushPainBOList);
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setName("etgh ");
feiShuChatDTO.setOwnerId(pushPainBOList.get(0).getOpenId());
feiShuChatDTO.setUserIdList(userIdList);
String chatId = feiShuApiService.createChatList(feiShuChatDTO);
massageService.sendMassageMsgCardToPiPiChat(pushPainBOList,chatId);
massageService.sendMassageMsgCardToPiPiChat(pushPainBOList,feiShuConfig.getChatId());
if (maxPain != null) { if (maxPain != null) {
maxPain.setEmployeeId(maxEmploeeId); maxPain.setEmployeeId(maxEmploeeId);
...@@ -281,7 +300,7 @@ public class FeiShuEventController { ...@@ -281,7 +300,7 @@ public class FeiShuEventController {
@PostMapping("/start") @PostMapping("/start")
public Result start() { public Result start() {
List<Pain> pains = painService.findListAsc(3); List<Pain> pains = painService.findListAsc(3);
for(Pain pain:pains){ for (Pain pain : pains) {
String messageId = pain.getMessageId(); String messageId = pain.getMessageId();
massageService.updateSingleMassageMsgCardWhenBegin(messageId); massageService.updateSingleMassageMsgCardWhenBegin(messageId);
//1代表正在按 //1代表正在按
......
...@@ -22,4 +22,6 @@ public interface EmployeeDao { ...@@ -22,4 +22,6 @@ public interface EmployeeDao {
List<Employee> findAll(); List<Employee> findAll();
List<Employee> findStartList(@Param(value = "startId") int startId,@Param(value = "floor") int floor,@Param(value = "limit") int limit); List<Employee> findStartList(@Param(value = "startId") int startId,@Param(value = "floor") int floor,@Param(value = "limit") int limit);
int findCountByFloor(@Param(value = "floor") int floor);
} }
...@@ -76,6 +76,7 @@ public class EmployeeService { ...@@ -76,6 +76,7 @@ public class EmployeeService {
employee.setName(systemFieldsDTO.getName()); employee.setName(systemFieldsDTO.getName());
employee.setMobile(systemFieldsDTO.getMobile()); employee.setMobile(systemFieldsDTO.getMobile());
} }
employee.setFloor(14);
this.create(employee); this.create(employee);
}); });
} }
...@@ -83,4 +84,8 @@ public class EmployeeService { ...@@ -83,4 +84,8 @@ public class EmployeeService {
public List<Employee> findStartList(int startId, int floor, int limit) { public List<Employee> findStartList(int startId, int floor, int limit) {
return employeeDao.findStartList(startId, floor, limit); return employeeDao.findStartList(startId, floor, limit);
} }
public int findCountByFloor(int floor) {
return employeeDao.findCountByFloor(floor);
}
} }
...@@ -45,8 +45,8 @@ public class MassageNoticeScheduleService { ...@@ -45,8 +45,8 @@ public class MassageNoticeScheduleService {
/** /**
* 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒 * 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
*/ */
@Async // @Async
@Scheduled(cron = "0 0 10 * * ?") // @Scheduled(cron = "0 0 10 * * ?")
public void massageStart(){ public void massageStart(){
List<Pain> pains = painService.findListAsc(3); List<Pain> pains = painService.findListAsc(3);
for(Pain pain:pains){ for(Pain pain:pains){
......
...@@ -31,6 +31,15 @@ ...@@ -31,6 +31,15 @@
</select> </select>
<select id="findCountByFloor" parameterType="java.lang.Integer" resultType="java.lang.Integer">
select
count(*)
from t_employee
<where>
floor = #{floor}
</where>
</select>
<select id="findStartList" resultMap="EmployeeResultMap"> <select id="findStartList" resultMap="EmployeeResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key1": "massage-singel.rob.%s" "key": "massage-singel.rob.%s"
} }
} }
], ],
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key1": "massage-singel.revice" "key": "massage-singel.revice"
} }
}, },
{ {
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key2": "massage-singel.giveUp" "key": "massage-singel.giveUp"
} }
}, },
{ {
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key3": "massage-singel.wait" "key": "massage-singel.wait"
} }
} }
], ],
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
"type": "default", "type": "default",
"value": { "value": {
"key1": "massage-singel.next" "key": "massage-singel.next"
} }
} }
], ],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!