lyhzzz 1 год назад
Родитель
Сommit
e584704a5e

+ 9 - 1
README.md

@@ -52,7 +52,7 @@
 ~~~~
 
 
-###**xj**
+###**xj-1.0.0**
 ~~~~
 1.设置支持上传自定义图片
     http://120.25.146.52:3090/project/369/interface/api/cat_1905
@@ -66,4 +66,12 @@
     http://120.25.146.52:3090/project/369/interface/api/cat_1917
 6.照片制卷管理
     http://120.25.146.52:3090/project/369/interface/api/cat_1921
+~~~~
+
+###**xj-1.0.0补充**
+~~~~
+1. /changePassword 修改密码接口修改,去掉code参数,增加oldPassword参数
+2. /web/user/restPassword 新增接口,重置密码
+    http://120.25.146.52:3090/project/369/interface/api/10296
+    
 ~~~~

+ 1 - 0
src/main/java/com/fdkankan/fusion/common/FilePath.java

@@ -17,6 +17,7 @@ public class FilePath {
    public final static String VIDEO_LOCAL_PATH = LOCAL_BASE_PATH + "%s/video/merge";
    public final static String OBJ_LOCAL_PATH = LOCAL_BASE_PATH + "%s/model/%s";
    public final static String SCENE_LOCAL_PATH = LOCAL_BASE_PATH + "%s/scene/%s";
+   public final static String SCENE_LOCAL_PATH = LOCAL_BASE_PATH + "%s/scene/%s";
 
 
 }

+ 49 - 0
src/main/java/com/fdkankan/fusion/common/util/Base64Converter.java

@@ -0,0 +1,49 @@
+package com.fdkankan.fusion.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+public class Base64Converter {
+
+    public static final Base64.Encoder encoder = Base64.getEncoder();
+    static final Base64.Decoder decoder = Base64.getDecoder();
+
+    public Base64Converter() {
+    }
+
+    public static String encode(String text) {
+        byte[] textByte = new byte[0];
+
+        try {
+            textByte = text.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException var3) {
+            var3.printStackTrace();
+        }
+
+        String encodedText = encoder.encodeToString(textByte);
+        return encodedText;
+    }
+
+    public static String encode(byte[] textByte) {
+        return encoder.encodeToString(textByte);
+    }
+
+    public static String decode(String encodedText) {
+        String text = null;
+
+        try {
+            text = new String(decoder.decode(encodedText), "UTF-8");
+        } catch (UnsupportedEncodingException var3) {
+            var3.printStackTrace();
+        }
+
+        return text;
+    }
+
+    public static String subText(String text) {
+        text = text.substring(8);
+        text = text.substring(0, text.length() - 8);
+        String result = text.substring(text.length() - 2) + text.substring(0, text.length() - 10);
+        return result;
+    }
+}

+ 69 - 0
src/main/java/com/fdkankan/fusion/controller/CameraVersionController.java

