Commit bfbe605a by weiss

1

1 parent 4a7e39e2
...@@ -181,6 +181,13 @@ ...@@ -181,6 +181,13 @@
<version>5.8.2</version> <version>5.8.2</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.sun.media/jai-codec -->
<dependency>
<groupId>com.sun.media</groupId>
<artifactId>jai-codec</artifactId>
<version>1.1.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
......
...@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
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.service.FeiShuEventService; import com.pipihelper.project.feishu.service.FeiShuEventService;
import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter; import com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -15,6 +17,7 @@ import javax.annotation.Resource; ...@@ -15,6 +17,7 @@ import javax.annotation.Resource;
* @author: charles * @author: charles
* @date: 2022年03月30日 17:39 * @date: 2022年03月30日 17:39
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/pipitest/feishu") @RequestMapping("/pipitest/feishu")
public class FeiShuEventController { public class FeiShuEventController {
...@@ -28,12 +31,13 @@ public class FeiShuEventController { ...@@ -28,12 +31,13 @@ public class FeiShuEventController {
@PostMapping("/event") @PostMapping("/event")
public JSONObject event(@RequestBody String s) throws Exception { public JSONObject event(@RequestBody String s) throws Exception {
log.info("接收到飞书事件,密文:{}", s);
JSONObject reqJsonObject = JSON.parseObject(s); JSONObject reqJsonObject = JSON.parseObject(s);
System.out.println(s);
FeiShuEventDataDecrypter d = new FeiShuEventDataDecrypter(feiShuConfig.getEncryptKey()); FeiShuEventDataDecrypter d = new FeiShuEventDataDecrypter(feiShuConfig.getEncryptKey());
JSONObject encryptJsonObject = JSON.parseObject(d.decrypt(reqJsonObject.getString("encrypt"))); JSONObject encryptJsonObject = JSON.parseObject(d.decrypt(reqJsonObject.getString("encrypt")));
System.out.println(encryptJsonObject); log.info("接收到飞书事件,明文:{}", encryptJsonObject);
if (encryptJsonObject.containsKey("challenge")) { if (encryptJsonObject.containsKey("challenge")) {
System.out.println(encryptJsonObject);
return encryptJsonObject; return encryptJsonObject;
} }
FeiShuEventDTO feiShuEventDTO = encryptJsonObject.toJavaObject(FeiShuEventDTO.class); FeiShuEventDTO feiShuEventDTO = encryptJsonObject.toJavaObject(FeiShuEventDTO.class);
...@@ -48,15 +52,19 @@ public class FeiShuEventController { ...@@ -48,15 +52,19 @@ 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) {
// JSONObject reqJsonObject = JSON.parseObject(s); log.info("接收到飞书消息卡片,密文:{}", s);
// System.out.println(s); JSONObject reqJsonObject = JSON.parseObject(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];
System.out.println(s);
return null;
}
// switch (actionType) { // switch (actionType) {
// case "TEST_DATA": // case "TEST_DATA":
// //
......
...@@ -549,33 +549,4 @@ public class FeiShuApiService { ...@@ -549,33 +549,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);
}
}
} }
<?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>
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!