lyhzzz hai 1 ano
pai
achega
cb54c0b7c0

+ 4 - 1
README.md

@@ -73,5 +73,8 @@
 1. /changePassword 修改密码接口修改,去掉code参数,增加oldPassword参数
 2. /web/user/restPassword 新增接口,重置密码
     http://120.25.146.52:3090/project/369/interface/api/10296
-    
+3.固件管理
+    http://120.25.146.52:3090/project/369/interface/api/cat_1957
+4.APP管理
+    http://120.25.146.52:3090/project/369/interface/api/cat_1961
 ~~~~

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

@@ -17,7 +17,6 @@ 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";
 
 
 }

+ 3 - 0
src/main/java/com/fdkankan/fusion/common/ResultCode.java

@@ -69,6 +69,9 @@ public enum ResultCode {
     CAMERA_SPACE_ERROR(7022, "相机容量不足"),
     INQUEST_ERROR(7023, "该案件已有勘验笔录"),
     INQUEST_ERROR2(7024, "该案件未有勘验笔录"),
+    CAMERA_VERSION_EXIT(7025, "相机版本号已存在"),
+    CAMERA_VERSION_NOTEXIT(7026, "相机版本号不存在"),
+    CAMERA_VERSION_STATUS_ERROR(7027, "相机版本状态错误"),
 
 
     ;

+ 7 - 0
src/main/java/com/fdkankan/fusion/common/util/DateUtils.java

@@ -72,4 +72,11 @@ public class DateUtils {
        // System.out.println(getMonthdateList(getYearAgo(),getMonthStr(new Date())));
         System.out.println(getYearAgo());
     }
+
+    public static String dateStr() {
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
+        String format = df.format(new Date());
+        long timeMillis = System.currentTimeMillis();
+        return format + "_" + timeMillis + "_";
+    }
 }

+ 89 - 0
src/main/java/com/fdkankan/fusion/common/util/FileMd5Util.java

@@ -0,0 +1,89 @@
+package com.fdkankan.fusion.common.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.MessageDigest;
+
+public class FileMd5Util {
+    public static final String KEY_MD5 = "MD5";
+    public static final String CHARSET_ISO88591 = "ISO-8859-1";
+
+    public FileMd5Util() {
+    }
+
+    public static String getFileMD5(File file) {
+        if (file.exists() && file.isFile()) {
+            MessageDigest digest = null;
+            FileInputStream in = null;
+            byte[] buffer = new byte[1024];
+
+            try {
+                digest = MessageDigest.getInstance("MD5");
+                in = new FileInputStream(file);
+
+                while(true) {
+                    int len;
+                    if ((len = in.read(buffer, 0, 1024)) == -1) {
+                        in.close();
+                        break;
+                    }
+
+                    digest.update(buffer, 0, len);
+                }
+            } catch (Exception var9) {
+                var9.printStackTrace();
+                return null;
+            }
+
+            byte[] by = digest.digest();
+            StringBuffer sbf = new StringBuffer();
+
+            for(int j = 0; j < by.length; ++j) {
+                int i = by[j];
+                if (i < 0) {
+                    i += 256;
+                } else if (i < 16) {
+                    sbf.append("0");
+                }
+
+                sbf.append(Integer.toHexString(i));
+            }
+
+            return sbf.toString();
+        } else {
+            return null;
+        }
+    }
+
+    public static String getFileMD5(String filepath) {
+        File file = new File(filepath);
+        return getFileMD5(file);
+    }
+
+    public static byte[] encryptMD5(byte[] data) throws Exception {
+        MessageDigest md5 = MessageDigest.getInstance("MD5");
+        md5.update(data);
+        return md5.digest();
+    }
+
+    public static byte[] encryptMD5(String data) throws Exception {
+        return encryptMD5(data.getBytes("ISO-8859-1"));
+    }
+
+    public static boolean isSameMd5(File file1, File file2) {
+        String md5_1 = getFileMD5(file1);
+        String md5_2 = getFileMD5(file2);
+        return md5_1.equals(md5_2);
+    }
+
+    public static boolean isSameMd5(String filepath1, String filepath2) {
+        File file1 = new File(filepath1);
+        File file2 = new File(filepath2);
+        return isSameMd5(file1, file2);
+    }
+
+    public static void main(String[] args) {
+        System.out.println("obj1: " + getFileMD5(new File("F:\\桌面\\c11m-T11-EA\\log\\i6VhiQ2Q-copy.obj")));
+        System.out.println("obj: " + getFileMD5(new File("F:\\桌面\\c11m-T11-EA\\log\\i6VhiQ2Q.obj")));
+    }
+}

