Ver Fonte

客户端功能

huangjn há 3 anos atrás
pai
commit
6cb885cf93

+ 21 - 0
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -16,6 +16,9 @@
  */
 package org.springblade.common.utils;
 
+import org.apache.commons.lang.StringUtils;
+
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -26,6 +29,24 @@ import java.util.List;
  */
 public class CommonUtil {
 
+    /**
+     * 判断参数是否是数字
+     * @param value 需要判断数据
+     * @return 判断结果,数字则为true,反之false
+     */
+    public static boolean checkIsBigDecimal(Object value){
+        try{
+            if(StringUtils.isNotEmpty(String.valueOf(value))){
+                new BigDecimal(String.valueOf(value));
+                return true;
+            } else {
+                return false;
+            }
+        }catch (Exception e){
+            return false;
+        }
+    }
+
     /**
      * 根据每页信息分组
      */

+ 5 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/ImageClassificationFile.java

@@ -94,6 +94,11 @@ public class ImageClassificationFile extends BaseEntity {
      */
     @ApiModelProperty("拍摄时间")
     private LocalDateTime shootingTime;
+    /**
+     * 上传日期
+     */
+    @ApiModelProperty("上传日期")
+    private String uploadTime;
     /**
      * 照片号,视频格式不填
      */

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/ImageClassificationFileVO.java

@@ -65,4 +65,10 @@ public class ImageClassificationFileVO extends ImageClassificationFile {
 	@ApiModelProperty("时间查询(年、年-月、年-月-日)")
 	private String queryDate;
 
+	/**
+	 * 拍摄时间,字符串
+	 */
+	@ApiModelProperty("拍摄时间,字符串")
+	private String shootingTimeStr;
+
 }

+ 4 - 5
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TreeVo.java

@@ -10,15 +10,14 @@ public class TreeVo {
 
     private String name;
 
+    private String hierarchy;
+
     private List<TreeVo> treeList = new ArrayList<>();
 
-    public TreeVo(String name, List<TreeVo> treeList){
+    public TreeVo(String name, List<TreeVo> treeList, String hierarchy){
         this.name = name;
         this.treeList = treeList;
-    }
-
-    public TreeVo(String name){
-        this.name = name;
+        this.hierarchy = hierarchy;
     }
 
     public TreeVo(){}

+ 22 - 18
blade-service/blade-business/src/main/java/org/springblade/business/controller/ImageClassificationFileController.java

@@ -1,5 +1,6 @@
 package org.springblade.business.controller;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.nacos.common.utils.StringUtils;
@@ -7,8 +8,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
-
-import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import org.springblade.business.entity.ImageClassificationShow;
 import org.springblade.business.service.ImageClassificationShowService;
@@ -34,7 +33,6 @@ import org.springblade.business.entity.ImageClassificationFile;
 import org.springblade.business.vo.ImageClassificationFileVO;
 import org.springblade.business.service.IImageClassificationFileService;
 import org.springblade.core.boot.ctrl.BladeController;
-import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -90,7 +88,6 @@ public class ImageClassificationFileController extends BladeController {
 //				});
 //			}
 		} else {
-			// todo 先写死项目ID
 			//不为空,获取其下子节点
 			rootTreeNode = this.wbsTreeContractClient.queryContractWbsTreeByContractIdAndType(contractId, 1, parentId);
 		}
@@ -225,17 +222,6 @@ public class ImageClassificationFileController extends BladeController {
 		return R.data(configVoList);
 	}
 
-	/**
-	 * 下载
-	 * @param id 要下载的数据ID
-	 */
-	@PostMapping("/downloadFileByUrl")
-	@ApiOperationSupport(order = 7)
-	@ApiOperation(value = "下载", notes = "传入id主键")
-	public void downloadFileByUrl(@RequestParam String id, HttpServletResponse response) throws IOException {
-
-	}
-
 	/**
 	 * 获取时间结构树
 	 * @param classifyId 分类ID
@@ -283,8 +269,15 @@ public class ImageClassificationFileController extends BladeController {
 	@PostMapping("/queryById")
 	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "详情", notes = "传入主键")
-	public R<ImageClassificationFile> queryById(@RequestParam String id){
-		return R.data(this.imageClassificationFileService.getById(id));
+	public R<ImageClassificationFileVO> queryById(@RequestParam String id){
+		ImageClassificationFile file = this.imageClassificationFileService.getById(id);
+		if(file != null){
+			ImageClassificationFileVO vo = new ImageClassificationFileVO();
+			BeanUtils.copyProperties(file, vo);
+			vo.setShootingTimeStr(DateUtil.format(file.getShootingTime(), "yyyy-MM-dd"));
+			return R.data(vo);
+		}
+		return R.data(null);
 	}
 
 	/**
@@ -325,9 +318,20 @@ public class ImageClassificationFileController extends BladeController {
 		ImageClassificationFile newFile = new ImageClassificationFile();
 		//复制数据
 		BeanUtils.copyProperties(fileVO, newFile);
+		try{
+			String shootingTime = fileVO.getShootingTimeStr();
+			String format = "yyyy-MM-dd";
+			if(shootingTime.contains(":")){
+				format = "yyyy-MM-dd HH:mm:ss";
+			}
+			newFile.setShootingTime(DateUtil.parseLocalDateTime(shootingTime, format));
+		}catch (Exception e){
+			e.printStackTrace();
+		}
+
 		//设置用户信息
 		setUserData(newFile, isCreate);
-		return new ImageClassificationFile();
+		return newFile;
 	}
 
 	/**

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ImageClassificationFileMapper.java

@@ -56,6 +56,6 @@ public interface ImageClassificationFileMapper extends BaseMapper<ImageClassific
 	 * @param imageClassificationFile 参数
 	 * @return 结果
 	 */
-	List<ImageClassificationFileVO> selectImageClassificationFilePage(@Param("current")long current, @Param("size")long size, @Param("param") ImageClassificationFileVO imageClassificationFile);
+	List<ImageClassificationFile> selectImageClassificationFilePage(@Param("current")long current, @Param("size")long size, @Param("param") ImageClassificationFileVO imageClassificationFile);
 
 }

+ 38 - 22
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ImageClassificationFileMapper.xml

@@ -23,6 +23,7 @@
         <result column="file_name" property="fileName"/>
         <result column="shooting_user" property="shootingUser"/>
         <result column="shooting_time" property="shootingTime"/>
+        <result column="upload_time" property="uploadTime"/>
         <result column="photo_code" property="photoCode"/>
         <result column="film_code" property="filmCode"/>
         <result column="see_also_code" property="seeAlsoCode"/>
@@ -46,30 +47,45 @@
 
     <select id="selectImageClassificationFilePage" resultMap="imageClassificationFileResultMap">
         select
-            id,
-            title,
-            text_content,
-            shooting_user,
-            shooting_time,
-            file_size,
-            image_url
-        from u_image_classification_file where is_deleted = 0
-        and project_id = #{param.projectId} and classify_id = #{param.classifyId}
-        <if test="param.contractId != null and param.contractId != ''">
-            and contract_id = #{param.contractId}
-        </if>
-        <if test="param.queryStr != null and param.queryStr != ''">
-            and (title like CONCAT('%',#{param.queryStr},'%') OR shooting_user like CONCAT('%',#{param.queryStr},'%'))
-        </if>
+            files.id,
+            files.title,
+            files.text_content,
+            files.shooting_user,
+            files.shooting_time,
+            files.file_size,
+            files.image_url,
+            files.type
+        from
+        (
+            select
+                id,
+                title,
+                text_content,
+                shooting_user,
+                shooting_time,
+                file_size,
+                image_url,
+                type,
+                date_format(shooting_time,'%Y-%m-%d') as shootingTimeStr
+            from u_image_classification_file where is_deleted = 0
+            and project_id = #{param.projectId} and classify_id = #{param.classifyId}
+            <if test="param.contractId != null and param.contractId != ''">
+                and contract_id = #{param.contractId}
+            </if>
+            <if test="param.queryStr != null and param.queryStr != ''">
+                and (title like concat('%',#{param.queryStr},'%') OR shooting_user like concat('%',#{param.queryStr},'%'))
+            </if>
+            <if test="param.wbsIds != null and param.wbsIds.size != 0">
+                and wbs_id in
+                <foreach collection="param.wbsIds" item="webId" open="(" separator="," close=")">#{webId}</foreach>
+            </if>
+            order by shooting_time desc
+        ) as files
+        where
+            1 = 1
         <if test="param.queryDate != null and param.queryDate != ''">
-            and shooting_time like COUNCAT('%',#{param.queryDate},'%')
-        </if>
-        <if test="param.wbsIds != null and param.wbsIds.size != 0">
-            and wbs_id in
-            <foreach collection="param.wbsIds" item="webId" open="(" separator="," close=")">#{webId}</foreach>
+            and files.shootingTimeStr like concat('%',#{param.queryDate},'%')
         </if>
-        order by shooting_time desc
-        limit ${current},${size}
     </select>
 
 </mapper>

+ 0 - 18
blade-service/blade-business/src/main/java/org/springblade/business/service/IImageClassificationFileService.java

@@ -1,19 +1,3 @@
-/*
- *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- *  Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the dreamlu.net developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: Chill 庄骞 (smallchill@163.com)
- */
 package org.springblade.business.service;
 
 import org.springblade.business.entity.ImageClassificationFile;
@@ -21,8 +5,6 @@ import org.springblade.business.vo.ImageClassificationFileVO;
 import org.springblade.business.vo.TreeVo;
 import org.springblade.core.mp.base.BaseService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import java.util.Date;
 import java.util.List;
 
 /**

+ 35 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ImageClassificationFileServiceImpl.java

@@ -25,6 +25,7 @@ import org.springblade.business.vo.ImageClassificationFileVO;
 import org.springblade.business.mapper.ImageClassificationFileMapper;
 import org.springblade.business.service.IImageClassificationFileService;
 import org.springblade.business.vo.TreeVo;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -72,7 +73,7 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
 
 		//循环年
 		for(Map.Entry<String,List<String>> yearMaps : yearMap.entrySet()){
-			String year = yearMaps.getKey();
+			String year = yearMaps.getKey().replace("年", "");
 			List<String> monthList = yearMaps.getValue();
 
 			//月集合
@@ -94,14 +95,15 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
 					monthMap = new TreeVo();
 				}
 				monthMap.setName(month + "月");
-				monthMap.getTreeList().add(new TreeVo(monthDays[1] + "日"));
+				monthMap.setHierarchy(year + "-" + month);
+				monthMap.getTreeList().add(new TreeVo(monthDays[1] + "日", new ArrayList<>(), year + "-" + month + "-" + monthDays[1]));
 				index ++;
 				if(index == monthList.size()){
 					monthResult.add(monthMap);
 				}
 			}
 			//年
-			TreeVo yearResult = new TreeVo(year, monthResult);
+			TreeVo yearResult = new TreeVo(year, monthResult, year);
 			result.add(yearResult);
 		}
 
@@ -115,7 +117,36 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
 			//查询下级节点信息
 			imageClassificationFile.setWbsIds(JSONArray.parseArray(JSONObject.toJSONString(imageClassificationFile.getWbsIdsStr().split(",")), String.class));
 		}
-		return page.setRecords(this.baseMapper.selectImageClassificationFilePage(current, page.getSize(), imageClassificationFile));
+		//获取数据
+		List<ImageClassificationFile> fileVOS = this.baseMapper.selectImageClassificationFilePage(current, page.getSize(), imageClassificationFile);
+		if(fileVOS != null && fileVOS.size() > 0){
+			//分组
+			List<List<ImageClassificationFile>> group = CommonUtil.getBatchSize(fileVOS, new Integer(String.valueOf(page.getSize())));
+
+			//获取数据并设置分页信息
+			List<ImageClassificationFile> result = group.get(new Integer(String.valueOf(page.getCurrent())) - 1);
+			//转换类型
+			List<ImageClassificationFileVO> resultVo = JSONArray.parseArray(JSONObject.toJSONString(result), ImageClassificationFileVO.class);
+
+			//处理文件大小单位
+			resultVo.forEach(vo -> {
+				//获取文件大小
+				String fileSize = vo.getFileSize();
+				if(StringUtils.isNotEmpty(fileSize) && CommonUtil.checkIsBigDecimal(fileSize)){
+					long size = new Long(fileSize);
+					if(size < 1024L){
+						vo.setFileSize(vo.getFileSize() + "B");
+					} else {
+						vo.setFileSize((size / 1024) + "K");
+					}
+				}
+			});
+
+			page.setTotal(fileVOS.size());
+			page.setRecords(resultVo);
+		}
+
+		return page;
 	}
 
 }