|
@@ -8,7 +8,7 @@ import com.hw.admin.model.mapper.WorkPackerMapper;
|
|
|
import com.hw.admin.model.service.WorkPackerService;
|
|
|
import com.hw.admin.system.listener.WorkPackerListener;
|
|
|
import com.hw.admin.system.utils.DateExUtils;
|
|
|
-import com.hw.admin.system.utils.Sequence;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -17,9 +17,12 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class WorkPackerServiceImpl implements WorkPackerService {
|
|
|
|
|
|
@Value("${file.path}")
|
|
@@ -53,6 +56,7 @@ public class WorkPackerServiceImpl implements WorkPackerService {
|
|
|
//return workPackerMapper.inserList(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void task(String time) {
|
|
|
// 有个很重要的点 DemoDataListener 不能被spring管理,要每次读取excel都要new,然后里面用到spring可以构造方法传进去
|
|
@@ -86,8 +90,32 @@ public class WorkPackerServiceImpl implements WorkPackerService {
|
|
|
|
|
|
@Override
|
|
|
public int update(WorkPacker workPacker) {
|
|
|
- checkData(workPacker.getId());
|
|
|
- return workPackerMapper.updateById(workPacker);
|
|
|
+ Set<String> files = new HashSet<>();
|
|
|
+ files.addAll(getFile(filepath));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 给定目录的绝对路径,获取该目录下的所有文件(子目录的文件也可递归得到)
|
|
|
+ public static List<String> getFile(String path) {
|
|
|
+ List<String> files = new ArrayList<>();
|
|
|
+ // File对象 可以是文件或者目录
|
|
|
+ File file = new File(path);
|
|
|
+ File[] array = file.listFiles();
|
|
|
+
|
|
|
+ for (int i = 0; i < array.length; i++) {
|
|
|
+ if (array[i].isFile()) {
|
|
|
+ // only take file name
|
|
|
+ log.info("^^^^^" + array[i].getName());
|
|
|
+ // take file path and name
|
|
|
+ log.info("#####" + array[i]);
|
|
|
+ // take file path and name
|
|
|
+ log.info("*****" + array[i].getPath());
|
|
|
+ files.add(array[i].getPath());
|
|
|
+ } else if (array[i].isDirectory()) {
|
|
|
+ getFile(array[i].getPath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return files;
|
|
|
}
|
|
|
|
|
|
@Override
|