Commit efea7e40 by zhaolianjie

Merge remote-tracking branch 'origin/master'

2 parents 9de9bef5 91d45789
Showing 29 changed files with 596 additions and 1060 deletions
...@@ -2,11 +2,12 @@ package com.pipihelper.project.feishu.controller; ...@@ -2,11 +2,12 @@ package com.pipihelper.project.feishu.controller;
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.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.chat.FeiShuChatDTO;
import com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO; import com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO;
import com.pipihelper.project.feishu.dto.employee.SystemFieldsDTO;
import com.pipihelper.project.feishu.entity.Employee;
import com.pipihelper.project.feishu.service.EmployeeService; import com.pipihelper.project.feishu.service.EmployeeService;
import com.pipihelper.project.feishu.service.FeiShuApiService; import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.FeiShuEventService; import com.pipihelper.project.feishu.service.FeiShuEventService;
...@@ -18,10 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -18,10 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* @Description: TODO * @Description: TODO
...@@ -68,55 +67,62 @@ public class FeiShuEventController { ...@@ -68,55 +67,62 @@ public class FeiShuEventController {
return null; return null;
} }
// @PostMapping("msg_card") @PostMapping("/msg_card")
// public JSONObject msgCardEvent(@RequestBody String s) throws Exception { public JSONObject msgCardEvent(@RequestBody String s) throws Exception {
// JSONObject reqJsonObject = JSON.parseObject(s); JSONObject reqJsonObject = JSON.parseObject(s);
// System.out.println(s); System.out.println(s);
// if (reqJsonObject.containsKey("challenge")) { if (reqJsonObject.containsKey("challenge")) {
// return reqJsonObject; return reqJsonObject;
// } }
// FeiShuMsgCardEventDTO feiShuMsgCardEventDTO = reqJsonObject.toJavaObject(FeiShuMsgCardEventDTO.class); FeiShuMsgCardEventDTO feiShuMsgCardEventDTO = reqJsonObject.toJavaObject(FeiShuMsgCardEventDTO.class);
// String actionType = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[0]; String actionType = feiShuMsgCardEventDTO.getAction().getValue().getKey().split("\\.")[0];
// switch (actionType) { /* switch (actionType) {
// case "TEST_DATA": case "massage-singel":*/
// //
//// default: //// default:
//// } //// }
// } // }
//
// } return null;
}
@PostMapping("/employee-list") @PostMapping("/employee-list")
public Object event() { public Object event() {
List<FeiShuEmployeeDTO> dtos = feiShuApiService.getEmployeeList();
List<Employee> employeeList = employeeService.findAll(); //employeeService.uprsetAllEmployee();
Map<String, Employee> employeeMap = employeeList.stream().collect(Collectors.toMap(Employee::getOpenId, Function.identity())); List<FeiShuEmployeeDTO> dtos = feiShuApiService.getEmployeeList();
List<String> openIdList = dtos.stream().map(FeiShuEmployeeDTO::getUserId).collect(Collectors.toList());
employeeList.forEach(it -> {
if (!openIdList.contains(it.getOpenId())) {
employeeService.deleteById(it.getId());
}
});
dtos.forEach(it -> {
Employee currentEmployee = employeeMap.get(it.getUserId());
if (currentEmployee != null) {
return;
}
Employee employee = new Employee();
SystemFieldsDTO systemFieldsDTO = it.getSystemFields();
employee.setOpenId(it.getUserId());
if (systemFieldsDTO != null) {
employee.setGender(systemFieldsDTO.getGender());
employee.setStatus(systemFieldsDTO.getStatus());
employee.setDepartmentId(systemFieldsDTO.getDepartmentId());
employee.setName(systemFieldsDTO.getName());
employee.setMobile(systemFieldsDTO.getMobile());
}
employeeService.create(employee);
});
return dtos; return dtos;
} }
@PostMapping("/department")
public Object department(String department) {
return feiShuApiService.getDepartment(department);
}
@PostMapping("/create-chart")
public Object createChatList(String department) {
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setName("按摩群");
feiShuChatDTO.setOwnerId("ou_5d72916b0a0b800b0fff6861eb52cf13");
ArrayList<String> strings = Lists.newArrayList("ou_5d72916b0a0b800b0fff6861eb52cf13", "ou_59498f75298812fbbed4de46fc5462e3"
, "ou_aa066da071443aefb2351ee248190583", "ou_5f30c2076fc2c5a5225bfdbb2da1ea6f", "ou_c902848a93e19928043a7fa38bef295b");
String[] userIds = new String[strings.size()];
for (int i = 0; i < strings.size(); i++) {
userIds[i] = strings.get(i);
}
feiShuChatDTO.setUserIdList(userIds);
return feiShuApiService.createChatList(feiShuChatDTO);
}
@PostMapping("/join-chart")
public Object joinChatList(String openId) {
FeiShuChatDTO feiShuChatDTO = new FeiShuChatDTO();
feiShuChatDTO.setChatId("oc_398c8c0b88421980d840db157c14ec20");
feiShuChatDTO.setIdList(new String[]{openId});
return feiShuApiService.joinChatList(feiShuChatDTO);
}
} }
...@@ -3,13 +3,18 @@ package com.pipihelper.project.feishu.controller; ...@@ -3,13 +3,18 @@ package com.pipihelper.project.feishu.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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.service.FeiShuApiService; import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.massage.MassageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/** /**
* @Description: TODO * @Description: TODO
* @author: charles * @author: charles
...@@ -24,18 +29,36 @@ public class SendMsgUseFeiShu { ...@@ -24,18 +29,36 @@ public class SendMsgUseFeiShu {
@Autowired @Autowired
private FeiShuConfig feiShuConfig; private FeiShuConfig feiShuConfig;
@Autowired
private MassageService massageService;
@PostMapping("/send-msg") @PostMapping("/send-msg")
public Result sendMsg(String receiveId, String msg, String receiveIdType){ public Result sendMsg(){
JSONObject sendMsg = new JSONObject(); PushPainBO pushPainBO = new PushPainBO();
sendMsg.put("receive_id", receiveId); pushPainBO.setIndex(1);
sendMsg.put("msg_type", "text"); pushPainBO.setName("柳双武");
JSONObject content = new JSONObject(); pushPainBO.setDepartMentName("技术中心");
content.put("text", msg); pushPainBO.setTimeRange("15:00-16:00");
sendMsg.put("content", content.toString()); PushPainBO pushPainBO1 = new PushPainBO();
feiShuApiService.sendMsg(receiveIdType, sendMsg); pushPainBO1.setIndex(1);
pushPainBO1.setName("柳双武");
pushPainBO1.setDepartMentName("技术中心");
pushPainBO1.setTimeRange("15:00-16:00");
PushPainBO pushPainBO2 = new PushPainBO();
pushPainBO2.setIndex(1);
pushPainBO2.setName("柳双武");
pushPainBO2.setDepartMentName("技术中心");
pushPainBO2.setTimeRange("15:00-16:00");
List<PushPainBO> userList = new ArrayList<>();
userList.add(pushPainBO);
userList.add(pushPainBO1);
userList.add(pushPainBO2);
massageService.sendMassageMsgCardToPiPiChat(userList);
return ResultGenerator.genSuccessResult(); return ResultGenerator.genSuccessResult();
} }
} }
...@@ -25,8 +25,7 @@ public class FeiShuConfig { ...@@ -25,8 +25,7 @@ public class FeiShuConfig {
private String verificationToken; private String verificationToken;
private String appId; private String appId;
private String appSecret; private String appSecret;
private String fkChatId; private String ChatId;
private String fkChatIdTest;
private String tableId; private String tableId;
private String peopleTableId; private String peopleTableId;
......
package com.pipihelper.project.feishu.service; package com.pipihelper.project.feishu.service;
import com.pipihelper.project.feishu.dao.EmployeeDao; import com.pipihelper.project.feishu.dao.EmployeeDao;
import com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO;
import com.pipihelper.project.feishu.dto.employee.SystemFieldsDTO;
import com.pipihelper.project.feishu.entity.Employee; import com.pipihelper.project.feishu.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service @Service
public class EmployeeService { public class EmployeeService {
...@@ -13,6 +18,9 @@ public class EmployeeService { ...@@ -13,6 +18,9 @@ public class EmployeeService {
@Autowired @Autowired
private EmployeeDao employeeDao; private EmployeeDao employeeDao;
@Autowired
private FeiShuApiService feiShuApiService;
public Employee findById(Integer id) { public Employee findById(Integer id) {
return employeeDao.findById(id); return employeeDao.findById(id);
} }
...@@ -36,4 +44,39 @@ public class EmployeeService { ...@@ -36,4 +44,39 @@ public class EmployeeService {
public List<Employee> findAll() { public List<Employee> findAll() {
return employeeDao.findAll(); return employeeDao.findAll();
} }
/**
* 同步所有花名册
*/
public void uprsetAllEmployee() {
List<FeiShuEmployeeDTO> dtos = feiShuApiService.getEmployeeList();
List<Employee> employeeList = this.findAll();
Map<String, Employee> employeeMap = employeeList.stream().collect(Collectors.toMap(Employee::getOpenId, Function.identity()));
List<String> openIdList = dtos.stream().map(FeiShuEmployeeDTO::getUserId).collect(Collectors.toList());
employeeList.forEach(it -> {
if (!openIdList.contains(it.getOpenId())) {
this.deleteById(it.getId());
}
});
dtos.forEach(it -> {
Employee currentEmployee = employeeMap.get(it.getUserId());
if (currentEmployee != null) {
return;
}
Employee employee = new Employee();
SystemFieldsDTO systemFieldsDTO = it.getSystemFields();
employee.setOpenId(it.getUserId());
if (systemFieldsDTO != null) {
employee.setGender(systemFieldsDTO.getGender());
employee.setStatus(systemFieldsDTO.getStatus());
employee.setDepartmentId(systemFieldsDTO.getDepartmentId());
employee.setName(systemFieldsDTO.getName());
employee.setMobile(systemFieldsDTO.getMobile());
}
this.create(employee);
});
}
} }
...@@ -85,34 +85,34 @@ public class FeiShuApiService { ...@@ -85,34 +85,34 @@ public class FeiShuApiService {
return responseEntity.getBody().get("tenant_access_token").toString(); return responseEntity.getBody().get("tenant_access_token").toString();
} }
/** // /**
* @param /https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create // * @param /https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create
* @param sendMsg // * @param sendMsg
* @return // * @return
*/ // */
public JSONObject sendMsg(String receive_id_type, JSONObject sendMsg) { // public JSONObject sendMsg(String receive_id_type, JSONObject sendMsg) {
System.out.println(sendMsg.toString()); // System.out.println(sendMsg.toString());
//
//发送消息 // //发送消息
String api = "/im/v1/messages?receive_id_type={receive_id_type}"; // String api = "/im/v1/messages?receive_id_type={receive_id_type}";
RestTemplate restTemplate = new RestTemplate(); // RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders(); // HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + getTenantToken()); // headers.set("Authorization", "Bearer " + getTenantToken());
headers.set("Content-Type", "application/json; charset=utf-8"); // headers.set("Content-Type", "application/json; charset=utf-8");
HttpEntity<String> requestEntity = new HttpEntity<>(sendMsg.toString(), headers); // HttpEntity<String> requestEntity = new HttpEntity<>(sendMsg.toString(), headers);
String url = feiShuConfig.getFeiShuOpenApiHost() + api; // String url = feiShuConfig.getFeiShuOpenApiHost() + api;
try { // try {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(url, requestEntity, JSONObject.class, receive_id_type); // ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(url, requestEntity, JSONObject.class, receive_id_type);
if (responseEntity.getBody().getJSONObject("data") == null) { // if (responseEntity.getBody().getJSONObject("data") == null) {
return null; // return null;
} // }
log.info("消息发送成功,接收人: {}", sendMsg.getString("receive_id")); // log.info("消息发送成功,接收人: {}", sendMsg.getString("receive_id"));
return responseEntity.getBody(); // return responseEntity.getBody();
} catch (Exception e) { // } catch (Exception e) {
log.error("飞书:" + api + "接口调用失败" + "\n" + e); // log.error("飞书:" + api + "接口调用失败" + "\n" + e);
throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e); // throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e);
} // }
} // }
@Async @Async
...@@ -378,7 +378,7 @@ public class FeiShuApiService { ...@@ -378,7 +378,7 @@ public class FeiShuApiService {
* @return * @return
*/ */
public String createChatList(FeiShuChatDTO feiShuChatDTO) { public String createChatList(FeiShuChatDTO feiShuChatDTO) {
String api = "/im/v1/chats"; String api = "/im/v1/chats?user_id_type=open_id";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + getTenantToken()); headers.set("Authorization", "Bearer " + getTenantToken());
...@@ -568,33 +568,4 @@ public class FeiShuApiService { ...@@ -568,33 +568,4 @@ public class FeiShuApiService {
} }
} }
//获取会议室列表
public List<FeiShuEmployeeDTO> getMeetingRooms() {
String api = "/ehr/v1/employees?view=full&status=2&status=4&page_size=100";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + getTenantToken());
headers.set("Content-Type", "application/json; charset=utf-8");
HttpEntity<String> requestEntity = new HttpEntity<>(headers);
String url = feiShuConfig.getFeiShuOpenApiHost() + api;
try {
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
Type type = new TypeReference<FeiShuResultDTO<FeiShuEmployeeDTO>>() {
}.getType();
FeiShuResultDTO feiShuResultDTO = JSONObject.parseObject(responseEntity.getBody(), type);
List<FeiShuEmployeeDTO> feiShuEmployeeDTOList = new ArrayList<>();
feiShuEmployeeDTOList.addAll(feiShuResultDTO.getData().getItems());
while (feiShuResultDTO.getData().getItems().size() >= 100) {
ResponseEntity<String> next = restTemplate.exchange(url + "&page_token=" + feiShuResultDTO.getData().getPageToken(), HttpMethod.GET, requestEntity, String.class);
feiShuResultDTO = JSONObject.parseObject(next.getBody(), type);
feiShuEmployeeDTOList.addAll(feiShuResultDTO.getData().getItems());
}
log.info("花名册获取完成,总计 {} 人", feiShuEmployeeDTOList.size());
return feiShuEmployeeDTOList;
} catch (Exception e) {
throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e);
}
}
} }
...@@ -46,8 +46,8 @@ public class FeiShuEventService { ...@@ -46,8 +46,8 @@ public class FeiShuEventService {
FeiShuEventReceiveMessageDTO.Sender sender= feiShuEventReceiveMessageDTO.getSender(); FeiShuEventReceiveMessageDTO.Sender sender= feiShuEventReceiveMessageDTO.getSender();
FeiShuEventReceiveMessageDTO.Message message= feiShuEventReceiveMessageDTO.getMessage(); FeiShuEventReceiveMessageDTO.Message message= feiShuEventReceiveMessageDTO.getMessage();
//单独处理群消息 //单独处理群消息
if (message.getChat_id().equals(feiShuConfig.getFkChatId()) if (message.getChat_id().equals(feiShuConfig.getChatId())
|| message.getChat_id().equals(feiShuConfig.getFkChatIdTest())) { //判断是否为指定群消息 || message.getChat_id().equals(feiShuConfig.getChatId())) { //判断是否为指定群消息
return; return;
} }
else { else {
......
package com.pipihelper.project.feishu.service.massage;
import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.utils.GraphicsGenerationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 16:17
*/
@Service
@Transactional
@Slf4j
public class MassageMsgCardSerivce {
@Autowired
private FeiShuApiService feiShuApiService;
public String genMassageMsgCardForCompany(List<List<String>> pushUser){
try {
List<String> title = Arrays.asList("序号","姓名","部门","时间段","签到");
pushUser.add(0,title);
byte[] bufferedImage = GraphicsGenerationUtil.bufferedImageToByte(pushUser);
//将图片上传
String imgKey = feiShuApiService.uploadFile("stream", "massageEmployee", null, bufferedImage);
String fileName = String.format("/templates/massage-msg-card.json");
String msgCardContent = String.format(getInteractiveCardStr(fileName), imgKey);
return msgCardContent;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 读取模板文件
* @param file
* @return
*/
public String getInteractiveCardStr(String file){
try {
InputStream in = this.getClass().getResourceAsStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(in);
Stream<String> streamOfString= new BufferedReader(inputStreamReader).lines();
String streamToString = streamOfString.collect(Collectors.joining());
return streamToString;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}
package com.pipihelper.project.feishu.service.massage;
import com.pipihelper.project.feishu.bo.PushPainBO;
import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.service.FeiShuApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 17:21
*/
@Service
@Transactional
@Slf4j
public class MassageService {
@Autowired
private MassageMsgCardSerivce massageMsgCardSerivce;
@Autowired
private FeiShuApiService feiShuApiService;
@Autowired
private FeiShuConfig feiShuConfig;
public void sendMassageMsgCardToPiPiChat(List<PushPainBO> pushPainBOList){
List<List<String>> pushUser = new ArrayList<>();
for(PushPainBO pushPainBO:pushPainBOList){
List<String> user = new ArrayList<>();
//给单个用户发送
//构建给大群发送的名单
user.add(pushPainBO.getIndex().toString());
user.add(pushPainBO.getName());
user.add(pushPainBO.getDepartMentName());
user.add(pushPainBO.getTimeRange());
user.add("");
pushUser.add(user);
}
String content = massageMsgCardSerivce.genMassageMsgCardForCompany(pushUser);
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setContent(content);
feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId());
feiShuApiService.sendMsg(feiShuMsgDTO, "open_id");
}
}
package com.pipihelper.project.scheduled;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 17:26
*/
public class MassageNoticeScheduleService {
/**
* 每周四定时生成要按摩的人员名单,并发送大群和单人消息
*/
@Async
@Scheduled(cron = "0 0 10 * * ?")
public void sendMsgCardToPipiChat(){
}
}
package com.pipihelper.project.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.util.List;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 16:12
*/
public class GraphicsGenerationUtil {
/**
* 生成图片
* @param data 以二维数组形式存放 表格里面的值
*/
public static BufferedImage graphicsGeneration(List<List<String>> data) {
// 字体大小
int fontTitileSize = 15;
// 横线的行数
int totalrow = data.size()+1;
// 竖线的行数
int totalcol = 0;
if (data.get(0) != null) {
totalcol = data.get(0).size();
}
// 图片宽度
int imageWidth = 1024;
// 行高
int rowheight = 40;
// 图片高度
int imageHeight = totalrow*rowheight+50;
// 起始高度
int startHeight = 10;
// 起始宽度
int startWidth = 10;
// 单元格宽度
int colwidth = (int)((imageWidth-20)/totalcol);
BufferedImage image = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0,0, imageWidth, imageHeight);
graphics.setColor(new Color(220,240,240));
//画横线
for(int j=0;j<totalrow; j++){
graphics.setColor(Color.black);
graphics.drawLine(startWidth, startHeight+(j+1)*rowheight, startWidth+colwidth*totalcol, startHeight+(j+1)*rowheight);
}
//画竖线
for(int k=0;k<totalcol+1;k++){
graphics.setColor(Color.black);
graphics.drawLine(startWidth+k*colwidth, startHeight+rowheight, startWidth+k*colwidth, startHeight+rowheight*totalrow);
}
//设置字体
Font font = new Font("微软雅黑",Font.BOLD,fontTitileSize);
graphics.setFont(font);
//写标题
String title = "【指标完成进度】";
graphics.drawString(title, startWidth, startHeight+rowheight-10);
//写入内容
for(int n=0;n< data.size();n++){
for(int l = 0; l< data.get(n).size(); l++){
if (n == 0) {
font = new Font("微软雅黑",Font.BOLD,fontTitileSize);
graphics.setFont(font);
}else if (n > 0 && l >0) {
font = new Font("微软雅黑",Font.PLAIN,fontTitileSize);
graphics.setFont(font);
graphics.setColor(Color.RED);
} else {
font = new Font("微软雅黑",Font.PLAIN,fontTitileSize);
graphics.setFont(font);
graphics.setColor(Color.BLACK);
}
graphics.drawString(data.get(n).get(l).toString(), startWidth+colwidth*l+5, startHeight+rowheight*(n+2)-10);
}
}
return image;
}
/**
* 将图片保存到指定位置
* @param data 表格数据
* @param fileLocation 文件位置
*/
public static void createImage(List<List<String>> data, String fileLocation) {
BufferedImage image = graphicsGeneration(data);
try {
FileOutputStream fos = new FileOutputStream(fileLocation);
ImageIO.write(image,"png", fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 将图片转byte
* @param data 表格数据
*/
public static byte[] bufferedImageToByte(List<List<String>> data) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BufferedImage image = graphicsGeneration(data);
try {
ImageIO.write(image,"png", byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
return null;
}
}
}
...@@ -18,9 +18,9 @@ feishu: ...@@ -18,9 +18,9 @@ feishu:
feiShuOpenApiHost: https://open.feishu.cn/open-apis feiShuOpenApiHost: https://open.feishu.cn/open-apis
encryptKey: aGTqmJcfXluKWfFWHGw5SdzIg6QIxPsp encryptKey: aGTqmJcfXluKWfFWHGw5SdzIg6QIxPsp
verificationToken: ChUEDdWQbyHpHUV6H5fVeL5fOP3HfBE6 verificationToken: ChUEDdWQbyHpHUV6H5fVeL5fOP3HfBE6
appId: cli_a3c2be2801f8500d appId: cli_a2cff17bd3f8d013
appSecret: bw3ZXzSj47DgHT19YT268bcwYVVnRTZD appSecret: E5vXXmRipOD6vyolib186b25XXLbdYfE
fkChatId: oc_5124ee21dbdecf5d802f9e9e33dab722 ChatId: oc_5124ee21dbdecf5d802f9e9e33dab722
# 腾讯云配置参数 # 腾讯云配置参数
tx: tx:
......
...@@ -15,7 +15,7 @@ feishu: ...@@ -15,7 +15,7 @@ feishu:
verificationToken: iFeLGB7JZQV37zDjIFTw0dUQ0QfFlkm5 verificationToken: iFeLGB7JZQV37zDjIFTw0dUQ0QfFlkm5
appId: cli_a3c0cb967f619013 appId: cli_a3c0cb967f619013
appSecret: NdqjzD2Bkaif6HyU8KCXGbFJzDhEEimt appSecret: NdqjzD2Bkaif6HyU8KCXGbFJzDhEEimt
fkChatId: oc_5124ee21dbdecf5d802f9e9e33dab722 ChatId: oc_2c70ffa8559b1bdd75c4dca0490b7a05
# 腾讯云配置参数 # 腾讯云配置参数
tx: tx:
......
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_fb35ed68-018e-4f10-b88d-b7f8c81ea50g",
"tag": "img"
},
{
"tag": "div",
"text": {
"content": "**嗨,%s,今天是你入职皮皮的1周年,祝你周年快乐!**",
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "markdown",
"content": "一年前的今天,你选择并加入了**皮皮**💕\n带着你的满腔热血与不懈的努力,一点一点收获成长,突破自我👍\n一年后的今天,你在**皮皮**也留下更多的回忆,皮皮也看到了不断成长的你✨\n**祝愿你初心不改,乘风破浪,朝着更好的自己出发!**",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉祝入职【1】周年快乐!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_8ad7651c-8d71-4c0b-bf3e-5b17b65f63ag",
"tag": "img"
},
{
"tag": "div",
"text": {
"content": "**嗨,%s,今天是你入职皮皮的3周年,祝你周年快乐!**",
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "markdown",
"content": "又到了这个特别的日子✨\n这是你跟皮皮相逢的纪念日,也是成为皮皮中一员的重要一天💕\n从第一个365天的不断尝试和试错💨\n到接下来两个365天的更加坚定和相互信任👏\n感谢你一如既往的坚持,在披荆斩棘的路上不畏艰难,闪闪发光💫\n**愿你永远炽热、真诚、坚定地奔赴你想要的未来~**",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉祝入职【3】周年快乐!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_26f282b8-ced6-47e0-9c6a-a07608c73dag",
"tag": "img"
},
{
"tag": "div",
"text": {
"content": "**嗨,%s,今天是你入职皮皮的5周年,祝你周年快乐!**",
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "markdown",
"content": "伴随着时光的脚步,走过了五个春夏秋冬🧭\n五年的时间,栉风沐雨🌥\n五年的时间,砥砺前行💨\n感恩你的坚持和付出,为皮皮增光添彩👏\n我们铭记你的付出,也见证了你的成长❤\n**未来的日子里愿你满腔热血拥抱无限可能~**",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉祝入职【5】周年快乐!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_592d3f6b-dedb-4fde-8f00-854edf5e06dg",
"tag": "img"
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "**哈喽!💕**\n**今天是%s入职两周年的日子,快去送上祝福和TA聊聊吧~**✨",
"tag": "lark_md"
}
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉团队小伙伴入职2周年啦!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_53fbf63d-2bf2-49e5-b061-f89f04d8188g",
"tag": "img"
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "**哈喽!💕**\n**今天是%s入职三周年的日子,快去送上祝福和TA聊聊吧~**✨",
"tag": "lark_md"
}
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉团队小伙伴入职3周年啦!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_f83c3a87-38fd-4690-992d-1e53b434bb5g",
"tag": "img"
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "**哈喽!💕**\n**今天是%s入职五周年的日子,快去送上祝福和TA聊聊吧~**✨",
"tag": "lark_md"
}
}
],
"header": {
"template": "orange",
"title": {
"content": "🎉🎉团队小伙伴入职5周年啦!",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"header": {
"template": "red",
"title": {
"content": "🎂 亲爱的 %s,祝你生日快乐!",
"tag": "plain_text"
}
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_a557f866-917f-415a-bf5e-04379ea67b8g",
"tag": "img"
},
{
"tag": "div",
"text": {
"content": "**生活因你而更精彩,愿你此后每一天,眼里是阳光,笑里是坦荡!**",
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "markdown",
"content": "\n**🎁领取专属生日礼物**\n地点:14楼前台\n时间:9:30—18:00</at>",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
}
]
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"header": {
"template": "red",
"title": {
"content": "🎈请查收一份生日提醒!",
"tag": "plain_text"
}
},
"elements": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_a557f866-917f-415a-bf5e-04379ea67b8g",
"tag": "img"
},
{
"tag": "div",
"text": {
"content": "**今天你的团队里有小伙伴过生日哦~记得给Ta送去一份生日祝福💌**",
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "markdown",
"content": "\n**👑今日寿星:%s**\n</at>",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
}
]
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"header": {
"template": "red",
"title": {
"content": "✨✨@%s,恭喜你转正啦!",
"tag": "plain_text"
}
},
"i18n_elements": {
"zh_cn": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_0e9d8b45-53c8-4e1d-a7a7-58908ec66cfg",
"tag": "img"
},
{
"tag": "markdown",
"content": "**人才服务中心“拍了拍你”**😘",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "\n亲爱的%s\n恭喜你今天**转正**啦~🎉🎉\n经过一段时间的相处,我们确定你就是与皮皮气味相投的**The one**!\n请在接下来的旅途中,继续**保持热爱,闪闪发光**吧!🌺🌺",
"tag": "lark_md"
}
},
{
"tag": "hr"
}
]
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true
},
"header": {
"template": "red",
"title": {
"content": "✨✨团队有小伙伴转正啦~",
"tag": "plain_text"
}
},
"i18n_elements": {
"zh_cn": [
{
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_0e9d8b45-53c8-4e1d-a7a7-58908ec66cfg",
"tag": "img"
},
{
"tag": "markdown",
"content": "**人才服务中心“拍了拍你”**😘",
"href": {
"urlVal": {
"url": "https://www.feishu.com",
"android_url": "https://developer.android.com/",
"ios_url": "lark://msgcard/unsupported_action",
"pc_url": "https://www.feishu.com"
}
}
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "\n哈喽~ %s 已顺利通过试用期,今天正式转正啦~🎉🎉\n作为上级可以表示一下祝福与欢迎,不要忘了与TA的**1v1沟通**噢🌺🌺",
"tag": "lark_md"
}
},
{
"tag": "hr"
}
]
}
}
\ No newline at end of file \ No newline at end of file
{
"config": {
"wide_screen_mode": true,
"update_multi":true
},
"elements": [
{
"tag": "div",
"text": {
"content": " 🔴 **${section}关键词:**\n**${keyWord}**",
"tag": "lark_md"
}
},
{
"tag": "div",
"text": {
"content": "**${section}反馈数:**\n**${totalFeedBack}**",
"tag": "lark_md"
}
},
{
"tag": "div",
"text": {
"content": "**${section}反馈平均处理时长:**\n**${totalAvgTime}秒**",
"tag": "lark_md"
}
},
{
"fields": [
{
"is_short": false,
"text": {
"content": "**${module}:**\n${section}受理问题最多,有${moduleSum}个",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": "",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": "**值班人名下剩余未关闭问题:**\n${dutyInfo}",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": "",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": " <at id=${verifyOpenId}></at>\n作为跟进人响应问题最快,平均${verifyAvgTime}秒",
"tag": "lark_md"
}
}
{
"is_short": false,
"text": {
"content": "",
"tag": "lark_md"
}
},
,
{
"is_short": false,
"text": {
"content": " <at id=${assignOpenId}></at>\n作为负责人响应问题最快,平均${assignAvgTime}秒",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": "",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": " <at id=${assignOpenId1}></at>\n作为负责人处理问题最快,平均${assignAvgTime1}秒",
"tag": "lark_md"
}
}
,
{
"is_short": false,
"text": {
"content": "",
"tag": "lark_md"
}
},
{
"is_short": false,
"text": {
"content": " <at id=${assignOpenId2}></at>\n作为负责人处理问题最多,共${assignSum2}条",
"tag": "lark_md"
}
}
],
"tag": "div"
},
{
"tag": "hr"
}
],
"header": {
"template": "red",
"title": {
"content": " 📢 ${section}反馈情况汇总",
"tag": "plain_text"
}
}
}
\ No newline at end of file \ No newline at end of file
{
"elements": [
{
"tag": "markdown",
"content": "${content}"
}
<#if action??>,
{
"tag": "action",
"actions": [
{
"tag": "select_static",
"placeholder": {
"tag": "plain_text",
"content": "${action.action_content}"
},
"value":{
"key" : "TEST_DATA.${action.action_type}"
},
"options": [
<#list action.options as option>
{
"text": {
"tag": "plain_text",
"content": "${option.option}"
},
"value": "${option.mobile_option}"
}
<#if option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
],
"config": {
"wide_screen_mode": true,
"update_multi":true
},
"header": {
"template": "${color}",
"title": {
"tag": "plain_text",
"content": "${mobile}"
}
}
}
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="buffId" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.metadata">=</stringProp>
<boolProp name="HTTPArgument.use_equals">true</boolProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.contentEncoding">utf-8</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
{ {
"config": { "config": {
"wide_screen_mode": true "wide_screen_mode": true,
"update_multi": true
}, },
"elements": [ "elements": [
{ {
"tag": "div",
"text": {
"content": "1. 按摩时间15:00-17:30;\n2. 按摩时长每人15分钟,3人一组,按照图片顺序从上至下依次进行;\n3. 按完请在自己的卡片上点击完成,系统会自动@下一位成员;4. 放弃请直接点击放弃,名额将会发送到大群秒杀,先到先得;\n5. 有事暂时来不了,可以推迟到最后;\n6. 轮到你的时候超过1分钟未确认,将自动调换至末尾,@下一位成员;",
"tag": "lark_md"
}
},
{
"alt": { "alt": {
"content": "", "content": "",
"tag": "plain_text" "tag": "plain_text"
}, },
"img_key": "img_v2_f4de8df4-204a-48c7-9cd4-8abff2e6593g", "img_key": "%s",
"tag": "img" "tag": "img"
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "**哈喽!💕**\n**今天是%s入职一周年的日子,快去送上祝福和TA聊聊吧~**✨",
"tag": "lark_md"
}
} }
], ],
"header": { "header": {
"template": "orange", "template": "red",
"title": { "title": {
"content": "🎉🎉团队小伙伴入职1周年啦!", "content": "🔔 叮~今日份按摩名单",
"tag": "plain_text" "tag": "plain_text"
} }
} }
......
{ {
"config": { "config": {
"wide_screen_mode": true "wide_screen_mode": true,
"update_multi":true
}, },
"elements": [ "elements": [
{ {
"alt": {
"content": "",
"tag": "plain_text"
},
"img_key": "img_v2_5273001f-8a08-4830-bc9e-3038f8d65f0g",
"tag": "img"
},
{
"tag": "div", "tag": "div",
"text": { "text": {
"content": "**嗨,%s,今天是你入职皮皮的2周年,祝你周年快乐!**", "content": "%s",
"tag": "lark_md" "tag": "lark_md"
} }
}, },
{ {
"tag": "hr" "actions": [
}, {
{ "tag": "button",
"tag": "markdown", "text": {
"content": "两年的时光,一晃而过💕\n感谢你的全力奔跑和付出的努力,也期待你在未来的日子闪闪发光,熠熠生辉✨\n**愿你初心如磐,奋楫笃行,复年更胜今年~~**", "content": "😁 接受",
"href": { "tag": "plain_text"
"urlVal": { },
"url": "https://www.feishu.com", "type": "default",
"android_url": "https://developer.android.com/", "value": {
"ios_url": "lark://msgcard/unsupported_action", "key1": "massage-singel.revice"
"pc_url": "https://www.feishu.com" }
},
{
"tag": "button",
"text": {
"content": "😢 怕疼",
"tag": "plain_text"
},
"type": "default",
"value": {
"key2": "massage-singel.giveUp"
}
},
{
"tag": "button",
"text": {
"content": "😢 等一下",
"tag": "plain_text"
},
"type": "default",
"value": {
"key2": "massage-singel.wait"
}
} }
} ],
}, "tag": "action"
{
"tag": "hr"
} }
], ],
"header": { "header": {
"template": "orange", "template": "turquoise",
"title": { "title": {
"content": "🎉🎉祝入职【2】周年快乐!", "content": "👻 按摩提醒请查收!",
"tag": "plain_text" "tag": "plain_text"
} }
} }
......
{
"elements": [
{
"tag": "markdown",
"content": "${content}"
}
<#if appType??>,
{
"tag": "action",
"actions": [
{
"tag": "${appType.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${appType.content}"
},
"value":{
"key" : "appType"
},
"options": [
<#list appType.options as appType_option>
{
"text": {
"tag": "plain_text",
"content": "${appType_option}"
},
"value": "${appType_option}"
}
<#if appType_option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
<#if module??>,
{
"tag": "action",
"actions": [
{
"tag": "${module.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${module.content}"
},
"value":{
"key" : "module"
},
"options": [
<#list module.options as module_option>
{
"text": {
"tag": "plain_text",
"content": "${module_option}"
},
"value": "${module_option}"
}
<#if module_option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
<#if level??>,
{
"tag": "action",
"actions": [
{
"tag": "${level.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${level.content}"
},
"value":{
"key" : "level"
},
"options": [
<#list level.options as levle_option>
{
"text": {
"tag": "plain_text",
"content": "${levle_option}"
},
"value": "${levle_option}"
}<#if levle_option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
<#if assign??>,
{
"tag": "action",
"actions": [
{
"tag": "${assign.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${assign.content}"
},
"value":{
"key" : "assign"
},
"options": [
<#list assign.options as assign_option>
{
"value": "${assign_option}"
}<#if assign_option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
<#if verify??>,
{
"tag": "action",
"actions": [
{
"tag": "${verify.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${verify.content}"
},
"value":{
"key" : "verify"
},
"options": [
<#list verify.options as verify_option>
{
"value": "${verify_option}"
}<#if verify_option_has_next>,</#if>
</#list>
]
}
]
}
</#if>
<#if handle??>,
{
"tag": "div",
"text": {
"content": "若需要转发可重新指派,自己处理请点击“我来”",
"tag": "lark_md"
}
},
{
"tag": "action",
"actions": [
{
"tag": "${handle.tag}",
"text": {
"tag": "plain_text",
"content": "${handle.content}"
},
"type": "primary",
"value":{
"key" : "handle"
}
}
]
}
</#if>
<#if finishTime??>,
{
"tag": "action",
"actions": [
{
"tag": "${finishTime.tag}",
"placeholder": {
"tag": "plain_text",
"content": "${finishTime.content}"
},
"value":{
"key" : "finishTime"
}
}
]
}
</#if>
<#if fileFinish??>,
{
"tag": "div",
"text": {
"tag": "lark_md",
"content": " 负责人任务已完成,您可选择直接完成或归档。注意后续仍需要跟进处理的请选择归档,系统会帮你创建飞书任务,请慎重选择!"
},
"extra": {
"tag": "${fileFinish.tag}",
"options": [
<#list fileFinish.options as fileFinish_option>
{
"text": {
"tag": "plain_text",
"content": "${fileFinish_option}"
},
"value": "${fileFinish_option}"
}<#if fileFinish_option_has_next>,</#if>
</#list>
],
"value": {
"key": "fileFinish"
}
}
}
</#if>
<#if finish??>,
{
"tag": "action",
"actions": [
{
"tag": "${finish.tag}",
"text": {
"tag": "plain_text",
"content": "${finish.content}"
},
"type": "primary",
"value":{
"key" : "finish"
}
}
]
}
</#if>
],
"header": {
"template": "${color}",
"title": {
"tag": "plain_text",
"content": "你有一条新的反馈群消息待处理!"
}
},
"card_link": {
"url": "https://applink.feishu.cn/client/chat/open?openChatId=oc_ffe88a3306221742b18f2bf9e119c17a"
},
"config": {
"wide_screen_mode": true,
"update_multi":true
}
}
\ No newline at end of file \ No newline at end of file
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 12:57
*/
public class myGraphicsGeneration {
/**
* 生成图片
* @param cellsValue 以二维数组形式存放 表格里面的值
* @param path 文件保存路径
*/
public static void myGraphicsGeneration(String cellsValue[][], String path) {
// 字体大小
int fontTitileSize = 15;
// 横线的行数
int totalrow = cellsValue.length+1;
// 竖线的行数
int totalcol = 0;
if (cellsValue[0] != null) {
totalcol = cellsValue[0].length;
}
// 图片宽度
int imageWidth = 1024;
// 行高
int rowheight = 40;
// 图片高度
int imageHeight = totalrow*rowheight+50;
// 起始高度
int startHeight = 10;
// 起始宽度
int startWidth = 10;
// 单元格宽度
int colwidth = (int)((imageWidth-20)/totalcol);
BufferedImage image = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0,0, imageWidth, imageHeight);
graphics.setColor(new Color(220,240,240));
//画横线
for(int j=0;j<totalrow; j++){
graphics.setColor(Color.black);
graphics.drawLine(startWidth, startHeight+(j+1)*rowheight, startWidth+colwidth*totalcol, startHeight+(j+1)*rowheight);
}
//画竖线
for(int k=0;k<totalcol+1;k++){
graphics.setColor(Color.black);
graphics.drawLine(startWidth+k*colwidth, startHeight+rowheight, startWidth+k*colwidth, startHeight+rowheight*totalrow);
}
//设置字体
Font font = new Font("微软雅黑",Font.BOLD,fontTitileSize);
graphics.setFont(font);
//写标题
String title = "【指标完成进度】";
graphics.drawString(title, startWidth, startHeight+rowheight-10);
//写入内容
for(int n=0;n<cellsValue.length;n++){
for(int l=0;l<cellsValue[n].length;l++){
if (n == 0) {
font = new Font("微软雅黑",Font.BOLD,fontTitileSize);
graphics.setFont(font);
}else if (n > 0 && l >0) {
font = new Font("微软雅黑",Font.PLAIN,fontTitileSize);
graphics.setFont(font);
graphics.setColor(Color.RED);
} else {
font = new Font("微软雅黑",Font.PLAIN,fontTitileSize);
graphics.setFont(font);
graphics.setColor(Color.BLACK);
}
graphics.drawString(cellsValue[n][l].toString(), startWidth+colwidth*l+5, startHeight+rowheight*(n+2)-10);
}
}
// 保存图片
createImage(image, path);
}
/**
* 将图片保存到指定位置
* @param image 缓冲文件类
* @param fileLocation 文件位置
*/
public static void createImage(BufferedImage image, String fileLocation) {
try {
FileOutputStream fos = new FileOutputStream(fileLocation);
// BufferedOutputStream bos = new BufferedOutputStream(fos);
// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
// encoder.encode(image);
// bos.close();
ImageIO.write(image,"png", fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
String tableData1[][] = {{"8月31日","累计用户数","目标值","完成进度","时间进度", "进度差异"}, {"掌厅客户端(户)","469281","1500000","31.2%","33.6%", "-2.4%"}};
String[][] tableData2 = {{"8月31日(户)","新增用户数","日访问量","累计用户数","环比上月"},
{"合肥和巢湖","469281","1500000","31.2%","33.6%"},
{"芜湖","469281","1500000","31.2%","33.6%"},
{"蚌埠","469281","1500000","31.2%","33.6%"},
{"淮南","469281","1500000","31.2%","33.6%"},
{"马鞍山","469281","1500000","31.2%","33.6%"},
{"淮北","469281","1500000","31.2%","33.6%"}};
myGraphicsGeneration(tableData2, "myPic.png");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!