1
This commit is contained in:
parent
896ebc9679
commit
04037fca60
@ -17,6 +17,13 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>3.0.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 新版 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
|
||||
@ -3,6 +3,7 @@ package com.evo.common.controller;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.evo.attendance.service.IRzAttendanceService;
|
||||
import com.evo.attendance.service.IRzAttendanceStatisticalService;
|
||||
@ -23,21 +24,25 @@ import com.evo.wechat.TemplateMessageUtil;
|
||||
import com.evo.wechat.dto.AbnormalAttendanceTemplate;
|
||||
import com.evo.wechat.dto.MessageTemplate;
|
||||
import com.evo.wechat.service.GZHAccessTokenService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jasypt.encryption.StringEncryptor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -70,7 +75,8 @@ public class TestController {
|
||||
private RzAttendanceDetailService rzAttendanceDetailService;
|
||||
@Resource
|
||||
private GZHAccessTokenService gzhAccessTokenService;
|
||||
|
||||
@Resource
|
||||
private StringEncryptor stringEncryptor;
|
||||
/**
|
||||
* 清洗加班
|
||||
*/
|
||||
@ -88,6 +94,24 @@ public class TestController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 清洗加班
|
||||
*/
|
||||
@GetMapping("/aes")
|
||||
public void aes() throws ParseException {
|
||||
// 1. 解密用户名(去掉ENC())
|
||||
String usernameCipher = "QpRNGkSzaeihXTOqXCqXCdAgTTBTOD8M";
|
||||
String usernamePlain = stringEncryptor.decrypt(usernameCipher);
|
||||
System.out.println("解密后的用户名:" + usernamePlain);
|
||||
|
||||
// 2. 解密密码(去掉ENC())
|
||||
String passwordCipher = "c5Sf+6DNzIgtVm2BoHLFmJqnsTJhqRQd721fQ5HXFEY=";
|
||||
String passwordPlain = stringEncryptor.decrypt(passwordCipher);
|
||||
System.out.println("解密后的密码:" + passwordPlain);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/buildUser")
|
||||
public AjaxResult buildUser() throws ParseException {
|
||||
List<SysStaff> staffList = sysStaffService.list(new LambdaQueryWrapper<SysStaff>().ne(SysStaff::getStatus, -1).isNull(SysStaff::getDingUserId));
|
||||
@ -114,6 +138,52 @@ public class TestController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 上传
|
||||
*/
|
||||
@GetMapping("/update")
|
||||
public void testUpload(@Param("file") MultipartFile filePath) throws Exception {
|
||||
GetFileUploadInfoResponseBody responseBody = DingUtils.resourceUrls();
|
||||
// 从接口返回信息中拿到url
|
||||
String resourceUrl = responseBody.getHeaderSignatureInfo().getResourceUrls().get(0);
|
||||
// 从接口返回信息中拿到headers
|
||||
Map<String, String> headers = responseBody.getHeaderSignatureInfo().getHeaders();
|
||||
URL url = new URL(resourceUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
if (headers != null) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
connection.setRequestProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("PUT");
|
||||
connection.setUseCaches(false);
|
||||
connection.setReadTimeout(10000);
|
||||
connection.setConnectTimeout(10000);
|
||||
connection.connect();
|
||||
OutputStream out = connection.getOutputStream();
|
||||
InputStream is = filePath.getInputStream();
|
||||
byte[] b =new byte[1024];
|
||||
int temp;
|
||||
while ((temp=is.read(b))!=-1){
|
||||
out.write(b,0,temp);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
int responseCode = connection.getResponseCode();
|
||||
connection.disconnect();
|
||||
if (responseCode == 200) {
|
||||
System.out.println("上传成功");
|
||||
} else {
|
||||
System.out.println("上传失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -122,7 +192,8 @@ public class TestController {
|
||||
@GetMapping("/testAdapterSend")
|
||||
public AjaxResult testSend() throws ParseException {
|
||||
String data = "{\"FormId\":\"BD_Empinfo\",\"FieldKeys\":\"FID\",\"FilterString\":[{\"Left\":\"\",\"FieldName\":\"FStaffNumber\",\"Compare\":\"17\",\"Value\":\"00046\",\"Right\":\"\",\"Logic\":0}],\"OrderString\":\"\",\"TopRowCount\":0,\"StartRow\":0,\"Limit\":2000,\"SubSystemId\":\"\"}";
|
||||
return AjaxResult.success(HttpUtils.sendPost("http://localhost:8089/distribution/kingdee/send", JSONObject.toJSONString(Collections.asMap("fromId","BD_Empinfo", "month","executeBillQuery", "data",data))));
|
||||
return AjaxResult.success(HttpUtils.sendPost("http://localhost:8089/distribution/kingdee/send", JSONObject.toJSONString(
|
||||
Collections.asMap("fromId","BD_Empinfo", "month","executeBillQuery", "parameterTypes",Collections.asList(String.class),"data",Collections.asMap("data",data)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.evo.ding;
|
||||
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
|
||||
import com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody;
|
||||
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
@ -46,6 +47,8 @@ public class DingUtils {
|
||||
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
|
||||
}else if(t == com.aliyun.dingtalkworkflow_1_0.Client.class){
|
||||
return new com.aliyun.dingtalkworkflow_1_0.Client(config);
|
||||
}else if(t == com.aliyun.dingtalkstorage_1_0.Client.class){
|
||||
return new com.aliyun.dingtalkstorage_1_0.Client(config);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -258,4 +261,56 @@ public class DingUtils {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static GetFileUploadInfoResponseBody resourceUrls() {
|
||||
|
||||
try {
|
||||
com.aliyun.dingtalkstorage_1_0.Client client = (com.aliyun.dingtalkstorage_1_0.Client) client(com.aliyun.dingtalkstorage_1_0.Client.class);
|
||||
com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoHeaders getFileUploadInfoHeaders = new com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoHeaders();
|
||||
getFileUploadInfoHeaders.xAcsDingtalkAccessToken = getAccessToken();
|
||||
com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoRequest getFileUploadInfoRequest = new com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoRequest();
|
||||
getFileUploadInfoRequest.setUnionId("IQ4KFIKVugR3UYfNOii5VzwiEiE");
|
||||
getFileUploadInfoRequest.setProtocol("HEADER_SIGNATURE");
|
||||
return client.getFileUploadInfoWithOptions("28629173113", getFileUploadInfoRequest, getFileUploadInfoHeaders, new com.aliyun.teautil.models.RuntimeOptions()).getBody();
|
||||
} catch (TeaException err) {
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
log.error("获取resourceUrls出现 TeaException 异常, 异常编码{}, 异常原因{}", err.getCode(), err.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception _err) {
|
||||
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||
// err 中含有 code 和 message 属性,可帮助开发定位问题
|
||||
log.error("获取resourceUrls出现 Exception 异常, 异常编码{}, 异常原因{}", err.getCode(), err.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -20,5 +20,5 @@ public interface DingShiftGroupMapper extends BaseMapper<DingShiftGroup> {
|
||||
|
||||
int updateCheckTimeByShiftIdAndType(@Param("shiftId")String shiftId, @Param("type")String type, @Param("checkTime")String checkTime);
|
||||
|
||||
List<DingShiftGroup> selectList(DingShiftGroup dingShiftGroup);
|
||||
List<DingShiftGroup> selectListByShiftId(@Param("shiftId") String shiftId);
|
||||
}
|
||||
|
||||
@ -36,6 +36,6 @@ public class DingShiftGroupServiceImpl extends ServiceImpl<DingShiftGroupMapper,
|
||||
|
||||
@Override
|
||||
public List<DingShiftGroup> selectList(DingShiftGroup dingShiftGroup) {
|
||||
return getBaseMapper().selectList(dingShiftGroup);
|
||||
return getBaseMapper().selectListByShiftId(dingShiftGroup.getShiftId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update ding_shift_group set check_time = #{checkTime} where shift_id=#{shiftId} and type = #{type}
|
||||
</update>
|
||||
|
||||
<select id="selectList" parameterType="com.evo.ding.domain.DingShiftGroup" resultMap="DingShiftGroupResult">
|
||||
<select id="selectListByShiftId" resultMap="DingShiftGroupResult">
|
||||
select
|
||||
dsg.id, dsg.group_id, dsg.shift_id, dsg.type, dsg.check_time,
|
||||
ds.name as shiftName,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user