diff --git a/evo-admin/pom.xml b/evo-admin/pom.xml index ae54177..dbd11ca 100644 --- a/evo-admin/pom.xml +++ b/evo-admin/pom.xml @@ -17,6 +17,13 @@ + + com.github.ulisesbocchio + jasypt-spring-boot-starter + 3.0.5 + + + com.aliyun diff --git a/evo-admin/src/main/java/com/evo/common/controller/TestController.java b/evo-admin/src/main/java/com/evo/common/controller/TestController.java index ea5bfda..5eca18d 100644 --- a/evo-admin/src/main/java/com/evo/common/controller/TestController.java +++ b/evo-admin/src/main/java/com/evo/common/controller/TestController.java @@ -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 staffList = sysStaffService.list(new LambdaQueryWrapper().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 headers = responseBody.getHeaderSignatureInfo().getHeaders(); + URL url = new URL(resourceUrl); + HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + if (headers != null) { + for (Map.Entry 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))))); } diff --git a/evo-admin/src/main/java/com/evo/ding/DingUtils.java b/evo-admin/src/main/java/com/evo/ding/DingUtils.java index 8d649b8..493ec8b 100644 --- a/evo-admin/src/main/java/com/evo/ding/DingUtils.java +++ b/evo-admin/src/main/java/com/evo/ding/DingUtils.java @@ -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,7 +47,9 @@ 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; + } + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/evo-admin/src/main/java/com/evo/ding/mapper/DingShiftGroupMapper.java b/evo-admin/src/main/java/com/evo/ding/mapper/DingShiftGroupMapper.java index 18fe014..1056e8f 100644 --- a/evo-admin/src/main/java/com/evo/ding/mapper/DingShiftGroupMapper.java +++ b/evo-admin/src/main/java/com/evo/ding/mapper/DingShiftGroupMapper.java @@ -20,5 +20,5 @@ public interface DingShiftGroupMapper extends BaseMapper { int updateCheckTimeByShiftIdAndType(@Param("shiftId")String shiftId, @Param("type")String type, @Param("checkTime")String checkTime); - List selectList(DingShiftGroup dingShiftGroup); + List selectListByShiftId(@Param("shiftId") String shiftId); } diff --git a/evo-admin/src/main/java/com/evo/ding/service/impl/DingShiftGroupServiceImpl.java b/evo-admin/src/main/java/com/evo/ding/service/impl/DingShiftGroupServiceImpl.java index 7063e3a..700bff3 100644 --- a/evo-admin/src/main/java/com/evo/ding/service/impl/DingShiftGroupServiceImpl.java +++ b/evo-admin/src/main/java/com/evo/ding/service/impl/DingShiftGroupServiceImpl.java @@ -36,6 +36,6 @@ public class DingShiftGroupServiceImpl extends ServiceImpl selectList(DingShiftGroup dingShiftGroup) { - return getBaseMapper().selectList(dingShiftGroup); + return getBaseMapper().selectListByShiftId(dingShiftGroup.getShiftId()); } } diff --git a/evo-admin/src/main/resources/mapper/ding/DingShiftGroupMapper.xml b/evo-admin/src/main/resources/mapper/ding/DingShiftGroupMapper.xml index 33f8d27..14b5a91 100644 --- a/evo-admin/src/main/resources/mapper/ding/DingShiftGroupMapper.xml +++ b/evo-admin/src/main/resources/mapper/ding/DingShiftGroupMapper.xml @@ -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} - select dsg.id, dsg.group_id, dsg.shift_id, dsg.type, dsg.check_time, ds.name as shiftName,