| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.persagy.business.maintain;
- import java.io.File;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import javax.annotation.Resource;
- import org.springframework.stereotype.Service;
- import com.persagy.core.service.BaseBusinessService;
- import com.persagy.core.service.BusinessService;
- import com.persagy.weather.service.HourRecordService;
- import com.persagy.weather.thread.FileDataTransThread;
- /**
- * 城市小时历史文件数据入库
- *
- */
- @Service("FileData2DB")
- @SuppressWarnings({"unchecked","rawtypes" })
- public class FileData2DB extends BaseBusinessService<Map> implements BusinessService {
- @Resource
- HourRecordService hourRecordService;
-
- @Override
- public void handle(Map dto, List content) throws Exception {
- String dirPath = (String) dto.get("dirPath");
- List<String> cityList = (List<String>) dto.get("cityList");
-
- File dir = new File(dirPath);
- if(!dir.exists() || !dir.isDirectory()) {
- throw new Exception("dirPath不是有效的目录");
- }
-
- if(null == cityList || cityList.isEmpty()) {
- throw new Exception("cityList不能为空");
- }
-
- Set<String> cityIds = new HashSet<>(cityList);
-
- if(FileDataTransThread.runningLogic.contains(dirPath)) {
- content.add("Task is Running");
- }else {
- new Thread(new FileDataTransThread(dirPath, hourRecordService, cityIds)).start();
- content.add("Task start Running");
- }
-
- }
- }
|