@@ -0,0 +1,69 @@
+package com.fdkankan.fusion.controller;
+
+
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.entity.CameraVersion;
+import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.request.CameraVersionParam;
+import com.fdkankan.fusion.service.ICameraVersionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * 相机版本表 前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-23
+ */
+@RestController
+@RequestMapping("/fusion/cameraVersion")
+public class CameraVersionController {
+
+    @Autowired
+    ICameraVersionService cameraVersionService;
+
+    /**
+     * 上传文件
+     * type     相机类型,1八目,2双目,不传默认八目
+     * file       文件流
+     * version    版本
+     * description  描述
+     */
+    @PostMapping(value = "/addAndUpload", consumes = { "multipart/form-data" })
+    public ResultData upload(@RequestParam("file") MultipartFile file,
+                             @RequestParam("version") String version,
+                             @RequestParam("description") String description,
+                             @RequestParam("minVersion") String minVersion,
+                             @RequestParam(value = "type",defaultValue = "1") Integer type) throws IOException {
+        cameraVersionService.addAndUpload(file,version,description,minVersion,type);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/update")
+    public ResultData update(@RequestBody CameraVersion param){
+        cameraVersionService.updateByParam(param);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/delete")
+    public ResultData delete(@RequestBody CameraVersion param){
+        if(param.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        cameraVersionService.removeById(param.getId());
+        return ResultData.ok();
+    }
+
+    @PostMapping("/list")
+    public ResultData list(@RequestBody CameraVersionParam param){
+        return ResultData.ok(cameraVersionService.pageList(param));
+    }
+}
+

+ 16 - 0
src/main/java/com/fdkankan/fusion/controller/TmUserController.java

@@ -98,5 +98,21 @@ public class TmUserController {
     public ResultData getUserListSelect( @RequestParam(name = "deptId", required = false) String deptId) {
         return ResultData.ok(tmUserService.getUserListSelect(deptId));
     }
+
+    /**
+     * 重置密码
+     */
+    @PostMapping("/restPassword")
+    public ResultData restPassword(@RequestBody UserAddRequest param){
+        if(StringUtils.isBlank(param.getUserName())){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        param.setClear("YES");
+        param.setPassword("Xj123456");
+        param.setConfirmPwd("Xj123456");
+        param.setOldPassword("Xj123456");
+        tmUserService.changePassword(param);
+        return ResultData.ok();
+    }
 }
 

+ 101 - 0
src/main/java/com/fdkankan/fusion/entity/CameraVersion.java

@@ -0,0 +1,101 @@
+package com.fdkankan.fusion.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 相机版本表
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-23
+ */
+@Getter
+@Setter
+@TableName("t_camera_version")
+public class CameraVersion implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 名称
+     */
+    @TableField("name")
+    private String name;
+
+    /**
+     * 文件rul
+     */
+    @TableField("file_url")
+    private String fileUrl;
+
+    /**
+     * 文件MD5
+     */
+    @TableField("file_md5")
+    private String fileMd5;
+
+    /**
+     * 描述
+     */
+    @TableField("description")
+    private String description;
+
+    /**
+     * 相机版本
+     */
+    @TableField("version")
+    private String version;
+
+    /**
+     * 相机类型,1八目,2双目, 3转台双目, 4激光转台
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * 活动状态:A: 生效,I: 禁用
+     */
+    @TableField("status")
+    private String status;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    /**
+     * 创建日期
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 修改日期
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 相机版本(最小)
+     */
+    @TableField("min_version")
+    private String minVersion;
+
+    /**
+     * 创建人
+     */
+    @TableField("sys_user_id")
+    private Long sysUserId;
+
+
+}

+ 5 - 5
src/main/java/com/fdkankan/fusion/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir") ;
 
         generate(path,"fusion", getTables(new String[]{
-               "t_case_img_tag"
+               "t_camera_version"
         }));
 
 //        generate(path,"goods", getTables(new String[]{
@@ -46,10 +46,10 @@ public class AutoGenerate {
 
 
     public static void  generate(String path,String moduleName,  List<String> tables){
-        FastAutoGenerator.create("jdbc:mysql://120.25.146.52:13306/fd_fusion_xj",
-                "root","JK123456%JIK")
-//        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
-//                "root","4Dage@4Dage#@168")
+//        FastAutoGenerator.create("jdbc:mysql://120.25.146.52:13306/fd_fusion_xj",
+//                "root","JK123456%JIK")
+        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
+                "root","4Dage@4Dage#@168")
                 .globalConfig(builder -> {
                     builder.author("")               //作者
                             .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)

+ 18 - 0
src/main/java/com/fdkankan/fusion/mapper/ICameraVersionMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.fusion.mapper;
+
+import com.fdkankan.fusion.entity.CameraVersion;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 相机版本表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-23
+ */
+@Mapper
+public interface ICameraVersionMapper extends BaseMapper<CameraVersion> {
+
+}

+ 10 - 0
src/main/java/com/fdkankan/fusion/request/CameraVersionParam.java

@@ -0,0 +1,10 @@
+package com.fdkankan.fusion.request;
+
+import com.fdkankan.fusion.common.RequestBase;
+import lombok.Data;
+
+@Data
+public class CameraVersionParam  extends RequestBase {
+    private String version;
+    private Integer type;
+}

+ 5 - 0
src/main/java/com/fdkankan/fusion/response/UserAddRequest.java

@@ -26,4 +26,9 @@ public class UserAddRequest extends RequestBase {
 
     //状态:1->可用;0->禁用
     private Integer status;
+
+    private String oldPassword;
+
+    private String clear;
+
 }

+ 23 - 0
src/main/java/com/fdkankan/fusion/service/ICameraVersionService.java

@@ -0,0 +1,23 @@
+package com.fdkankan.fusion.service;
+
+import com.fdkankan.fusion.entity.CameraVersion;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.fusion.request.CameraVersionParam;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ * 相机版本表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-23
+ */
+public interface ICameraVersionService extends IService<CameraVersion> {
+
+    void addAndUpload(MultipartFile file, String version, String description, String minVersion, Integer type);
+
+    void updateByParam(CameraVersion param);
+
+    Object pageList(CameraVersionParam param);
+}

+ 184 - 0
src/main/java/com/fdkankan/fusion/service/impl/CameraVersionServiceImpl.java

@@ -0,0 +1,184 @@
+package com.fdkankan.fusion.service.impl;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.fusion.common.FilePath;
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.ShellUtil;
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
+import com.fdkankan.fusion.entity.CameraVersion;
+import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.mapper.ICameraVersionMapper;
+import com.fdkankan.fusion.service.ICameraVersionService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.fusion.service.ITmUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 相机版本表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-23
+ */
+@Service
+@Slf4j
+@DS("db2")
+public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper, CameraVersion> implements ICameraVersionService {
+
+    public static String DIR_NAME = "camera_version/";
+
+    @Value("${fyun.host:https://4dkk.4dage.com/}")
+    private String ossUrlPrefix;
+    @Autowired
+    private UploadToOssUtil uploadToOssUtil;
+    @Autowired
+    ITmUserService  sysUserService;
+
+    @Override
+    public void addAndUpload(MultipartFile file, String version, String description, String minVersion, Integer type)  {
+        if(StringUtils.isBlank(version)){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        log.info("run upload");
+        if (!file.isEmpty()&& file.getSize() <= 0) {
+            throw new BusinessException(ResultCode.UPLOAD_ERROR);
+        }
+        // 文件名全名
+        String fullFileName = file.getOriginalFilename();
+        String resourcePath = FilePath.LOCAL_BASE_PATH  ;
+        log.info("resourcePath: {}", resourcePath);
+        // 创建目录
+        String dirPath = resourcePath + DIR_NAME;
+        FileUtils.createDir(dirPath);
+        // 拼接唯一文件名
+        String fileName = DateUtil.dateStr() + fullFileName;
+        // 文件保存路径
+        String filePath = dirPath + DateUtil.dateStr() + fullFileName;
+        // 写文件到本地
+        File file1 = new File(filePath);
+        file.transferTo(file1);
+
+        // 添加对象信息
+//        switch (type){
+//            case 1: type = 1;break;
+//            case 2: type = 9;break;
+//            case 3: type = 10;break;
+//            default: throw new BusinessException(ResultCode.CAMERA_TYPE_ERROR);
+//        }
+        List<CameraVersion> cameraVersions = this.getByVersion(version,type);
+        if(cameraVersions != null && cameraVersions.size() >0){
+            throw new BusinessException(ResultCode.VISION_EXIST.code(),ResultCode.VISION_EXIST.message());
+        }
+        log.info("filePath: {}", filePath);
+        // 上传到阿里云sso
+        ShellUtil.yunUpload(filePath,DIR_NAME + fileName);
+        log.info("upload success");
+        String url = ossUrlPrefix + DIR_NAME + fileName;
+        log.info("upload url: {}" + url);
+
+        CameraVersion versionEntity = new CameraVersion();
+        versionEntity.setName(fileName);
+        versionEntity.setFileUrl(url);
+        versionEntity.setVersion(version);
+        versionEntity.setDescription(description);
+        versionEntity.setType(type);
+        versionEntity.setMinVersion(minVersion);
+        versionEntity.setStatus("I");
+        versionEntity.setFileMd5(FileMd5Util.getFileMD5(new File(filePath)));
+        versionEntity.setSysUserId(Long.valueOf(StpUtil.getLoginId().toString()));
+        this.save(versionEntity);
+        // 删除本地文件
+        FileUtils.deleteFile(filePath);
+    }
+
+    private List<CameraVersion> getByVersion(String version,Integer type) {
+        LambdaQueryWrapper<CameraVersion> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CameraVersion::getVersion,version);
+        wrapper.eq(CameraVersion::getType,type);
+        return this.list(wrapper);
+    }
+
+    @Override
+    public PageInfo pageList(CameraVersionParam param) {
+        Integer type = param.getType();
+//        switch (type){
+//            case 1: type = 1;break;     //看看
+//            case 2: type = 9;break;     //看见
+//            case 3: type = 10;break;    //深时
+//            default: throw new BusinessException(ResultCode.CAMERA_TYPE_ERROR);
+//        }
+        LambdaQueryWrapper<CameraVersion> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CameraVersion::getType,type);
+        if (StringUtils.isNotBlank(param.getVersion())) {
+            queryWrapper.like(CameraVersion::getVersion,param.getVersion());
+        }
+        queryWrapper.orderByDesc(CameraVersion::getCreateTime);
+        Page<CameraVersion> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), queryWrapper);
+
+        List<CameraVersionVo> voList = new ArrayList<>();
+        for (CameraVersion record : page.getRecords()) {
+            CameraVersionVo vo = new CameraVersionVo();
+            BeanUtils.copyProperties(record,vo);
+            if(record.getSysUserId() !=null){
+                SysUser user = sysUserService.getById(record.getSysUserId());
+                if(user != null){
+                    vo.setCreateName(user.getNickName());
+                }
+            }
+            voList.add(vo);
+        }
+
+        Page<CameraVersionVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
+        voPage.setRecords(voList);
+        voPage.setTotal(page.getTotal());
+
+        return PageInfo.PageInfo(voPage);
+    }
+
+    @Override
+    public void updateByParam(CameraVersion param) {
+        if(param.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        CameraVersion cameraVersion = this.getById(param.getId());
+        if(cameraVersion == null){
+            throw new BusinessException(ResultCode.CAMERA_VERSION_NOT_EXIST);
+        }
+        if(StringUtils.isNotBlank(param.getStatus()) && !param.getStatus().equals(cameraVersion.getStatus())){
+            if(StringUtils.isBlank(param.getStatus()) || param.getType() == null){
+                throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+            }
+            if (!ValidationUtils.validateRecStatus(param.getStatus())) {
+                throw new BusinessException(ResultCode.CAMERA_VERSION_STATUS_ERROR);
+            }
+            // 仅有有一台相机是活动状态
+            // 查找所以活动状态相机
+            if(param.getStatus().equals("A")){
+                LambdaUpdateWrapper<CameraVersion> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.set(CameraVersion::getStatus,"I")
+                        .eq(CameraVersion::getStatus,"A")
+                        .eq(CameraVersion::getType,param.getType());
+                this.update(updateWrapper);
+            }
+            this.updateById(param);
+            return;
+        }
+        this.saveOrUpdate(param);
+    }
+}

+ 10 - 2
src/main/java/com/fdkankan/fusion/service/impl/TmUserServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.fusion.common.PageInfo;
 import com.fdkankan.fusion.common.enums.IdPreEnum;
+import com.fdkankan.fusion.common.util.Base64Converter;
 import com.fdkankan.fusion.common.util.IdUtils;
 import com.fdkankan.fusion.httpClient.response.FdkkLoginVo;
 
@@ -188,7 +189,7 @@ public class TmUserServiceImpl extends ServiceImpl<ITmUserMapper, TmUser> implem
     @Override
     public void changePassword(UserAddRequest param) {
         if(StringUtils.isBlank(param.getUserName()) || StringUtils.isBlank(param.getPassword())
-                || StringUtils.isBlank(param.getConfirmPwd()) || StringUtils.isBlank(param.getCode())){
+                || StringUtils.isBlank(param.getConfirmPwd()) || StringUtils.isBlank(param.getOldPassword())){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         TmUser tmUser = this.getByUserName(param.getUserName());
@@ -198,7 +199,14 @@ public class TmUserServiceImpl extends ServiceImpl<ITmUserMapper, TmUser> implem
         if (!StringUtils.equals(param.getPassword(), param.getConfirmPwd())) {
             throw new BusinessException(ResultCode.USER_PASSWORD_ERROR);
         }
-        FdkkLoginRequest request = new FdkkLoginRequest(param.getUserName(),param.getPassword(),param.getConfirmPwd(),param.getCode());
+        if(StringUtils.isBlank(param.getClear()) || !param.getClear().equals("YES")) {
+            String password = Base64Converter.decode(Base64Converter.subText(param.getOldPassword()));
+            if(!tmUser.getPassword().equals(password)){
+                throw new BusinessException(ResultCode.PROJECT_PASSWORD_ERROR);
+            }
+        }
+
+        FdkkLoginRequest request = new FdkkLoginRequest(param.getUserName(),param.getPassword(),param.getConfirmPwd());
         FdkkResponse fdkkResponse = fdKKClient.fdkkChangePassword(request);
         if(fdkkResponse.getCode() != 0){
             throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());

+ 5 - 0
src/main/resources/mapper/fusion/CameraVersionMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.fusion.mapper.ICameraVersionMapper">
+
+</mapper>