From 21345aaa5d9f3a9f66f78e4b22b523b0500ab797 Mon Sep 17 00:00:00 2001 From: bonus <1203338439@qq.com> Date: Mon, 11 Dec 2023 10:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E9=AA=8C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E3=80=81=E4=BF=9D=E9=99=A9=E4=BF=A1=E6=81=AF=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E8=AF=A2=EF=BC=8C=E7=9F=AD=E4=BF=A1=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DevInfoServiceImpl.java | 17 +- .../main/resources/mapper/DevInfoMapper.xml | 14 +- .../bonus/zlpt/file/config/MinioConfig.java | 164 +++++++++--------- .../zlpt/file/config/ResourcesConfig.java | 100 +++++------ .../file/controller/SysFileController.java | 96 +++++----- .../file/service/MinioSysFileServiceImpl.java | 98 +++++------ .../zlpt/system/config/SmsComponent.java | 11 +- .../system/service/impl/ISmsServiceImpl.java | 2 +- .../src/main/resources/bootstrap.yml | 20 +-- 9 files changed, 263 insertions(+), 259 deletions(-) diff --git a/zlpt-modules/zlpt-equip/src/main/java/com/bonus/zlpt/equip/service/impl/DevInfoServiceImpl.java b/zlpt-modules/zlpt-equip/src/main/java/com/bonus/zlpt/equip/service/impl/DevInfoServiceImpl.java index bb5dff8..292a0c4 100644 --- a/zlpt-modules/zlpt-equip/src/main/java/com/bonus/zlpt/equip/service/impl/DevInfoServiceImpl.java +++ b/zlpt-modules/zlpt-equip/src/main/java/com/bonus/zlpt/equip/service/impl/DevInfoServiceImpl.java @@ -34,12 +34,12 @@ import static com.bonus.zlpt.common.core.web.domain.AjaxResult.error; /** * 设备信息Service业务层处理 - * + * * @author xsheng * @date 2023-12-02 */ @Service -public class DevInfoServiceImpl implements IDevInfoService +public class DevInfoServiceImpl implements IDevInfoService { private final Integer ASPECT_PICTURE = 20; private final Integer EXAMINATION_PDF = 28; @@ -54,7 +54,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 查询设备信息 - * + * * @param maId 设备信息主键 * @return 设备信息 */ @@ -121,7 +121,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 查询设备信息列表 - * + * * @param devInfo 设备信息 * @return 设备信息 */ @@ -204,6 +204,7 @@ public class DevInfoServiceImpl implements IDevInfoService // } if (devInfoVo.getCityId().equals(Integer.valueOf(address.getCode()))) { devInfoVo.setCityStr(address.getName()); + break; } // if (String.valueOf(devInfoVo.getAreaId()).equals(String.valueOf(address.getId()))) { // devInfoVo.setAreaStr(address.getName()); @@ -214,7 +215,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 新增设备信息 - * + * * @param devInfo 设备信息 * @return 结果 */ @@ -243,7 +244,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 修改设备信息 - * + * * @param devInfo 设备信息 * @return 结果 */ @@ -256,7 +257,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 批量删除设备信息 - * + * * @param maIds 需要删除的设备信息主键 * @return 结果 */ @@ -268,7 +269,7 @@ public class DevInfoServiceImpl implements IDevInfoService /** * 删除设备信息信息 - * + * * @param maId 设备信息主键 * @return 结果 */ diff --git a/zlpt-modules/zlpt-equip/src/main/resources/mapper/DevInfoMapper.xml b/zlpt-modules/zlpt-equip/src/main/resources/mapper/DevInfoMapper.xml index 12f15f6..5f19f3b 100644 --- a/zlpt-modules/zlpt-equip/src/main/resources/mapper/DevInfoMapper.xml +++ b/zlpt-modules/zlpt-equip/src/main/resources/mapper/DevInfoMapper.xml @@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join ma_type_info mt2 on mt1.parent_id = mt2.type_id left join ma_type_info mt3 on mt2.parent_id = mt3.type_id left join bm_company_info c on d.own_co = c.company_id - + and d.ma_id = #{maId} and d.code = #{code} @@ -251,16 +251,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT s.dic_id, s.file_name as name,s.file_url as url from ma_dev_info d left join sys_file_info s on d.ma_id = s.model_id - WHERE d.ma_id = #{maId} and d.is_active='1' and s.dic_id = 20 + WHERE d.ma_id = #{maId} and d.is_active='1' and s.dic_id in (20,28,29) - + insert into ma_dev_info @@ -458,4 +458,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join ma_up_off u on d.ma_id = u.ma_id ORDER BY d.create_time desc - \ No newline at end of file + diff --git a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/MinioConfig.java b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/MinioConfig.java index ca59c2e..34ae281 100644 --- a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/MinioConfig.java +++ b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/MinioConfig.java @@ -1,82 +1,82 @@ -package com.bonus.zlpt.file.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import io.minio.MinioClient; - -/** - * Minio 配置信息 - * - * @author ruoyi - */ -@Configuration -@ConfigurationProperties(prefix = "minio") -public class MinioConfig -{ - /** - * 服务地址 - */ - private String url; - - /** - * 用户名 - */ - private String accessKey; - - /** - * 密码 - */ - private String secretKey; - - /** - * 存储桶名称 - */ - private String bucketName; - - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - public String getAccessKey() - { - return accessKey; - } - - public void setAccessKey(String accessKey) - { - this.accessKey = accessKey; - } - - public String getSecretKey() - { - return secretKey; - } - - public void setSecretKey(String secretKey) - { - this.secretKey = secretKey; - } - - public String getBucketName() - { - return bucketName; - } - - public void setBucketName(String bucketName) - { - this.bucketName = bucketName; - } - - @Bean - public MinioClient getMinioClient() - { - return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build(); - } -} +//package com.bonus.zlpt.file.config; +// +//import org.springframework.boot.context.properties.ConfigurationProperties; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import io.minio.MinioClient; +// +///** +// * Minio 配置信息 +// * +// * @author ruoyi +// */ +//@Configuration +//@ConfigurationProperties(prefix = "minio") +//public class MinioConfig +//{ +// /** +// * 服务地址 +// */ +// private String url; +// +// /** +// * 用户名 +// */ +// private String accessKey; +// +// /** +// * 密码 +// */ +// private String secretKey; +// +// /** +// * 存储桶名称 +// */ +// private String bucketName; +// +// public String getUrl() +// { +// return url; +// } +// +// public void setUrl(String url) +// { +// this.url = url; +// } +// +// public String getAccessKey() +// { +// return accessKey; +// } +// +// public void setAccessKey(String accessKey) +// { +// this.accessKey = accessKey; +// } +// +// public String getSecretKey() +// { +// return secretKey; +// } +// +// public void setSecretKey(String secretKey) +// { +// this.secretKey = secretKey; +// } +// +// public String getBucketName() +// { +// return bucketName; +// } +// +// public void setBucketName(String bucketName) +// { +// this.bucketName = bucketName; +// } +// +// @Bean +// public MinioClient getMinioClient() +// { +// return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build(); +// } +//} diff --git a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/ResourcesConfig.java b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/ResourcesConfig.java index 1543731..61e9bc2 100644 --- a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/ResourcesConfig.java +++ b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/config/ResourcesConfig.java @@ -1,50 +1,50 @@ -package com.bonus.zlpt.file.config; - -import java.io.File; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * 通用映射配置 - * - * @author ruoyi - */ -@Configuration -public class ResourcesConfig implements WebMvcConfigurer -{ - /** - * 上传文件存储在本地的根路径 - */ - @Value("${file.path}") - private String localFilePath; - - /** - * 资源映射路径 前缀 - */ - @Value("${file.prefix}") - public String localFilePrefix; - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) - { - /** 本地文件上传路径 */ - registry.addResourceHandler(localFilePrefix + "/**") - .addResourceLocations("file:" + localFilePath + File.separator); - } - - /** - * 开启跨域 - */ - @Override - public void addCorsMappings(CorsRegistry registry) { - // 设置允许跨域的路由 - registry.addMapping(localFilePrefix + "/**") - // 设置允许跨域请求的域名 - .allowedOrigins("*") - // 设置允许的方法 - .allowedMethods("GET"); - } -} \ No newline at end of file +//package com.bonus.zlpt.file.config; +// +//import java.io.File; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.web.servlet.config.annotation.CorsRegistry; +//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +// +///** +// * 通用映射配置 +// * +// * @author ruoyi +// */ +//@Configuration +//public class ResourcesConfig implements WebMvcConfigurer +//{ +// /** +// * 上传文件存储在本地的根路径 +// */ +// @Value("${file.path}") +// private String localFilePath; +// +// /** +// * 资源映射路径 前缀 +// */ +// @Value("${file.prefix}") +// public String localFilePrefix; +// +// @Override +// public void addResourceHandlers(ResourceHandlerRegistry registry) +// { +// /** 本地文件上传路径 */ +// registry.addResourceHandler(localFilePrefix + "/**") +// .addResourceLocations("file:" + localFilePath + File.separator); +// } +// +// /** +// * 开启跨域 +// */ +// @Override +// public void addCorsMappings(CorsRegistry registry) { +// // 设置允许跨域的路由 +// registry.addMapping(localFilePrefix + "/**") +// // 设置允许跨域请求的域名 +// .allowedOrigins("*") +// // 设置允许的方法 +// .allowedMethods("GET"); +// } +//} diff --git a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/controller/SysFileController.java b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/controller/SysFileController.java index 7371bc2..2a0069d 100644 --- a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/controller/SysFileController.java +++ b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/controller/SysFileController.java @@ -1,48 +1,48 @@ -package com.bonus.zlpt.file.controller; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import com.bonus.zlpt.common.core.domain.R; -import com.bonus.zlpt.common.core.utils.file.FileUtils; -import com.bonus.zlpt.file.service.ISysFileService; -import com.bonus.zlpt.system.api.domain.SysFile; - -/** - * 文件请求处理 - * - * @author ruoyi - */ -@RestController -public class SysFileController -{ - private static final Logger log = LoggerFactory.getLogger(SysFileController.class); - - @Autowired - private ISysFileService sysFileService; - - /** - * 文件上传请求 - */ - @PostMapping("upload") - public R upload(MultipartFile file) - { - try - { - // 上传并返回访问地址 - String url = sysFileService.uploadFile(file); - SysFile sysFile = new SysFile(); - sysFile.setName(FileUtils.getName(url)); - sysFile.setUrl(url); - return R.ok(sysFile); - } - catch (Exception e) - { - log.error("上传文件失败", e); - return R.fail(e.getMessage()); - } - } -} \ No newline at end of file +//package com.bonus.zlpt.file.controller; +// +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RestController; +//import org.springframework.web.multipart.MultipartFile; +//import com.bonus.zlpt.common.core.domain.R; +//import com.bonus.zlpt.common.core.utils.file.FileUtils; +//import com.bonus.zlpt.file.service.ISysFileService; +//import com.bonus.zlpt.system.api.domain.SysFile; +// +///** +// * 文件请求处理 +// * +// * @author ruoyi +// */ +//@RestController +//public class SysFileController +//{ +// private static final Logger log = LoggerFactory.getLogger(SysFileController.class); +// +// @Autowired +// private ISysFileService sysFileService; +// +// /** +// * 文件上传请求 +// */ +// @PostMapping("upload") +// public R upload(MultipartFile file) +// { +// try +// { +// // 上传并返回访问地址 +// String url = sysFileService.uploadFile(file); +// SysFile sysFile = new SysFile(); +// sysFile.setName(FileUtils.getName(url)); +// sysFile.setUrl(url); +// return R.ok(sysFile); +// } +// catch (Exception e) +// { +// log.error("上传文件失败", e); +// return R.fail(e.getMessage()); +// } +// } +//} diff --git a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/service/MinioSysFileServiceImpl.java b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/service/MinioSysFileServiceImpl.java index ed79721..14d2a3f 100644 --- a/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/service/MinioSysFileServiceImpl.java +++ b/zlpt-modules/zlpt-file/src/main/java/com/bonus/zlpt/file/service/MinioSysFileServiceImpl.java @@ -1,49 +1,49 @@ -package com.bonus.zlpt.file.service; - -import java.io.InputStream; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import com.alibaba.nacos.common.utils.IoUtils; -import com.bonus.zlpt.file.config.MinioConfig; -import com.bonus.zlpt.file.utils.FileUploadUtils; -import io.minio.MinioClient; -import io.minio.PutObjectArgs; - -/** - * Minio 文件存储 - * - * @author ruoyi - */ -@Service -public class MinioSysFileServiceImpl implements ISysFileService -{ - @Autowired - private MinioConfig minioConfig; - - @Autowired - private MinioClient client; - - /** - * Minio文件上传接口 - * - * @param file 上传的文件 - * @return 访问地址 - * @throws Exception - */ - @Override - public String uploadFile(MultipartFile file) throws Exception - { - String fileName = FileUploadUtils.extractFilename(file); - InputStream inputStream = file.getInputStream(); - PutObjectArgs args = PutObjectArgs.builder() - .bucket(minioConfig.getBucketName()) - .object(fileName) - .stream(inputStream, file.getSize(), -1) - .contentType(file.getContentType()) - .build(); - client.putObject(args); - IoUtils.closeQuietly(inputStream); - return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; - } -} +//package com.bonus.zlpt.file.service; +// +//import java.io.InputStream; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import org.springframework.web.multipart.MultipartFile; +//import com.alibaba.nacos.common.utils.IoUtils; +//import com.bonus.zlpt.file.config.MinioConfig; +//import com.bonus.zlpt.file.utils.FileUploadUtils; +//import io.minio.MinioClient; +//import io.minio.PutObjectArgs; +// +///** +// * Minio 文件存储 +// * +// * @author ruoyi +// */ +//@Service +//public class MinioSysFileServiceImpl implements ISysFileService +//{ +//// @Autowired +//// private MinioConfig minioConfig; +// +// @Autowired +// private MinioClient client; +// +// /** +// * Minio文件上传接口 +// * +// * @param file 上传的文件 +// * @return 访问地址 +// * @throws Exception +// */ +// @Override +// public String uploadFile(MultipartFile file) throws Exception +// { +// String fileName = FileUploadUtils.extractFilename(file); +// InputStream inputStream = file.getInputStream(); +// PutObjectArgs args = PutObjectArgs.builder() +// .bucket(minioConfig.getBucketName()) +// .object(fileName) +// .stream(inputStream, file.getSize(), -1) +// .contentType(file.getContentType()) +// .build(); +// client.putObject(args); +// IoUtils.closeQuietly(inputStream); +// return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; +// } +//} diff --git a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java index 0c8442f..cf61b03 100644 --- a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java +++ b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -86,10 +87,12 @@ public class SmsComponent { req.setPhoneNumberSet(phoneNumberSet); req.setSignName(signName); req.setTemplateId(templateId); - // 根据模板所需参数量选择 - String[] templateParamSetOne = {code}; - String[] templateParamSetTwo = {code,param2}; - req.setTemplateParamSet(templateParamSetOne); + String[] templateParamSet = new String[2]; + templateParamSet[0] = code; + if (templateId.equals("2014506")){ + templateParamSet[1] = param2; + } + req.setTemplateParamSet(templateParamSet); return req; // 返回请求参数内容 } diff --git a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/service/impl/ISmsServiceImpl.java b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/service/impl/ISmsServiceImpl.java index 2380878..b0fd7ac 100644 --- a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/service/impl/ISmsServiceImpl.java +++ b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/service/impl/ISmsServiceImpl.java @@ -61,7 +61,7 @@ public class ISmsServiceImpl implements ISmsService { String code = getSixBitCode(); // 生成新的验证码 //存储 phone -> code到Redis中 redisCache.setCacheObject(RedisConstants.REDIS_PHONE_CODE_KEY + phone, code, Long.parseLong(leastTime+""), TimeUnit.MILLISECONDS); - smsComponent.sendCode(phone, code,"",type); + smsComponent.sendCode(phone, code,""+leastTime/1000/60,type); return "已发送验证码 " + phone; } diff --git a/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml b/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml index 51c5bb9..1aa190d 100644 --- a/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml +++ b/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml @@ -7,11 +7,11 @@ tencent: sms: # 腾讯云账户API访问密钥 secretId: AKIDbF1pTyU6iHn6EH9uc9O6kJgrrfI2rV04 - keysecret: zGPRJ9z68AGZVMAoHYyDFDAxhR2Xs0Qf + secretKey: zGPRJ9z68AGZVMAoHYyDFDAxhR2Xs0Qf # 短信应用ID - smsSdkAppId: 1400874270 + sdkAppId: 1400874270 # 短信签名内容 - signName: 南网机具租赁共享平台 + signName: 作业智慧管控系统小程序 # 正文模板ID templateCodeIds: 1: 2014506 @@ -35,19 +35,19 @@ spring: name: zlpt-system profiles: # 环境配置 - active: zlpt_cloud_de + active: zlpt_cloud_dev cloud: nacos: - # username: nacos - # password: Bonus@admin123! + username: nacos + password: nacos discovery: # 服务注册地址 - server-addr: 10.40.92.74:8848 - namespace: zlpt_cloud_de + server-addr: 127.0.0.1:8848 + namespace: zlpt_cloud_dev config: # 配置中心地址 - server-addr: 10.40.92.74:8848 - namespace: zlpt_cloud_de + server-addr: 127.0.0.1:8848 + namespace: zlpt_cloud_dev # 配置文件格式 file-extension: yml # 共享配置