夏文涛 преди 6 месеца
родител
ревизия
2c3abae9e8

+ 12 - 0
pom.xml

@@ -268,6 +268,18 @@
             <artifactId>dingtalk</artifactId>
             <version>2.1.14</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <!-- 移除 version,使用 Spring Boot 管理的版本 -->
+        </dependency>
+
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.11</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 25 - 0
src/main/java/com/template/api/FileControllerAPI.java

@@ -0,0 +1,25 @@
+package com.template.api;
+
+import com.template.annotation.PassToken;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+
+@Api(tags = {"FileController"}, value = "导入File表")
+@RequestMapping("/api/file")
+public interface FileControllerAPI {
+
+    @GetMapping(value = "/uploadFilesByCos")
+    @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod = "POST")
+    CommonResult uploadFilesByCos() throws Exception;
+
+    @PostMapping(value = "/uploadFile")
+    @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod = "POST")
+    CommonResult uploadFile(@RequestParam("file") MultipartFile file) throws Exception;
+
+}

+ 65 - 0
src/main/java/com/template/common/utils/CustomMultipartFile.java

@@ -0,0 +1,65 @@
+package com.template.common.utils;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+
+/**
+ * @Author: xwt
+ * @Date: 2025/11/5 星期三 15:59
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class CustomMultipartFile implements MultipartFile {
+    private final byte[] fileContent;
+    private final String fileName;
+    private final String contentType;
+
+    public CustomMultipartFile(byte[] fileContent, String fileName, String contentType) {
+        this.fileContent = fileContent;
+        this.fileName = fileName;
+        this.contentType = contentType;
+    }
+
+    @Override
+    public String getName() {
+        return "file";
+    }
+
+    @Override
+    public String getOriginalFilename() {
+        return fileName;
+    }
+
+    @Override
+    public String getContentType() {
+        return contentType;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return fileContent == null || fileContent.length == 0;
+    }
+
+    @Override
+    public long getSize() {
+        return fileContent.length;
+    }
+
+    @Override
+    public byte[] getBytes() throws IOException {
+        return fileContent;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(fileContent);
+    }
+
+    @Override
+    public void transferTo(File dest) throws IOException, IllegalStateException {
+        try (FileOutputStream fos = new FileOutputStream(dest)) {
+            fos.write(fileContent);
+        }
+    }
+}

+ 85 - 20
src/main/java/com/template/common/utils/MultipartFileUtils.java

@@ -1,32 +1,97 @@
 package com.template.common.utils;
 
 import org.springframework.web.multipart.MultipartFile;
-import sun.misc.BASE64Decoder;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
 
 public class MultipartFileUtils {
 
-    public static MultipartFile base64ToMultipartFile (String s) {
-        MultipartFile image = null;
-        StringBuilder base64 = new StringBuilder("");
-        if (s != null && !"".equals(s)) {
-            base64.append(s);
-            String[] baseStrs = base64.toString().split(",");
-            BASE64Decoder decoder = new BASE64Decoder();
-            byte[] b = new byte[0];
-            try {
-                b = decoder.decodeBuffer(baseStrs[1]);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-            for (int j = 0; j < b.length; ++j) {
-                if (b[j] < 0) {
-                    b[j] += 256;
-                }
+    public static MultipartFile base64ToMultipartFile(String base64) {
+        if (base64 == null || base64.isEmpty()) {
+            return null;
+        }
+
+        try {
+            String[] parts = base64.split(",");
+            String header = parts[0];
+            String data = parts[1];
+
+            byte[] bytes = Base64.getDecoder().decode(data);
+
+            String contentType = header.split(":")[1].split(";")[0];
+            String filename = "file_" + System.currentTimeMillis() + getFileExtension(contentType);
+
+            return new CustomMultipartFile(bytes, filename, contentType);
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to convert base64 to MultipartFile", e);
+        }
+    }
+
+    private static String getFileExtension(String contentType) {
+        switch (contentType) {
+            case "image/jpeg": return ".jpg";
+            case "image/png": return ".png";
+            case "image/gif": return ".gif";
+            case "application/pdf": return ".pdf";
+            default: return ".bin";
+        }
+    }
+
+    static class CustomMultipartFile implements MultipartFile {
+        private final byte[] fileContent;
+        private final String fileName;
+        private final String contentType;
+
+        public CustomMultipartFile(byte[] fileContent, String fileName, String contentType) {
+            this.fileContent = fileContent;
+            this.fileName = fileName;
+            this.contentType = contentType;
+        }
+
+        @Override
+        public String getName() {
+            return "file";
+        }
+
+        @Override
+        public String getOriginalFilename() {
+            return fileName;
+        }
+
+        @Override
+        public String getContentType() {
+            return contentType;
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return fileContent == null || fileContent.length == 0;
+        }
+
+        @Override
+        public long getSize() {
+            return fileContent.length;
+        }
+
+        @Override
+        public byte[] getBytes() throws IOException {
+            return fileContent;
+        }
+
+        @Override
+        public InputStream getInputStream() throws IOException {
+            return new ByteArrayInputStream(fileContent);
+        }
+
+        @Override
+        public void transferTo(java.io.File dest) throws IOException, IllegalStateException {
+            // 简单实现,实际使用时可能需要更完善的错误处理
+            try (java.io.FileOutputStream fos = new java.io.FileOutputStream(dest)) {
+                fos.write(fileContent);
             }
-            image = new  BASE64DecodedMultipartFile(b, baseStrs[0]);
         }
-        return image;
     }
 }

+ 292 - 0
src/main/java/com/template/controller/FileController.java

@@ -0,0 +1,292 @@
+package com.template.controller;
+
+import com.jcraft.jsch.*;
+import com.template.annotation.DESRespondSecret;
+import com.template.annotation.PassToken;
+import com.template.api.ExcelControllerAPI;
+import com.template.api.FileControllerAPI;
+import com.template.common.utils.CustomMultipartFile;
+import com.template.common.utils.TimeExchange;
+import com.template.model.pojo.SmartAccess;
+import com.template.model.pojo.SmartApply;
+import com.template.model.pojo.SmartUser;
+import com.template.model.pojo.SystemUser;
+import com.template.model.request.uploadFileResponse;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
+import com.template.services.SmartAccessService;
+import com.template.services.SmartApplyService;
+import com.template.services.SmartUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.net.*;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+//返回参数加密注解
+@DESRespondSecret
+public class FileController implements FileControllerAPI {
+
+    @Autowired
+    private SmartAccessService smartAccessService;
+
+    @Override
+    @PassToken
+    public CommonResult uploadFilesByCos() throws Exception {
+        List<SmartAccess> updateUsers = new ArrayList<>();
+
+        for (int i = 0;i<15000;i++) {
+            Thread.sleep(5000);
+            PageUtils<SmartAccess> pageDatas = smartAccessService.getPageDatas(1,120);
+            List<SmartAccess> users = pageDatas != null && pageDatas.getList().size() > 0 ?  pageDatas.getList() : new ArrayList<>();
+            for (SmartAccess user : users) {
+                if(org.springframework.util.StringUtils.hasText(user.getImage())){
+                    MultipartFile fileData = convert(user.getImage());
+                    String result = uploadFileStatic(fileData,"/home/images/warnings","https://xj.chuanghai-tech.com/wzimage/warnings/");
+                    if(org.springframework.util.StringUtils.hasText(result)){
+                        user.setImage(result);
+                        updateUsers.add(user);
+                    }
+                    else{
+                        String sdsd = "";
+                    }
+
+                }
+            }
+
+            boolean result = smartAccessService.updateBatchById(updateUsers);
+        }
+
+        return CommonResult.ok();
+    }
+
+    //图片格式 头像 https://xj.chuanghai-tech.com/wzimage/355377EF8A889F8C9009ABA2B9F0C08A.png
+    //告警图片 https://xj.chuanghai-tech.com/wzimage/warnings/v2-bb4414441455d233c5d963cbd4c6ba26_xld.jpeg
+    @Override
+    public CommonResult uploadFile(MultipartFile file) throws Exception {
+        //限制文件类型
+        List<String> allowedTypes = new ArrayList<>();
+        allowedTypes.add("image/png");
+        allowedTypes.add("image/jpeg");
+        allowedTypes.add("image/jpg");
+        allowedTypes.add("application/pdf");
+        allowedTypes.add("audio/mpeg");
+        allowedTypes.add("video/mp4");
+        String contentType = file.getContentType();
+
+        if (!allowedTypes.contains(contentType)) {
+            return CommonResult.fail("不支持的文件类型: " + contentType);
+        }
+        System.out.println( "测试上传文件");
+        uploadFileResponse result = new uploadFileResponse();
+        System.out.println( "测试上传文件1");
+        String url = uploadFileStatic(file,"/home/images","https://xj.chuanghai-tech.com/wzimage/");
+        System.out.println( "测试上传文件2");
+        if(org.springframework.util.StringUtils.hasText(url)){
+            result.setFileUrl(url);
+        }else{
+            return CommonResult.fail();
+        }
+        return CommonResult.ok(result);
+    }
+
+    public static String uploadFileStatic(MultipartFile file, String remotePath,String urlEx) throws IOException {
+        uploadFileResponse result = new uploadFileResponse();
+        System.out.println("上传文件进来了");
+        //String name = TimeExchange.DateNowTimeStamo() + "-" + file.getOriginalFilename();
+        String name = file.getOriginalFilename().replace(" ","");
+
+        String fileName = getDecodedFileNameFromUrl(name);
+        if (fileName.contains(",")) {
+            return null;
+        }
+
+        String user = "root"; //SFTP服务器用户名
+        String password = "Chuanghai2023"; // SFTP服务器密码
+        String host = "223.84.177.126";  //  SFTP服务器地址
+        System.out.println("服务器地址"+host);
+        int port = 22; // SFTP 服务器端口
+        String remoteDirPath = remotePath; // 远程目录路径
+
+        String urlexist = urlEx + fileName;
+        if (isImageUrlValid(urlexist)) {
+            result.setFileUrl(urlexist);
+            return result.getFileUrl();
+        }
+
+        //从MultipartFile对象中获取流
+        InputStream inputStream = null;
+        inputStream = file.getInputStream();
+        //String downpath="/book/《Python爬虫开发与项目实战》.pdf";
+        //String spath="C:/Users/F1339769/Desktop";
+        JSch jsch = new JSch();
+        Session session = null;
+        ChannelSftp channelSftp = null;
+        try {
+            session = jsch.getSession(user, host, port);
+            session.setPassword(password);
+            session.setConfig("StrictHostKeyChecking", "no");
+            session.connect(30000);
+            System.out.println("连接成功");
+            channelSftp = (ChannelSftp) session.openChannel("sftp");
+            channelSftp.connect();
+            // 创建远程目录
+            String[] dirArr = remoteDirPath.split("/");
+            String path = "";
+            for (int i = 0; i < dirArr.length; i++) {
+                path = path + "/" + dirArr[i];
+                try {
+                    channelSftp.cd(path);
+                } catch (SftpException e) {
+                    channelSftp.mkdir(path);
+                    channelSftp.cd(path);
+                }
+            }
+            //  文件上传到远程服务器上
+            channelSftp.put(inputStream, fileName);
+            //  从远程服务器上下载文件
+            //channelSftp.get(downpath, spath);
+        } catch (JSchException | SftpException e) {
+            e.printStackTrace();
+        } finally {
+            if (channelSftp != null) {
+                channelSftp.disconnect();
+            }
+            if (session != null) {
+                session.disconnect();
+            }
+
+            String url = urlEx + fileName;
+
+            System.out.println(remoteDirPath);
+            System.out.println(fileName);
+            System.out.println(name);
+
+            if (isImageUrlValid(urlexist)) {
+                result.setFileUrl(url);
+            }else {
+                return null;
+            }
+        }
+        return result.getFileUrl();
+    }
+    public static boolean isImageUrlValid(String imageUrl) {
+        try {
+            URL url = new URL(imageUrl);
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod("HEAD");
+            connection.setConnectTimeout(5000);
+            connection.setReadTimeout(5000);
+
+            int responseCode = connection.getResponseCode();
+
+            // 检查HTTP状态码
+            if (responseCode != HttpURLConnection.HTTP_OK) {
+                return false;
+            }
+
+            // 检查Content-Type是否为图片类型
+            String contentType = connection.getContentType();
+            return contentType != null && contentType.startsWith("image/");
+
+        } catch (IOException e) {
+            return false;
+        }
+    }
+
+    /**
+     * 在线图片地址转换为MultipartFile文件
+     *
+     * @param imageUrl
+     * @return
+     * @throws IOException
+     */
+    public static MultipartFile convert(String imageUrl) throws IOException {
+        System.out.println(imageUrl);
+        URL url = new URL(imageUrl);
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+
+        // 设置请求头,避免被服务器拒绝
+        connection.setRequestProperty("User-Agent", "Mozilla/5.0");
+
+        try (InputStream inputStream = connection.getInputStream();
+             ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+
+            byte[] buffer = new byte[1024];
+            int bytesRead;
+            while ((bytesRead = inputStream.read(buffer)) != -1) {
+                outputStream.write(buffer, 0, bytesRead);
+            }
+
+            byte[] bytes = outputStream.toByteArray();
+            String fileName = extractFilenameFromUrl(imageUrl);
+            String contentType = determineContentTypeFromUrl(imageUrl);
+
+            return new CustomMultipartFile(bytes, fileName, contentType);
+        } finally {
+            connection.disconnect();
+        }
+    }
+
+    /**
+     * 从URL中提取文件名
+     */
+    private static String extractFilenameFromUrl(String imageUrl) {
+        try {
+            String path = new URL(imageUrl).getPath();
+            String filename = path.substring(path.lastIndexOf('/') + 1);
+
+            // 如果文件名没有扩展名,添加默认扩展名
+            if (!filename.contains(".")) {
+                filename += ".jpg";
+            }
+
+            return filename;
+        } catch (Exception e) {
+            return "downloaded_image.jpg";
+        }
+    }
+
+    /**
+     * 根据URL推断内容类型
+     */
+    private static String determineContentTypeFromUrl(String imageUrl) {
+        if (imageUrl.toLowerCase().endsWith(".jpg") || imageUrl.toLowerCase().endsWith(".jpeg")) {
+            return "image/jpeg";
+        } else if (imageUrl.toLowerCase().endsWith(".png")) {
+            return "image/png";
+        } else if (imageUrl.toLowerCase().endsWith(".gif")) {
+            return "image/gif";
+        } else if (imageUrl.toLowerCase().endsWith(".bmp")) {
+            return "image/bmp";
+        } else if (imageUrl.toLowerCase().endsWith(".webp")) {
+            return "image/webp";
+        } else {
+            return "image/jpeg"; // 默认类型
+        }
+    }
+
+    public static String getDecodedFileNameFromUrl(String url) {
+        try {
+            // 提取URL中的文件名部分
+            String fileName = url.substring(url.lastIndexOf('/') + 1);
+
+            // 如果有查询参数,去掉查询参数部分
+            if (fileName.contains("?")) {
+                fileName = fileName.substring(0, fileName.indexOf("?"));
+            }
+
+            // URL解码
+            return URLDecoder.decode(fileName, "UTF-8");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+}

+ 2 - 0
src/main/java/com/template/controller/LoginController.java

@@ -55,7 +55,9 @@ public class LoginController implements LoginControllerAPI {
     @DESRespondSecret(validated = true)
     @PassToken
     public CommonResult getAesStr(){
+        System.out.println("获取登录码");
         String str = wechatScanLoginService.getAesStr();
+        System.out.println("获取登录码1");
         return CommonResult.ok("200","state参数",str);
     }
 

+ 19 - 5
src/main/java/com/template/controller/SmartFaceDiscernController.java

@@ -317,14 +317,18 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
     @DESRespondSecret(validated = false)
     public String callBack(HttpServletRequest request, HttpServletResponse response) {
         try {
+            System.out.println("测试是否正确进入百胜设备推送");
             BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
+            System.out.println(1);
             StringBuilder responseStrBuilder = new StringBuilder();
+            System.out.println(2);
             String inputStr;
             while ((inputStr = streamReader.readLine()) != null) {
                 responseStrBuilder.append(inputStr);
             }
+            System.out.println(3);
             JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
-
+            System.out.println(4);
             DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
             //                比对时间
             String time = jsonObject.getString("time");
@@ -370,13 +374,14 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
                 }
             }
 
+            System.out.println("推送平台数据1");
 //                    出入标识: 1-进, 0-出
             Integer inout = jsonObject.getInteger("inout");
 //                    开门方式:0-白名单比对,1-人证比对,2-IC卡比对
             Integer openType = jsonObject.getInteger("openType");
-
+            System.out.println("推送平台数据2");
             SmartAccess smartFaceDiscern = new SmartAccess();
-
+            System.out.println("推送平台数据3");
             smartFaceDiscern.setName(s);
             smartFaceDiscern.setLocation(address);
             smartFaceDiscern.setType(type);
@@ -387,6 +392,7 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
             smartFaceDiscern.setInOut(inout);
             smartFaceDiscern.setOpenType(openType);
             smartFaceDiscern.setResultStatus(resultStatus);
+            System.out.println("推送平台数据4");
             if (userId != 0) {
                 //                    判断是否已经添加
                 LambdaQueryWrapper<SmartAccess> wrapperFD = new LambdaQueryWrapper<>();
@@ -397,13 +403,19 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
                     //          抓拍的照片 base64字符串
                     String scenePhoto = jsonObject.getString("scenePhoto");
                     scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+
                     logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
+                    System.out.println("推送平台数据4.1");
+                    System.out.println(scenePhoto);
 //            base64转文件
                     MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                    System.out.println("推送平台数据4.2");
                     String image = "";
+                    System.out.println("推送平台数据4.3");
                     try {
                         //            上传到cos桶,并生成图片地址
-                        image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                        //image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                        image = FileController.uploadFileStatic(multipartFile,"/home/images/warnings","https://xj.chuanghai-tech.com/wzimage/warnings/");
                     } catch (Exception e) {
                         e.printStackTrace();
                         logger.error("上传cos桶失败");
@@ -501,6 +513,7 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
 
                             }
                         }
+                        System.out.println("推送平台数据5");
 
                         //                    获取推送配置
                         List<SmartPushConfig> pushConfigs = smartPushConfigService.list(new LambdaQueryWrapper<>());
@@ -615,7 +628,8 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
                     String image = "";
                     try {
                         //            上传到cos桶,并生成图片地址
-                        image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                        //image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                        image = FileController.uploadFileStatic(multipartFile,"/home/images/warnings","https://xj.chuanghai-tech.com/wzimage/warnings/");
                     } catch (Exception e) {
                         e.printStackTrace();
                         logger.error("上传cos桶失败");

+ 1 - 1
src/main/java/com/template/controller/SmartScoreController.java

@@ -881,7 +881,7 @@ public class SmartScoreController implements SmartScoreControllerAPI {
     @Override
     @DESRespondSecret(validated = true)
     public CommonResult downloadScoreExcel() {
-        return CommonResult.ok("200", "操作成功", "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/成绩信息表.xlsx");
+        return CommonResult.ok("200", "操作成功", "https://xj.chuanghai-tech.com/wzimage/excelModel/成绩信息表.xlsx");
     }
 
     @Override

+ 14 - 9
src/main/java/com/template/controller/SmartUserController.java

@@ -503,7 +503,7 @@ public class SmartUserController implements SmartUserControllerAPI {
         String uploadResult = smartUploadService.upload(multipartFileHashMap.toArray(new MultipartFile[0]));
         List<String> uploadImages = Arrays.asList(uploadResult.split(","));
         for (SmartUser user : result) {
-            Optional<String> headImage = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/headImage/" + user.getHeadImage())).findFirst();
+            Optional<String> headImage = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://xj.chuanghai-tech.com/wzimage/headImage/" + user.getHeadImage())).findFirst();
             if (headImage != null && headImage.isPresent()) {
                 user.setHeadImage(headImage.get());
             }
@@ -600,7 +600,7 @@ public class SmartUserController implements SmartUserControllerAPI {
 
         List<String> uploadImages = Arrays.asList(headImage.split(","));
         for (SmartUser user : result) {
-            Optional<String> image = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/" + user.getHeadImage())).findFirst();
+            Optional<String> image = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://xj.chuanghai-tech.com/wzimage/" + user.getHeadImage())).findFirst();
             if (image != null && image.isPresent()) {
                 user.setHeadImage(image.get());
             } else {
@@ -727,7 +727,6 @@ public class SmartUserController implements SmartUserControllerAPI {
                         student.setXwStudentUid(seewoResultData.get().getUserUid());
                     }
                 }
-
             }
 
 
@@ -1339,7 +1338,10 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             user.setIsCancel(eLogOff.Unlogout.getValue());
-
+                            String xwid = dataFormatter.formatCellValue(row.getCell(18));//希沃id
+                            if (!ObjectUtils.isEmpty(xwid)) {
+                                user.setXwStudentUid(xwid);
+                            }
                             result.add(user);
 
                             //部门是否为空判断
@@ -1812,7 +1814,10 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             user.setIsCancel(eLogOff.Unlogout.getValue());
-
+                            String xwid = dataFormatter.formatCellValue(row.getCell(18));//希沃id
+                            if (!ObjectUtils.isEmpty(xwid)) {
+                                user.setXwStudentUid(xwid);
+                            }
                             result.add(user);
 
                             //部门是否为空判断
@@ -2437,7 +2442,7 @@ public class SmartUserController implements SmartUserControllerAPI {
             }
             List<String> uploadImages = Arrays.asList(headImage.split(","));
             for (SmartUser user : insertStudents) {
-                Optional<String> image = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/" + user.getHeadImage())).findFirst();
+                Optional<String> image = uploadImages == null ? null : uploadImages.stream().filter(e -> e.equals("https://xj.chuanghai-tech.com/wzimage/" + user.getHeadImage())).findFirst();
                 if (image != null && image.isPresent()) {
                     user.setHeadImage(image.get());
                 } else {
@@ -8226,7 +8231,7 @@ public class SmartUserController implements SmartUserControllerAPI {
     @DESRespondSecret(validated = true)
     public CommonResult downloadUserExcel
     () {
-        return CommonResult.ok("200", "操作成功", "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/人员信息表.xlsx");
+        return CommonResult.ok("200", "操作成功", "https://xj.chuanghai-tech.com/wzimage/excelModel/人员信息表.xlsx");
     }
     //endregion
 
@@ -8235,7 +8240,7 @@ public class SmartUserController implements SmartUserControllerAPI {
     @DESRespondSecret(validated = true)
     public CommonResult downloadTeacherExcel
     () {
-        return CommonResult.ok("200", "操作成功", "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/教师信息表.xlsx");
+        return CommonResult.ok("200", "操作成功", "https://xj.chuanghai-tech.com/wzimage/excelModel/教师信息表.xlsx");
     }
     //endregion
 
@@ -8244,7 +8249,7 @@ public class SmartUserController implements SmartUserControllerAPI {
     @DESRespondSecret(validated = true)
     public CommonResult downloadUpdateUserExcel
     () {
-        return CommonResult.ok("200", "操作成功", "https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/更新信息表.xlsx");
+        return CommonResult.ok("200", "操作成功", "https://xj.chuanghai-tech.com/wzimage/excelModel/更新信息表.xlsx");
     }
     //endregion
 

+ 1 - 1
src/main/java/com/template/controller/UploadController.java

@@ -56,7 +56,7 @@ public class UploadController implements UploadControllerAPI {
         //1、初始化
         COSCredentials cred = new BasicCOSCredentials("AKIDCPVZdcWIxgHpy5FYxVyPiqkZGrhdXUBg", "NkyCN3cz97qKaeXLvHOGxOcdS8f184pL");
 
-        //2、设置所属地域:https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com
+        //2、设置所属地域:https://xj.chuanghai-tech.com/wzimage
         ClientConfig clientConfig = new ClientConfig();
         Region region = new Region("ap-shanghai");//更换为cos所属地域
         clientConfig.setRegion(region);

+ 19 - 0
src/main/java/com/template/model/request/uploadFileResponse.java

@@ -0,0 +1,19 @@
+package com.template.model.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+
+/**
+ * 设备指令响应
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class uploadFileResponse implements Serializable {
+    private String fileUrl;
+}
+

+ 2 - 0
src/main/java/com/template/services/SmartAccessService.java

@@ -21,6 +21,8 @@ public interface SmartAccessService extends IService<SmartAccess> {
 
     List<SmartAccess> track(String stateTime, String endTime, Integer id);
 
+    PageUtils<SmartAccess> getPageDatas(Integer currentPage, Integer pageCount);
+
     PageUtils<SmartAccessVo> getPage(Integer currentPage, Integer pageCount,String keyWord,Integer gradeId, Integer classId, Integer departmentId,String openType,String resultStatus,String startTime,String endTime);
 
     List<SmartAccessVo> getPageExport(String keyWord, Integer gradeId, Integer classId, Integer departmentId,String openType,String resultStatus, String startTime, String endTime);

+ 2 - 0
src/main/java/com/template/services/SmartUserService.java

@@ -24,6 +24,8 @@ public interface SmartUserService extends IService<SmartUser> {
 
     int updateSmartUser(SmartUser rns);
 
+    PageUtils<SmartUser> queryPageSmartUserDatas(int currentPage, int pageCount);
+
     PageUtils<SmartUser> queryPageSmartUsers(int currentPage, int pageCount, List<Integer> departmentIds);
 
     List<SmartUser> getSmartUserByIds(List<Integer> ids);

+ 12 - 0
src/main/java/com/template/services/impl/SmartAccessServiceImpl.java

@@ -1,11 +1,13 @@
 package com.template.services.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.template.model.pojo.SmartAccess;
 import com.template.mapper.SmartAccessMapper;
 import com.template.model.pojo.SmartFaceDiscern;
+import com.template.model.pojo.SmartUser;
 import com.template.model.result.PageUtils;
 import com.template.model.vo.SmartAccessVo;
 import com.template.model.vo.VisitorPageVo;
@@ -42,6 +44,16 @@ public class SmartAccessServiceImpl extends ServiceImpl<SmartAccessMapper, Smart
     }
 
     @Override
+    public PageUtils<SmartAccess> getPageDatas(Integer currentPage, Integer pageCount) {
+        Page<SmartAccess> page = new Page<>(currentPage, pageCount);
+        QueryWrapper<SmartAccess> queryWrapper = new QueryWrapper<>();
+        queryWrapper.notLike("image", "https://xj.chuanghai-tech.com/wzimage/");
+        queryWrapper.orderByDesc("create_time");
+        IPage<SmartAccess> result = smartAccessMapper.selectPage(page, queryWrapper);
+        return new PageUtils<>(result);
+    }
+
+    @Override
     public PageUtils<SmartAccessVo> getPage(Integer currentPage, Integer pageCount,String keyWord,Integer gradeId, Integer classId, Integer departmentId, String openType,String resultStatus,String startTime,String endTime) {
         Page<SmartAccessVo> page = new Page<>();
         page.setCurrent(currentPage);

+ 9 - 0
src/main/java/com/template/services/impl/SmartUserServiceImpl.java

@@ -48,6 +48,15 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
     }
 
     @Override
+    public PageUtils<SmartUser> queryPageSmartUserDatas(int currentPage, int pageCount) {
+        Page<SmartUser> page = new Page<>(currentPage, pageCount);
+        QueryWrapper<SmartUser> queryWrapper = new QueryWrapper<>();
+        queryWrapper.notLike("head_image", "https://xj.chuanghai-tech.com/wzimage/");
+        IPage<SmartUser> result = smartUserMapper.selectPage(page, queryWrapper);
+        return new PageUtils<>(result);
+    }
+
+    @Override
     public PageUtils<SmartUser> queryPageSmartUsers(int currentPage, int pageCount, List<Integer> departmentIds) {
         Page<SmartUser> page = new Page<>(currentPage, pageCount);
 //        QueryWrapper<SmartUser> queryWrapper = new QueryWrapper<>();

+ 4 - 0
src/main/java/com/template/services/impl/WechatScanLoginServiceImpl.java

@@ -76,9 +76,13 @@ public class WechatScanLoginServiceImpl implements WechatScanLoginService {
 
     @Override
     public String getAesStr(){
+        System.out.println("获取登录码2");
         String content = Constanst.PWD_MD5 + DateUtils.getYYYYMMdd();
+        System.out.println("获取登录码3");
         byte[] encrypt = AesUtil.encrypt(content, AesUtil.PASSWORD_SECRET_KEY, 16);
+        System.out.println("获取登录码4");
         String parseByte2HexStr = AesUtil.parseByte2HexStr(encrypt);
+        System.out.println("获取登录码5");
         return parseByte2HexStr;
     }
 

+ 1 - 1
src/main/resources/application-dev.yml

@@ -51,7 +51,7 @@ cos:
   secretKey: NkyCN3cz97qKaeXLvHOGxOcdS8f184pL
   region: ap-shanghai
   bucketName: wanzai-1306339220
-  path: https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com
+  path: https://xj.chuanghai-tech.com/wzimage
 
 #希沃班牌相关配置信息
 seewo:

+ 4 - 4
src/main/resources/application-prod.yml

@@ -12,8 +12,8 @@ spring:
       max-request-size: 150MB
   datasource:
     username: root
-    password: Chuanghai2023.
-    url: jdbc:mysql://111.231.169.217:3306/smart_middle?useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+    password: asdf()!#321
+    url: jdbc:mysql://43.139.211.126:3306/smart_middle?useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
       type: redis
@@ -51,7 +51,7 @@ cos:
   secretKey: NkyCN3cz97qKaeXLvHOGxOcdS8f184pL
   region: ap-shanghai
   bucketName: wanzai-1306339220
-  path: https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com
+  path: https://xj.chuanghai-tech.com/wzimage
 
 #希沃班牌相关配置信息
 seewo:
@@ -88,7 +88,7 @@ tencentcloud:
 #1:开启
 #0:关闭
 schedule:
-  isOpen: 1
+  isOpen: 0
 
 ding:
   #钉钉配置