Kaynağa Gözat

新增个人按日查询

wuweihao 4 yıl önce
ebeveyn
işleme
8b83ec39c4

+ 2 - 1
gis_common/src/main/java/com/gis/common/config/WebMvcConfig.java

@@ -76,7 +76,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
 
 
         // 设置全程返回时间
-        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+//        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+        fastJsonConfig.setDateFormat("yyyy-MM-dd");
         // 设置返回值为null是时输出,不写的话,null 字段 不返回。也可以设置返回空串, 可以同时设置多个
         fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
 

+ 43 - 3
gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -6,12 +6,11 @@ import cn.hutool.core.util.URLUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.util.ResourceUtils;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.net.URL;
 import java.util.*;
 
@@ -137,4 +136,45 @@ public class FileUtils {
         System.out.println(StringUtils.substringBefore(a, "cms_fdkanzhan_data"+ File.separator));
         System.out.println(StringUtils.substringBetween(a, "cms_fdkanzhan_data"+ File.separator));
     }
+
+
+    /**
+     * 读取资源文内容
+     * @param resourcePath : data/someData.json
+     * @return
+     */
+    public static String getResourceContent(String resourcePath){
+        InputStream resource = FileUtils.getResource(resourcePath);
+        StringBuilder sb = new StringBuilder();
+        String line;
+        String str = null ;
+        BufferedReader br = new BufferedReader(new InputStreamReader(resource));
+        while (true) {
+            try {
+                if ((line = br.readLine()) == null) break;
+                sb.append(line);
+                str = sb.toString();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return str;
+    }
+
+
+    // jar包运行,只能用文件流的形式获取文件
+    public static InputStream getResource(String path){
+        ClassPathResource classPathResource = new ClassPathResource(path);
+        InputStream inputStream = null;
+        try {
+            inputStream = classPathResource.getInputStream();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return inputStream;
+    }
+
+
+
+
 }

+ 4 - 0
gis_domain/src/main/java/com/gis/domain/entity/UserEntity.java

@@ -31,6 +31,10 @@ public class UserEntity extends ZtBaseEntity implements Serializable {
     @ApiModelProperty(value = "部门")
     private Integer dept;
 
+    @ApiModelProperty(value = "工号")
+    private String slack;
+
+
 
 
 

+ 40 - 0
gis_web/src/main/java/com/gis/web/controller/PersonalController.java

@@ -1,5 +1,6 @@
 package com.gis.web.controller;
 
+import cn.hutool.core.io.FileUtil;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.PersonalPageDateDto;
 import com.gis.domain.dto.PersonalPageDto;
@@ -12,10 +13,13 @@ import com.gis.service.UserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 
 
@@ -72,5 +76,41 @@ public class PersonalController extends BaseController {
         return taskesTimateService.workByDayDetail(param);
     }
 
+
+    /**
+     * 插入工号时,需要把deleted的字段注释他
+     * @return
+     */
+
+//    @ApiOperation(value = "")
+//    @GetMapping(value = "tset1")
+//    public Result tset1() {
+//        List<UserEntity> all = userService.findAll();
+//        HashMap<String, String> map = test3();
+//        for (UserEntity userEntity : all) {
+//            String realname = userEntity.getRealname();
+//            String s = map.get(realname);
+//            if (s != null) {
+//                userEntity.setSlack(s);
+//                userService.update(userEntity);
+//                log.info("更新工号: " + realname + ": " + s);
+//            }
+//        }
+//        return Result.success();
+//    }
+
+
+    public HashMap<String, String> test3(){
+        String a = "C:\\Users\\Administrator\\Desktop\\33\\11.txt";
+        List<String> strings = FileUtil.readLines(a, "utf-8");
+        HashMap<String, String> map = new HashMap<>();
+        for (String str : strings) {
+            List<String> sub = Arrays.asList(str.split(","));
+            map.put(sub.get(0).trim(), sub.get(1));
+        }
+
+        return map;
+    }
+
     
 }