| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.dto.ActionUtil; |
| | | import com.whyc.dto.FileParamToXml; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.XmlFileOpreate; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.dto.*; |
| | | import com.whyc.mapper.FileParamMapper; |
| | | import com.whyc.pojo.FileInfo; |
| | | import com.whyc.pojo.FileParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.lang.reflect.Field; |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class FileParamService { |
| | | @Autowired |
| | | private FileParamMapper mapper; |
| | | |
| | | //解析xml文件 |
| | | public Response getXmlValue(String filePath) { |
| | | File file=new File(filePath); |
| | | List list=new ArrayList(); |
| | | if(file.exists()){ |
| | | FileInfo fileInfo=XmlFileOpreate.readXml(filePath); |
| | | return new Response().setII(1,fileInfo!=null,fileInfo,"返回解析数据"); |
| | | if(file.isFile()){ |
| | | FileInfo fileInfo=XmlFileOpreate.readXml(filePath); |
| | | fileInfo.setFileUrl(filePath); |
| | | list.add(fileInfo); |
| | | }else{ |
| | | //3.如果是文件夹:获取文件夹下所有的文件 |
| | | List<File> allFile= FileOpreate.getAllFile(filePath); |
| | | if(allFile!=null&&allFile.size()>0){ |
| | | for (File f:allFile){ |
| | | if(!f.getName().contains(".xml")){ |
| | | continue; |
| | | } |
| | | FileInfo fileInfo=XmlFileOpreate.readXml(f.getPath()); |
| | | fileInfo.setFileUrl(f.getPath()); |
| | | list.add(fileInfo); |
| | | } |
| | | } |
| | | } |
| | | return new Response().setII(1,list.size()>0,list,"返回解析数据"); |
| | | }else{ |
| | | return new Response().set(1,false,"文件路径不正确"); |
| | | } |
| | |
| | | } |
| | | return new Response().setII(1,bl,map,"修改文件"); |
| | | } |
| | | //查询数据中存在的电池标称电压类型 |
| | | public Response getMonVolStd() { |
| | | List<Integer> list=mapper.getMonVolStd(); |
| | | return new Response().setII(1,list.size()>0,list,"返回所有的标称电压类型"); |
| | | } |
| | | //按照筛选条件查询数据库信息 |
| | | public Response getDataByCondition(Date testTime1, Date testTime2, int battVol) { |
| | | List<FileParam> list=mapper.getDataByCondition(testTime1,testTime2,battVol); |
| | | return new Response().setII(1,list.size()>0,list,"筛选数据库信息"); |
| | | } |
| | | } |