+ 71 - 0
src/main/java/com/fdkankan/fusion/controller/CameraVersionAppController.java

@@ -0,0 +1,71 @@
+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.entity.CameraVersionApp;
+import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.request.CameraVersionParam;
+import com.fdkankan.fusion.service.ICameraVersionAppService;
+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-24
+ */
+@RestController
+@RequestMapping("/cameraVersionApp")
+public class CameraVersionAppController {
+
+    @Autowired
+    ICameraVersionAppService cameraVersionAppService;
+
+    /**
+     * 上传文件
+     * 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 {
+        cameraVersionAppService.addAndUpload(file,version,description,minVersion,type);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/update")
+    public ResultData update(@RequestBody CameraVersionApp param){
+        cameraVersionAppService.updateByParam(param);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/delete")
+    public ResultData delete(@RequestBody CameraVersion param){
+        if(param.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        cameraVersionAppService.removeById(param.getId());
+        return ResultData.ok();
+    }
+
+    @PostMapping("/list")
+    public ResultData list(@RequestBody CameraVersionParam param){
+        return ResultData.ok(cameraVersionAppService.pageList(param));
+    }
+}
+

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

@@ -23,7 +23,7 @@ import java.io.IOException;
  * @since 2024-07-23
  */
 @RestController
-@RequestMapping("/fusion/cameraVersion")
+@RequestMapping("/cameraVersion")
 public class CameraVersionController {
 
     @Autowired

+ 0 - 21
src/main/java/com/fdkankan/fusion/controller/TmUserRoleController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.fusion.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 用户角色关系表 前端控制器
- * </p>
- *
- * @author 
- * @since 2023-07-28
- */
-@RestController
-@RequestMapping("/fusion/tmUserRole")
-public class TmUserRoleController {
-
-}
-

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

@@ -70,6 +70,7 @@ public class CameraVersion implements Serializable {
     /**
      * 记录的状态,A: 生效,I: 禁用
      */
+    @TableField("rec_status")
     @TableLogic(value = "A",delval = "I")
     private String recStatus;
 

+ 102 - 0
src/main/java/com/fdkankan/fusion/entity/CameraVersionApp.java

@@ -0,0 +1,102 @@
+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-24
+ */
+@Getter
+@Setter
+@TableName("t_camera_version_app")
+public class CameraVersionApp 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;
+
+    /**
+     * app 类型0安卓,1iOS
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * 活动状态:A: 生效,I: 禁用
+     */
+    @TableField("status")
+    private String status;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @TableField("rec_status")
+    @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;
+
+
+}

+ 1 - 1
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_camera_version"
+               "t_camera_version_app"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

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

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

+ 9 - 0
src/main/java/com/fdkankan/fusion/response/CameraVersionVo.java

@@ -0,0 +1,9 @@
+package com.fdkankan.fusion.response;
+
+import com.fdkankan.fusion.entity.CameraVersion;
+import lombok.Data;
+
+@Data
+public class CameraVersionVo extends CameraVersion {
+    private String createName;
+}

+ 24 - 0
src/main/java/com/fdkankan/fusion/service/ICameraVersionAppService.java

@@ -0,0 +1,24 @@
+package com.fdkankan.fusion.service;
+
+import com.fdkankan.fusion.entity.CameraVersion;
+import com.fdkankan.fusion.entity.CameraVersionApp;
+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-24
+ */
+public interface ICameraVersionAppService extends IService<CameraVersionApp> {
+
+    void addAndUpload(MultipartFile file, String version, String description, String minVersion, Integer type);
+
+    void updateByParam(CameraVersionApp param);
+
+    Object pageList(CameraVersionParam param);
+}

+ 203 - 0
src/main/java/com/fdkankan/fusion/service/impl/CameraVersionAppServiceImpl.java

@@ -0,0 +1,203 @@
+package com.fdkankan.fusion.service.impl;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.io.FileUtil;
+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.PageInfo;
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.DateUtils;
+import com.fdkankan.fusion.common.util.FileMd5Util;
+import com.fdkankan.fusion.common.util.ShellUtil;
+import com.fdkankan.fusion.entity.CameraVersionApp;
+import com.fdkankan.fusion.entity.TmUser;
+import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.mapper.ICameraVersionAppMapper;
+import com.fdkankan.fusion.request.CameraVersionParam;
+import com.fdkankan.fusion.response.CameraVersionVo;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.fusion.service.ICameraVersionAppService;
+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.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 相机版本表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-24
+ */
+@Service
+@Slf4j
+@DS("db2")
+public class CameraVersionAppServiceImpl extends ServiceImpl<ICameraVersionAppMapper, CameraVersionApp> implements ICameraVersionAppService {
+
+    public static String DIR_NAME = "camera_version_app/";
+
+    @Value("${upload.query-path}")
+    private String ossUrlPrefix;
+    @Autowired
+    ITmUserService tmUserService;
+
+    @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);
+        }
+        try {
+            // 文件名全名
+            String fullFileName = file.getOriginalFilename();
+            String resourcePath = FilePath.LOCAL_BASE_PATH  ;
+            log.info("resourcePath: {}", resourcePath);
+            // 创建目录
+            String dirPath = resourcePath + DIR_NAME;
+            FileUtil.mkdir(dirPath);
+            // 拼接唯一文件名
+            String fileName = DateUtils.dateStr() + fullFileName;
+            // 文件保存路径
+            String filePath = dirPath + DateUtils.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<CameraVersionApp> CameraVersionApps = this.getByVersion(version,type);
+            if(CameraVersionApps != null && CameraVersionApps.size() >0){
+                throw new BusinessException(ResultCode.CAMERA_VERSION_EXIT);
+            }
+            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);
+
+            CameraVersionApp versionEntity = new CameraVersionApp();
+            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);
+            // 删除本地文件
+            FileUtil.del(filePath);
+        }catch (Exception e){
+
+        }finally {
+
+        }
+
+
+    }
+
+    private List<CameraVersionApp> getByVersion(String version,Integer type) {
+        LambdaQueryWrapper<CameraVersionApp> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CameraVersionApp::getVersion,version);
+        wrapper.eq(CameraVersionApp::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<CameraVersionApp> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CameraVersionApp::getType,type);
+        if (StringUtils.isNotBlank(param.getVersion())) {
+            queryWrapper.like(CameraVersionApp::getVersion,param.getVersion());
+        }
+        queryWrapper.orderByDesc(CameraVersionApp::getCreateTime);
+        Page<CameraVersionApp> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), queryWrapper);
+
+        List<CameraVersionVo> voList = new ArrayList<>();
+        for (CameraVersionApp record : page.getRecords()) {
+            CameraVersionVo vo = new CameraVersionVo();
+            BeanUtils.copyProperties(record,vo);
+            if(record.getSysUserId() !=null){
+                TmUser user = tmUserService.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(CameraVersionApp param) {
+        if(param.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        CameraVersionApp cameraVersionApp = this.getById(param.getId());
+        if(cameraVersionApp == null){
+            throw new BusinessException(ResultCode.CAMERA_VERSION_NOTEXIT);
+        }
+        if(StringUtils.isNotBlank(param.getStatus()) && !param.getStatus().equals(cameraVersionApp.getStatus())){
+            if(StringUtils.isBlank(param.getStatus()) || param.getType() == null){
+                throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+            }
+            if (!validateRecStatus(param.getStatus())) {
+                throw new BusinessException(ResultCode.CAMERA_VERSION_STATUS_ERROR);
+            }
+            // 仅有有一台相机是活动状态
+            // 查找所以活动状态相机
+            if(param.getStatus().equals("A")){
+                LambdaUpdateWrapper<CameraVersionApp> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.set(CameraVersionApp::getStatus,"I")
+                        .eq(CameraVersionApp::getStatus,"A")
+                        .eq(CameraVersionApp::getType,param.getType());
+                this.update(updateWrapper);
+            }
+            this.updateById(param);
+            return;
+        }
+        this.saveOrUpdate(param);
+    }
+
+    public static boolean validateRecStatus(String str) {
+        if (StringUtils.isEmpty(str)) {
+            return Boolean.FALSE;
+        } else {
+            return !"A".equals(str) && !"I".equals(str) ? Boolean.FALSE : Boolean.TRUE;
+        }
+    }
+}

+ 67 - 46
src/main/java/com/fdkankan/fusion/service/impl/CameraVersionServiceImpl.java

@@ -1,17 +1,24 @@
 package com.fdkankan.fusion.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.io.FileUtil;
 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.PageInfo;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.DateUtils;
+import com.fdkankan.fusion.common.util.FileMd5Util;
 import com.fdkankan.fusion.common.util.ShellUtil;
 import com.fdkankan.fusion.common.util.UploadToOssUtil;
 import com.fdkankan.fusion.entity.CameraVersion;
+import com.fdkankan.fusion.entity.TmUser;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.ICameraVersionMapper;
+import com.fdkankan.fusion.request.CameraVersionParam;
+import com.fdkankan.fusion.response.CameraVersionVo;
 import com.fdkankan.fusion.service.ICameraVersionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.fusion.service.ITmUserService;
@@ -43,12 +50,10 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
 
     public static String DIR_NAME = "camera_version/";
 
-    @Value("${fyun.host:https://4dkk.4dage.com/}")
+    @Value("${upload.query-path}")
     private String ossUrlPrefix;
     @Autowired
-    private UploadToOssUtil uploadToOssUtil;
-    @Autowired
-    ITmUserService  sysUserService;
+    ITmUserService  tmUserService;
 
     @Override
     public void addAndUpload(MultipartFile file, String version, String description, String minVersion, Integer type)  {
@@ -59,52 +64,60 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
         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);
-
-        // 添加对象信息
+        try {
+            // 文件名全名
+            String fullFileName = file.getOriginalFilename();
+            String resourcePath = FilePath.LOCAL_BASE_PATH  ;
+            log.info("resourcePath: {}", resourcePath);
+            // 创建目录
+            String dirPath = resourcePath + DIR_NAME;
+            FileUtil.mkdir(dirPath);
+            // 拼接唯一文件名
+            String fileName = DateUtils.dateStr() + fullFileName;
+            // 文件保存路径
+            String filePath = dirPath + DateUtils.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());
+            List<CameraVersion> cameraVersions = this.getByVersion(version,type);
+            if(cameraVersions != null && cameraVersions.size() >0){
+                throw new BusinessException(ResultCode.CAMERA_VERSION_EXIT);
+            }
+            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);
+            // 删除本地文件
+            FileUtil.del(filePath);
+        }catch (Exception e){
+
+        }finally {
+
         }
