Bladeren bron

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/GeoHazardMonitor

gao.qiang 2 jaren geleden
bovenliggende
commit
bd7f094f83

+ 33 - 20
hazard-admin/src/main/java/com/ozs/web/controller/system/SysDeptController.java

@@ -65,16 +65,8 @@ public class SysDeptController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:dept:listAll')")
     @GetMapping("/listAll")
     public AjaxResult listAll(SysDept dept) {
-        List<SysDept> depts = deptService.selectDeptListAll(dept);
-        for (SysDept sysDept : depts) {
-            for (SysDept dept1 : depts) {
-                if (dept1.getDeptId().equals(sysDept.getParentId())) {
-                    sysDept.setParentName(dept1.getDeptName());
-                    break;
-                }
-            }
-        }
-        return success(depts);
+        List<SysDept> sysDeptS = forDeptList(dept);
+        return success(sysDeptS);
     }
 
     /**
@@ -91,7 +83,7 @@ public class SysDeptController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('system:dept:list')")
     @GetMapping("/list/exclude/{deptId}")
-    public AjaxResult excludeChild(@PathVariable(value = "deptId" , required = false) Long deptId) {
+    public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
         List<SysDept> depts = deptService.selectDeptList(new SysDept());
         depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
         return success(depts);
@@ -113,18 +105,18 @@ public class SysDeptController extends BaseController {
      * 新增部门
      */
     @PreAuthorize("@ss.hasPermi('system:dept:add')")
-    @Log(title = "部门管理" , businessType = BusinessType.INSERT)
+    @Log(title = "部门管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysDept dept) {
         if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
             return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
         }
-        LambdaQueryWrapper<SysDept> wq=new LambdaQueryWrapper<SysDept>();
+        LambdaQueryWrapper<SysDept> wq = new LambdaQueryWrapper<SysDept>();
         if (ObjectUtils.isNotEmpty(dept.getDeptCode())) {
             wq.eq(SysDept::getDeptCode, dept.getDeptCode());
         }
         SysDept sysDept = deptService.getOne(wq);
-        if (ObjectUtils.isNotEmpty(sysDept)){
+        if (ObjectUtils.isNotEmpty(sysDept)) {
             return error("新增部门'" + dept.getDeptCode() + "'失败,部门编码已存在");
         }
         dept.setCreateBy(getUserId());
@@ -136,7 +128,7 @@ public class SysDeptController extends BaseController {
      * 修改部门
      */
     @PreAuthorize("@ss.hasPermi('system:dept:edit')")
-    @Log(title = "部门管理" , businessType = BusinessType.UPDATE)
+    @Log(title = "部门管理", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody SysDept dept) {
         Long deptId = dept.getDeptId();
@@ -148,13 +140,13 @@ public class SysDeptController extends BaseController {
         } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
             return error("该部门包含未停用的子部门!");
         }
-        LambdaQueryWrapper<SysDept> wq=new LambdaQueryWrapper<SysDept>();
+        LambdaQueryWrapper<SysDept> wq = new LambdaQueryWrapper<SysDept>();
         if (ObjectUtils.isNotEmpty(dept.getDeptCode())) {
             wq.eq(SysDept::getDeptCode, dept.getDeptCode());
-            wq.ne(SysDept::getDeptId,dept.getDeptId());
+            wq.ne(SysDept::getDeptId, dept.getDeptId());
         }
         SysDept sysDept = deptService.getOne(wq);
-        if (ObjectUtils.isNotEmpty(sysDept)){
+        if (ObjectUtils.isNotEmpty(sysDept)) {
             return error("新增部门'" + dept.getDeptCode() + "'失败,部门编码已存在");
         }
         dept.setUpdateBy(getUserId());
@@ -165,7 +157,7 @@ public class SysDeptController extends BaseController {
      * 删除部门
      */
     @PreAuthorize("@ss.hasPermi('system:dept:remove')")
-    @Log(title = "部门管理" , businessType = BusinessType.DELETE)
+    @Log(title = "部门管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{deptId}")
     public AjaxResult remove(@PathVariable Long deptId) {
         if (deptService.hasChildByDeptId(deptId)) {
@@ -183,8 +175,29 @@ public class SysDeptController extends BaseController {
     @PostMapping("/export")
     @ApiOperation("部门导出")
     public void export(HttpServletResponse response, SysDept dept) {
-        List<SysDept> list = deptService.selectDeptListAll(dept);
+        List<SysDept> list = forDeptList(dept);
         ExcelUtil<SysDept> util = new ExcelUtil<SysDept>(SysDept.class);
         util.exportExcel(response, list, "部门数据");
     }
+
+    /**
+     * 遍历列表,给字段赋值
+     */
+    private List<SysDept> forDeptList(SysDept dept) {
+        List<SysDept> list = deptService.selectDeptListAll(dept);
+        for (SysDept sysDept : list) {
+            for (SysDept dept1 : list) {
+                if (dept1.getDeptId().equals(sysDept.getParentId())) {
+                    sysDept.setParentName(dept1.getDeptName());
+                    break;
+                }
+            }
+        }
+        for (SysDept sysDept : list) {
+            if (ObjectUtils.isEmpty(sysDept.getParentName())) {
+                sysDept.setParentName(sysDept.getDeptName());
+            }
+        }
+        return list;
+    }
 }

+ 30 - 2
hazard-admin/src/main/java/com/ozs/web/controller/upload/UploadController.java

@@ -31,7 +31,6 @@ public class UploadController {
 
     @Value("${minio.bucketName}")
     private String bucketName;
-
     @Resource
     MinioUtils minioUtils;
     @Autowired
@@ -39,7 +38,6 @@ public class UploadController {
     @Autowired
     BaseRailwayManagementService baseRailwayManagementService;
 
-
     @PostMapping("/upLoadImage")
     public AjaxResult upLoadImage(@RequestParam("file") MultipartFile image,
                                   @RequestParam(value = "cameraCode", required = false) String cameraCode,
@@ -78,4 +76,34 @@ public class UploadController {
         }
         return AjaxResult.success(uploadFile);
     }
+
+    /**
+     * 相机版本文件上传
+     * @param image
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/upLoadCameraVersion")
+    public AjaxResult upLoadCameraVersion(@RequestParam("file") MultipartFile image) throws Exception {
+        if (image.isEmpty()) {
+            return AjaxResult.error("不能上传空文件哦");
+        }
+        //图片保存路径
+        String uploadFile = null;
+        if (image != null || !image.isEmpty()) {
+            String imageName = image.getOriginalFilename();
+            if (StringUtils.isNotBlank(imageName)) {
+                // String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+                String filename = IdUtils.fastSimpleUUID() + image.getOriginalFilename().substring(image.getOriginalFilename().lastIndexOf("."));
+                SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
+                String format1 = dateFormat1.format(new Date());
+                String imgName = "cameraVersion" + format1 + "/" + filename;
+                minioUtils.minIoClientUpload(image.getInputStream(), imgName);
+                uploadFile = "/cameraVersion/" + format1 + "/" + filename;
+            }
+        } else {
+            return AjaxResult.error("上传功能出错");
+        }
+        return AjaxResult.success(uploadFile);
+    }
 }