-        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) {
@@ -136,7 +149,7 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
             CameraVersionVo vo = new CameraVersionVo();
             BeanUtils.copyProperties(record,vo);
             if(record.getSysUserId() !=null){
-                SysUser user = sysUserService.getById(record.getSysUserId());
+                TmUser user = tmUserService.getById(record.getSysUserId());
                 if(user != null){
                     vo.setCreateName(user.getNickName());
                 }
@@ -158,13 +171,13 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
         }
         CameraVersion cameraVersion = this.getById(param.getId());
         if(cameraVersion == null){
-            throw new BusinessException(ResultCode.CAMERA_VERSION_NOT_EXIST);
+            throw new BusinessException(ResultCode.CAMERA_VERSION_NOTEXIT);
         }
         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())) {
+            if (!validateRecStatus(param.getStatus())) {
                 throw new BusinessException(ResultCode.CAMERA_VERSION_STATUS_ERROR);
             }
             // 仅有有一台相机是活动状态
@@ -181,4 +194,12 @@ public class CameraVersionServiceImpl extends ServiceImpl<ICameraVersionMapper,
         }
         this.saveOrUpdate(param);
     }
+
+    public static boolean validateRecStatus(String str) {
+        if (StringUtils.isEmpty(str)) {
+            return Boolean.FALSE;
+        } else {
+            return !"A".equals(str) && !"I".equals(str) ? Boolean.FALSE : Boolean.TRUE;
+        }
+    }
 }

+ 5 - 0
src/main/resources/mapper/fusion/CameraVersionAppMapper.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.ICameraVersionAppMapper">
+
+</mapper>